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 vSphere Cloud Provider simulator based tests #55918
Conversation
/ok-to-test |
/retest |
@rohitjogvmw @tusharnt anyone from the VCP team available to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @dougm for adding this.
|
||
vc := &VSphereConnection{GoVmomiClient: c} | ||
|
||
_, err = GetDatacenter(ctx, vc, "enoent") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would better to add constants here instead of directly using strings. Do we have govmomi constants for the strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we can add a constant for this name, but would be in this test rather than govmomi (see below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding constant in this file it would be better to add in here "pkg/cloudprovider/providers/vsphere/vclib/constants.go" so other tests can use it
t.Error("expected error") | ||
} | ||
|
||
dc, err := GetDatacenter(ctx, vc, "DC0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case DC0
is expected to exist. I can change the tests to avoid the string literal names, just makes the test code more verbose. For example, instead of hardcoding DCO
and LocalDS_0
: https://github.com/vmware/govmomi/blob/68f3d8490ce3e7967e0ec283cd13bee465887c78/simulator/virtual_machine_test.go#L54-L71
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is safer to avoid string literals. We can add util functions to avoid repetition of the same code across multiple tests.
vc := &VSphereConnection{GoVmomiClient: c} | ||
|
||
_, err = GetDatacenter(ctx, vc, "enoent") | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain why enoent
should return err as nil? Is this handled differently in the simulator? Since I cannot find it here https://github.com/vmware/govmomi/blob/master/vcsim/README.md/#usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the opposite, these tests are making sure that enoent
returns an error that is not nil. Look at the line below, calls t.Error
if err == nil
. The name enoent
does not exist anywhere in the inventory, the tests are expecting these calls to fail, providing coverage of the error paths in datacenter.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
t.Error(err) | ||
} | ||
|
||
vmdk := ds.Path(avm.Name + "/disk1.vmdk") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer variable name such as disk1Path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I'll change that.
/test pull-kubernetes-e2e-gce |
@dougm just executing command |
@abrarshivani yes, |
@abrarshivani I've moved the string literals to named constants. |
/test pull-kubernetes-unit |
LGTM |
9b2e443
to
5e875c7
Compare
/retest |
/lgtm |
Initial set of vcsim based tests.
@cheftako the move-out can't happen soon enough :) I'm going to approve this since it is tests and not functionality. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abrarshivani, dougm, thockin Associated issue requirement bypassed by: thockin The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all Tests are more than 96 hours old. Re-running tests. |
/test pull-kubernetes-e2e-kops-aws |
/test pull-kubernetes-verify |
/test pull-kubernetes-e2e-kops-aws |
/test all Tests are more than 96 hours old. Re-running tests. |
/retest |
/test pull-kubernetes-e2e-kops-aws |
1 similar comment
/test pull-kubernetes-e2e-kops-aws |
/test all Tests are more than 96 hours old. Re-running tests. |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue (batch tested with PRs 58756, 58758, 58725, 52799, 58534). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add vSphere Cloud Provider vclib tests **What this PR does / why we need it**: Additional vSphere Cloud Provider functional tests against vcsim, providing more test coverage without having to run against a real vCenter instance. Follow up to #55918 **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: **Special notes for your reviewer**: This set of tests focuses on Datastore, Folder and VirtualMachine types. A couple of TODOs depend on changes to vcsim, I will follow up on those. **Release note**: ```release-note NONE ```
What this PR does / why we need it:
Initial set of vSphere Cloud Provider functional tests against the vCenter simulator, provides test coverage without having to run against a real vCenter instance.
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 #
Special notes for your reviewer:
The vsphere simulator recently moved from vmware/vic to govmomi, I had discussed the idea of introducing it for testing with vSphere Cloud Provider maintainers. These tests provide 90%+ coverage for vclib/datacenter.go, but we can expand further of course.
Release note: