Skip to content

Commit 84534a1

Browse files
committed
acceptance: Skip noauth tests if config not provided
This is a non-default (and somewhat esoteric) configuration. Skip the tests unless explicitly provided. Signed-off-by: Stephen Finucane <[email protected]>
1 parent ef98774 commit 84534a1

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

internal/acceptance/clients/clients.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func NewBlockStorageV2NoAuthClient() (*gophercloud.ServiceClient, error) {
218218
}
219219

220220
// NewBlockStorageV3NoAuthClient returns a noauth *ServiceClient for
221-
// making calls to the OpenStack Block Storage v2 API. An error will be
221+
// making calls to the OpenStack Block Storage v3 API. An error will be
222222
// returned if client creation was not possible.
223223
func NewBlockStorageV3NoAuthClient() (*gophercloud.ServiceClient, error) {
224224
client, err := blockstorageNoAuth.NewClient(gophercloud.AuthOptions{

internal/acceptance/clients/conditions.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,24 @@ func RequireNovaNetwork(t *testing.T) {
8383
}
8484
}
8585

86-
// RequireIronicHTTPBasic will restric a test to be only run in
87-
// environments that have Ironic using http_basic.
86+
// RequireCinderNoAuth will restrict a test to be only run in environments that
87+
// have Cinder using noauth.
88+
func RequireCinderNoAuth(t *testing.T) {
89+
if os.Getenv("CINDER_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" {
90+
t.Skip("this test requires Cinder using noauth, set OS_USERNAME and CINDER_ENDPOINT")
91+
}
92+
}
93+
94+
// RequireIronicNoAuth will restrict a test to be only run in environments that
95+
// have Ironic using noauth.
96+
func RequireIronicNoAuth(t *testing.T) {
97+
if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" {
98+
t.Skip("this test requires IRONIC using noauth, set OS_USERNAME and IRONIC_ENDPOINT")
99+
}
100+
}
101+
102+
// RequireIronicHTTPBasic will restrict a test to be only run in environments
103+
// that have Ironic using http_basic.
88104
func RequireIronicHTTPBasic(t *testing.T) {
89105
if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" || os.Getenv("OS_PASSWORD") == "" {
90106
t.Skip("this test requires Ironic using http_basic, set OS_USERNAME, OS_PASSWORD and IRONIC_ENDPOINT")

internal/acceptance/openstack/baremetal/noauth/allocations_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
func TestAllocationsCreateDestroy(t *testing.T) {
1717
clients.RequireLong(t)
18+
clients.RequireIronicNoAuth(t)
1819

1920
client, err := clients.NewBareMetalV1NoAuthClient()
2021
th.AssertNoErr(t, err)

internal/acceptance/openstack/baremetal/noauth/nodes_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
func TestNodesCreateDestroy(t *testing.T) {
1818
clients.RequireLong(t)
19+
clients.RequireIronicNoAuth(t)
1920

2021
client, err := clients.NewBareMetalV1NoAuthClient()
2122
th.AssertNoErr(t, err)
@@ -48,6 +49,7 @@ func TestNodesCreateDestroy(t *testing.T) {
4849

4950
func TestNodesUpdate(t *testing.T) {
5051
clients.RequireLong(t)
52+
clients.RequireIronicNoAuth(t)
5153

5254
client, err := clients.NewBareMetalV1NoAuthClient()
5355
th.AssertNoErr(t, err)
@@ -72,6 +74,7 @@ func TestNodesUpdate(t *testing.T) {
7274
func TestNodesRAIDConfig(t *testing.T) {
7375
clients.SkipReleasesBelow(t, "stable/ussuri")
7476
clients.RequireLong(t)
77+
clients.RequireIronicNoAuth(t)
7578

7679
client, err := clients.NewBareMetalV1NoAuthClient()
7780
th.AssertNoErr(t, err)

internal/acceptance/openstack/baremetal/noauth/ports_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
func TestPortsCreateDestroy(t *testing.T) {
1818
clients.RequireLong(t)
19+
clients.RequireIronicNoAuth(t)
1920

2021
client, err := clients.NewBareMetalV1NoAuthClient()
2122
th.AssertNoErr(t, err)
@@ -50,6 +51,7 @@ func TestPortsCreateDestroy(t *testing.T) {
5051

5152
func TestPortsUpdate(t *testing.T) {
5253
clients.RequireLong(t)
54+
clients.RequireIronicNoAuth(t)
5355

5456
client, err := clients.NewBareMetalV1NoAuthClient()
5557
th.AssertNoErr(t, err)

internal/acceptance/openstack/blockstorage/noauth/snapshots_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
)
1313

1414
func TestSnapshotsList(t *testing.T) {
15+
clients.RequireCinderNoAuth(t)
16+
1517
client, err := clients.NewBlockStorageV3NoAuthClient()
1618
if err != nil {
1719
t.Fatalf("Unable to create a blockstorage client: %v", err)
@@ -33,6 +35,8 @@ func TestSnapshotsList(t *testing.T) {
3335
}
3436

3537
func TestSnapshotsCreateDelete(t *testing.T) {
38+
clients.RequireCinderNoAuth(t)
39+
3640
client, err := clients.NewBlockStorageV3NoAuthClient()
3741
if err != nil {
3842
t.Fatalf("Unable to create a blockstorage client: %v", err)

internal/acceptance/openstack/blockstorage/noauth/volumes_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
)
1313

1414
func TestVolumesList(t *testing.T) {
15+
clients.RequireCinderNoAuth(t)
16+
1517
client, err := clients.NewBlockStorageV3NoAuthClient()
1618
if err != nil {
1719
t.Fatalf("Unable to create a blockstorage client: %v", err)
@@ -33,6 +35,8 @@ func TestVolumesList(t *testing.T) {
3335
}
3436

3537
func TestVolumesCreateDestroy(t *testing.T) {
38+
clients.RequireCinderNoAuth(t)
39+
3640
client, err := clients.NewBlockStorageV3NoAuthClient()
3741
if err != nil {
3842
t.Fatalf("Unable to create blockstorage client: %v", err)

0 commit comments

Comments
 (0)