8000 Adding UT coverage for VM validation in VRG by abhijeet219 · Pull Request #2052 · RamenDR/ramen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding UT coverage for VM validation in VRG #2052

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

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

Conversation

abhijeet219
Copy link
Member

UT coverage for VM-DR epic:
Writing unit tests and validations of VRG status for different combination of VMs(with and without protection label) and their states.

@abhijeet219 abhijeet219 requested review from pruthvitd and removed request for ShyamsundarR and BenamarMk May 22, 2025 12:20
@abhijeet219 abhijeet219 force-pushed the ut_vm-dr branch 5 times, most recently from bd07b83 to 7942c6a Compare May 22, 2025 14:50
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to keep the kubvirt crd in ramen source? This is 5835 lines file. We can install this from kubevirt release for the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried out other options:

  1. Downloading VirtualMachine crd yaml raw file in runtime from the testEnv: kubevirt doesn't provide CRDs. I tried some URLs to download the CRD, but they are not reliable.

  2. Applying kubevirt-operator and kubevirt-cr, expecting it to install VirtualMachine CRD, eventually. But the kubevirt-operator.yaml defines deployments that won’t run in envtest, because there's no controller manager or scheduler. The operator won't function, so it never installs the CRDs like VirtualMachine.

  3. Instead of downloading CRDs from unreliable URLs, we can generate the necessary CRDs locally during the test setup. But we will need to clone the kubevirt repo, and generate manifests there.. but that also doesn't look like a better solution. right?

Any comments on the approaches I tried? or any other suggestions?

vrgTestCase.cleanupVRG()
})

It("VM do not have the protection label, but is in protected vms list of secondary vrg", func() {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to test VM? can we use deployment for testing the same thing? We should not have vm specific code in ramen, so we don't need vm specific tests.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @nirs, these tests are added specifically to test VM-recipe. The virtualmachine instances gets validated by the VRG controller, in-order to simulate the scenarios we need to create VM instances in testenv.

Copy link
Member
@pruthvitd pruthvitd left a comment

Choose a reason for hiding this comment

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

LGTM

@abhijeet219 abhijeet219 force-pushed the ut_vm-dr branch 3 times, most recently from b1f7564 to 39c2d56 Compare June 3, 2025 03:39
Copy link
Member

Choose a reason for hiding this comment

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

The minimized version looks nice. Please add a comment explaining that this is minimized version of the original crd, and add a link to source you took it from.

@@ -35,7 +35,7 @@ require (
k8s.io/component-base v0.31.1
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
kubevirt.io/api v1.5.0
kubevirt.io/api v1.5.1
Copy link
Member

Choose a reason for hiding this comment

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

Upgrading to 1.5.1 is not related to the test change, this should be done separately, and use latest version:
https://github.com/kubevirt/kubevirt/releases/tag/v1.5.2

Note that in drenv we are still testing kubevirt 1.3. We need to upgrade it to 1.5.2 as well.

@@ -1072,6 +1076,426 @@ var _ = Describe("VolumeReplicationGroupVolRepController", func() {
})
})

var vrgTestCase *vrgTest
var vrgTestCase1 *vrgTest
Copy link
Member

Choose a reason for hiding this comment

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

These names do not describe the purpose of the variable. It would be better to define them at the context scope so we use the same short variable name for the entire context.

Looking at the new code vrgTestCase1 is not used in this context.

Expect(condition.Message).To(Equal("VolumeReplicationGroup is not in the admin namespace: " +
"VolumeReplicationGroup is not allowed to protect namespaces"))

vrgTestCase.cleanupVRG()
Copy link
Member

Choose a reason for hiding this comment

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

Is this called if an assertion failed before the test?

for example
39c2d56#diff-af799cf0d298b89e62ed4257879ffdf53d91e60f4f4871f01bc3811c61366209R1113

Cleanup code must be called from cleanup handler so it is always called, even on failures.

}, vrgtimeout, vrginterval).Should(BeTrue(), "while waiting for VRG TRUE condition on secondary %s",
vrgTestCase.vrgName)

deleteVM(vm, vmNamespacedName)
Copy link
Member

Choose a reason for hiding this comment

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

Other tests do not delete the vm - should they?

Expect(condition.Status).To(Equal(metav1.ConditionFalse))
Expect(condition.Reason).To(Equal("ClusterDataConflictSecondary"))

deleteVM(vm1, vmNamespacedName1)
Copy link
Member

Choose a reason for hiding this comment

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

This will not be called if the assetions before fail, but we don't call this later in a cleanup.

@abhijeet219 abhijeet219 force-pushed the ut_vm-dr branch 2 times, most recently from de5c64f to f19469d Compare June 27, 2025 05:56
Signed-off-by: Abhijeet Shakya <abhijeetshakya21@gmail.com>
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
0