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

✨ Add VirtualMachine conversion tests #304

Merged
merged 2 commits into from
Dec 18, 2023

Conversation

bryanv
Copy link
Contributor

@bryanv bryanv commented Dec 13, 2023

Start with a nearly fully populated v1a2 VM and ensure that the VM resulting from conversion is the same. We can keep adding these explicit conversion tests to ensure that fields are converted as we expect instead of always depending on the fuzzer.

Fix a few conversion issues around the Network and Advanced fields.

Always restore the full VM status from the annotations. Our controller should be the only one updating the Status, and an update from the conversion will cause our controllers to reconcile and reevaluate the Status.

NONE

@bryanv bryanv requested a review from akutz December 13, 2023 19:06
@github-actions github-actions bot added testing-needed-e2e-fast size/L Denotes a PR that changes 100-499 lines. labels Dec 13, 2023
@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch 4 times, most recently from 25a7feb to f8b30d4 Compare December 13, 2023 22:18
@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch from f8b30d4 to efc49c8 Compare December 13, 2023 22:59
@akutz
Copy link
Collaborator

akutz commented Dec 14, 2023

an update from the conversion will cause our controllers to reconcile and reevaluate the Status.

Why do we want to eval the status? Should we not configure a filter that ignores updates to the status sub-resource?

Copy link
Collaborator

@akutz akutz left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks!

api/v1alpha1/conversion_test.go Show resolved Hide resolved
api/v1alpha1/virtualmachine_conversion.go Show resolved Hide resolved
@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch from efc49c8 to c5bf8e0 Compare December 14, 2023 17:26
@bryanv
Copy link
Contributor Author

bryanv commented Dec 14, 2023

an update from the conversion will cause our controllers to reconcile and reevaluate the Status.

Why do we want to eval the status? Should we not configure a filter that ignores updates to the status sub-resource?

If the Spec changes, then yes. I don't think we're using the filter to skip the Status updated induced reconcile ATM.

@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch from c5bf8e0 to 615996c Compare December 14, 2023 17:37
@akutz
Copy link
Collaborator

akutz commented Dec 14, 2023

an update from the conversion will cause our controllers to reconcile and reevaluate the Status.

Why do we want to eval the status? Should we not configure a filter that ignores updates to the status sub-resource?

If the Spec changes, then yes. I don't think we're using the filter to skip the Status updated induced reconcile ATM.

Sorry, I mean we never "evaluate" the status, or rather, we shouldn't. We construct it by evaluating and reconciling the spec. I think we just thought different things when we used the word "reevaluate."

@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch 3 times, most recently from e7bedff to f793c5e Compare December 15, 2023 16:57
Start with a nearly fully populated v1a2 VM and ensure that
the VM resulting from conversion is the same. We can keep adding
these explicit conversion tests to ensure that fields are converted
as we expect instead of always depending on the fuzzer. Add typical
v1a1 TKG VM and ensure spoke-hub-spoke conversion works.

Fix a few conversion issues around the Network and Advanced fields.

Always restore the full VM Status from the annotations. Our controller
should be the only one updating the Status, and an update from the
conversion will cause our controllers to reconcile and reevaluate the
Status.
@bryanv bryanv force-pushed the bryanv/more-vm-conversion-tests branch from f793c5e to 8b0ed54 Compare December 18, 2023 17:51
@github-actions github-actions bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Dec 18, 2023
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/api/utilconversion 91%
github.com/vmware-tanzu/vm-operator/api/v1alpha1 36%
github.com/vmware-tanzu/vm-operator/api/v1alpha2 28%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/cloudinit 24%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/common 15%
github.com/vmware-tanzu/vm-operator/api/v1alpha2/sysprep 27%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/clustercontentlibraryitem 83%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/contentlibraryitem 82%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/contentsource 87%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha1/utils 95%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/clustercontentlibraryitem 86%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/contentlibraryitem 85%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/v1alpha2/utils 91%
github.com/vmware-tanzu/vm-operator/controllers/infracluster 75%
github.com/vmware-tanzu/vm-operator/controllers/infraprovider 75%
github.com/vmware-tanzu/vm-operator/controllers/providerconfigmap 75%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/util/remote 41%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/v1alpha1 44%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/v1alpha2 70%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass/v1alpha1 31%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass/v1alpha2 22%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest/v1alpha1 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest/v1alpha2 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/providers 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/providers/simplelb 66%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha1/utils 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/providers 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/providers/simplelb 66%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/v1alpha2/utils 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy/v1alpha1 80%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy/v1alpha2 80%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 74%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha2 72%
github.com/vmware-tanzu/vm-operator/controllers/volume/v1alpha1 87%
github.com/vmware-tanzu/vm-operator/controllers/volume/v1alpha2 86%
github.com/vmware-tanzu/vm-operator/pkg/builder 73%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/conditions2 92%
github.com/vmware-tanzu/vm-operator/pkg/context 0%
github.com/vmware-tanzu/vm-operator/pkg/context/fake 100%
github.com/vmware-tanzu/vm-operator/pkg/lib 87%
github.com/vmware-tanzu/vm-operator/pkg/manager 78%
github.com/vmware-tanzu/vm-operator/pkg/metrics 90%
github.com/vmware-tanzu/vm-operator/pkg/metrics2 85%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/patch2 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 92%
github.com/vmware-tanzu/vm-operator/pkg/prober/context 100%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake 85%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/fake/worker 88%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 86%
github.com/vmware-tanzu/vm-operator/pkg/prober2 91%
github.com/vmware-tanzu/vm-operator/pkg/prober2/context 100%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake 85%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake/probe 83%
github.com/vmware-tanzu/vm-operator/pkg/prober2/fake/worker 89%
github.com/vmware-tanzu/vm-operator/pkg/prober2/probe 92%
github.com/vmware-tanzu/vm-operator/pkg/prober2/worker 80%
github.com/vmware-tanzu/vm-operator/pkg/record 89%
github.com/vmware-tanzu/vm-operator/pkg/topology 85%
github.com/vmware-tanzu/vm-operator/pkg/util 85%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 90%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/schema 25%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 92%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 89%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 74%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/fake 74%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere 71%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/client 49%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/clustermodules 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/config 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/contentlibrary 71%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/instancestorage 92%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/internal 0%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/network 88%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/placement 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/resources 47%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/session 84%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/storage 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/test 98%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/vcenter 80%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere/virtualmachine 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2 69%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/client 49%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/clustermodules 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/config 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/contentlibrary 72%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/instancestorage 92%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/internal 0%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/network 85%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/placement 70%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/resources 38%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/session 83%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/storage 77%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/test 98%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/vcenter 80%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/virtualmachine 84%
github.com/vmware-tanzu/vm-operator/pkg/vmprovider/providers/vsphere2/vmlifecycle 79%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 53%
github.com/vmware-tanzu/vm-operator/webhooks/common 100%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha1/mutation 81%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha1/validation 94%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha2/mutation 81%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/v1alpha2/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha1/mutation 59%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha1/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha2/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/v1alpha2/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/v1alpha2/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha1/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha1/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha2/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/v1alpha2/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha1/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha1/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/v1alpha2/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha2/validation 92%
Summary 70% (13423 / 19304)

Minimum allowed line rate is 60%

@bryanv bryanv added the testing-done-e2e-fast Indicates the fast, low-cost e2e testing has been used to validate a PR label Dec 18, 2023
@bryanv bryanv changed the title ✨ Add VirtualMachine hub-spoke-hub test ✨ Add VirtualMachine conversion tests Dec 18, 2023
@bryanv bryanv merged commit 3ceff4d into vmware-tanzu:main Dec 18, 2023
14 of 15 checks passed
@bryanv bryanv deleted the bryanv/more-vm-conversion-tests branch December 18, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required size/XL Denotes a PR that changes 500-999 lines. testing-done-e2e-fast Indicates the fast, low-cost e2e testing has been used to validate a PR testing-needed-e2e-fast
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants