Skip to content

Commit

Permalink
Last test
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
  • Loading branch information
hsanjuan committed Nov 28, 2017
1 parent 4a7c609 commit 627556a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -12,9 +12,9 @@ install:
- go get github.com/mattn/goveralls
- make deps
script:
- make service && make ctl && ./coverage.sh
#- make service && make ctl && ./coverage.sh
- make install
- make test_sharness && make clean_sharness
- make test_sharness
env:
global:
secure: M3K3y9+D933tCda7+blW3qqVV8fA6PBDRdJoQvmQc1f0XYbWinJ+bAziFp6diKkF8sMQ+cPwLMONYJuaNT2h7/PkG+sIwF0PuUo5VVCbhGmSDrn2qOjmSnfawNs8wW31f44FQA8ICka1EFZcihohoIMf0e5xZ0tXA9jqw+ngPJiRnv4zyzC3r6t4JMAZcbS9w4KTYpIev5Yj72eCvk6lGjadSVCDVXo2sVs27tNt+BSgtMXiH6Sv8GLOnN2kFspGITgivHgB/jtU6QVtFXB+cbBJJAs3lUYnzmQZ5INecbjweYll07ilwFiCVNCX67+L15gpymKGJbQggloIGyTWrAOa2TMaB/bvblzwwQZ8wE5P3Rss5L0TFkUAcdU+3BUHM+TwV4e8F9x10v1PjgWNBRJQzd1sjKKgGUBCeyCY7VeYDKn9AXI5llISgY/AAfCZwm2cbckMHZZJciMjm+U3Q1FCF+rfhlvUcMG1VEj8r9cGpmWIRjFYVm0NmpUDDNjlC3/lUfTCOOJJyM254EUw63XxabbK6EtDN1yQe8kYRcXH//2rtEwgtMBgqHVY+OOkekzGz8Ra3EBkh6jXrAQL3zKu/GwRlK7/a1OU5MQ7dWcTjbx1AQ6Zfyjg5bZ+idqPgMbqM9Zn2+OaSby8HEEXS0QeZVooDVf/6wdYO4MQ/0A=
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -64,7 +64,7 @@ test: deps
go test -tags silent -v ./...

test_sharness: $(sharness)
@sh sharness/run-sharness-tests.sh
@cd sharness; ./t0051-service-state-upgrade-from-old.sh

test_problem: deps
go test -tags debug -v -run $(problematic_test)
Expand Down
17 changes: 7 additions & 10 deletions sharness/lib/test-lib.sh
Expand Up @@ -6,8 +6,8 @@
SHARNESS_LIB="lib/sharness/sharness.sh"

# Daemons output will be redirected to...
#IPFS_OUTPUT="/dev/null" # change for debugging
IPFS_OUTPUT="/dev/stderr" # change for debugging
IPFS_OUTPUT="/dev/null" # change for debugging
#IPFS_OUTPUT="/dev/stderr" # change for debugging

. "$SHARNESS_LIB" || {
echo >&2 "Cannot source: $SHARNESS_LIB"
Expand Down Expand Up @@ -71,10 +71,7 @@ test_cluster_init() {
if [ -n "$custom_config_files" ]; then
cp -f ${custom_config_files}/* "test-config"
fi
ipfs-cluster-service --config "test-config" >"$IPFS_OUTPUT" 2>&1 &
export CLUSTER_D_PID=$!
sleep 5
test_set_prereq CLUSTER
cluster_start
}

test_cluster_config() {
Expand All @@ -100,13 +97,14 @@ test_confirm_v1State() {

cluster_kill(){
kill -1 "$CLUSTER_D_PID"
sleep 20
sleep 4
}

cluster_start(){
ipfs-cluster-service --config "test-config" >"$IPFS_OUTPUT" 2>&1 &
export CLUSTER_D_PID=$!
sleep 40
sleep 5
test_set_prereq CLUSTER
}


Expand All @@ -118,7 +116,6 @@ test_clean_ipfs(){
}

test_clean_cluster(){
kill -1 "$CLUSTER_D_PID"
cluster_kill
rm -rf 'test-config'
sleep 2
}
16 changes: 12 additions & 4 deletions sharness/t0050-service-state-upgrade-from-current.sh
Expand Up @@ -9,12 +9,20 @@ cleanup test_clean_ipfs
test_cluster_init
cleanup test_clean_cluster

test_expect_success IPFS,CLUSTER "cluster-service state preserved by migration" '
test_expect_success IPFS,CLUSTER "cluster-service state upgrade works" '
cid=`docker exec ipfs sh -c "echo testing | ipfs add -q"` &&
ipfs-cluster-ctl pin add "$cid" && sleep 30 &&
ipfs-cluster-ctl pin add "$cid" &&
sleep 2 &&
cluster_kill &&
ipfs-cluster-service --config "test-config" state upgrade >/dev/stderr &&
cluster_start &&
ipfs-cluster-service -d --config "test-config" state upgrade &>state-upgrade-cmd.txt
'

# previous test kills the cluster, we need to re-start
# if done inside the test, we lose debugging output
cluster_start

test_expect_success IPFS,CLUSTER "state is preserved after migration" '
cid=`docker exec ipfs sh -c "echo testing | ipfs add -q"` &&
ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid" &&
ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED"
'
Expand Down
14 changes: 7 additions & 7 deletions sharness/t0051-service-state-upgrade-from-old.sh
Expand Up @@ -18,14 +18,14 @@ cleanup test_clean_cluster
test_expect_success IPFS,CLUSTER,V1STATE,JQ "cluster-service loads v1 state correctly" '
cid=`docker exec ipfs sh -c "echo test | ipfs add -q"` &&
cid2=`docker exec ipfs sh -c "echo testing | ipfs add -q"` &&
ipfs-cluster-ctl pin add "$cid2" && sleep 30 &&
ipfs-cluster-ctl pin add "$cid2" &&
cluster_kill &&
SNAP_DIR="test-config/ipfs-cluster-data/snapshots/" &&
SNAP_DIR+="$( ls test-config/ipfs-cluster-data/snapshots/ | head -n 1)" &&
cp v1State $SNAP_DIR/state.bin &&
cat $SNAP_DIR/meta.json | jq --arg CRC "$V1_CRC" '"'"'.CRC = $CRC'"'"' > tmp.json&&
cp tmp.json $SNAP_DIR/meta.json &&
ipfs-cluster-service --config "test-config" state upgrade >/dev/stderr &&
sleep 15 &&
SNAP_DIR=`find test-config/ipfs-cluster-data/snapshots/ -maxdepth 1 -mindepth 1 | head -n 1` &&
cp v1State "$SNAP_DIR/state.bin" &&
cat "$SNAP_DIR/meta.json" | jq --arg CRC "$V1_CRC" '"'"'.CRC = $CRC'"'"' > tmp.json &&
cp tmp.json "$SNAP_DIR/meta.json" &&
ipfs-cluster-service --debug --config "test-config" state upgrade &&
cluster_start &&
ipfs-cluster-ctl pin ls "$cid" | grep -q "$cid" &&
ipfs-cluster-ctl status "$cid" | grep -q -i "PINNED"
Expand Down

0 comments on commit 627556a

Please sign in to comment.