Skip to content

Commit

Permalink
added tests for reversibility
Browse files Browse the repository at this point in the history
I cannot test these-- i dont have docker in osx. I would spend
more time but can't. Here's as far as i will get in the near future.
  • Loading branch information
jbenet committed Feb 16, 2017
1 parent 6de8f1e commit 2e8b5a3
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sharness/t0071-migration-many-backward.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

test_description="Migration to many different versions"

. lib/test-lib.sh

test_expect_success "start a docker container" '
DOCID=$(start_docker)
'

test_install_version "v0.4.5"

test_expect_success "'ipfs init' succeeds" '
export IPFS_PATH=/root/.ipfs &&
exec_docker "$DOCID" "IPFS_PATH=$IPFS_PATH BITS=2048 ipfs init" >actual 2>&1 ||
test_fsh cat actual
'

test_expect_success ".ipfs/ has been created" '
exec_docker "$DOCID" "test -d /root/.ipfs && test -f /root/.ipfs/config"
exec_docker "$DOCID" "test -d /root/.ipfs/datastore && test -d /root/.ipfs/blocks"
'

test_install_version "v0.4.0"
test_repo_version "0.4.0"

# ipfs-update should allow migrating back
test_install_version "v0.3.10"
test_repo_version "0.3.10"

test_expect_success "stop docker container" '
stop_docker "$DOCID"
'

test_done
49 changes: 49 additions & 0 deletions sharness/t0100-migrate-many-backward-5-to-3-sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

test_description="Simple fs-repo-migrations backwards tests"

. lib/test-lib.sh

test_expect_success "start a docker container" '
DOCID=$(start_docker)
'

test_expect_success "fs-repo-migrations binary is on the container" '
exec_docker "$DOCID" "test -f $GUEST_FS_REPO_MIG"
'

test_install_version "v0.4.5"

test_expect_success "'ipfs init' succeeds" '
exec_docker "$DOCID" "IPFS_PATH=/root/.ipfs BITS=2048 ipfs init" >actual 2>&1 ||
test_fsh cat actual
'

test_expect_success ".ipfs/ has been created" '
exec_docker "$DOCID" "test -d /root/.ipfs && test -f /root/.ipfs/config"
exec_docker "$DOCID" "test -d /root/.ipfs/datastore && test -d /root/.ipfs/blocks"
'

test_expect_failure "'fs-repo-migrations -y' fails (no --revert-ok) flag" '
exec_docker "$DOCID" "$GUEST_FS_REPO_MIG -y -to=3" 2>actual
'

test_expect_success "'fs-repo-migrations -y' failure output looks good" '
grep "attempt to run backward migration" actual &&
grep "--revert-ok" actual
'

test_expect_success "'fs-repo-migrations -y --revert-ok' works" '
exec_docker "$DOCID" "$GUEST_FS_REPO_MIG -y -to=3 --revert-ok" >actual
'

test_expect_success "'fs-repo-migrations -y' output looks good" '
grep "Migration 5 to 4 succeeded" actual &&
grep "Migration 4 to 3 succeeded" actual
'

test_expect_success "stop docker container" '
stop_docker "$DOCID"
'

test_done

0 comments on commit 2e8b5a3

Please sign in to comment.