Skip to content

Commit 7d4eea3

Browse files
Fiona-Watersopenshift-ci[bot]
authored andcommitted
skip test if not OSD
1 parent c66f1d7 commit 7d4eea3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

test/e2e/instascale_machinepool_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func TestInstascaleMachinePool(t *testing.T) {
3333
test := With(t)
3434
test.T().Parallel()
3535

36+
if !IsOsd(test) {
37+
test.T().Skip("Skipping test as not running on an OSD cluster")
38+
}
39+
3640
namespace := test.NewTestNamespace()
3741

3842
// Test configuration

test/support/codeflare.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ package support
1818

1919
import (
2020
"os"
21+
"strconv"
22+
23+
"github.com/onsi/gomega"
2124
)
2225

2326
const (
@@ -38,6 +41,8 @@ const (
3841
InstaScaleOcmSecretNamespace = "INSTASCALE_OCM_SECRET_NAMESPACE"
3942
// Cluster ID for OSD cluster used in tests, used for testing InstaScale
4043
OsdClusterID = "CLUSTERID"
44+
// Determine if test is being run on an OSD cluster, used for testing InstaScale.
45+
IsOSD = "IS_OSD"
4146
)
4247

4348
func GetCodeFlareSDKVersion() string {
@@ -68,6 +73,18 @@ func GetOsdClusterId() (string, bool) {
6873
return os.LookupEnv(OsdClusterID)
6974
}
7075

76+
func IsOsd(test Test) bool {
77+
test.T().Helper()
78+
env := lookupEnvOrDefault(IsOSD, "false")
79+
osd, err := strconv.ParseBool(env)
80+
if err != nil {
81+
test.T().Logf("error parsing IS_OSD environment variable, using default 'false' value, error: %v ", err)
82+
return false
83+
}
84+
test.Expect(err).NotTo(gomega.HaveOccurred())
85+
return osd
86+
}
87+
7188
func lookupEnvOrDefault(key, value string) string {
7289
if v, ok := os.LookupEnv(key); ok {
7390
return v

0 commit comments

Comments
 (0)