-
Notifications
You must be signed in to change notification settings - Fork 2
/
conditions.go
91 lines (79 loc) · 2.77 KB
/
conditions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package clients
import (
"os"
"testing"
)
// RequireAdmin will restrict a test to only be run by admin users.
func RequireAdmin(t *testing.T) {
if os.Getenv("OS_USERNAME") != "admin" {
t.Skip("must be admin to run this test")
}
}
// RequireNonAdmin will restrict a test to only be run by non-admin users.
func RequireNonAdmin(t *testing.T) {
if os.Getenv("OS_USERNAME") == "admin" {
t.Skip("must be a non-admin to run this test")
}
}
// RequirePortForwarding will restrict a test to only be run in environments
// that support port forwarding
func RequirePortForwarding(t *testing.T) {
if os.Getenv("OS_PORTFORWARDING_ENVIRONMENT") == "" {
t.Skip("this test requires support for port forwarding")
}
}
// RequireDNS will restrict a test to only be run in environments
// that support DNSaaS.
func RequireDNS(t *testing.T) {
if os.Getenv("OS_DNS_ENVIRONMENT") == "" {
t.Skip("this test requires DNSaaS")
}
}
// RequireGuestAgent will restrict a test to only be run in
// environments that support the QEMU guest agent.
func RequireGuestAgent(t *testing.T) {
if os.Getenv("OS_GUEST_AGENT") == "" {
t.Skip("this test requires support for qemu guest agent and to set OS_GUEST_AGENT to 1")
}
}
// RequireIdentityV2 will restrict a test to only be run in
// environments that support the Identity V2 API.
func RequireIdentityV2(t *testing.T) {
if os.Getenv("OS_IDENTITY_API_VERSION") != "2.0" {
t.Skip("this test requires support for the identity v2 API")
}
}
// RequireLiveMigration will restrict a test to only be run in
// environments that support live migration.
func RequireLiveMigration(t *testing.T) {
if os.Getenv("OS_LIVE_MIGRATE") == "" {
t.Skip("this test requires support for live migration and to set OS_LIVE_MIGRATE to 1")
}
}
// RequireLong will ensure long-running tests can run.
func RequireLong(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
}
// RequireNovaNetwork will restrict a test to only be run in
// environments that support nova-network.
func RequireNovaNetwork(t *testing.T) {
if os.Getenv("OS_NOVANET") == "" {
t.Skip("this test requires nova-network and to set OS_NOVANET to 1")
}
}
// RequireIronicHTTPBasic will restric a test to be only run in
// environments that have Ironic using http_basic.
func RequireIronicHTTPBasic(t *testing.T) {
if os.Getenv("IRONIC_ENDPOINT") == "" || os.Getenv("OS_USERNAME") == "" || os.Getenv("OS_PASSWORD") == "" {
t.Skip("this test requires Ironic using http_basic, set OS_USERNAME, OS_PASSWORD and IRONIC_ENDPOINT")
}
}
// SkipRelease will have the test be skipped on a certain
// release. Releases are named such as 'stable/mitaka', master, etc.
func SkipRelease(t *testing.T, release string) {
if os.Getenv("OS_BRANCH") == release {
t.Skipf("this is not supported in %s", release)
}
}