-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 18 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
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,96 @@ | ||
//go:build system_test | ||
|
||
package systemtests | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSnapshotsV1(t *testing.T) { | ||
if isV2() { | ||
t.Skip() | ||
} | ||
|
||
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) | ||
nodeDir := filepath.Join(WorkDir, "testnet", "node0", "simd") | ||
|
||
// 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 * 5) | ||
|
||
// export snapshot at height 5 | ||
res := cli.RunCommandWithArgs("snapshots", "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("snapshots", "list", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "height: 5") | ||
|
||
// Dump snapshot | ||
res = cli.RunCommandWithArgs("snapshots", "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("snapshots", "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("snapshots", "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) | ||
|
||
res = cli.RunCommandWithArgs("snapshots", "restore", "5", "3", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/application.db", nodeDir)) | ||
} | ||
|
||
func TestPruneV1(t *testing.T) { | ||
if isV2() { | ||
t.Skip() | ||
} | ||
|
||
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) | ||
nodeDir := filepath.Join(WorkDir, "testnet", "node0", "simd") | ||
|
||
// 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 | ||
res := cli.RunCommandWithArgs("prune", "everything", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "successfully pruned the application root multi stores") | ||
} |
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,98 @@ | ||
//go:build system_test | ||
|
||
package systemtests | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSnapshotsV2(t *testing.T) { | ||
if !isV2() { | ||
t.Skip() | ||
} | ||
|
||
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) | ||
nodeDir := filepath.Join(WorkDir, "testnet", "node0", "simdv2") | ||
|
||
// 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 * 5) | ||
|
||
// export snapshot at height 5 | ||
res := cli.RunCommandWithArgs("store", "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("store", "list", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "height: 5") | ||
|
||
// Dump snapshot | ||
res = cli.RunCommandWithArgs("store", "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("store", "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("store", "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) | ||
err = os.RemoveAll(fmt.Sprintf("%s/data/ss", nodeDir)) | ||
require.NoError(t, err) | ||
|
||
res = cli.RunCommandWithArgs("store", "restore", "5", "3", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/application.db", nodeDir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/ss", nodeDir)) | ||
} | ||
|
||
func TestPruneV2(t *testing.T) { | ||
if !isV2() { | ||
t.Skip() | ||
} | ||
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) | ||
nodeDir := filepath.Join(WorkDir, "testnet", "node0", "simdv2") | ||
|
||
// 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 | ||
res := cli.RunCommandWithArgs("store", "prune", "--keep-recent=1", fmt.Sprintf("--home=%s", nodeDir)) | ||
require.Contains(t, res, "successfully pruned the application root multi stores") | ||
} |
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
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.
Grammar correction needed in error message.
The error message in the condition check uses incorrect grammar. It should be corrected to maintain professionalism and clarity in the codebase. Here's the suggested correction:
Committable suggestion