From 18f1486e9776c1c8e3b9bedfb9789b0cc4faad20 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Thu, 8 Feb 2018 08:41:38 -0500 Subject: [PATCH] Skip TestRoutes when there are no vm(s) 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 --- .../providers/openstack/openstack_routes_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/providers/openstack/openstack_routes_test.go b/pkg/cloudprovider/providers/openstack/openstack_routes_test.go index f8143a08dee..b38d7ffc257 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_routes_test.go +++ b/pkg/cloudprovider/providers/openstack/openstack_routes_test.go @@ -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 {