Skip to content

Commit 31e5851

Browse files
committed
Update migration sharness tests for new migrations
With the new migrations, go-ipfs no longer uses fs-repo-migrations to do repo migrations, and was downloading real migration binaries from the network and running them. This caused failure, but was not caught because the test was expecting `ipfs daemon --migrate` to fail for other reasons. This PR fixes the migration tests by creating the appropriate fake migration binaries in the PATH so that those get run and avoid downloading the real ones. This also fixes a test that was previously marked broken.
1 parent ef866a1 commit 31e5851

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

test/sharness/t0066-migration.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@ test_description="Test migrations auto update prompt"
1010

1111
test_init_ipfs
1212

13+
# Create fake migration binaries instead of letting ipfs download from network
14+
# To test downloading and running actual binaries, comment out this test.
1315
test_expect_success "setup mock migrations" '
1416
mkdir bin &&
15-
echo "#!/bin/bash" > bin/fs-repo-migrations &&
16-
echo "echo 5" >> bin/fs-repo-migrations &&
17-
chmod +x bin/fs-repo-migrations &&
17+
echo "#!/bin/bash" > bin/fs-repo-7-to-8 &&
18+
echo "echo fake applying 7-to-8 repo migration" >> bin/fs-repo-7-to-8 &&
19+
chmod +x bin/fs-repo-7-to-8 &&
20+
echo "#!/bin/bash" > bin/fs-repo-8-to-9 &&
21+
echo "echo fake applying 8-to-9 repo migration" >> bin/fs-repo-8-to-9 &&
22+
chmod +x bin/fs-repo-8-to-9 &&
23+
echo "#!/bin/bash" > bin/fs-repo-9-to-10 &&
24+
echo "echo fake applying 9-to-10 repo migration" >> bin/fs-repo-9-to-10 &&
25+
chmod +x bin/fs-repo-9-to-10 &&
26+
echo "#!/bin/bash" > bin/fs-repo-10-to-11 &&
27+
echo "echo fake applying 10-to-11 repo migration" >> bin/fs-repo-10-to-11 &&
28+
chmod +x bin/fs-repo-10-to-11 &&
1829
export PATH="$(pwd)/bin":$PATH
1930
'
2031

21-
test_expect_success "manually reset repo version to 3" '
22-
echo "3" > "$IPFS_PATH"/version
32+
test_expect_success "manually reset repo version to 7" '
33+
echo "7" > "$IPFS_PATH"/version
2334
'
2435

2536
test_expect_success "ipfs daemon --migrate=false fails" '
@@ -30,17 +41,25 @@ test_expect_success "output looks good" '
3041
grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out
3142
'
3243

44+
# The migrations will succeed, but the daemon will still exit with 1 because
45+
# the fake migrations do not update the repo version number.
46+
#
47+
# If run with real migrations, the daemon continues running and must be killed.
3348
test_expect_success "ipfs daemon --migrate=true runs migration" '
34-
test_expect_code 1 ipfs daemon --migrate=true > true_out
49+
test_expect_code 1 ipfs daemon --migrate=true > true_out 2>&1
3550
'
3651

37-
test_expect_failure "output looks good" '
38-
grep "Running: " true_out > /dev/null &&
39-
grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null
52+
test_expect_success "output looks good" '
53+
grep "applying 7-to-8 repo migration" true_out > /dev/null &&
54+
grep "applying 8-to-9 repo migration" true_out > /dev/null &&
55+
grep "applying 9-to-10 repo migration" true_out > /dev/null &&
56+
grep "applying 10-to-11 repo migration" true_out > /dev/null &&
57+
grep "Success: fs-repo migrated to version 11" true_out > /dev/null
4058
'
4159

60+
# Daemon exits with 1 after the prompt gets "n" when asking to migrate.
4261
test_expect_success "'ipfs daemon' prompts to auto migrate" '
43-
test_expect_code 1 ipfs daemon > daemon_out 2> daemon_err
62+
test_expect_code 1 bash -c "echo n | ipfs daemon > daemon_out 2> daemon_err"
4463
'
4564

4665
test_expect_success "output looks good" '

0 commit comments

Comments
 (0)