Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update migration sharness tests for new migrations #8053

Merged
merged 5 commits into from
Apr 15, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions test/sharness/t0066-migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,27 @@ test_description="Test migrations auto update prompt"

test_init_ipfs

# Create fake migration binaries instead of letting ipfs download from network
# To test downloading and running actual binaries, comment out this test.
Copy link
Contributor

@aschmahmann aschmahmann Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We weren't testing real binaries here before, right? So this is just a heads up for developers/testers.

Not that it's strictly necessary (as it can cause CI flakiness, slow downs, etc.), but do we happen to already have any integration tests that handle the end-to-end workflow here?

Copy link
Contributor Author

@gammazero gammazero Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, before we were also testing a fake migration binary (mocked fs-repo-migrations). No that we do not have one fs-repo-migration, but have separate migration executables, I make fake versions of those now.

The actual migrations are tested in fs-repo-migrations sharness tests. This part tests that the go-ipfs will actually run the migrations.

The part that is missing from a complete end-to-end test is testing go-ipfs downloading migrations from the network.

test_expect_success "setup mock migrations" '
mkdir bin &&
echo "#!/bin/bash" > bin/fs-repo-migrations &&
echo "echo 5" >> bin/fs-repo-migrations &&
chmod +x bin/fs-repo-migrations &&
echo "#!/bin/bash" > bin/fs-repo-7-to-8 &&
echo "echo fake applying 7-to-8 repo migration" >> bin/fs-repo-7-to-8 &&
chmod +x bin/fs-repo-7-to-8 &&
echo "#!/bin/bash" > bin/fs-repo-8-to-9 &&
echo "echo fake applying 8-to-9 repo migration" >> bin/fs-repo-8-to-9 &&
chmod +x bin/fs-repo-8-to-9 &&
echo "#!/bin/bash" > bin/fs-repo-9-to-10 &&
echo "echo fake applying 9-to-10 repo migration" >> bin/fs-repo-9-to-10 &&
chmod +x bin/fs-repo-9-to-10 &&
echo "#!/bin/bash" > bin/fs-repo-10-to-11 &&
echo "echo fake applying 10-to-11 repo migration" >> bin/fs-repo-10-to-11 &&
chmod +x bin/fs-repo-10-to-11 &&
export PATH="$(pwd)/bin":$PATH
'

test_expect_success "manually reset repo version to 3" '
echo "3" > "$IPFS_PATH"/version
test_expect_success "manually reset repo version to 7" '
echo "7" > "$IPFS_PATH"/version
'

test_expect_success "ipfs daemon --migrate=false fails" '
Expand All @@ -30,13 +41,20 @@ test_expect_success "output looks good" '
grep "Please get fs-repo-migrations from https://dist.ipfs.io" false_out
'

# The migrations will succeed, but the daemon will still exit with 1 because
# the fake migrations do not update the repo version number.
#
# If run with real migrations, the daemon continues running and must be killed.
test_expect_success "ipfs daemon --migrate=true runs migration" '
test_expect_code 1 ipfs daemon --migrate=true > true_out
'

test_expect_failure "output looks good" '
grep "Running: " true_out > /dev/null &&
grep "Success: fs-repo has been migrated to version 5." true_out > /dev/null
test_expect_success "output looks good" '
grep "applying 7-to-8 repo migration" true_out > /dev/null &&
grep "applying 8-to-9 repo migration" true_out > /dev/null &&
grep "applying 9-to-10 repo migration" true_out > /dev/null &&
grep "applying 10-to-11 repo migration" true_out > /dev/null &&
grep "Success: fs-repo migrated to version 11" true_out > /dev/null
'

test_expect_success "'ipfs daemon' prompts to auto migrate" '
Expand Down