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

VM hot plugging and unplugging #11149

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

ayush-patni
Copy link
Contributor

This PR consists of test cases resp for CNV: Verify that hotplugging and hot unplugging of a PVC to/from a VM works

@ayush-patni ayush-patni requested review from a team as code owners January 15, 2025 06:54
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines label Jan 15, 2025
Copy link

openshift-ci bot commented Jan 15, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ayush-patni

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

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

PR validation on existing cluster

Cluster Name: apatni-cnv-hotpl2
Cluster Configuration:
PR Test Suite:
PR Test Path: tests/functional/workloads/cnv/test_vm_hotplug_unplug.py
Additional Test Params:
OCP VERSION: 4.18
OCS VERSION: 4.18
tested against branch: master

Job UNSTABLE (some or all tests failed).

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

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

PR validation on existing cluster

Cluster Name: apatni-cnv-hotpl2
Cluster Configuration:
PR Test Suite:
PR Test Path: tests/functional/workloads/cnv/test_vm_hotplug_unplug.py
Additional Test Params:
OCP VERSION: 4.18
OCS VERSION: 4.18
tested against branch: master

Job UNSTABLE (some or all tests failed).

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

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

PR validation on existing cluster

Cluster Name: apatni-cnv-hotpl2
Cluster Configuration:
PR Test Suite:
PR Test Path: tests/functional/workloads/cnv/test_vm_hotplug_unplug.py
Additional Test Params:
OCP VERSION: 4.18
OCS VERSION: 4.18
tested against branch: master

Job UNSTABLE (some or all tests failed).

Copy link

@ocs-ci ocs-ci left a comment

Choose a reason for hiding this comment

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

PR validation on existing cluster

Cluster Name: apatni-cnv-hotpl2
Cluster Configuration:
PR Test Suite:
PR Test Path: tests/functional/workloads/cnv/test_vm_hotplug_unplug.py
Additional Test Params:
OCP VERSION: 4.18
OCS VERSION: 4.18
tested against branch: master

Job PASSED.

volume_name (str): Name of the volume to verify

Returns:
str: stdout of command
Copy link
Contributor

Choose a reason for hiding this comment

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

return is bool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

vm_obj.restart(wait=True, verify=True)

# Verify that the disk is still attached
verifyvolume(vm_obj, volume_name=pvc_obj.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

assert here if verification is not successfull

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

), f"Failed to unplug disk from VM {vm_obj.name}"

# Confirm disk removal
if not verifyvolume(vm_obj, volume_name=pvc_obj.name):
Copy link
Contributor

Choose a reason for hiding this comment

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

assert here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

)
run_dd_io(vm_obj=vm_obj, file_path=file_paths[1])
else:
pytest.fail(
Copy link
Contributor

Choose a reason for hiding this comment

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

can be part of assert message


# Hotplug the PVC to the VM
vm_obj.addvolume(volume_name=pvc_obj.name)
verifyvolume(vm_obj, volume_name=pvc_obj.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

assert here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


@magenta_squad
@workloads
@pytest.mark.polarion_id("OCS-")
Copy link
Contributor

Choose a reason for hiding this comment

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

polarion id

9. login into VM and confirm disk is no longer listed.
10 Repeat the above tests for DVT based VM
"""

Choose a reason for hiding this comment

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

Please consider making this as common function(s) so it can be used by other tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per today's discussion, we'll be updating addvolume as enhancement
https://github.com/red-hat-storage/ocs-ci/pull/11149/files#r1923196525

@ayush-patni ayush-patni added the team/e2e E2E team related issues/PRs label Jan 17, 2025
Signed-off-by: AYUSH-D-PATNI <[email protected]>
log.info(f"Disks before hotplug:\n{before_disks}")

# Hotplug the PVC to the VM
vm_obj.addvolume(volume_name=pvc_obj.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add multiple hot disks?

Comment on lines +383 to +384
cmd = f"oc get vm {vm_obj.name} -o=jsonpath='{{.spec.volumes}}'"
output = run_cmd(cmd=cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

you can replace it with vm_obj.get()


Args:
vm_obj (str): vm obj
volume_name (str): Name of the volume to verify
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
volume_name (str): Name of the volume to verify
volume_name (str): Name of the volume (PVC) to verify

Comment on lines +83 to +86
# Perform I/O operation on the new disk
log.info(
f"Running I/O operation on the newly attached disk in VM {vm_obj.name}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

from the log message, it looks like you are running IO to the newly attached disk. How are you making sure that the created file indeed goes to the new disk?

@@ -33,5 +33,5 @@ def test_vm_single_disk_hot_plugging_unplugging(self, cnv_workload, setup_cnv):
access_mode=constants.ACCESS_MODE_RWX,
volume_mode=constants.VOLUME_MODE_BLOCK,
)
vm_obj.addvolme(volume_name=pvc_obj.name)
vm_obj.addvolume(volume_name=pvc_obj.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

since this test is covered with the new test in this PR, the old test can be depreciated

Comment on lines +70 to +72
assert verifyvolume(
vm_obj, volume_name=pvc_obj.name
), f"Unable to found volume {pvc_obj.name} mounted on VM: {vm_obj.name}"
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add an additional arg like verify the addvolume function and move the verification code under it in the function. that way you can remove the repeated verification code in the test calling that function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L PR that changes 100-499 lines team/e2e E2E team related issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants