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): add node down during migration test cases #2208

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

Conversation

yangchiu
Copy link
Member

@yangchiu yangchiu commented Dec 18, 2024

Which issue(s) this PR fixes:

Issue longhorn/longhorn#9905 longhorn/longhorn#8817 longhorn/longhorn#8906

What this PR does / why we need it:

add node down during migration test cases

Special notes for your reviewer:

Additional documentation or context

Summary by CodeRabbit

  • New Features
    • Introduced four new test cases for negative scenarios in volume migration, enhancing the testing framework's coverage.
      • Migration Rollback After Migration Node Down
      • Migration Confirmation After Original Node Down
      • Migration Rollback After Original Node Down
      • Migration Confirmation After Migration Node Down

@yangchiu yangchiu self-assigned this Dec 18, 2024
@yangchiu yangchiu requested a review from a team as a code owner December 18, 2024 12:47
Copy link

coderabbitai bot commented Dec 18, 2024

Walkthrough

This pull request adds four new negative test cases to the live_migration.robot file, focusing on volume migration scenarios in Kubernetes environments. The test cases simulate different node failure conditions during volume migration, including scenarios where migration nodes or original nodes are powered off. These tests aim to validate the robustness of the volume migration process under various failure conditions, ensuring data integrity and proper volume status management.

Changes

File Change Summary
e2e/tests/negative/live_migration.robot Added 4 new test cases:
- Migration Rollback After Migration Node Down
- Migration Confirmation After Original Node Down
- Migration Rollback After Original Node Down
- Migration Confirmation After Migration Node Down

Assessment against linked issues

Objective Addressed Explanation
Add negative test cases for volume live migration [#9905]

Possibly related PRs

Suggested reviewers

  • chriscchien

Poem

🐰 Migrations dance, nodes come and go,
Volumes twirl in a resilient show
Robots test each twist and turn
Where data's fate we'll surely learn
Live migration's robust ballet! 🤖💃


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

🔭 Outside diff range comments (1)
e2e/tests/negative/live_migration.robot (1)

Line range hint 1-106: Consider refactoring common test patterns

The test cases share similar setup and verification patterns. Consider:

  1. Creating a custom keyword for the common volume setup sequence
  2. Enhancing data integrity checks to verify more than just presence
  3. Adding comprehensive volume state validation keywords

Example keyword extraction:

*** Keywords ***
Setup Migration Test Volume
    [Arguments]    ${node_index}
    Create volume 0 with    migratable=True    accessMode=RWX    dataEngine=${DATA_ENGINE}
    Attach volume 0 to node ${node_index}
    Wait for volume 0 healthy
    Write data to volume 0

Verify Volume State And Data
    [Arguments]    ${expected_node}    ${expected_state}
    Wait for volume 0 ${expected_state}
    Wait for volume 0 to stay on node ${expected_node}
    Check volume 0 data is intact
🧹 Nitpick comments (2)
e2e/tests/negative/live_migration.robot (2)

Line range hint 1-40: Consider adding explicit timeout parameters for wait operations

The test case effectively validates migration behavior when the migration node fails. However, consider adding explicit timeout parameters to wait operations to handle varying cluster response times.

Example modification:

-    Then Check volume 0 kept in attaching
+    Then Check volume 0 kept in attaching    timeout=300

41-59: Add validation for error messages and events

While the test case verifies the rollback behavior and data integrity, it would be valuable to also validate that appropriate error messages or events are generated during the rollback process.

Consider adding validation steps like:

And Verify error event "Migration failed due to node down" exists
And Verify volume condition "Degraded" has reason "NodeDown"
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a921646 and dd5d449.

📒 Files selected for processing (1)
  • e2e/tests/negative/live_migration.robot (1 hunks)
🔇 Additional comments (1)
e2e/tests/negative/live_migration.robot (1)

60-80: Address potential test flakiness due to K8s pod eviction timing

The test depends on Kubernetes pod eviction controller timing, which could make it flaky. Consider:

  1. Adding retry mechanisms with appropriate timeouts
  2. Moving the detailed comments about K8s behavior to test documentation

Let's check if similar timing issues exist in other test files:

Comment on lines +81 to +106
Migration Rollback After Original Node Down
Given Create volume 0 with migratable=True accessMode=RWX dataEngine=${DATA_ENGINE}
And Attach volume 0 to node 0
And Wait for volume 0 healthy
And Write data to volume 0

And Attach volume 0 to node 1
And Wait for volume 0 migration to be ready

# power off original node
When Power off node 0
# migration rollback by detaching from the migration node
And Detach volume 0 from node 1

# migration is stuck until the Kubernetes pod eviction controller decides to
# terminate the instance-manager pod that was running on the original node.
# then Longhorn detaches the volume and attempts to cleanly reattach it to the original node,
# but it is stuck in attaching until the node comes back.
Then Check volume 0 kept in attaching

# power on original node
When Power on off nodes

Then Wait for volume 0 to stay on node 0
And Wait for volume 0 healthy
And Check volume 0 data is intact
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Ensure proper test isolation and cleanup for node power operations

The test manipulates node power state which could affect other tests. Consider:

  1. Adding verification steps in the test teardown to ensure nodes are powered back on
  2. Verifying cluster state is fully restored before the next test

Add these steps to the test teardown:

[Teardown]
    Power on off nodes
    Wait for all nodes ready    timeout=300
    Cleanup test resources

# power off original node
When Power off node 0
# migration confirmation by detaching from the original node
And Detach volume 0 from node 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to detach explicitly from node 0? Should we just wait for the instance-manager to terminate?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test case is Migration Confirmation After Original Node Down, so we should detach the original node to Confirm the Migration.

If no action was taken after the original node went down, it seems to be another test case, called Original Node Down After Migration Ready.
And I just tested this scenario: after the migration was ready, powered off the original node, and then did nothing. Eventually the volume was clearly detached:

$ kubectl get volumes -n longhorn-system pvc-8bf2ae3a-be4d-4110-b9e0-a9a124db8095 -oyaml -w | grep -i nodeid
  migrationNodeID: ""
  nodeID: ""
  currentMigrationNodeID: ""
  currentNodeID: ""
  pendingNodeID: ""

Even after powering on the original node again, the volume remains in detached state permanently.

supportbundle_ef8a6972-0c68-48f9-bd45-1e575e519d95_2024-12-19T00-29-41Z.zip

If we need this test case, it needs @derekbit and @PhanLe1010 to confirm whether this is the expected behavior first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is expected behavior. The volume will remain in detached until CSI flow or user detach the volume from the original node. This is the new design that when volume crash, migration will be stop, volume remain in detach state waiting for the user/csi to make decision about what is the only node Longhorn attach to. The reason behind this is that volume already crash so we don't need live migration anymore. This reduces the risk of unnecessary migration and chaotic.

Ref longhorn/longhorn#8735 (comment)
Manual test case is updated at #1948

e2e/tests/negative/live_migration.robot Show resolved Hide resolved
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.

3 participants