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

chore: update e2e tests to knuu 0.16.1 #3911

Conversation

mojtaba-esk
Copy link
Member

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

This PR proposes updating the e2e tests code to use the latest version of knuu (v0.16.1)

The main changes of this release are:

  1. Use unique static names for instances: now knuu does not add a random string to the names of the instances to make them predictable; therefore, it paves the path to the long running tests.
  2. CTRL+C to run timeout handler with no sleep: optimizes the termination request by the user
  3. Ability to fetch logs from instances
  4. Adjust stopped status actions for the update image: From now on, user can Stop the instance, then update the image, arguments, start command and or env vars, then commit and start the instance. This is handy for upgrade test.

BTW: the e2e tests are passing locally.

  • test-e2e2024/09/25 10:42:37 --- ✅ PASS: MinorVersionCompatibility
  • test-e2e2024/09/25 10:44:47 --- ✅ PASS: MajorUpgradeToV2
  • test-e2e2024/09/25 10:46:34 --- ✅ PASS: E2ESimple

@mojtaba-esk mojtaba-esk requested a review from a team as a code owner September 26, 2024 06:57
@mojtaba-esk mojtaba-esk requested review from cmwaters and staheri14 and removed request for a team September 26, 2024 06:57
@mojtaba-esk mojtaba-esk self-assigned this Sep 26, 2024
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request includes significant updates to the go.mod file, modifying dependency versions and removing several indirect dependencies. Additionally, it refactors multiple test files, enhancing variable declarations and simplifying context management in the MajorUpgradeToV2 and MinorVersionCompatibility functions. The Upgrade method in the Node struct has been restructured to ensure a proper stop-start sequence during Docker image upgrades. Logging enhancements and clearer preloader instantiation have also been implemented in the Testnet struct.

Changes

File Path Change Summary
go.mod Updated versions for several dependencies and removed multiple indirect dependencies.
test/e2e/major_upgrade_v2.go Refactored MajorUpgradeToV2 function with improved variable declarations and context handling.
test/e2e/minor_version_compatibility.go Simplified context management and variable initialization in MinorVersionCompatibility.
test/e2e/simple.go Introduced cancellation context for lifecycle management in E2ESimple function.
test/e2e/testnet/node.go Modified Upgrade method to include a stop-start sequence for Docker image upgrades.
test/e2e/testnet/testnet.go Enhanced logging in New function and clarified preloader instantiation in NewPreloader.

Possibly related PRs

Suggested labels

knuu, WS: Maintenance 🔧

Suggested reviewers

  • staheri14
  • cmwaters
  • evan-forbes
  • rootulp

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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

@celestia-bot celestia-bot requested a review from a team September 26, 2024 06:58
@mojtaba-esk mojtaba-esk added testing items that are strictly related to adding or extending test coverage and removed external labels Sep 26, 2024
go.mod Outdated Show resolved Hide resolved
cmwaters
cmwaters previously approved these changes Sep 26, 2024
@@ -61,11 +66,11 @@ func (t *Testnet) Knuu() *knuu.Knuu {
return t.knuu
}

func (t *Testnet) NewPreloader() (*preloader.Preloader, error) {
func (t *Testnet) NewPreloader(name string) (*preloader.Preloader, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could we just use the name of the testnet here and not need to add the argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

do we need only one preloader per test? if so, yes we can do that

Copy link
Member Author

Choose a reason for hiding this comment

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

applied

ninabarbakadze
ninabarbakadze previously approved these changes Sep 26, 2024
Copy link
Member

@ninabarbakadze ninabarbakadze left a comment

Choose a reason for hiding this comment

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

lgtm

rach-id
rach-id previously approved these changes Sep 26, 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.

LGTM

go.mod Outdated Show resolved Hide resolved
test/e2e/simple.go Show resolved Hide resolved
@celestia-bot celestia-bot requested review from a team and rootulp and removed request for a team September 26, 2024 13:07
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 (9)
test/e2e/minor_version_compatibility.go (2)

21-24: Approved changes with a suggestion for improvement

The introduction of this block improves code readability by grouping variable declarations. Using context.Background() is appropriate for the root context in a test function.

Consider making numNodes configurable to increase test flexibility. For example:

 var (
-		numNodes = 4
+		numNodes = getConfigurableNodeCount() // Default to 4 if not specified
 		ctx      = context.Background()
 	)

+func getConfigurableNodeCount() int {
+	if count := os.Getenv("E2E_NODE_COUNT"); count != "" {
+		if n, err := strconv.Atoi(count); err == nil && n > 0 {
+			return n
+		}
+	}
+	return 4 // Default value
+}

This change would allow easier testing with different node counts without modifying the code.


Line range hint 1-138: Consider a comprehensive review of the entire file

The changes made to the MinorVersionCompatibility function improve context management and variable initialization, aligning with the PR objectives of updating e2e tests for knuu 0.16.1. However, given the scope of the update, it might be beneficial to review the entire file for potential further improvements or adjustments needed to fully leverage the new knuu version features, such as:

  1. Utilizing the new log fetching capability mentioned in the PR objectives.
  2. Implementing the improved stopped status actions for upgrade tests.
  3. Ensuring that the test takes advantage of the unique static names for instances.

Consider conducting a comprehensive review of the entire file to identify any additional opportunities for improvement or alignment with the new knuu features.

test/e2e/major_upgrade_v2.go (1)

19-23: LGTM! Consider adding comments for clarity.

The grouping of variable declarations in a var block improves code organization. The direct initialization of ctx with context.Background() is appropriate for this use case.

Consider adding brief comments to explain the purpose of numNodes and upgradeHeight for improved readability:

var (
    numNodes      = 4    // Number of nodes in the testnet
    upgradeHeight = int64(10)  // Block height at which the upgrade occurs
    ctx           = context.Background()
)
test/e2e/testnet/testnet.go (1)

73-75: Simplified preloader naming

The change to use a fixed name "preloader" for all nodes in the testnet is a good improvement:

  1. It simplifies the code and ensures consistency across all nodes.
  2. This aligns with the PR objective of utilizing unique static names for instances.

The added comment provides clear reasoning for this change, which is helpful for future maintainers.

Consider slightly rewording the comment for clarity:

-	// Since there is one dedicated knuu object for the testnet, each one has its own namespace, and
-	// there is one preloader per testnet, can use the same preloader name for all nodes
+	// Since there is one dedicated knuu object per testnet (each with its own namespace),
+	// and one preloader per testnet, we can use the same preloader name for all nodes
test/e2e/testnet/node.go (5)

398-400: Add context to returned errors for better debugging

When returning errors, consider adding context to improve traceability. This can be achieved using fmt.Errorf to wrap the error with additional information about the operation that failed.


402-404: Add context to returned errors for better debugging

Similarly, when handling the error from SetImage, adding context to the returned error can provide more insight into what caused the failure.


406-408: Implement setting new arguments or start command during upgrade

The comments indicate that new arguments or a start command can be set during the upgrade process, but this functionality is not currently implemented. If changing the node's startup behavior is required during an upgrade, consider implementing this logic here.

Do you want me to assist in adding this functionality or open a GitHub issue to track this task?


409-411: Add context to returned errors for better debugging

When returning errors from Commit, wrapping the error with additional context will help identify where and why the error occurred.


412-412: Add context to returned errors for better debugging

Consider adding context to the error returned by Start to aid in debugging if the execution instance fails to start.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 32fc690 and 32a77e0.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • go.mod (3 hunks)
  • test/e2e/major_upgrade_v2.go (1 hunks)
  • test/e2e/minor_version_compatibility.go (2 hunks)
  • test/e2e/testnet/node.go (1 hunks)
  • test/e2e/testnet/testnet.go (2 hunks)
🔇 Additional comments (9)
test/e2e/minor_version_compatibility.go (1)

38-38: Approved changes in testnet creation

The updates to the testnet.New function call are appropriate:

  1. The function name now matches the actual function name, improving consistency.
  2. The use of the ctx variable aligns with the context management changes.

These modifications are in line with the PR objectives of updating e2e tests for the new knuu version.

test/e2e/major_upgrade_v2.go (2)

26-26: LGTM! Improved naming consistency.

The change from "runMajorUpgradeToV2" to "MajorUpgradeToV2" in the testnet creation call improves naming consistency with the function name. This enhances code clarity without affecting functionality.


19-26: Overall changes align well with PR objectives.

The modifications in this file, while minimal, contribute to the PR's goal of updating e2e tests for knuu 0.16.1. The improved variable organization and consistent naming support the execution of long-running tests by enhancing code clarity and maintainability. These changes don't alter the core functionality of the MajorUpgradeToV2 test but make it more robust and easier to understand.

go.mod (5)

11-11: Approved: Update to knuu v0.16.1

This update aligns with the PR objectives and introduces important new features for e2e testing, including unique static names for instances, optimized termination requests, and log fetching capabilities. These improvements should enhance the reliability and functionality of the e2e testing framework.


Line range hint 1-241: Summary: go.mod updates approved with verifications

The changes in this file, particularly the update to knuu v0.16.1, align well with the PR objectives and should enhance the e2e testing capabilities. The standard library updates and the resolution of the websocket package version are also positive improvements.

To ensure a smooth integration of these changes, please run the verification scripts provided in the previous comments. These scripts will help confirm that:

  1. The updated standard library packages don't introduce compatibility issues.
  2. The removed indirect dependencies are not used elsewhere in the project.
  3. The websocket package update doesn't cause any unexpected issues.

Once these verifications are complete and pass successfully, this update can be confidently merged.


Line range hint 1-241: Verify removal of indirect dependencies

The update has removed several indirect dependencies, including Docker-related packages and the go-playground validator. While this is likely due to updates in direct dependencies, it's important to ensure these removals don't affect the project.

Please run the following script to verify that the removed dependencies are not used elsewhere in the project:

#!/bin/bash
# Description: Check for usage of removed dependencies in the codebase

# List of removed packages to check
packages=(
  "github.com/distribution/reference"
  "github.com/docker/docker"
  "github.com/docker/go-connections"
  "github.com/docker/go-units"
  "github.com/go-playground/validator/v10"
  "github.com/opencontainers/go-digest"
)

# Check for imports of these packages
for package in "${packages[@]}"; do
  echo "Checking for imports of $package"
  rg --type go "import.*$package" || echo "No imports found for $package"
done

# Check for direct usage of these packages (excluding import statements)
for package in "${packages[@]}"; do
  echo "Checking for usage of $package"
  rg --type go --glob '!go.mod' --glob '!go.sum' "$package" | grep -v "import" || echo "No usage found for $package"
done

236-236: Approved: Update to nhooyr.io/websocket v1.8.17

This update resolves the version conflict discussed in previous reviews. The change from v1.8.6 to v1.8.17 should address the issue of not finding the correct version.

To ensure this update doesn't introduce any new issues, please run the following verification script:

#!/bin/bash
# Description: Verify the usage and impact of the updated nhooyr.io/websocket package

# Test: Check for any direct usage of the websocket package
rg --type go "nhooyr.io/websocket"

# Test: Verify if there are any build issues related to the websocket package
go build ./... 2>&1 | grep -i "websocket"

# Test: Run tests that might be affected by the websocket package
go test ./... -v 2>&1 | grep -E "(websocket|FAIL)"

217-223: Approved: Standard library package updates

The updates to golang.org/x packages (crypto, net, sys, term, text) are good practice for maintaining security and performance. These are indirect dependencies, likely pulled in by the knuu update or other direct dependencies.

To ensure these updates don't introduce any compatibility issues, please run the following verification script:

✅ Verification successful

Verification Script Error Detected

The previous verification script encountered a syntax error, preventing accurate assessment of compatibility issues. Please run the following corrected verification script to ensure the updates do not introduce any compatibility problems:


Verified: Standard Library Package Updates

The updates to golang.org/x packages (crypto, net, sys, term, text) have been successfully verified. No compatibility issues or test failures were detected, ensuring that these indirect dependency updates maintain the project's security and performance.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the updated standard library packages don't cause any compatibility issues.

# Test: Check if there are any compatibility warnings or errors when building the project
go build ./... 2>&1 | grep -i "compatibility\|deprecated"

# Test: Run all tests to ensure nothing breaks with the new versions
go test ./... -v 2>&1 | grep -i "fail\|error"

Length of output: 17273


Script:

#!/bin/bash
set -e
# Description: Verify that the updated standard library packages don't cause any compatibility issues.

# Test: Check if there are any compatibility warnings or errors when building the project
go build ./... 2>&1 | grep -i "compatibility\|deprecated"

# Test: Run all tests to ensure nothing breaks with the new versions
go test ./... -v 2>&1 | grep -i "fail\|error"

Length of output: 63

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

48-53: Improved logging and signal handling

The changes in this segment enhance the testnet initialization process:

  1. Adding the "TestName" field to the log message improves traceability and debugging capabilities.
  2. Calling HandleStopSignal immediately after initialization ensures that the testnet can be gracefully stopped from the beginning, which is crucial for managing long-running tests.

These improvements align well with the PR objectives, particularly in facilitating the execution of long-running tests and optimizing termination requests.

rootulp
rootulp previously approved these changes Sep 26, 2024
@celestia-bot celestia-bot requested a review from a team September 30, 2024 07:28
evan-forbes
evan-forbes previously approved these changes Sep 30, 2024
test/e2e/major_upgrade_v2.go Show resolved Hide resolved
defer cancel()

testNet, err := testnet.New(ctx, "runMinorVersionCompatibility", seed, nil, "test")
testNet, err := testnet.New(ctx, "MinorVersionCompatibility", seed, nil, "test")
Copy link
Member

Choose a reason for hiding this comment

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

Why change the name here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems like the term run does not seem to add any value to the test name. If it is preferred to keep it, we can put it back.

@celestia-bot celestia-bot requested a review from a team September 30, 2024 15:04
@mojtaba-esk mojtaba-esk mentioned this pull request Oct 1, 2024
@mojtaba-esk mojtaba-esk dismissed stale reviews from evan-forbes and rootulp via b46ec6e October 1, 2024 07:39
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

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

Line range hint 1-71: Suggestions for improving test robustness and maintainability

While the current implementation works, consider the following improvements:

  1. Replace hard-coded values with constants or configurable parameters. This enhances flexibility and maintainability.

  2. Consider using a more robust waiting mechanism instead of time.Sleep(). This can help prevent flaky tests.

  3. The error handling for the deferred cancel() could be improved, although it's generally fine as is.

Here are some code snippets demonstrating these improvements:

  1. Using constants:
const (
    numValidators = 4
    waitDuration  = 30 * time.Second
    minTxs        = 10
)
  1. Robust waiting:
err := testnet.WaitForHeight(ctx, testNet.Node(0), targetHeight, waitDuration)
if err != nil {
    return fmt.Errorf("failed to reach target height: %w", err)
}
  1. Improved error handling for cancel (if deemed necessary):
defer func() {
    if err := recover(); err != nil {
        cancel()
        panic(err) // re-panic after cancelling
    } else {
        cancel()
    }
}()

Consider implementing these changes to enhance the overall quality of the test.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 32a77e0 and ff0990d.

📒 Files selected for processing (3)
  • test/e2e/major_upgrade_v2.go (1 hunks)
  • test/e2e/minor_version_compatibility.go (2 hunks)
  • test/e2e/simple.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/e2e/major_upgrade_v2.go
  • test/e2e/minor_version_compatibility.go

test/e2e/simple.go Show resolved Hide resolved
@celestia-bot celestia-bot requested a review from a team October 1, 2024 14:55
@evan-forbes evan-forbes merged commit 0f44600 into celestiaorg:main Oct 2, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing items that are strictly related to adding or extending test coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants