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

Return errors in rollback/rebuild commands when using snapshots #2044

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

manish-sethi
Copy link
Contributor

Signed-off-by: manish manish.sethi@gmail.com

Type of change

  • Bug fix

Description

  • Returns errors in the rollback and rebuild-dbs commands if any channel is bootstrapped from snapshot.
  • Checks for upgrade format before dropping the dbs

Additional details

see [FAB-17800](https://jira.hyperledger.org/browse/FAB-17800

@manish-sethi manish-sethi requested a review from a team as a code owner October 26, 2020 04:12
This commit returns errors in the rollback/rebuild commands if any
channel is bootstrapped from snapshot.

For more details, see FAB-17800

Signed-off-by: manish <manish.sethi@gmail.com>
require.False(t, os.IsNotExist(err))
}

// this should return an error as no ledger has been set up
Copy link
Contributor

Choose a reason for hiding this comment

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

The test name TestRebuildDBsCmd() implies a positive test, but it is actually a negative test to verify an error, should we update the test name to indicate the scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unit test at this level is all about whether the code in this package invokes the actual code in the kvledger package. So, with that intention it's still a positive test. Checking for error case rather helps minimizing the dependency on the kvledger package as it does not need to know internal details of kvledger package. Same for the below comments as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, given the good code comments, I agree.

expectedErr := "ledgerID [ch1] does not exist"
require.Equal(t, expectedErr, err.Error())
// this should return an error as no ledger has been set up
require.Contains(t, err.Error(), "error while checking if any ledger has been bootstrapped from snapshot")
Copy link
Contributor

Choose a reason for hiding this comment

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

The test name TestRollbackCmd() implies a positive test, but it is actually a negative test to verify an error, should we update the test name to indicate the scenario?

@@ -21,5 +21,5 @@ func TestUpgradeDBsCmd(t *testing.T) {
defer os.RemoveAll(testPath)

cmd := upgradeDBsCmd()
require.NoError(t, cmd.Execute())
require.EqualError(t, cmd.Execute(), "the data format is already up to date. No upgrade is required")
Copy link
Contributor

Choose a reason for hiding this comment

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

The test name TestUpgradeDBsCmd() implies a positive test, but it is actually a negative test to verify an error, should we update the test name to indicate the scenario?

@denyeart denyeart merged commit 2c921bc into hyperledger:master Oct 27, 2020
@manish-sethi manish-sethi deleted the error_rollback branch November 4, 2020 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants