cluster-api-provider-vsphere icon indicating copy to clipboard operation
cluster-api-provider-vsphere copied to clipboard

Add tests for `pkg/services/govmomi/service.go`

Open ditsuke opened this issue 3 years ago • 6 comments
trafficstars

What this PR does / why we need it: Adds tests for exported functions in pkg/services/govmomi/service.go. These functions include:

  • [ ] ReconcileVM() This function reconciles a vm reference to make sure it is in a consistent and desired state by:

    • Creating the VM if it doesn't exist.
    • Updating the VM with bootstrap init data (cloud and user).
    • Powering on the VM.
    • Returning a VirtualMachine struct with updated real-time state of the machine.

    To test this function, it is necessary to mock the various states a target VM can be in, passing in contexts with invalid VM UUIDs, contexts with non-existent VMs and then asserting for desired behaviors like non-reconcillation of VMs with inflight tasks, errors on invalid VM refs, creation of new VMs with contexts lacking a VM, etc. I'm yet to document all the scenarios but would appreciate any insights here.

  • [ ] DestroyVM() This function is used to destroy the VM referenced by the context. DestroyVM() seems to share some reconcilation logic with ReconcileVM() which might be an opportunity for refactoring. The behaviors to test for include ensuring VMs with inflight tasks are not destroyed, errors are not returned when invalid references are passed (the VMs are assumed to be destroyed), and that on passing valid refs the underlying VM is destroyed if its powered on and if not, a task to destroy the VM is queued in the context.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #1479

Special notes for your reviewer: None yet.

Signed-off-by: ditsuke [email protected]

ditsuke avatar Mar 22 '22 18:03 ditsuke

Hi @ditsuke. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

k8s-ci-robot avatar Mar 22 '22 18:03 k8s-ci-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: To complete the pull request process, please assign neolit123 after the PR has been reviewed. You can assign the PR to them by writing /assign @neolit123 in a comment when ready.

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

k8s-ci-robot avatar Mar 22 '22 18:03 k8s-ci-robot

/ok-to-test

aartij17 avatar Apr 10 '22 18:04 aartij17

This PR is currently blocked because we could not figure out if there's a way to mock in-flight tasks on a VCSim VMs or a VMContext. I believe we need the ability to reliably create these mock tasks to test how ReconcileVM() behaves when a VM is busy. The second, and I think easier to resolve blocker is setting valid bootstrap data for a VSphereVM Spec. Would appreciate all help and any pointers on these issues! We also have a Slack thread here.

ditsuke avatar Apr 30 '22 13:04 ditsuke

@ditsuke: The following tests 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-cluster-api-provider-vsphere-test 69121e693e62b88c3415ae286d11e592348a2e8a link true /test pull-cluster-api-provider-vsphere-test
pull-cluster-api-provider-vsphere-apidiff-main 274779a074c5c06c38fe7e75d797d80b71afddfd link true /test pull-cluster-api-provider-vsphere-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

k8s-ci-robot avatar May 10 '22 20:05 k8s-ci-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Aug 09 '22 06:08 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Sep 08 '22 07:09 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Oct 08 '22 08:10 k8s-triage-robot

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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/test-infra repository.

k8s-ci-robot avatar Oct 08 '22 08:10 k8s-ci-robot