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
92
93
94
95
96
97
98
99
100
101
102
103
104
105package test
import (
"fmt"
"os"
"strings"
)
// IsCalicoCNIDisabled returns true if the Calico CNI plugin is disabled in the test environment.
func IsCalicoCNIDisabled() bool {
ret := strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CALICO")) == "true"
if ret {
fmt.Println("INFO: CalicoCNI plugin is disabled")
} else {
fmt.Println("INFO: CalicoCNI plugin is enabled")
}
return ret
}
// IsCertManagerDisabled returns true if the Cert-Manager is disabled in the test environment.
func IsCertManagerDisabled() bool {
ret := strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CERTMANAGER")) == "true"
if ret {
fmt.Println("INFO: CertManager plugin is disabled")
} else {
fmt.Println("INFO: CertManager plugin is enabled")
}
return ret
}
// IsMetalLBDisabled returns true if the MetalLB is disabled in the test environment.
func IsMetalLBDisabled() bool {
ret := strings.ToLower(os.Getenv("KONG_TEST_DISABLE_METALLB")) == "true"
if ret {
fmt.Println("INFO: MetalLB plugin is disabled")
} else {
fmt.Println("INFO: MetalLB plugin is enabled")
}
return ret
}
// IsInstallingCRDsDisabled returns true if installing CRDs is disabled in the test environment.
func IsInstallingCRDsDisabled() bool {
ret := strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CRD_INSTALL")) == "true"
if ret {
fmt.Println("INFO: Installing CRDs is disabled")
} else {
fmt.Println("INFO: Installing CRDs is enabled")
}
return ret
}
// KonnectAccessToken returns the Konnect access token for the test environment.
func KonnectAccessToken() string {
return os.Getenv("KONG_TEST_KONNECT_ACCESS_TOKEN")
}
// KonnectServerURL returns the Konnect server URL for the test environment.
func KonnectServerURL() string {
return os.Getenv("KONG_TEST_KONNECT_SERVER_URL")
}
// IsWebhookEnabled returns true if the webhook is enabled in the test environment.
func IsWebhookEnabled() bool {
return strings.ToLower(os.Getenv("WEBHOOK_ENABLED")) == "true"
}
// IsTelepresenceDisabled returns true if the telepresence is disabled in the test environment.
func IsTelepresenceDisabled() bool {
ret := strings.ToLower(os.Getenv("KONG_TEST_TELEPRESENCE_DISABLED")) == "true"
if ret {
fmt.Println("INFO: Telepresence is disabled")
} else {
fmt.Println("INFO: Telepresence is enabled")
}
return ret
}
// KeepTestCluster indicates whether the caller wants the cluster created by the test suite
// to persist after the test for inspection. This has no effect when an existing cluster
// is provided, as cleanup is not performed for existing clusters.
func KeepTestCluster() bool {
envVar := strings.ToLower(os.Getenv("KONG_TEST_CLUSTER_PERSIST"))
keepTestCluster := envVar == "true" || envVar == "1"
fmt.Printf("INFO: keeping test cluster after tests: %t\n", keepTestCluster)
return keepTestCluster
}
// IsCI indicates whether or not the tests are running in a CI environment.
func IsCI() bool {
// It's a common convention that e.g. GitHub, GitLab, and other CI providers
// set the CI environment variable.
envVar := strings.ToLower(os.Getenv("CI"))
isCI := envVar == "true" || envVar == "1"
fmt.Printf("INFO: running in CI: %t\n", isCI)
return isCI
}
// SkipCleanup indicates whether or not the test environment should skip cleanup,
// either because it's running in a CI environment or because the user has
// explicitly requested to keep the test cluster.
func SkipCleanup() bool {
return IsCI() || !KeepTestCluster()
}