-
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
Changes from all commits
5b815ef
0758a91
59486ec
c25487e
957446f
92c8ad7
c5f3dad
b0cbc41
15c15e5
56d7c9d
8b6328d
8b178b6
a09b4bb
114e21b
0920242
0cd347c
faab668
e642da5
edc05fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
//go:build system_test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? 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 commentThe reason will be displayed to describe this comment to others. Learn more. should we update the prefix, most diff is that v2 has |
||
|
||
package systemtests | ||
|
||
import ( | ||
"fmt" | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestSnapshots(t *testing.T) { | ||
|
||
sut.ResetChain(t) | ||
cli := NewCLIWrapper(t, sut, verbose) | ||
sut.StartChain(t) | ||
|
||
// Wait for chain produce some blocks | ||
sut.AwaitNBlocks(t, 6) | ||
// Stop all nodes | ||
sut.StopChain() | ||
|
||
var ( | ||
command string | ||
restoreableDirs []string | ||
) | ||
node0Dir := sut.NodeDir(0) | ||
if isV2() { | ||
command = "store" | ||
restoreableDirs = []string{fmt.Sprintf("%s/data/application.db", node0Dir), fmt.Sprintf("%s/data/ss", node0Dir)} | ||
} else { | ||
command = "snapshots" | ||
restoreableDirs = []string{fmt.Sprintf("%s/data/application.db", node0Dir)} | ||
} | ||
|
||
// export snapshot at height 5 | ||
res := cli.RunCommandWithArgs(command, "export", "--height=5", fmt.Sprintf("--home=%s", node0Dir)) | ||
require.Contains(t, res, "Snapshot created at height 5") | ||
require.DirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", node0Dir)) | ||
|
||
// Check snapshots list | ||
res = cli.RunCommandWithArgs(command, "list", fmt.Sprintf("--home=%s", node0Dir)) | ||
require.Contains(t, res, "height: 5") | ||
|
||
// Dump snapshot | ||
res = cli.RunCommandWithArgs(command, "dump", "5", "3", fmt.Sprintf("--home=%s", node0Dir), fmt.Sprintf("--output=%s/5-3.tar.gz", node0Dir)) | ||
// Check if output file exist | ||
require.FileExists(t, fmt.Sprintf("%s/5-3.tar.gz", node0Dir)) | ||
|
||
// Delete snapshots | ||
res = cli.RunCommandWithArgs(command, "delete", "5", "3", fmt.Sprintf("--home=%s", node0Dir)) | ||
require.NoDirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", node0Dir)) | ||
|
||
// Load snapshot from file | ||
res = cli.RunCommandWithArgs(command, "load", fmt.Sprintf("%s/5-3.tar.gz", node0Dir), fmt.Sprintf("--home=%s", node0Dir)) | ||
require.DirExists(t, fmt.Sprintf("%s/data/snapshots/5/3", node0Dir)) | ||
|
||
// Restore from snapshots | ||
for _, dir := range restoreableDirs { | ||
require.NoError(t, os.RemoveAll(dir)) | ||
} | ||
// Remove database | ||
err := os.RemoveAll(fmt.Sprintf("%s/data/application.db", node0Dir)) | ||
require.NoError(t, err) | ||
if isV2() { | ||
require.NoError(t, os.RemoveAll(fmt.Sprintf("%s/data/ss", node0Dir))) | ||
} | ||
|
||
res = cli.RunCommandWithArgs(command, "restore", "5", "3", fmt.Sprintf("--home=%s", node0Dir)) | ||
for _, dir := range restoreableDirs { | ||
require.DirExists(t, dir) | ||
} | ||
} | ||
|
||
func TestPrune(t *testing.T) { | ||
sut.ResetChain(t) | ||
cli := NewCLIWrapper(t, sut, verbose) | ||
|
||
sut.StartChain(t) | ||
|
||
// Wait for chain produce some blocks | ||
sut.AwaitNBlocks(t, 6) | ||
|
||
// Stop all nodes | ||
sut.StopChain() | ||
|
||
node0Dir := sut.NodeDir(0) | ||
|
||
// prune | ||
var command []string | ||
if isV2() { | ||
command = []string{"store", "prune", "--keep-recent=1"} | ||
} else { | ||
command = []string{"prune", "everything"} | ||
} | ||
res := cli.RunCommandWithArgs(append(command, fmt.Sprintf("--home=%s", node0Dir))...) | ||
require.Contains(t, res, "successfully pruned the application root multi stores") | ||
} |
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