Merge pull request #59571 from dims/skip-test-routes-when-there-are-no-vms

Automatic merge from submit-queue. 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>.

Skip TestRoutes when there are no vm(s)

**What this PR does / why we need it**:

TestRoutes assumes that there is at least one vm in the OpenStack it
is connecting to. So let's limit this test to run properly only when
we are running in a VM or one was created already outside of the
test harness


**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**:
Please see https://github.com/dims/openstack-cloud-controller-manager/issues/73 for some more context

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2018-02-12 10:25:55 -08:00 committed by GitHub
commit 7488d1c921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,9 +40,17 @@ func TestRoutes(t *testing.T) {
t.Fatalf("Failed to construct/authenticate OpenStack: %s", err)
}
vms := getServers(os)
_, err = os.InstanceID()
if err != nil || len(vms) == 0 {
t.Skipf("Please run this test in an OpenStack vm or create at least one VM in OpenStack before you run this test.")
}
// We know we have at least one vm.
servername := vms[0].Name
// Pick the first router and server to try a test with
os.routeOpts.RouterID = getRouters(os)[0].ID
servername := getServers(os)[0].Name
r, ok := os.Routes()
if !ok {