Skip to content

Commit e87fa0f

Browse files
Merge pull request #539 from rhmdnd/implement-rosa-hcp-e2e-testing
implement rosa hcp e2e testing
2 parents e5fe4bc + 6896b8f commit e87fa0f

7 files changed

Lines changed: 53 additions & 10 deletions

File tree

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ bundle: check-operator-version operator-sdk manifests update-skip-range kustomiz
320320
$(SDK_BIN) generate kustomize manifests --apis-dir=./pkg/apis -q
321321
@echo "kustomize using deployment image $(IMG)"
322322
cd config/manager && $(KUSTOMIZE) edit set image $(APP_NAME)=$(IMG)
323+
if [ $(PLATFORM) = "openshift" ]; then \
324+
sed -i 's%../default-bundle%../openshift-bundle%' config/manifests/kustomization.yaml; \
325+
fi
323326
$(KUSTOMIZE) build config/manifests | $(SDK_BIN) generate bundle -q $(BUNDLE_SA_OPTS) --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
327+
git restore config/manifests/kustomization.yaml
324328
$(SDK_BIN) bundle validate ./bundle
325329

326330
.PHONY: bundle-image
@@ -445,6 +449,10 @@ test-unit: fmt vet ## Run tests.
445449
e2e: e2e-set-image prep-e2e
446450
@$(GO) test ./tests/e2e $(E2E_GO_TEST_FLAGS) -args $(E2E_ARGS)
447451

452+
.PHONY: e2e-rosa
453+
e2e-rosa: e2e-set-image prep-e2e
454+
@$(GO) test ./tests/e2e $(E2E_GO_TEST_FLAGS) -args $(E2E_ARGS) --platform rosa
455+
448456
.PHONY: prep-e2e
449457
prep-e2e: kustomize
450458
rm -rf $(TEST_SETUP_DIR)

config/manager/deployment.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ spec:
5353
secret:
5454
secretName: file-integrity-operator-serving-cert
5555
optional: true
56-
nodeSelector:
57-
node-role.kubernetes.io/master: ""
5856
tolerations:
59-
- key: "node-role.kubernetes.io/master"
60-
operator: "Exists"
61-
effect: "NoSchedule"
6257
- key: "node.kubernetes.io/unreachable"
6358
operator: "Exists"
6459
effect: "NoExecute"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace: openshift-compliance
2+
3+
bases:
4+
- ../crd
5+
- ../rbac
6+
- ../manager
7+
- ../ns
8+
9+
patches:
10+
- path: manager_patch.yaml
11+
target:
12+
kind: Deployment
13+
name: file-integrity-operator
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: file-integrity-operator
5+
spec:
6+
template:
7+
spec:
8+
nodeSelector:
9+
node-role.kubernetes.io/master: ""
10+
tolerations:
11+
- key: "node-role.kubernetes.io/master"
12+
operator: "Exists"
13+
effect: "NoSchedule"

tests/e2e/helpers.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,19 @@ func deleteStatusEvents(f *framework.Framework, namespace string) error {
416416
func setupTestRequirements(t *testing.T) *framework.Context {
417417
fileIntegrities := &v1alpha1.FileIntegrityList{}
418418
nodeStatus := &v1alpha1.FileIntegrityNodeStatusList{}
419+
f := framework.NewContext(t)
419420

420421
err := framework.AddToFrameworkScheme(v1alpha1.AddToScheme, fileIntegrities)
421422
if err != nil {
422423
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
423424
}
424425

425-
mcList := &mcfgv1.MachineConfigList{}
426-
err = framework.AddToFrameworkScheme(mcfgapi.Install, mcList)
427-
if err != nil {
428-
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
426+
if f.GetPlatform() != "rosa" {
427+
mcList := &mcfgv1.MachineConfigList{}
428+
err = framework.AddToFrameworkScheme(mcfgapi.Install, mcList)
429+
if err != nil {
430+
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
431+
}
429432
}
430433

431434
err = framework.AddToFrameworkScheme(v1alpha1.AddToScheme, nodeStatus)
@@ -439,7 +442,7 @@ func setupTestRequirements(t *testing.T) *framework.Context {
439442
if err != nil {
440443
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
441444
}
442-
return framework.NewContext(t)
445+
return f
443446
}
444447

445448
func replaceNamespaceFromManifest(t *testing.T, nsFrom, nsTo string, namespacedManPath *string) {

tests/framework/context.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Context struct {
2727
kubeclient kubernetes.Interface
2828
restMapper *restmapper.DeferredDiscoveryRESTMapper
2929
skipCleanupOnError bool
30+
platform string
3031
}
3132

3233
// todo(camilamacedo86): Remove the following line just added for we are able to deprecated TestCtx
@@ -71,6 +72,7 @@ func (f *Framework) newContext(t *testing.T) *Context {
7172
kubeclient: f.KubeClient,
7273
restMapper: f.restMapper,
7374
skipCleanupOnError: f.skipCleanupOnError,
75+
platform: f.Platform,
7476
}
7577
}
7678

@@ -111,3 +113,7 @@ func (ctx *Context) Cleanup() {
111113
func (ctx *Context) AddCleanupFn(fn cleanupFn) {
112114
ctx.cleanupFns = append(ctx.cleanupFns, fn)
113115
}
116+
117+
func (ctx *Context) GetPlatform() string {
118+
return ctx.platform
119+
}

tests/framework/framework.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type Framework struct {
6868
NamespacedManPath *string
6969
OperatorNamespace string
7070
WatchNamespace string
71+
Platform string
7172

7273
restMapper *restmapper.DeferredDiscoveryRESTMapper
7374

@@ -88,6 +89,7 @@ type frameworkOpts struct {
8889
localOperatorArgs string
8990
isLocalOperator bool
9091
skipCleanupOnError bool
92+
platform string
9193
}
9294

9395
const (
@@ -98,6 +100,7 @@ const (
98100
LocalOperatorFlag = "localOperator"
99101
LocalOperatorArgs = "localOperatorArgs"
100102
SkipCleanupOnErrorFlag = "skipCleanupOnError"
103+
PlatformFlag = "platform"
101104

102105
TestOperatorNamespaceEnv = "TEST_OPERATOR_NAMESPACE"
103106
TestWatchNamespaceEnv = "TEST_WATCH_NAMESPACE"
@@ -115,6 +118,7 @@ func (opts *frameworkOpts) addToFlagSet(flagset *flag.FlagSet) {
115118
flagset.BoolVar(&opts.skipCleanupOnError, SkipCleanupOnErrorFlag, false,
116119
"If set as true, the cleanup function responsible to remove all artifacts "+
117120
"will be skipped if an error is faced.")
121+
flagset.StringVar(&opts.platform, PlatformFlag, "openshift", "The type of deployment hosting the tests. The only supported option besides OpenShift is \"rosa\".")
118122
}
119123

120124
func newFramework(opts *frameworkOpts) (*Framework, error) {
@@ -168,6 +172,7 @@ func newFramework(opts *frameworkOpts) (*Framework, error) {
168172
kubeconfigPath: opts.kubeconfigPath,
169173
restMapper: restMapper,
170174
skipCleanupOnError: opts.skipCleanupOnError,
175+
Platform: opts.platform,
171176
}
172177

173178
// This is required because controller-runtime expects its consumers to

0 commit comments

Comments
 (0)