Skip to content

Conformance tests for vm_test.go #12682

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

Merged
merged 12 commits into from
Sep 14, 2024
Merged

Conversation

fossedihelm
Copy link
Contributor

@fossedihelm fossedihelm commented Aug 27, 2024

What this PR does

A new label (conformance) is introduced and will be used to tag those tests that will be part of the conformance tests.
This PR aims to identify and label the tests in the vm_tests.go file.
Also, a cleanup and refactoring of the tests is performed:

  • convert e2e test into a unit test if possible;
  • remove tests that do not add anything to an already present unit test;
  • use patchset;
  • remove duplicates;
  • merge similar tests.

This is a starting point for several PRs, whose goal is to cover all the conformance tests.

For the number lovers:
Previous number of e2e tests: 84
Current number of e2e tests: 77
Conformance e2e tests: 27

Fixes #

Why we need it and why it was done in this way

The following tradeoffs were made:

The following alternatives were considered:

Links to places where the discussion took place:

Special notes for your reviewer

Release note

NONE

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Aug 27, 2024
@fossedihelm
Copy link
Contributor Author

/cc @xpivarc

@kubevirt-bot kubevirt-bot added sig/storage needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 27, 2024
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 28, 2024
tests/vm_test.go Outdated
vmi.Spec.Domain.Resources.Requests = k8sv1.ResourceList{
Entry("[test_id:6867] when VM scheduling error occurs with unsatisfiable resource requirements",
libvmi.New(
libvmi.WithContainerDisk("disk0", "no-such-image"),
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need the CD?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so

tests/vm_test.go Outdated
@@ -246,7 +245,7 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:cnv-qe@redhat.com][level:com
validateGenerationState(vm, 6, 6, 6, 6)
})

DescribeTable("[test_id:1520]should update VirtualMachine once VMIs are up", func(createTemplate vmiBuilder) {
DescribeTable("[test_id:1520]should update VirtualMachine once VMIs are up", decorators.Conformance, func(createTemplate vmiBuilder) {
Copy link
Member

Choose a reason for hiding this comment

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

Where is the assert here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The assertion in the libvmops.StartVirtualMachine function itself

Copy link
Member

Choose a reason for hiding this comment

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

But what is the update? I am not sure I understand what this test does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update is that the vm.Status.Ready becomes true. Maybe we can drop this?

Copy link
Member

Choose a reason for hiding this comment

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

Seems like duplicate then...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah! Already dropped in a new commit

tests/vm_test.go Outdated
@@ -359,6 +358,7 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:cnv-qe@redhat.com][level:com
Expect(pod.Name).ToNot(Equal(firstPod.Name))
})

//TODO does it make sense?
Copy link
Member

Choose a reason for hiding this comment

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

What are your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering if this makes sense since we have test_id:1526 that checks stop and start multiple times. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Let's drop the comment for now and track it offline

tests/vm_test.go Outdated
@@ -575,7 +573,7 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:cnv-qe@redhat.com][level:com
}
})

It("[test_id:7679]should report an error status when data volume error occurs", func() {
It("[test_id:7679]should report an error status when data volume error occurs", decorators.Conformance, func() {
Copy link
Member

Choose a reason for hiding this comment

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

We should not use Skip inside Conformance 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.

Removed from the conformance set

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2024
@kubevirt-bot kubevirt-bot added size/XL and removed size/L needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 3, 2024
@fossedihelm
Copy link
Contributor Author

Thank you for the review @xpivarc.
PTAL

@fossedihelm fossedihelm force-pushed the conformance-vm branch 2 times, most recently from a4cbde7 to de5b441 Compare September 3, 2024 12:26
@dominikholler
Copy link
Contributor

A new label (conformance) is introduced and will be used to tag those tests that will be part of the conformance tests.
This PR aims to identify and label the tests in the vm_tests.go file.

Exciting idea!

Also, a cleanup and refactoring of the tests is performed:

No doubts that the cleanup and refactoring is required, but I wonder in which way is this is related to the new label?

@fossedihelm
Copy link
Contributor Author

No doubts that the cleanup and refactoring is required, but I wonder in which way is this is related to the new label?

Thank you! I have to analyze every test to decide if they are or are not part of the conformance.
While doing this, if I find something that can be improved I think it is correct to it.
If we can stabilize/remove/convert_to_unittest why shouldn't we do it?
I mean, from my POV this is part of the stabilization/lowering flakes process.

@dominikholler
Copy link
Contributor

Thank you! I have to analyze every test to decide if they are or are not part of the conformance.
While doing this, if I find something that can be improved I think it is correct to it.
If we can stabilize/remove/convert_to_unittest why shouldn't we do it?

No doubts that we should do it and that it is great, I just wonder if it is clean to introduce the change in the PR which is about adding the new label.

I mean, from my POV this is part of the stabilization/lowering flakes process.

No doubts that the changes are highly welcome.

@fossedihelm
Copy link
Contributor Author

No doubts that we should do it and that it is great, I just wonder if it is clean to introduce the change in the PR which is about adding the new label.

By nature, Conformance tests should be as stable as possible. So, I think it is correct to do them all together :)

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2024
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2024
@kubevirt-bot kubevirt-bot added size/L and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 10, 2024
Copy link
Member

@xpivarc xpivarc left a comment

Choose a reason for hiding this comment

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

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xpivarc

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

The pull request process is described 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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2024
@fossedihelm
Copy link
Contributor Author

@EdDev can you please have a look at the libvmi WithNodeSelectorFor signature change? Thank you

Copy link
Member

@vladikr vladikr left a comment

Choose a reason for hiding this comment

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

Looks great, just some nits

vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Name: "testdisk",
Context("with an invalid VM", func() {
It("should reject the request with unrecognized field", func() {
Copy link
Member

Choose a reason for hiding this comment

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

@fossedihelm @xpivarc Did we previously ignored unrecognized fields?
Are we sure we need to reject these?
Are we sure that it's not going to affect upgrades?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vladikr I did not change any behavior here. I just converted the e2e test to unit test :)
So yes, we were rejecting unrecognized fields even before.
It is something that we do for every resource and looks like we have always done it:
93eecf3#diff-37e7f54f2a03b510af54f5d608e432bb0447d09ea6066a9970e0be8beab66649R1214

AFAIK k8s does not allow unrecognized fields as well.

Also, maybe we can perform this instructing openapi, instead of manually doing this check.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the fields were rejected as previously the Kube would only ignore the fields. In case of typo the behavior could be different..

Template: &v1.VirtualMachineInstanceTemplateSpec{
Spec: vmi.Spec,

It("reject syntax valid VM, but with invalid spec", func() {
Copy link
Member

Choose a reason for hiding this comment

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

What is invalid in this test?
Is it that a matching volume doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly!
Don't know how but looks like I accidentally deleted this comment:

			// Add a disk that doesn't map to a volume.
			// This should get rejected which tells us the webhook validator is working.

I will reintroduce it. Thanks

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

The invalid vm spec e2e test can easily be a unit test.
We can lower the e2e test time by moving it.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Currently, `WithNodeSelectorFor` takes the pointer to
a node to create the nodeSelector field of a vmi.
In most of the cases we just have the node name. Indeed,
we can see that a dummy node obj is passed to respect the
function signature.
The node name is enough to achieve what we want.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Signed-off-by: fossedihelm <ffossemo@redhat.com>
Annotations carrying was not covering all the cases.

The annotation carrying mechanism should ensure that
annotations listed in the vm.spec.template object were
propagated, while those listed in the vm objects are
discarded.

In other words, the vm annotations is not propagated to
the vmi.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Currently we have two e2e tests: the first one that checks
that a revision is created when a vm starts and the second one
that checks that the revision is updated when a vm is restarted.

The second one includes all the steps of the first one, so there is
no reason to have both.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Signed-off-by: fossedihelm <ffossemo@redhat.com>
Signed-off-by: fossedihelm <ffossemo@redhat.com>
- Unwrap Delete out of Eventually block
- Use `GetPodByVirtualMachineInstance` utility function

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Check for events rather than logs, which is well-defined API for users compared to
logs that is mostly available only to admins.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
The test just checks that a vm becomes
ready once the vmi is started.
This is performed almost in every other
tests, so we can drop it.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
Signed-off-by: fossedihelm <ffossemo@redhat.com>
Signed-off-by: fossedihelm <ffossemo@redhat.com>
@fossedihelm
Copy link
Contributor Author

Change Addressed @vladikr comment.
Followed by Rebase

@acardace
Copy link
Member

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 13, 2024
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-windows2016
/test pull-kubevirt-e2e-kind-1.27-vgpu
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.30-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.29-sig-network
/test pull-kubevirt-e2e-k8s-1.29-sig-storage
/test pull-kubevirt-e2e-k8s-1.29-sig-compute
/test pull-kubevirt-e2e-k8s-1.29-sig-operator
/test pull-kubevirt-e2e-k8s-1.30-sig-network
/test pull-kubevirt-e2e-k8s-1.30-sig-storage
/test pull-kubevirt-e2e-k8s-1.30-sig-compute
/test pull-kubevirt-e2e-k8s-1.30-sig-operator

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Sep 13, 2024

@fossedihelm: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-e2e-arm64 dde8a54 link false /test pull-kubevirt-e2e-arm64

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@kubevirt-commenter-bot
Copy link

/retest-required
This bot automatically retries required jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot kubevirt-bot merged commit 6aba1bc into kubevirt:main Sep 14, 2024
39 of 40 checks passed
@EdDev
Copy link
Member

EdDev commented Sep 16, 2024

@EdDev can you please have a look at the libvmi WithNodeSelectorFor signature change? Thank you

Sorry for the late reply, it looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. sig/network sig/storage size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants