Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ bundle: check-operator-version operator-sdk manifests update-skip-range kustomiz
$(SDK_BIN) generate kustomize manifests --apis-dir=./pkg/apis -q
@echo "kustomize using deployment image $(IMG)"
cd config/manager && $(KUSTOMIZE) edit set image $(APP_NAME)=$(IMG)
if [ $(PLATFORM) = "openshift" ]; then \
sed -i 's%../default-bundle%../openshift-bundle%' config/manifests/kustomization.yaml; \
fi
$(KUSTOMIZE) build config/manifests | $(SDK_BIN) generate bundle -q $(BUNDLE_SA_OPTS) --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
git restore config/manifests/kustomization.yaml
$(SDK_BIN) bundle validate ./bundle

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

.PHONY: e2e-rosa
e2e-rosa: e2e-set-image prep-e2e
@$(GO) test ./tests/e2e $(E2E_GO_TEST_FLAGS) -args $(E2E_ARGS) --platform rosa

.PHONY: prep-e2e
prep-e2e: kustomize
rm -rf $(TEST_SETUP_DIR)
Expand Down
5 changes: 0 additions & 5 deletions config/manager/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ spec:
secret:
secretName: file-integrity-operator-serving-cert
optional: true
nodeSelector:
node-role.kubernetes.io/master: ""
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
Expand Down
13 changes: 13 additions & 0 deletions config/openshift-bundle/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace: openshift-compliance

bases:
- ../crd
- ../rbac
- ../manager
- ../ns

patches:
- path: manager_patch.yaml
target:
kind: Deployment
name: file-integrity-operator
13 changes: 13 additions & 0 deletions config/openshift-bundle/manager_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: file-integrity-operator
spec:
template:
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Exists"
effect: "NoSchedule"
13 changes: 8 additions & 5 deletions tests/e2e/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,19 @@ func deleteStatusEvents(f *framework.Framework, namespace string) error {
func setupTestRequirements(t *testing.T) *framework.Context {
fileIntegrities := &v1alpha1.FileIntegrityList{}
nodeStatus := &v1alpha1.FileIntegrityNodeStatusList{}
f := framework.NewContext(t)

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

mcList := &mcfgv1.MachineConfigList{}
err = framework.AddToFrameworkScheme(mcfgapi.Install, mcList)
if err != nil {
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
if f.GetPlatform() != "rosa" {
mcList := &mcfgv1.MachineConfigList{}
err = framework.AddToFrameworkScheme(mcfgapi.Install, mcList)
if err != nil {
t.Fatalf("TEST SETUP: failed to add custom resource scheme to framework: %v", err)
}
}

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

func replaceNamespaceFromManifest(t *testing.T, nsFrom, nsTo string, namespacedManPath *string) {
Expand Down
6 changes: 6 additions & 0 deletions tests/framework/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Context struct {
kubeclient kubernetes.Interface
restMapper *restmapper.DeferredDiscoveryRESTMapper
skipCleanupOnError bool
platform string
}

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

Expand Down Expand Up @@ -111,3 +113,7 @@ func (ctx *Context) Cleanup() {
func (ctx *Context) AddCleanupFn(fn cleanupFn) {
ctx.cleanupFns = append(ctx.cleanupFns, fn)
}

func (ctx *Context) GetPlatform() string {
return ctx.platform
}
5 changes: 5 additions & 0 deletions tests/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Framework struct {
NamespacedManPath *string
OperatorNamespace string
WatchNamespace string
Platform string

restMapper *restmapper.DeferredDiscoveryRESTMapper

Expand All @@ -88,6 +89,7 @@ type frameworkOpts struct {
localOperatorArgs string
isLocalOperator bool
skipCleanupOnError bool
platform string
}

const (
Expand All @@ -98,6 +100,7 @@ const (
LocalOperatorFlag = "localOperator"
LocalOperatorArgs = "localOperatorArgs"
SkipCleanupOnErrorFlag = "skipCleanupOnError"
PlatformFlag = "platform"

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

func newFramework(opts *frameworkOpts) (*Framework, error) {
Expand Down Expand Up @@ -168,6 +172,7 @@ func newFramework(opts *frameworkOpts) (*Framework, error) {
kubeconfigPath: opts.kubeconfigPath,
restMapper: restMapper,
skipCleanupOnError: opts.skipCleanupOnError,
Platform: opts.platform,
}

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