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 vSphere Cloud Provider simulator based tests #55918

Merged
merged 2 commits into from Jan 19, 2018

Conversation

dougm
Copy link
Member

@dougm dougm commented Nov 17, 2017

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:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 17, 2017
@dougm dougm changed the title Vcp vcsim Add vSphere Cloud Provider simulator based tests Nov 17, 2017
@dims
Copy link
Member

dims commented Nov 17, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 17, 2017
@dougm
Copy link
Member Author

dougm commented Nov 20, 2017

/retest

@dougm
Copy link
Member Author

dougm commented Nov 27, 2017

Test failures are fixed by #56136 , but after rebase currently fails locally due to #56393 - I'll rebase again when that is fixed.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 28, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2017
@dougm
Copy link
Member Author

dougm commented Dec 12, 2017

@rohitjogvmw @tusharnt anyone from the VCP team available to review?

Copy link
Contributor

@abrarshivani abrarshivani left a 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")
Copy link
Contributor

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?

Copy link
Member Author

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).

Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

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

Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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")
Copy link
Contributor

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

Copy link
Member Author

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.

@abrarshivani
Copy link
Contributor

/test pull-kubernetes-e2e-gce

@abrarshivani
Copy link
Contributor

abrarshivani commented Dec 14, 2017

@dougm just executing command make test is enough to run the tests, right?

@dougm
Copy link
Member Author

dougm commented Dec 14, 2017

@abrarshivani yes, make test will run these tests.

@dougm
Copy link
Member Author

dougm commented Dec 15, 2017

@abrarshivani I've moved the string literals to named constants.

@abrarshivani
Copy link
Contributor

/test pull-kubernetes-unit

@abrarshivani
Copy link
Contributor

LGTM

@dougm dougm force-pushed the vcp-vcsim branch 3 times, most recently from 9b2e443 to 5e875c7 Compare December 16, 2017 00:56
@dougm
Copy link
Member Author

dougm commented Dec 16, 2017

/retest

@abrarshivani
Copy link
Contributor

/lgtm

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2018
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2018
@lavalamp lavalamp assigned cheftako and thockin and unassigned jbeda, lavalamp and abrarshivani Jan 8, 2018
@lavalamp
Copy link
Member

lavalamp commented Jan 8, 2018

Assigning to @thockin and @cheftako, one of them should know the current req's for cloud provider changes.

@thockin
Copy link
Member

thockin commented Jan 18, 2018

@cheftako the move-out can't happen soon enough :)

I'm going to approve this since it is tests and not functionality.

/lgtm
/approve no-issue

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 18, 2018
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 18, 2018
@k8s-github-robot
Copy link
Contributor

/test all

Tests are more than 96 hours old. Re-running tests.

@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/test pull-kubernetes-e2e-kops-aws

@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/test pull-kubernetes-verify

@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link
Contributor

/test all

Tests are more than 96 hours old. Re-running tests.

@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/retest

@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/test pull-kubernetes-e2e-kops-aws

1 similar comment
@dougm
Copy link
Member Author

dougm commented Jan 18, 2018

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link
Contributor

/test all

Tests are more than 96 hours old. Re-running tests.

@k8s-github-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link
Contributor

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit c1f2da7 into kubernetes:master Jan 19, 2018
k8s-github-robot pushed a commit that referenced this pull request Jan 24, 2018
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
```
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants