Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(robot): fix volume nodeID transient state that causes test case to fail after a cluster restart #2268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yangchiu
Copy link
Member

@yangchiu yangchiu commented Jan 14, 2025

Which issue(s) this PR fixes:

Issue longhorn/longhorn#10203

What this PR does / why we need it:

fix volume nodeID transient state that causes test case to fail after a cluster restart

Special notes for your reviewer:

Additional documentation or context

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced cluster restart test scenarios with improved tagging.
    • Added test case for cluster restart during heavy writing and recurring jobs.
  • Tests

    • Expanded negative test coverage for cluster resilience with new test cases.
    • Improved organization of existing tests through tagging for better categorization.

@yangchiu yangchiu self-assigned this Jan 14, 2025
@yangchiu yangchiu requested a review from a team as a code owner January 14, 2025 01:41
Copy link

coderabbitai bot commented Jan 14, 2025

Walkthrough

The pull request modifies the e2e/tests/negative/cluster_restart.robot file by adding a new test case that focuses on cluster restart scenarios with heavy writing and recurring jobs. Additionally, it updates an existing test case to enhance its categorization with a new tag. The changes aim to improve the robustness of testing Longhorn's volume management during critical operational scenarios.

Changes

File Change Summary
e2e/tests/negative/cluster_restart.robot - Added new test case: "Restart Cluster While Heavy Writing And Recurring Jobs Exist"
- Modified existing test case "Restart Cluster While Workload Heavy Writing" with additional tag [Tags] cluster
e2e/libs/volume/crd.py - Updated write_random_data and keep_writing_data methods to ensure volume is in "attached" state before operations
- Enhanced error handling in attach method for volume attachment failures

Assessment against linked issues

Objective Addressed Explanation
Automate e2e test cases for instability after power failure [#10203]

Possibly related PRs

Suggested reviewers

  • chriscchien

Poem

🐰 Cluster restart, volumes spin,
Recurring jobs dance, testing begins!
Bits and bytes in wild array,
Resilience tested, Longhorn's way!
Restart the dance, see what we find! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

CodeRabbit Configuration 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.

Copy link

@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

🧹 Nitpick comments (1)
e2e/tests/negative/cluster_restart.robot (1)

102-104: Add timeout parameters for health checks.

The volume health checks should have explicit timeouts to prevent test hangs if volumes fail to recover.

Consider adding timeout parameters:

-        And Wait for volume 0 healthy
-        And Wait for volume 1 healthy
-        And Wait for volume 2 healthy
+        And Wait for volume 0 healthy    timeout=300
+        And Wait for volume 1 healthy    timeout=300
+        And Wait for volume 2 healthy    timeout=300
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f3e118 and e91d362.

📒 Files selected for processing (1)
  • e2e/tests/negative/cluster_restart.robot (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (4)
e2e/tests/negative/cluster_restart.robot (4)

8-8: LGTM! Resource imports align with test requirements.

The addition of volume.resource and recurringjob.resource is appropriate for supporting the new test case functionality.

Also applies to: 16-16


24-24: LGTM! Tag addition improves test categorization.

Adding the explicit cluster tag improves test discoverability and maintains consistency with the new test case.


95-97: Verify snapshot/backup cleanup mechanism.

The test creates recurring snapshot and backup jobs but doesn't specify cleanup procedures. This could lead to resource accumulation over multiple test runs.

Consider adding cleanup steps or verifying if the test teardown handles this automatically.


86-86: Consider increasing replica count for volume 0.

Using a single replica for volume 0 might risk data durability during cluster restarts. Consider using 3 replicas for better resilience.

e2e/tests/negative/cluster_restart.robot Outdated Show resolved Hide resolved
@yangchiu yangchiu marked this pull request as draft January 15, 2025 06:39
@yangchiu yangchiu force-pushed the robot-recurring branch 3 times, most recently from cd7fab6 to b2d9146 Compare January 17, 2025 02:24
@yangchiu yangchiu changed the title test(robot): add Restart Cluster While Heavy Writing And Recurring Jobs Exist test case test(robot): fix volume nodeID transient state that causes test case to fail after a cluster restart Jan 17, 2025
@yangchiu yangchiu marked this pull request as ready for review January 17, 2025 02:25
…to fail after a cluster restart

Signed-off-by: Yang Chiu <[email protected]>
@yangchiu yangchiu requested review from a team and removed request for a team January 17, 2025 02:26
Copy link

@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

🧹 Nitpick comments (2)
e2e/libs/volume/crd.py (2)

441-449: LGTM! Fix for volume nodeID transient state.

The changes properly handle the transient state by:

  1. Waiting for volume to be in "attached" state
  2. Adding retry logic to wait for nodeID availability

However, the loop control variable i is not used within the loop body.

-    for i in range(self.retry_count):
+    for _i in range(self.retry_count):
🧰 Tools
🪛 Ruff (0.8.2)

444-444: Loop control variable i not used within loop body

Rename unused i to _i

(B007)


465-473: Fix unused loop control variable.

The loop control variable i is not used within the loop body.

-    for i in range(self.retry_count):
+    for _i in range(self.retry_count):
🧰 Tools
🪛 Ruff (0.8.2)

468-468: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e91d362 and 0fe7f0b.

📒 Files selected for processing (2)
  • e2e/libs/volume/crd.py (2 hunks)
  • e2e/tests/negative/cluster_restart.robot (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
e2e/libs/volume/crd.py

444-444: Loop control variable i not used within loop body

Rename unused i to _i

(B007)


468-468: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build images
  • GitHub Check: Summary
🔇 Additional comments (2)
e2e/tests/negative/cluster_restart.robot (2)

22-22: LGTM! Tag addition improves test categorization.

The addition of the [Tags] cluster tag enhances test organization and discoverability.


Line range hint 22-89: Enhance data integrity verification after cluster restart.

While the test verifies that workloads are stable and "work" after restart, it should also validate data integrity to ensure no data corruption occurred during the cluster restart.

Add data integrity checks after the cluster restart:

        When Restart cluster
        And Wait for longhorn ready
        And Wait for workloads pods stable
        ...    deployment 0    deployment 1    deployment 2    deployment 3    deployment 4    deployment 5
        ...    statefulset 0    statefulset 1    statefulset 2    statefulset 3    statefulset 4    statefulset 5

+       Then Verify data integrity in deployment 0
+       And Verify data integrity in deployment 1
+       And Verify data integrity in deployment 2
+       And Verify data integrity in deployment 3
+       And Verify data integrity in deployment 4
+       And Verify data integrity in deployment 5
+       And Verify data integrity in statefulset 0
+       And Verify data integrity in statefulset 1
+       And Verify data integrity in statefulset 2
+       And Verify data integrity in statefulset 3
+       And Verify data integrity in statefulset 4
+       And Verify data integrity in statefulset 5

        Then Check deployment 0 works

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.

1 participant