Add vSphere Cloud Provider simulator based tests #55918
Conversation
/ok-to-test |
/retest |
@rohitjogvmw @tusharnt anyone from the VCP team available to review? |
Thanks, @dougm for adding this. |
|
||
vc := &VSphereConnection{GoVmomiClient: c} | ||
|
||
_, err = GetDatacenter(ctx, vc, "enoent") |
abrarshivani
Dec 14, 2017
Contributor
I think it would better to add constants here instead of directly using strings. Do we have govmomi constants for the strings?
I think it would better to add constants here instead of directly using strings. Do we have govmomi constants for the strings?
dougm
Dec 14, 2017
Author
Member
Sure we can add a constant for this name, but would be in this test rather than govmomi (see below).
Sure we can add a constant for this name, but would be in this test rather than govmomi (see below).
abrarshivani
Dec 15, 2017
Contributor
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
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") |
abrarshivani
Dec 14, 2017
Contributor
ditto
ditto
dougm
Dec 14, 2017
Author
Member
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
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
abrarshivani
Dec 15, 2017
Contributor
It is safer to avoid string literals. We can add util functions to avoid repetition of the same code across multiple tests.
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 { |
abrarshivani
Dec 14, 2017
•
Contributor
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
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
dougm
Dec 14, 2017
Author
Member
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
.
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
.
abrarshivani
Dec 15, 2017
Contributor
Sounds good to me
Sounds good to me
t.Error(err) | ||
} | ||
|
||
vmdk := ds.Path(avm.Name + "/disk1.vmdk") |
abrarshivani
Dec 14, 2017
Contributor
I would prefer variable name such as disk1Path
I would prefer variable name such as disk1Path
dougm
Dec 14, 2017
Author
Member
sure, I'll change that.
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
/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. |
c1f2da7
into
kubernetes:master
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: