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

tests: add option to dump genesis files in E2E tests #6100

Merged
merged 38 commits into from
Apr 11, 2024

Conversation

bznein
Copy link
Contributor

@bznein bznein commented Apr 6, 2024

Description

Adds new fields in the e2e config to enable dumping of Genesis files.

closes: #6032


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Summary by CodeRabbit

  • Tests
    • Improved test suites in multiple modules by adding Genesis debug export configuration for enhanced debugging and diagnostics.
  • Chores
    • Renamed function getE2EDir to GetE2EDir in diagnostics.go for consistent naming.
    • Introduced new constants, variables, methods, and structs for Genesis debug management in testconfig.go.
  • Chores
    • Updated tool naming conventions in diagnostics.go for better clarity.

Copy link
Contributor

coderabbitai bot commented Apr 6, 2024

Walkthrough

The overarching change across the end-to-end (E2E) test suite involves adding support for dumping genesis files for debugging purposes. This is achieved by introducing a new configuration method, ConfigureGenesisDebugExport, across various test suites and updating the test configuration to handle environment variables related to genesis file export. These enhancements are aimed at improving debuggability and traceability of the test environments.

Changes

File Path Change Summary
e2e/tests/core/.../client_test.go
e2e/tests/core/.../connection_test.go
e2e/tests/interchain_accounts/...
e2e/tests/transfer/...
e2e/tests/upgrades/...
Added ConfigureGenesisDebugExport before running test suites using testifysuite.Run.
e2e/testsuite/diagnostics/diagnostics.go Renamed getE2EDir to GetE2EDir.
e2e/testsuite/testconfig.go Added new constants, variables, methods, and updated structs for genesis debug export configuration.

Assessment against linked issues

Objective Addressed Explanation
Add support for dumping genesis files in E2Es (#6032)

Poem

In the garden of code, where the test suites bloom,
A rabbit hopped in, with a debug tool in the room.
🐇💻 With a hop, skip, and jump, it began to export,
Genesis files in hand, making debugging an effort.
🌟📁 "Trace your steps back," it cheerfully said,
"For every test run, let no clue go unsaid."
In the realm of bytes, it left no stone unturned, every mystery, it yearned.


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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@@ -59,7 +59,7 @@ _verify_dependencies

# if the dev configs directory is present, enable fzf completion to select a test config file to use.
if [[ -d "dev-configs" ]]; then
export E2E_CONFIG_PATH="$(pwd)/dev-configs/$(_select_test_config)"
export E2E_CONFIG_PATH="/workspaces/ibc-go/e2e/dev-configs/config.yaml"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be reverted before review. I had to do it as I don't have fzf available on github codespaces

@bznein bznein changed the title E2e genesis tests: add option to dump genesis files in E2E tests Apr 6, 2024
@bznein bznein marked this pull request as ready for review April 6, 2024 15:41
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between aae184b and 3a78f8c.
Files selected for processing (20)
  • e2e/tests/core/02-client/client_test.go (1 hunks)
  • e2e/tests/core/03-connection/connection_test.go (1 hunks)
  • e2e/tests/interchain_accounts/base_test.go (1 hunks)
  • e2e/tests/interchain_accounts/gov_test.go (1 hunks)
  • e2e/tests/interchain_accounts/groups_test.go (1 hunks)
  • e2e/tests/interchain_accounts/incentivized_test.go (1 hunks)
  • e2e/tests/interchain_accounts/localhost_test.go (1 hunks)
  • e2e/tests/interchain_accounts/params_test.go (1 hunks)
  • e2e/tests/interchain_accounts/query_test.go (1 hunks)
  • e2e/tests/interchain_accounts/upgrades_test.go (1 hunks)
  • e2e/tests/transfer/authz_test.go (1 hunks)
  • e2e/tests/transfer/base_test.go (1 hunks)
  • e2e/tests/transfer/incentivized_test.go (1 hunks)
  • e2e/tests/transfer/localhost_test.go (1 hunks)
  • e2e/tests/transfer/upgrades_test.go (1 hunks)
  • e2e/tests/upgrades/genesis_test.go (1 hunks)
  • e2e/tests/upgrades/upgrade_test.go (1 hunks)
  • e2e/testsuite/diagnostics/diagnostics.go (2 hunks)
  • e2e/testsuite/testconfig.go (7 hunks)
  • e2e/testsuite/testsuite.go (2 hunks)
Additional comments not posted (24)
e2e/tests/interchain_accounts/gov_test.go (1)

31-33: Ensure the ConfigureGenesisDebugExport method is implemented correctly and adheres to the intended debug export configuration for Genesis files.

e2e/tests/core/03-connection/connection_test.go (1)

28-30: Ensure the ConfigureGenesisDebugExport method is correctly implemented to enable Genesis file debugging as intended.

e2e/tests/interchain_accounts/query_test.go (1)

29-31: Confirm that the ConfigureGenesisDebugExport method is implemented as expected to facilitate Genesis file debugging.

e2e/testsuite/diagnostics/diagnostics.go (1)

165-166: The renaming of getE2EDir to GetE2EDir improves consistency and clarity in naming conventions. Ensure that all references to this function have been updated accordingly.

e2e/tests/transfer/localhost_test.go (1)

23-25: Verify that the ConfigureGenesisDebugExport method is correctly implemented to enable Genesis file debugging for the LocalhostTransferTestSuite.

e2e/tests/interchain_accounts/groups_test.go (1)

62-64: Ensure the ConfigureGenesisDebugExport method is implemented correctly for the InterchainAccountsGroupsTestSuite to facilitate Genesis file debugging.

e2e/tests/upgrades/genesis_test.go (1)

32-34: Confirm that the ConfigureGenesisDebugExport method is correctly implemented for the GenesisTestSuite to enable Genesis file debugging.

e2e/tests/interchain_accounts/params_test.go (1)

34-36: LGTM! Ensure that the integration and functionality of the Genesis file dumping feature are verified through additional testing.

e2e/tests/transfer/authz_test.go (1)

26-28: LGTM! The addition of ConfigureGenesisDebugExport before running the test suite is a good practice for setting up test configurations, especially for debugging purposes.

e2e/tests/interchain_accounts/upgrades_test.go (1)

32-34: LGTM! The addition of ConfigureGenesisDebugExport before running the test suite is a good practice for setting up test configurations, especially for debugging purposes.

e2e/tests/interchain_accounts/incentivized_test.go (1)

31-33: LGTM! The addition of ConfigureGenesisDebugExport before running the test suite is a good practice for setting up test configurations, especially for debugging purposes.

e2e/tests/transfer/upgrades_test.go (1)

24-26: The addition of ConfigureGenesisDebugExport before running the test suite is appropriate for enabling Genesis file dumping for debugging purposes. Ensure that this new setup integrates well with the existing test suite and does not introduce any side effects.

e2e/tests/interchain_accounts/localhost_test.go (1)

33-35: The addition of ConfigureGenesisDebugExport before running the test suite is appropriate for enabling Genesis file dumping for debugging purposes. Ensure that this new setup integrates well with the existing test suite and does not introduce any side effects.

e2e/tests/transfer/base_test.go (1)

28-30: LGTM! The addition of ConfigureGenesisDebugExport before running the test suite ensures that Genesis file dumping is configured correctly for debugging purposes.

e2e/tests/interchain_accounts/base_test.go (1)

39-41: LGTM! The addition of ConfigureGenesisDebugExport before running the test suite ensures that Genesis file dumping is configured correctly for debugging purposes.

e2e/testsuite/testsuite.go (3)

7-10: The import statements for os, path, and testing are correctly added to support the new functionality introduced in this PR.


73-112: The logic and flow within the ConfigureGenesisDebugExport function are correctly implemented to configure the environment for Genesis file export based on the test configuration.


102-111: The setting of environment variables EXPORT_GENESIS_FILE_PATH and EXPORT_GENESIS_CHAIN is correctly implemented. Ensure that the usage and purpose of these environment variables are well-documented for maintainability and clarity for other developers.

e2e/tests/core/02-client/client_test.go (1)

47-49: The addition of ConfigureGenesisDebugExport before running the test suite is appropriate for enabling Genesis file dumping for debugging. Ensure that this function does not inadvertently alter test behavior when Genesis file dumping is not enabled.

e2e/testsuite/testconfig.go (3)

71-77: The addition of defaultGenesisExportPath and defaultChainNames provides sensible defaults for the Genesis file dumping feature and chain naming, respectively. These are straightforward and support the new functionality well.


173-200: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [176-260]

The addition of GetChainIndex, validateGenesisDebugConfig, GetChainName, and GetGenesisChainName methods enhances the test suite's configuration capabilities, especially for the new Genesis file dumping feature. Ensure that appropriate error handling is implemented for GetChainIndex to manage cases where an invalid chain name is provided.


280-302: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [271-292]

The introduction of a Name field in the ChainConfig struct and the creation of the GenesisDebugConfig struct are key enhancements for supporting the Genesis file dumping feature. It's recommended to document the expected format or constraints for the ExportFilePath in GenesisDebugConfig to guide users in configuring this feature correctly.

e2e/tests/transfer/incentivized_test.go (1)

35-36: The addition of the ConfigureGenesisDebugExport method call before running the test suite is correctly placed and aligns with the PR's objectives to enable Genesis file dumping for debugging purposes.

e2e/tests/upgrades/upgrade_test.go (1)

50-52: Ensure that the behavior of the test suite remains consistent when Genesis file dumping is not enabled or when the environment variables controlling this feature are not set.

if exportPath == "" {
e2eDir, err := diagnostics.GetE2EDir(t)
if err != nil {
s.Fail("can't get e2edir: %w", err)
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 6, 2024

Choose a reason for hiding this comment

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

Consider using s.Require().NoError(err) instead of s.Fail for error handling to immediately halt the test execution upon encountering an error, ensuring cleaner test failures and avoiding potential subsequent errors.

- s.Fail("can't get e2edir: %w", err)
+ s.Require().NoError(err, "can't get e2edir")

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.

Suggested change
s.Fail("can't get e2edir: %w", err)
s.Require().NoError(err, "can't get e2edir")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you kind rabbit!

Copy link
Contributor

Choose a reason for hiding this comment

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

@bznein, you're very welcome! I'm here to help. 😊

(\__/) 
(•ㅅ•) CodeRabbit is happy to assist!
/   づ

If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3a78f8c and 06795b2.
Files selected for processing (1)
  • e2e/testsuite/testsuite.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/testsuite/testsuite.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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 06795b2 and 1cd3073.
Files selected for processing (1)
  • e2e/testsuite/testsuite.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • e2e/testsuite/testsuite.go

@bznein bznein marked this pull request as ready for review April 8, 2024 09:32
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1cd3073 and 0261a22.
Files selected for processing (2)
  • e2e/testsuite/testconfig.go (7 hunks)
  • e2e/testsuite/testsuite.go (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • e2e/testsuite/testconfig.go
  • e2e/testsuite/testsuite.go

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM, we can hold off on merging in case the test failures are related (I don't think they are 🤔 )


// If no path is provided, use the default (e2e/diagnostics/genesis.json).
if exportPath == "" {
e2eDir, err := diagnostics.GetE2EDir(s.T())
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth moving this to an e2e/internal instead of diagnostics? Since it's being used elsewhere now, I think either is probably fine though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, done!

exportPath = gopath.Join(wd, exportPath)
}

t.Setenv("EXPORT_GENESIS_FILE_PATH", exportPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a link to interchaintest code for where this is used

@@ -68,8 +68,14 @@ const (
// defaultConfigFileName is the default filename for the config file that can be used to configure
// e2e tests. See sample.config.yaml as an example for what this should look like.
defaultConfigFileName = ".ibc-go-e2e-config.yaml"

// defaultGenesisExportPath is the default path to which Genesis debug files will be exported to.
defaultGenesisExportPath = "diagnostics/genesis.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

if we end up moving the GetE2EPath to internal, maybe we can move this constant there too.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0261a22 and 63db86c.
Files selected for processing (4)
  • e2e/internal/directories/directories.go (1 hunks)
  • e2e/testsuite/diagnostics/diagnostics.go (3 hunks)
  • e2e/testsuite/testconfig.go (7 hunks)
  • e2e/testsuite/testsuite.go (3 hunks)
Files skipped from review as they are similar to previous changes (3)
  • e2e/testsuite/diagnostics/diagnostics.go
  • e2e/testsuite/testconfig.go
  • e2e/testsuite/testsuite.go
Additional comments not posted (1)
e2e/internal/directories/directories.go (1)

14-15: Introduce a configurable path for Genesis file export.

While having a default path (diagnostics/genesis.json) for Genesis file exports is a good practice, it might be beneficial to allow this path to be configurable through environment variables or test configuration. This would provide flexibility in specifying the output directory based on different testing environments or requirements.

e2e/internal/directories/directories.go Show resolved Hide resolved
@chatton chatton enabled auto-merge (squash) April 9, 2024 10:21
@@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"os"
gopath "path"
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why an alias was chosen here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch and yes! The reason is that at line 175 we have a function that uses a variable named path, and this made the linter sad :(

Of course, now that I think about it, I could have easily just changed the variable instead, which is probably cleaner. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

No super strong opinion but I'd go with changing the var name personally. Prefer to keep the stdlib imports as unaliased as possible 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@bznein bznein requested a review from DimitrisJim April 10, 2024 10:50
auto-merge was automatically disabled April 10, 2024 11:26

Head branch was pushed to by a user without write access

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

lgtm, left one tangible q just to make sure I'm understanding the flow correctly

e2e/testsuite/testsuite.go Outdated Show resolved Hide resolved
@@ -67,6 +70,49 @@ func newPath(chainA, chainB ibc.Chain) pathPair {
}
}

func (s *E2ETestSuite) SetupTest() {
s.ConfigureGenesisDebugExport()
Copy link
Contributor

Choose a reason for hiding this comment

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

this basically means we'll run these per test yea? Is this expected behavior?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, basically just a way to make sure that env vars get set for each specific test based on the config.

}

// ConfigureGenesisDebugExport sets, if needed, env variables to enable exporting of Genesis debug files.
func (s *E2ETestSuite) ConfigureGenesisDebugExport() {
Copy link
Contributor

Choose a reason for hiding this comment

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

looking now, I think we can make this unexported actually, should never have as need for this outside of this testsuite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@chatton chatton merged commit 4e9bd4e into cosmos:main Apr 11, 2024
77 checks passed
bznein added a commit to bznein/ibc-go that referenced this pull request Apr 12, 2024
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: Cian Hatton <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for dumping genesis files in E2Es
3 participants