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

test(server/v2): Add system-test for store's command #21357

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

hieuvubk
Copy link
Contributor

@hieuvubk hieuvubk commented Aug 19, 2024

Description

Closes: #21184

Add system-test for snapshots & prune
Currently v1 TestSnapshots failed because of #21404

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new method for executing CLI commands with arguments, improving clarity and testing capabilities.
    • Added comprehensive system tests for snapshot management, covering creation, listing, dumping, deletion, loading, and restoration.
    • Implemented methods for starting and stopping individual validator nodes, enhancing control over testing environments.
  • Bug Fixes

    • Improved validation of snapshot restoration processes to prevent errors related to unexpected payload states.

@hieuvubk hieuvubk requested a review from a team as a code owner August 19, 2024 13:01
Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Walkthrough

Walkthrough

The recent changes introduce enhanced testing capabilities for a blockchain application, focusing on CLI command execution and snapshot management. A new method for running commands with arguments was added, along with comprehensive system tests for snapshot operations such as creation, deletion, and restoration. Additionally, the ability to start and stop individual validator nodes was integrated, allowing for improved control during testing scenarios.

Changes

Files Change Summary
tests/systemtests/cli.go Added RunCommandWithArgs method to CLIWrapper for executing CLI commands with arguments.
tests/systemtests/system.go Added StopSingleNode and StartSingleNode methods to SystemUnderTest for managing validator nodes.
tests/systemtests/snapshots_test.go Introduced system tests for snapshot management, covering creation, listing, dumping, deletion, and loading.
tests/systemtests/snapshots_v1_test.go Added system tests for snapshot management, including exporting, listing, dumping, deleting, and loading.
tests/systemtests/snapshots_v2_test.go Enhanced system tests for snapshot lifecycle and pruning operations within the blockchain.

Sequence Diagram(s)

sequenceDiagram
    participant CLIWrapper
    participant SystemUnderTest
    participant SnapshotManager

    CLIWrapper->>SystemUnderTest: RunCommandWithArgs(args)
    SystemUnderTest->>CLIWrapper: Execute command
    alt Command Success
        CLIWrapper-->>SystemUnderTest: Return output
        SystemUnderTest->>SnapshotManager: Manage snapshot operations
        SnapshotManager->>SnapshotManager: Create, List, Delete, Load snapshots
    else Command Failure
        CLIWrapper-->>SystemUnderTest: Return error output
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add system-test for store's commands (#[21184])
Validate snapshot management functions (#[21184])
Improve CLI command execution for testing (#[21184])
Enhance control over individual nodes for testing (#[21184])

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 294b608 and 5b815ef.

Files selected for processing (3)
  • tests/systemtests/cli.go (1 hunks)
  • tests/systemtests/snapshots_test.go (1 hunks)
  • tests/systemtests/system.go (1 hunks)
Additional context used
Path-based instructions (3)
tests/systemtests/snapshots_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

tests/systemtests/cli.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

tests/systemtests/system.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (15)
tests/systemtests/snapshots_test.go (12)

16-26: Ensure chain is properly reset and started.

The chain is reset and started before performing snapshot operations, which is good practice to ensure a clean test environment.


34-37: Verify snapshot export operation.

The test correctly verifies the snapshot export operation by checking for the presence of a success message and the existence of the snapshot directory.


39-41: Check snapshot list operation.

The snapshot list operation is verified by checking for the expected height in the output.


43-46: Validate snapshot dump operation.

The test ensures that the snapshot dump operation is successful by checking for the existence of the output file.


48-50: Confirm snapshot delete operation.

The snapshot delete operation is validated by confirming the absence of the snapshot directory.


52-54: Verify snapshot load operation.

The snapshot load operation is verified by checking for the re-creation of the snapshot directory.


58-62: Ensure databases are removed before restore.

The test correctly removes the application and state sync databases before attempting to restore from a snapshot, ensuring a clean state.


64-66: Validate snapshot restore operation.

The snapshot restore operation is confirmed by checking the existence of the restored databases.


68-69: Restart node after snapshot operations.

The node is restarted after completing snapshot operations, which is necessary to ensure the system is back to a running state.


72-82: Ensure chain is properly reset and started for prune test.

The chain is reset and started before performing the prune operation, ensuring a clean test environment.


90-92: Verify prune operation.

The prune operation is validated by checking for a success message in the output.


94-95: Restart node after prune operation.

The node is restarted after the prune operation, ensuring the system is back to a running state.

tests/systemtests/cli.go (1)

172-180: Well-implemented method for running CLI commands.

The RunCommandWithArgs method is correctly implemented as a wrapper around the run method, providing a clear interface for executing CLI commands with arguments.

tests/systemtests/system.go (2)

334-351: Ensure error handling for stopping nodes.

The StopSingleNode method is well-implemented for stopping a single validator node. Ensure that the method is used in contexts where stopping the first node is appropriate, as it assumes the first PID corresponds to the node to be stopped.


353-362: Correct implementation for starting a single node.

The StartSingleNode method is correctly implemented, executing the command to start a node and ensuring no errors occur during the process.

@julienrbrt julienrbrt added backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release and removed backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release labels Aug 19, 2024
Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

nice job!!

"github.com/stretchr/testify/require"
)

const nodeDir = "./testnet/node0/simdv2"
Copy link
Member

Choose a reason for hiding this comment

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

this wont work with v1, we should make sure it works with both

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5b815ef and 0758a91.

Files selected for processing (2)
  • tests/systemtests/snapshots_test.go (1 hunks)
  • tests/systemtests/system.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tests/systemtests/snapshots_test.go
  • tests/systemtests/system.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0758a91 and 59486ec.

Files selected for processing (1)
  • tests/systemtests/snapshots_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/systemtests/snapshots_test.go

// RunCommandWithArgs use for run cli command, not tx
func (c CLIWrapper) RunCommandWithArgs(args ...string) string {
c.t.Helper()
execOutput, ok := c.run(args)
Copy link
Member

Choose a reason for hiding this comment

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

It always returns the execOutput here, shouldn't it return an error if not okay? Or is that expected that ok is ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think should ignore it with the local command. execOutput already returns err if cmd failed, handler by run func.

}

// Kill the 1st node
return p.Kill()
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to kill it that way? This sends iirc a SIGKILL, we may want to stop the node more gracefully with SIGTERM

@@ -0,0 +1,121 @@
//go:build system_test
Copy link
Member

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

Copy link
Contributor Author

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 has snapshots?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 59486ec and c25487e.

Files selected for processing (2)
  • tests/systemtests/cli.go (1 hunks)
  • tests/systemtests/system.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tests/systemtests/cli.go
  • tests/systemtests/system.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c25487e and 957446f.

Files selected for processing (1)
  • tests/systemtests/system.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/systemtests/system.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 957446f and 92c8ad7.

Files selected for processing (2)
  • tests/systemtests/cli.go (1 hunks)
  • tests/systemtests/system.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • tests/systemtests/cli.go
  • tests/systemtests/system.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 92c8ad7 and 15c15e5.

Files selected for processing (4)
  • tests/systemtests/Makefile (1 hunks)
  • tests/systemtests/snapshots_v1_test.go (1 hunks)
  • tests/systemtests/snapshots_v2_test.go (1 hunks)
  • tests/systemtests/system.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/systemtests/system.go
Additional context used
Path-based instructions (3)
tests/systemtests/Makefile (1)

Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"

tests/systemtests/snapshots_v1_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

tests/systemtests/snapshots_v2_test.go (3)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

Additional comments not posted (1)
tests/systemtests/Makefile (1)

8-8: LGTM!

The dynamic construction of the -tags option based on the presence of v2 in the COSMOS_BUILD_OPTIONS variable enhances the flexibility of the test command.

The code changes are approved.

Comment on lines +17 to +66
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)
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))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a more reliable synchronization mechanism.

The hardcoded sleep durations might make the tests flaky. Consider using a more reliable synchronization mechanism, such as waiting for a specific log message or event, to ensure the chain has produced the required blocks or the node has stopped.

Comment on lines +68 to +90
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)
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")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a more reliable synchronization mechanism.

The hardcoded sleep durations might make the tests flaky. Consider using a more reliable synchronization mechanism, such as waiting for a specific log message or event, to ensure the chain has produced the required blocks or the node has stopped.

Comment on lines +17 to +70
func TestSnapshots(t *testing.T) {
fmt.Println("TestSnapshots")
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))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a more reliable synchronization mechanism.

The hardcoded sleep durations might make the tests flaky. Consider using a more reliable synchronization mechanism, such as waiting for a specific log message or event, to ensure the chain has produced the required blocks or the node has stopped.

Comment on lines +72 to +94
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)
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")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a more reliable synchronization mechanism.

The hardcoded sleep durations might make the tests flaky. Consider using a more reliable synchronization mechanism, such as waiting for a specific log message or event, to ensure the chain has produced the required blocks or the node has stopped.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 15c15e5 and 56d7c9d.

Files selected for processing (1)
  • tests/systemtests/system.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • tests/systemtests/system.go

julienrbrt
julienrbrt previously approved these changes Aug 27, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

ACK

@julienrbrt julienrbrt self-assigned this Sep 2, 2024
@julienrbrt julienrbrt dismissed their stale review September 4, 2024 14:48

found things to change

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

the test looks failing, plus I don't think it runs the v2 in CI until #21539

@@ -5,7 +5,7 @@ WAIT_TIME ?= 45s
all: test

test:
go test -mod=readonly -failfast -tags='system_test' ./... --wait-time=$(WAIT_TIME) --verbose $(if $(findstring v2,$(COSMOS_BUILD_OPTIONS)),--binary=simdv2)
go test -mod=readonly -failfast -tags='system_test $(if $(findstring v2,$(COSMOS_BUILD_OPTIONS)),v2)' ./... --wait-time=$(WAIT_TIME) --verbose $(if $(findstring v2,$(COSMOS_BUILD_OPTIONS)),--binary=simdv2)
Copy link
Member

Choose a reason for hiding this comment

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

In https://github.com/cosmos/cosmos-sdk/pull/21539/files#diff-d430b065976a77ab03608cab74b5c1db97ec128880faab2ea96b24db767ed75eR16-R20, we added a isV2() function, maybe let's use that instead of build tags and just use t.Skip within the test.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 56d7c9d and 114e21b.

Files selected for processing (2)
  • store/snapshots/manager.go (1 hunks)
  • store/v2/snapshots/manager.go (1 hunks)
Additional context used
Path-based instructions (2)
store/snapshots/manager.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

store/v2/snapshots/manager.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (1)
store/snapshots/manager.go (1)

391-395: Correct grammatical error and verify new logic for payload handling.

The error message on line 392 contains a grammatical error. It should be corrected to:

- return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
+ return fmt.Errorf("extension %s has not exhausted the payload stream", metadata.Name)

Additionally, verify that the new logic correctly handles cases where the payload is not fully consumed, which could prevent potential errors in snapshot restoration.

Comment on lines +440 to +444
payload := nextItem.GetExtensionPayload()
if payload != nil && len(payload.Payload) != 0 {
return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
} else {
break
Copy link
Contributor

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:

- return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
+ return fmt.Errorf("extension %s has not exhausted the payload stream", metadata.Name)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
payload := nextItem.GetExtensionPayload()
if payload != nil && len(payload.Payload) != 0 {
return fmt.Errorf("extension %s don't exhausted payload stream", metadata.Name)
} else {
break
payload := nextItem.GetExtensionPayload()
if payload != nil && len(payload.Payload) != 0 {
return fmt.Errorf("extension %s has not exhausted the payload stream", metadata.Name)
} else {
break

@tac0turtle
Copy link
Member

ping on this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Server/v2]: Add system-test for store's commands
4 participants