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

refactor(e2e): migrate the tests to the new knuu #3873

Merged
merged 10 commits into from
Sep 17, 2024

Conversation

mojtaba-esk
Copy link
Member

@mojtaba-esk mojtaba-esk commented Sep 12, 2024

Closes #3780

Since this PR points to a branch on a fork, GetLatestVersion does not fetch the latest commit hash to the main; instead, it fetches the latest commit of the forked repo. So it is tested with the hard coded version 07411e2 which is, currently, the latest commit on the main.
The E2ESimple test passes, did not test the benchmarks which also were not needed for this purpose.

@mojtaba-esk mojtaba-esk requested a review from a team as a code owner September 12, 2024 15:57
@mojtaba-esk mojtaba-esk requested review from staheri14 and rach-id and removed request for a team September 12, 2024 15:57
@celestia-bot celestia-bot requested a review from a team September 12, 2024 15:58
Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

Walkthrough

The pull request introduces substantial modifications to the Testnet struct and its methods, primarily to integrate the knuu package more effectively. Key changes involve the addition of context.Context parameters to various functions, enhancing the ability to manage cancellations and timeouts. A new method for creating a preloader instance has been added, and existing methods have been updated for improved resource management and operational control.

Changes

Files Change Summary
test/e2e/testnet/testnet.go Significant modifications to the Testnet struct, including the addition of context parameters to multiple methods for context-aware operations.
test/e2e/testnet/testnet.go New method NewPreloader added for creating a preloader instance using knuu system dependencies.
test/e2e/testnet/testnet.go Updated Cleanup method to include context handling for cleaning up the knuu instance.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Testnet
    participant Knuu

    User->>Testnet: New(ctx)
    Testnet->>Knuu: Initialize(options)
    Testnet->>User: Testnet Instance Ready
    User->>Testnet: CreateGenesisNode(ctx)
    Testnet->>Knuu: Create Node with Context
    Knuu-->>Testnet: Node Created
    Testnet-->>User: Genesis Node Created
    User->>Testnet: Cleanup(ctx)
    Testnet->>Knuu: Cleanup Instance
    Knuu-->>Testnet: Instance Cleaned
Loading

Assessment against linked issues

Objective Addressed Explanation
Stop using deprecated knuu methods (Issue #3780)

Possibly related PRs

Suggested labels

knuu, WS: Maintenance 🔧


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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 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.

test/e2e/main.go Outdated Show resolved Hide resolved
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

Outside diff range and nitpick comments (1)
test/e2e/minor_version_compatibility.go (1)

20-20: Remove the unused parameter.

The additional string parameter _ in the function signature is unused. Consider removing it to keep the function signature clean and concise.

Apply this diff to remove the unused parameter:

-func MinorVersionCompatibility(logger *log.Logger, _ string) error {
+func MinorVersionCompatibility(logger *log.Logger) error {
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3aeb3c5 and 6a60da0.

Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
Files selected for processing (12)
  • go.mod (7 hunks)
  • test/e2e/benchmark/benchmark.go (5 hunks)
  • test/e2e/benchmark/throughput.go (4 hunks)
  • test/e2e/main.go (4 hunks)
  • test/e2e/major_upgrade_v2.go (2 hunks)
  • test/e2e/minor_version_compatibility.go (3 hunks)
  • test/e2e/simple.go (1 hunks)
  • test/e2e/testnet/defaults.go (1 hunks)
  • test/e2e/testnet/node.go (13 hunks)
  • test/e2e/testnet/setup.go (2 hunks)
  • test/e2e/testnet/testnet.go (20 hunks)
  • test/e2e/testnet/txsimNode.go (5 hunks)
Additional context used
GitHub Check: lint / golangci-lint
test/e2e/main.go

[failure] 25-25:
ineffectual assignment to latestVersion (ineffassign)

Additional comments not posted (77)
test/e2e/testnet/defaults.go (1)

6-9: LGTM! The changes improve type safety and align with best practices.

The modifications to the DefaultResources variable, replacing string literals with calls to resource.MustParse, offer several benefits:

  1. Enhanced type safety: By using resource.MustParse, the resource values are correctly parsed into the appropriate types expected by Kubernetes APIs, reducing the risk of type-related errors.

  2. Improved validation and handling: The changes allow for better validation and handling of resource specifications, ensuring that the values are properly formatted and within acceptable ranges.

  3. Alignment with best practices: The use of resource.MustParse aligns with best practices for resource management in Kubernetes environments, promoting consistency and maintainability.

Overall, these changes contribute to a more robust and reliable implementation of resource specifications in the testnet package.

test/e2e/testnet/txsimNode.go (12)

5-5: LGTM!

The import of the context package aligns with the PR objective of enhancing context handling and is consistent with the AI-generated summary.


8-8: LGTM!

The import of the instance package aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


23-23: LGTM!

The modification of the Instance field in the TxSim struct to use *instance.Instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


27-27: LGTM!

The addition of the context.Context parameter to the CreateTxClient function aligns with the PR objective of enhancing context handling and is consistent with the AI-generated summary.


37-37: LGTM!

The addition of the *knuu.Knuu parameter to the CreateTxClient function aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package.


39-39: LGTM!

The creation of a new instance using knuu.NewInstance(name) aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


48-48: LGTM!

The use of txIns.Build().SetImage(ctx, image) to set the image for the instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary. The addition of the ctx parameter also aligns with the PR objective of enhancing context handling.


56-56: LGTM!

The use of txIns.Resources().SetMemory(resources.MemoryRequest, resources.MemoryLimit) to set the memory resources for the instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


60-60: LGTM!

The use of txIns.Resources().SetCPU(resources.CPU) to set the CPU resources for the instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


64-64: LGTM!

The use of txIns.Storage().AddVolumeWithOwner(volumePath, resources.Volume, 10001) to add a volume to the instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


78-78: LGTM!

The use of txIns.Build().SetArgs(args...) to set the arguments for the instance aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.


84-84: LGTM!

The return of a TxSim struct with the Instance field set to txIns aligns with the PR objective of refactoring to eliminate deprecated methods from the knuu package and is consistent with the AI-generated summary.

test/e2e/main.go (4)

15-15: LGTM!

The modification to the TestFunc type to accept a version parameter aligns with the PR objective of migrating the tests to the new Knuu framework. This change can improve the flexibility and clarity of the testing process by explicitly associating tests with the application version they are intended to validate.


25-31: Changes look good! The hardcoded version is a valid temporary workaround.

The changes to retrieve and log the application version align with the PR objective of migrating the tests to the new Knuu framework.

Regarding the hardcoded version on line 29, I acknowledge the past review comment indicating that it's a temporary workaround for a known issue with BBR on Kubernetes. The TODO comment appropriately indicates the intent to remove this workaround once the underlying issue is resolved.

Please ignore the static analysis hint about the ineffectual assignment to latestVersion. It's a false positive because latestVersion is used in subsequent code.

Tools
GitHub Check: lint / golangci-lint

[failure] 25-25:
ineffectual assignment to latestVersion (ineffassign)


44-44: LGTM!

The update to the runTest invocation to pass the latestVersion to each test aligns with the PR objective of migrating the tests to the new Knuu framework. This change ensures that the tests have access to the correct application version during execution.


62-64: LGTM!

The modifications to the runTest function to accept an appVersion parameter and pass it to the test function align with the PR objective of migrating the tests to the new Knuu framework. These changes ensure that the tests have access to the correct application version during execution.

test/e2e/simple.go (5)

17-17: LGTM!

The addition of the appVersion parameter to the function signature is a good change. It allows for more flexibility in specifying the application version directly when calling the function, which is consistent with the PR objective of migrating the tests to the new knuu framework.


18-18: Great job with the context management improvements!

The introduction of the context.Context parameter, ctx, and passing it to various method calls within the testNet object is a great improvement. It enhances the handling of cancellation and deadlines for the operations, which is consistent with the best practices for context management in Go. Also, deferring the testNet.Cleanup method with the ctx parameter ensures proper cleanup even if an error occurs.

Also applies to: 22-22, 25-26


36-36: LGTM!

Passing the ctx parameter to the testNet.Setup and testNet.Start methods is consistent with the context management improvements. It ensures that the setup and start operations respect the context cancellation and deadlines.

Also applies to: 39-39


45-45: LGTM!

Passing the ctx parameter to the testnode.ReadBlockchainHeaders function is consistent with the context management improvements. It ensures that the operation of reading blockchain headers respects the context cancellation and deadlines.


29-29: Verify the assumption about the endpoints slice.

The changes to pass the ctx parameter to the testNet.RemoteGRPCEndpoints and testNet.CreateTxClient methods are consistent with the context management improvements.

However, using the first element of the endpoints slice assumes that there is at least one endpoint available. Please verify this assumption to ensure that it holds true in all scenarios.

You can use the following script to verify the assumption:

Also applies to: 31-31

test/e2e/testnet/setup.go (1)

16-23: LGTM!

The addition of the context.Context parameter is a good practice for managing cancellation and timeouts in the function. The parameter is correctly propagated to the node.AddressP2P method, which allows the method to respect any cancellation or timeout signals from the caller. The changes look good to me.

test/e2e/minor_version_compatibility.go (2)

37-40: LGTM: Context management changes.

The introduction of context parameters in various function calls and the corresponding changes to the testnet creation, preloader methods, error handling, and upgrade process to utilize the context are crucial for improving the handling of cancellation, timeouts, and proper lifecycle management. These changes enhance the function's robustness and responsiveness.

Also applies to: 45-45, 48-48, 50-50, 57-59, 63-63, 65-65, 70-70, 72-72, 88-88, 91-91


91-91: LGTM: Timeout adjustment.

Extending the timeout duration in the waitForHeight function is a more robust approach to waiting for node synchronization after upgrades. This change helps ensure that the nodes have sufficient time to reach the expected height, reducing the chances of false positives in the compatibility test.

test/e2e/major_upgrade_v2.go (1)

Line range hint 18-97: Excellent work on refactoring the MajorUpgradeToV2 function!

The changes made to the function significantly improve its flexibility, robustness, and resource management. Key improvements include:

  1. The introduction of the appVersion parameter, which allows for better version management during the upgrade process.
  2. The consistent use of context for various operations, enhancing the function's ability to handle cancellations and timeouts gracefully.
  3. The modifications to the upgrade process for each node, ensuring proper management of long-running operations and appropriate release of resources.
  4. Updating the method for adding Docker images to the preloader to use the appVersion parameter, aligning image management with the specified application version and enhancing reliability and predictability during upgrades.

These changes align perfectly with the objectives outlined in the PR summary and the linked issue #3780, which aim to stop using deprecated Knuu methods and enable staticcheck in the e2e package. The refactoring efforts contribute to the overall goal of modernizing the codebase and improving the robustness of the end-to-end testing framework.

test/e2e/benchmark/throughput.go (14)

4-4: LGTM!

The import of the context package is necessary for the changes made to introduce context parameters in various functions.


10-10: LGTM!

The import of the resource package from k8s.io/apimachinery/pkg/api is necessary for the changes made to use resource.MustParse for resource specifications.


22-22: LGTM!

The change to use resource.MustParse("12Gi") for the MemoryRequest field in the ValidatorResource structure enhances type safety and ensures that the memory request is correctly parsed and validated.


23-23: LGTM!

The change to use resource.MustParse("12Gi") for the MemoryLimit field in the ValidatorResource structure enhances type safety and ensures that the memory limit is correctly parsed and validated.


24-24: LGTM!

The change to use resource.MustParse("8") for the CPU field in the ValidatorResource structure enhances type safety and ensures that the CPU resource is correctly parsed and validated.


25-25: LGTM!

The change to use resource.MustParse("20Gi") for the Volume field in the ValidatorResource structure enhances type safety and ensures that the volume resource is correctly parsed and validated.


28-28: LGTM!

The change to use resource.MustParse("1Gi") for the MemoryRequest field in the TxClientsResource structure enhances type safety and ensures that the memory request is correctly parsed and validated.


29-29: LGTM!

The change to use resource.MustParse("3Gi") for the MemoryLimit field in the TxClientsResource structure enhances type safety and ensures that the memory limit is correctly parsed and validated.


30-30: LGTM!

The change to use resource.MustParse("2") for the CPU field in the TxClientsResource structure enhances type safety and ensures that the CPU resource is correctly parsed and validated.


31-31: LGTM!

The change to use resource.MustParse("1Gi") for the Volume field in the TxClientsResource structure enhances type safety and ensures that the volume resource is correctly parsed and validated.


100-102: LGTM!

The introduction of context handling using context.WithCancel(context.Background()) in the TwoNodeSimple function allows for better management of cancellation signals and timeouts during the benchmark test. The cancel function is deferred to ensure proper cleanup.


105-105: LGTM!

The change to update the Cleanup method of the benchTest object to accept a context.Context parameter allows for better control over the cleanup process by utilizing the context for cancellation and timeout management.


110-110: LGTM!

The change to update the Run method of the benchTest object to accept a context.Context parameter allows for better control over the benchmark test execution by utilizing the context for cancellation and timeout management.


124-126: LGTM!

The introduction of context handling using context.WithCancel(context.Background()) in the runBenchmarkTest function allows for better management of cancellation signals and timeouts during the benchmark test. The cancel function is deferred to ensure proper cleanup.

The changes to update the Cleanup and Run methods of the benchTest object to accept the context parameter enable better control over the cleanup process and test execution by utilizing the context for cancellation and timeout management.

Also applies to: 129-129, 133-133

test/e2e/benchmark/benchmark.go (3)

24-24: LGTM!

The introduction of the context.Context parameter in the NewBenchmarkTest function aligns with the PR objective of enhancing context handling for better control over operation lifecycles. This change is consistent with the alterations mentioned in the AI-generated summary.


39-52: LGTM!

The updates to the SetupNodes function, including the introduction of the context.Context parameter and the use of the provided context to create genesis nodes and obtain GRPC endpoints, align with the PR objective of enhancing context handling for better control over operation lifecycles. These changes are consistent with the alterations mentioned in the AI-generated summary and improve the ability to manage timeouts and cancellations.


101-130: LGTM!

The modifications to the Run function, including the introduction of the context.Context parameter and the use of the provided context to start nodes and tx clients, align with the PR objective of enhancing context handling for better control over operation lifecycles. These changes are consistent with the alterations mentioned in the AI-generated summary and ensure that operations can be canceled or timed out appropriately. Additionally, the streamlined error handling with inline variable declarations improves readability.

go.mod (8)

10-10: Verify compatibility with the updated knuu dependency.

The version upgrade of github.com/celestiaorg/knuu from v0.14.0 to v0.15.2 looks good. However, please ensure that you have thoroughly tested the integration with the updated dependency version to confirm that it doesn't introduce any breaking changes or unexpected behavior.


37-37: Ensure correct and efficient usage of the added k8s.io/apimachinery dependency.

The addition of the k8s.io/apimachinery dependency with version v0.30.2 looks good. However, please ensure that the dependency is being used correctly and efficiently throughout the codebase to leverage its functionalities effectively.


93-93: LGTM!

The version update of github.com/go-ini/ini to v1.67.0 looks good.


104-104: LGTM!

The version update of github.com/goccy/go-json from v0.10.2 to v0.10.3 looks good.


146-147: LGTM!

The version updates of klauspost/compress to v1.17.9 and klauspost/cpuid/v2 to v2.2.8 look good.


160-160: LGTM!

The version update of github.com/minio/minio-go/v7 to v7.0.74 looks good.


228-228: Verify compatibility with the updated k8s.io/api dependency.

The version upgrade of k8s.io/api from v0.28.2 to v0.30.2 looks good. However, please ensure that you have thoroughly tested the integration with the updated dependency version to confirm that it doesn't introduce any breaking changes or unexpected behavior.


229-229: Verify compatibility with the updated k8s.io/client-go dependency.

The version upgrade of k8s.io/client-go from v0.28.2 to v0.30.2 looks good. However, please ensure that you have thoroughly tested the integration with the updated dependency version to confirm that it doesn't introduce any breaking changes or unexpected behavior.

test/e2e/testnet/node.go (12)

Line range hint 101-181: LGTM!

The changes to the NewNode function improve its functionality and integration with the knuu package. The addition of the context.Context parameter allows for context-aware operations, while the new method chain simplifies the initialization of the knuu.Instance. The use of the resource.Quantity type from Kubernetes enhances the precision of resource allocation.


183-186: LGTM!

The EnableNetShaper method is a valuable addition to the Node struct, allowing for the enabling of the netshaper sidecar. The implementation is correct and straightforward.


188-193: LGTM!

The SetLatencyAndJitter method is a useful addition to the Node struct, allowing for the setting of latency and jitter parameters for the netshaper sidecar. The implementation is correct, and the error handling ensures that the netshaper sidecar is enabled before setting the parameters.


Line range hint 195-274: LGTM!

The changes to the Init method improve its functionality by allowing for context-aware operations when committing the knuu.Instance and adding the sidecars. The rest of the function remains largely unchanged and is correctly implemented.


Line range hint 280-289: LGTM!

The changes to the AddressP2P method improve its functionality by allowing for context-aware operations when retrieving the IP address. The rest of the function remains unchanged and is correctly implemented.


306-312: LGTM!

The changes to the RemoteAddressGRPC method improve its functionality by allowing for context-aware operations when retrieving the IP address. The rest of the function remains unchanged and is correctly implemented.


Line range hint 315-321: LGTM!

The changes to the RemoteAddressRPC method improve its functionality by allowing for context-aware operations when retrieving the IP address. The rest of the function remains unchanged and is correctly implemented.


Line range hint 327-333: LGTM!

The changes to the RemoteAddressTracing method improve its functionality by allowing for context-aware operations when retrieving the IP address. The rest of the function remains unchanged and is correctly implemented.


344-350: LGTM!

The changes to the Start method improve its functionality by allowing for context-aware operations when starting the Node instance. The rest of the function remains unchanged and is correctly implemented.


352-354: LGTM!

The changes to the StartAsync method improve its functionality by allowing for context-aware operations when starting the Node instance asynchronously. The rest of the function remains unchanged and is correctly implemented.


Line range hint 356-384: LGTM!

The changes to the WaitUntilStartedAndCreateProxy method improve its functionality by allowing for context-aware operations when waiting for the Node instance to start and creating the necessary proxies. The rest of the function remains unchanged and is correctly implemented.


397-403: LGTM!

The changes to the Upgrade method improve its functionality by allowing for context-aware operations when upgrading the Node instance to a new version. The rest of the function remains unchanged and is correctly implemented.

test/e2e/testnet/testnet.go (14)

Line range hint 33-56: LGTM!

The changes to the New function look good. The addition of the context.Context parameter and the initialization of the knuu instance with specific options enhance the testnet's ability to manage dependencies and configurations dynamically. The error handling for the knuu instance creation is also properly implemented.


58-63: LGTM!

The new NewPreloader method looks good. It properly checks if the knuu instance is initialized and returns an error if it's not. Creating a new preloader instance using the knuu system dependencies ensures that the knuu instance is properly utilized.


Line range hint 73-89: LGTM!

The changes to the CreateGenesisNode method look good. The addition of the context.Context parameter and passing it to the NewNode function allows for context-aware operations, enabling the ability to cancel or timeout the node creation process. The rest of the function remains unchanged, which is appropriate.


91-98: LGTM!

The changes to the CreateGenesisNodes method look good. The addition of the context.Context parameter and passing it to the CreateGenesisNode method allows for context-aware operations, enabling the ability to cancel or timeout the node creation process for multiple nodes. The rest of the function remains unchanged, which is appropriate.


Line range hint 100-124: LGTM!

The changes to the CreateTxClients method look good. The addition of the context.Context parameter and passing it to the CreateTxClient method allows for context-aware operations, enabling the ability to cancel or timeout the transaction client creation process for multiple clients. The rest of the function remains unchanged, which is appropriate.


Line range hint 136-186: LGTM!

The changes to the CreateTxClient method look good. The addition of the context.Context parameter and passing it to the CreateTxClient function allows for context-aware operations, enabling the ability to cancel or timeout the transaction client creation process. Committing the transaction client instance using the context ensures that the operation can be properly canceled or timed out. The rest of the function remains unchanged, which is appropriate.


Line range hint 188-210: LGTM!

The changes to the StartTxClients method look good. The addition of the context.Context parameter and passing it to the StartAsync and WaitInstanceIsRunning methods allows for context-aware operations, enabling the ability to cancel or timeout the transaction client starting process for multiple clients. The rest of the function remains unchanged, which is appropriate.


255-268: LGTM!

The changes to the CreateNode method look good. The addition of the context.Context parameter and passing it to the NewNode function allows for context-aware operations, enabling the ability to cancel or timeout the node creation process. The rest of the function remains unchanged, which is appropriate.


Line range hint 270-293: LGTM!

The changes to the Setup method look good. The addition of the context.Context parameter and passing it to the AddressP2P and Init methods allows for context-aware operations, enabling the ability to cancel or timeout the testnet setup process. The rest of the function remains unchanged, which is appropriate.


Line range hint 314-324: LGTM!

The changes to the RemoteGRPCEndpoints method look good. The addition of the context.Context parameter and passing it to the RemoteAddressGRPC method allows for context-aware operations, enabling the ability to cancel or timeout the retrieval of remote gRPC endpoint addresses. The rest of the function remains unchanged, which is appropriate.


Line range hint 336-346: LGTM!

The changes to the RemoteRPCEndpoints method look good. The addition of the context.Context parameter and passing it to the RemoteAddressRPC method allows for context-aware operations, enabling the ability to cancel or timeout the retrieval of remote RPC endpoint addresses. The rest of the function remains unchanged, which is appropriate.


Line range hint 350-384: LGTM!

The changes to the WaitToSync method look good. The addition of the context.Context parameter and passing it to the Status method allows for context-aware operations, enabling the ability to cancel or timeout the waiting process for node synchronization. The rest of the function remains unchanged, which is appropriate.


Line range hint 389-416: LGTM!

The changes to the StartNodes method look good. The addition of the context.Context parameter and passing it to the StartAsync and WaitUntilStartedAndCreateProxy methods allows for context-aware operations, enabling the ability to cancel or timeout the node starting and proxy setup process. The rest of the function remains unchanged, which is appropriate.


418-432: LGTM!

The changes to the Start method look good. The addition of the context.Context parameter and passing it to the StartNodes, WaitToSync, and StartTxClients methods allows for context-aware operations, enabling the ability to cancel or timeout the testnet starting process. The rest of the function remains unchanged, which is appropriate.

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: 2

Outside diff range and nitpick comments (1)
test/e2e/minor_version_compatibility.go (1)

Line range hint 20-114: Consider refactoring the function into smaller, more focused functions.

The MinorVersionCompatibility function is quite large and could benefit from being broken down into smaller, more focused functions. This would improve readability and maintainability.

For example, you could extract the logic for starting the nodes, upgrading the nodes, and checking the node heights into separate functions.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6a60da0 and 8195717.

Files selected for processing (4)
  • test/e2e/main.go (4 hunks)
  • test/e2e/minor_version_compatibility.go (3 hunks)
  • test/e2e/simple.go (1 hunks)
  • test/e2e/testnet/node.go (13 hunks)
Files skipped from review as they are similar to previous changes (3)
  • test/e2e/main.go
  • test/e2e/simple.go
  • test/e2e/testnet/node.go

testNet, err := testnet.New(ctx, "runMinorVersionCompatibility", seed, nil, "test")
testnet.NoError("failed to create testnet", err)

defer testNet.Cleanup(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pass the context to the cleanup functions.

Please consider passing the ctx to the testNet.Cleanup and preloader.EmptyImages calls for consistency with the context usage throughout the function.

Apply this diff to pass the ctx:

-	defer testNet.Cleanup(ctx)
+	defer func() { testnet.NoError("failed to cleanup testnet", testNet.Cleanup(ctx)) }()

-	defer func() { _ = preloader.EmptyImages(ctx) }()
+	defer func() { testnet.NoError("failed to empty preloader images", preloader.EmptyImages(ctx)) }()

Also applies to: 48-48

Copy link
Member Author

Choose a reason for hiding this comment

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

this could be done in a followup issue.

test/e2e/minor_version_compatibility.go Outdated Show resolved Hide resolved
rach-id
rach-id previously approved these changes Sep 12, 2024
Copy link
Member

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

utAck

test/e2e/main.go Outdated
Comment on lines 23 to 24
// latestVersion, err := testnet.GetLatestVersion()
// testnet.NoError("failed to get latest version", err)
Copy link
Member

Choose a reason for hiding this comment

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

if this code is not used, can we delete it?

Copy link
Member Author

Choose a reason for hiding this comment

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

we will use it once the BRR issue is resolved

Copy link
Collaborator

Choose a reason for hiding this comment

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

The --force-no-bbr flag exists on main but may not exist on v2.1.2

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks. the hard coded version removed after having the tests passed with the main. Since it was on a fork branch, the 07411e2 version from main is used.

test/e2e/testnet/node.go Outdated Show resolved Hide resolved
@celestia-bot celestia-bot requested review from a team and cmwaters and removed request for a team September 13, 2024 08:01
rootulp
rootulp previously approved these changes Sep 13, 2024
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM if e2e tests pass, thanks Mojtaba!

@rootulp
Copy link
Collaborator

rootulp commented Sep 13, 2024

@mojtaba-esk looks like test-e2e doesn't run on every PR. Can you run it manually locally and update the PR description with a testing section that states if it passes or fails.

@mojtaba-esk
Copy link
Member Author

@mojtaba-esk looks like test-e2e doesn't run on every PR. Can you run it manually locally and update the PR description with a testing section that states if it passes or fails.

sure

staheri14
staheri14 previously approved these changes Sep 13, 2024
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

Thanks @mojtaba-esk for integration of the new knuu! LGTM! One comment though:

In the previous version of knuu, there used to be a log message

Initializing knuu with scope: ...

that appeared when running the tests, indicating the test scope, which could then be used to tear down lingering instances or monitor the state of instances (e.g., via Lens). Currently, this log message is not showing up. Could you let me know how we can obtain this information i.e., the scope in the new version of knuu?

I also ran the following tests locally based on your branch and they worked for me:

  • E2ESimple
  • MajorUpgradeToV2
  • MinorVersionCompatibility: I am unable to run this one as I get context deadline exceeded error, but it might be a temporary thing. Update: Could get a successful run of MinorVersionCompatibility
  • TwoNodeBigBlock8MBLatency together with passing push configs (among all the e2e benchmark tests, testing this one seems sufficient to me to ensure almost everything works for all the other benchmark tests)

ninabarbakadze
ninabarbakadze previously approved these changes Sep 16, 2024
@rootulp
Copy link
Collaborator

rootulp commented Sep 16, 2024

The E2ESimple test passes, did not test the benchmarks which also were not needed for this purpose.

What about the rest of the e2e tests? Sanaz's comment makes it seem like MinorVersionCompatibility doesn't pass but idk if it passed before this PR.

@staheri14
Copy link
Contributor

Update: I was able to run MinorVersionCompatibility as well. So, all good.

rootulp
rootulp previously approved these changes Sep 16, 2024
@mojtaba-esk
Copy link
Member Author

One comment though:

In the previous version of knuu, there used to be a log message

Initializing knuu with scope: ...

oh yes, this is omitted from knuu logs by default. User can add it if they want it. Let me add that one quickly.

@celestia-bot celestia-bot requested a review from a team September 17, 2024 06:08
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

Outside diff range and nitpick comments (1)
test/e2e/testnet/testnet.go (1)

Line range hint 138-188: Approved with a suggestion

The changes to the CreateTxClient method are comprehensive and well-structured. The addition of the context.Context parameter enables context-aware operations throughout the process of creating a transaction client. The method handles the creation of the keyring directory, the creation of an account, and the initialization of the transaction client instance effectively.

One suggestion for improvement:

Consider extracting the logic for creating the keyring directory and the account into separate helper methods. This would enhance the readability and maintainability of the CreateTxClient method by reducing its complexity and making it more focused on the core functionality of creating the transaction client instance.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 536efed and 37c1778.

Files selected for processing (1)
  • test/e2e/testnet/testnet.go (19 hunks)
Additional comments not posted (11)
test/e2e/testnet/testnet.go (11)

33-49: LGTM!

The changes to the New function look good. The addition of the context.Context parameter and the initialization of the knuu instance with specific options enhance the testnet's ability to manage dependencies and configurations dynamically.


60-65: Looks good!

The new NewPreloader method is a useful addition to the Testnet struct. It ensures that the knuu instance is initialized before creating the preloader instance, preventing potential issues. Using the knuu system dependencies to create the preloader is a good approach for consistency and compatibility.


Line range hint 75-91: Approved!

The changes to the CreateGenesisNode method look good. The addition of the context.Context parameter enhances the method's ability to handle context-aware operations. The logic for creating a genesis node remains clear and concise, generating the necessary keys and adding the node to the genesis validators and the testnet's list of nodes.


93-100: Changes look good!

The modifications to the CreateGenesisNodes method are straightforward and effective. The addition of the context.Context parameter ensures that the method can handle context-aware operations when creating multiple genesis nodes. The method continues to iterate over the specified number of nodes and calls the CreateGenesisNode method with the provided configuration, maintaining its original functionality.


Line range hint 102-126: Looks good to me!

The updates to the CreateTxClients method are well-structured and maintain the original functionality while incorporating the context.Context parameter for context-aware operations. The method continues to iterate over the provided gRPC endpoints, calling the CreateTxClient method with the appropriate configuration for each endpoint. Error handling and logging are in place to handle any issues that may occur during the creation of transaction clients.


Line range hint 190-212: Changes look good!

The modifications to the StartTxClients method are well-implemented and incorporate the context.Context parameter effectively. The method maintains its original functionality of starting the transaction clients asynchronously and waiting for each client's instance to be running. The addition of the context.Context parameter allows for context-aware operations during the start process.

The error handling and logging mechanisms are in place to handle any issues that may occur during the start process and provide informative error messages.


257-270: LGTM!

The updates to the CreateNode method are straightforward and effective. The addition of the context.Context parameter enables context-aware operations when creating a new node. The method continues to generate the necessary signer and network keys using the key generator and creates a new node with the provided configuration and the generated keys. The created node is then appended to the list of nodes in the testnet, maintaining the original functionality.


Line range hint 272-296: Looks good!

The modifications to the Setup method are well-structured and incorporate the context.Context parameter effectively. The method maintains its original functionality of setting up the testnet by exporting the genesis configuration, retrieving the peer addresses for each node, and initializing each node with the exported genesis, peers, and provided configuration options.

The addition of the context.Context parameter enables context-aware operations, particularly when retrieving the peer addresses using the AddressP2P method, which now accepts the context parameter.


Line range hint 316-326: Changes look good!

The updates to the RemoteGRPCEndpoints method are straightforward and effective. The addition of the context.Context parameter allows for context-aware operations when retrieving the remote gRPC endpoints of the testnet nodes. The method continues to iterate over the nodes, retrieving the remote gRPC endpoint for each node using the RemoteAddressGRPC method, which now accepts the context parameter.

Error handling is in place to return any errors that may occur during the retrieval process. The retrieved gRPC endpoints are stored in a slice and returned, maintaining the original functionality of the method.


Line range hint 338-348: LGTM!

The modifications to the RemoteRPCEndpoints method are well-implemented and incorporate the context.Context parameter effectively. The method maintains its original functionality of retrieving the remote RPC endpoints of the testnet nodes while adding context-aware operations.

The method iterates over the nodes, retrieving the remote RPC endpoint for each node using the RemoteAddressRPC method, which now accepts the context parameter. Error handling is in place to return any errors that may occur during the retrieval process. The retrieved RPC endpoints are stored in a slice and returned, preserving the expected behavior of the method.


Line range hint 352-386: Looks good!

The updates to the WaitToSync method are well-structured and incorporate the context.Context parameter effectively. The method maintains its original functionality of waiting for the testnet nodes to sync

@rootulp rootulp merged commit 07ebd7b into celestiaorg:main Sep 17, 2024
31 of 32 checks passed
Copy link

gitpoap-bot bot commented Sep 17, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2024 Celestia Contributor:

GitPOAP: 2024 Celestia Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

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.

6 participants