Skip to content

Commit 4ea575e

Browse files
committed
[e2e] Enable tests to run against minikube
- Add a new Makefile target for minikube - Update e2e-tests.sh to accept an argument that will decide which namespace the marketplace operator is running in - Only run the ClusterOperator test if the API can be added to the scheme
1 parent fb5540a commit 4ea575e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ e2e-test:
5454

5555
e2e-job:
5656
./scripts/run-e2e-job.sh
57+
58+
e2e-test-minikube:
59+
./scripts/e2e-tests.sh minikube

scripts/e2e-tests.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
2-
set -e
2+
set -eu
33

4-
TEST_NAMESPACE="openshift-marketplace"
4+
ARG1=${1-}
5+
if [ "$ARG1" = "minikube" ]; then
6+
TEST_NAMESPACE="marketplace"
7+
else
8+
TEST_NAMESPACE="openshift-marketplace"
9+
fi
510

611
# Run the tests through the operator-sdk
712
echo "Running operator-sdk test"

test/e2e/main_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1616
)
1717

18+
var coAPINotPresent = true
19+
1820
func TestMain(m *testing.M) {
1921
test.MainEntry(m)
2022
}
@@ -24,7 +26,9 @@ func TestMarketplace(t *testing.T) {
2426
initTestingFramework(t)
2527

2628
// Run Test Groups
27-
t.Run("cluster-operator-status-test-group", testgroups.ClusterOperatorTestGroup)
29+
if coAPINotPresent {
30+
t.Run("cluster-operator-status-test-group", testgroups.ClusterOperatorTestGroup)
31+
}
2832
t.Run("operator-source-test-group", testgroups.OperatorSourceTestGroup)
2933
t.Run("no-setup-test-group", testgroups.NoSetupTestGroup)
3034
}
@@ -74,8 +78,13 @@ func initTestingFramework(t *testing.T) {
7478
configv1.SchemeGroupVersion.Group, configv1.SchemeGroupVersion.Version),
7579
},
7680
}
81+
82+
// We are assuming that ClusterOperator API will always be added successfully
83+
// on an OpenShift cluster. This is to allow the tests be run on non-OpenSHift
84+
// clusters
7785
err = test.AddToFrameworkScheme(configv1.Install, clusterOperator)
7886
if err != nil {
79-
t.Fatalf("failed to add ClusterOperator custom resource scheme to framework: %v", err)
87+
t.Logf("failed to add ClusterOperator custom resource scheme to framework: %v. ClusterOperator test will not run.", err)
88+
coAPINotPresent = false
8089
}
8190
}

0 commit comments

Comments
 (0)