-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
test(server/v2): Add system-test for store's command #21357
Merged
Merged
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5b815ef
add store tests
hieuvubk 0758a91
update
hieuvubk 59486ec
update test
hieuvubk c25487e
feedback
hieuvubk 957446f
update
hieuvubk 92c8ad7
Merge branch 'main' into hieu/systemtest/store
hieuvubk c5f3dad
sort pids before stop the 1st node
hieuvubk b0cbc41
split the tests
hieuvubk 15c15e5
Merge branch 'hieu/systemtest/store' of https://github.com/cosmos/cos…
hieuvubk 56d7c9d
fix
hieuvubk 8b6328d
Merge branch 'main' into hieu/systemtest/store
hieuvubk 8b178b6
temp fix
hieuvubk a09b4bb
Merge branch 'hieu/systemtest/store' of https://github.com/cosmos/cos…
hieuvubk 114e21b
Merge branch 'main' into hieu/systemtest/store
hieuvubk 0920242
resolve conflit
hieuvubk 0cd347c
update v2 test
hieuvubk faab668
lint
hieuvubk e642da5
update tests
hieuvubk edc05fb
Merge v1/v2 tests (#21857)
alpe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
//go:build system_test | ||
|
||
package systemtests | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func getBinaryNameAndPrefix(isSnapshot bool) (string, string) { | ||
if sut.execBinary == filepath.Join(WorkDir, "binaries", "simd") { | ||
if isSnapshot { | ||
return "simd", "snapshots" | ||
} | ||
return "simd", "" | ||
} | ||
return "simdv2", "store" | ||
} | ||
|
||
func TestSnapshots(t *testing.T) { | ||
sut.ResetChain(t) | ||
cli := NewCLIWrapper(t, sut, verbose) | ||
// add genesis account with some tokens | ||
account1Addr := cli.AddKey("account1") | ||
sut.ModifyGenesisCLI(t, | ||
[]string{"genesis", "add-genesis-account", account1Addr, "10000000stake"}, | ||
) | ||
|
||
sut.StartChain(t) | ||
|
||
binary, snapshotPrefix := getBinaryNameAndPrefix(true) | ||
nodeDir := fmt.Sprintf("./testnet/node0/%s", binary) | ||
|
||
// Wait for chain produce some blocks | ||
time.Sleep(time.Second * 10) | ||
// Stop 1 node | ||
err := sut.StopSingleNode() | ||
require.NoError(t, err) | ||
time.Sleep(time.Second) | ||
|
||
// export snapshot at height 5 | ||
res := cli.RunCommandWithArgs(snapshotPrefix, "export", "--height=5", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "Snapshot created at height 5") | ||
require.DirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", nodeDir)) | ||
|
||
// Check snapshots list | ||
res = cli.RunCommandWithArgs(snapshotPrefix, "list", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "height: 5") | ||
|
||
// Dump snapshot | ||
res = cli.RunCommandWithArgs(snapshotPrefix, "dump", "5", "3", fmt.Sprintf("--home=%s", nodeDir), fmt.Sprintf("--output=%s/5-3.tar.gz", nodeDir)) | ||
// Check if output file exist | ||
require.FileExists(t, fmt.Sprintf("%s/5-3.tar.gz", nodeDir)) | ||
|
||
// Delete snapshots | ||
res = cli.RunCommandWithArgs(snapshotPrefix, "delete", "5", "3", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.NoDirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", nodeDir)) | ||
|
||
// Load snapshot from file | ||
res = cli.RunCommandWithArgs(snapshotPrefix, "load", fmt.Sprintf("%s/5-3.tar.gz", nodeDir), fmt.Sprintf("--home=%s", nodeDir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", nodeDir)) | ||
|
||
// Restore from snapshots | ||
|
||
// Remove database | ||
err = os.RemoveAll(fmt.Sprintf("%s/data/application.db", nodeDir)) | ||
require.NoError(t, err) | ||
|
||
// Only v2 have ss database | ||
if binary == "simdv2" { | ||
err = os.RemoveAll(fmt.Sprintf("%s/data/ss", nodeDir)) | ||
require.NoError(t, err) | ||
} | ||
|
||
res = cli.RunCommandWithArgs(snapshotPrefix, "restore", "5", "3", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/application.db", nodeDir)) | ||
if binary == "simdv2" { | ||
require.DirExists(t, fmt.Sprintf("%s/data/ss", nodeDir)) | ||
} | ||
|
||
// Start the node | ||
sut.StartSingleNode(t, nodeDir) | ||
} | ||
|
||
func TestPrune(t *testing.T) { | ||
sut.ResetChain(t) | ||
cli := NewCLIWrapper(t, sut, verbose) | ||
// add genesis account with some tokens | ||
account1Addr := cli.AddKey("account1") | ||
sut.ModifyGenesisCLI(t, | ||
[]string{"genesis", "add-genesis-account", account1Addr, "10000000stake"}, | ||
) | ||
|
||
sut.StartChain(t) | ||
|
||
binary, prefix := getBinaryNameAndPrefix(false) | ||
nodeDir := fmt.Sprintf("./testnet/node0/%s", binary) | ||
|
||
// Wait for chain produce some blocks | ||
time.Sleep(time.Second * 10) | ||
// Stop 1 node | ||
err := sut.StopSingleNode() | ||
require.NoError(t, err) | ||
time.Sleep(time.Second) | ||
|
||
// prune | ||
var res string | ||
if binary == "simdv2" { | ||
res = cli.RunCommandWithArgs(prefix, "prune", "--keep-recent=1", fmt.Sprintf("--home=%s", nodeDir)) | ||
} else { | ||
res = cli.RunCommandWithArgs("prune", "everything", fmt.Sprintf("--home=%s", nodeDir)) | ||
} | ||
require.Contains(t, res, "successfully pruned the application root multi stores") | ||
// Start the node | ||
sut.StartSingleNode(t, nodeDir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the commands are really different between simapp and simapp v2, shall we not split the test in two tests?
The multiple if conditions will make it harder to maintain.
We can then just skip the tests when we run with COSMOS_BUILD_OPTIONS v2 and vice versa
Wdyt? cc @tac0turtle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we update the prefix, most diff is that v2 has
store
prefix and v1 hassnapshots
?