Skip to content

Commit bae42cd

Browse files
Merge pull request #444 from perdasilva/update_plugin_e2e
OCPBUGS-7102: make plugin e2e tests skippable
2 parents 8aa0b41 + 4a28010 commit bae42cd

File tree

15 files changed

+65
-32
lines changed

15 files changed

+65
-32
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ e2e/operator-registry: ## Run e2e registry tests
124124
e2e/olm: ## Run e2e olm tests
125125
$(MAKE) e2e WHAT=operator-lifecycle-manager E2E_CATALOG_NS=openshift-marketplace E2E_INSTALL_NS=openshift-operator-lifecycle-manager E2E_TEST_NS=openshift-operators E2E_TIMEOUT=120m KUBECTL=oc
126126

127+
.PHONY: update-plugin-deps
128+
update-plugin-deps:
129+
./scripts/update_plugin_deps.sh
130+
127131
.PHONY: vendor
128-
vendor:
132+
vendor: update-plugin-deps
129133
go mod tidy
130134
go mod vendor
131135
go mod verify

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ require (
177177
github.com/opencontainers/go-digest v1.0.0 // indirect
178178
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
179179
github.com/openshift/client-go v0.0.0-20220525160904-9e1acff93e4a // indirect
180-
github.com/openshift/cluster-policy-controller v0.0.0-20220825134653-523e4104074f // indirect
180+
github.com/openshift/cluster-policy-controller v0.0.0-20230112143856-3f8efde27bb6 // indirect
181181
github.com/otiai10/copy v1.2.0 // indirect
182182
github.com/pbnjay/strptime v0.0.0-20140226051138-5c05b0d668c9 // indirect
183183
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,8 @@ github.com/openshift/api v0.0.0-20210517065120-b325f58df679/go.mod h1:dZ4kytOo3s
983983
github.com/openshift/build-machinery-go v0.0.0-20210209125900-0da259a2c359/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
984984
github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0 h1:kMiuiZXH1GdfbiMwsuAQOqGaMxlo9NCUk0wT4XAdfNM=
985985
github.com/openshift/client-go v0.0.0-20200326155132-2a6cd50aedd0/go.mod h1:uUQ4LClRO+fg5MF/P6QxjMCb1C9f7Oh4RKepftDnEJE=
986-
github.com/openshift/cluster-policy-controller v0.0.0-20220825134653-523e4104074f h1:ll0eE7rgGHsFlrI6ksr6nXL2ur8GYBe8Jj0GwNQ/1+o=
987-
github.com/openshift/cluster-policy-controller v0.0.0-20220825134653-523e4104074f/go.mod h1:r9ZZT5wjwoS2heBfYR26uJhhkGYwgmFqomu9ww0y9Qw=
986+
github.com/openshift/cluster-policy-controller v0.0.0-20230112143856-3f8efde27bb6 h1:JJ8cHS+mXYwaYjpDnmnEWNj/KPvlVhed1dFLsz3zJ3g=
987+
github.com/openshift/cluster-policy-controller v0.0.0-20230112143856-3f8efde27bb6/go.mod h1:mxj0Tg1YG9PpVJDOBLsAkjZNVvQTNu1LJkw9fSAkOE4=
988988
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
989989
github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k=
990990
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=

scripts/update_plugin_deps.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# This script is used to keep certain dependencies regularly updated
4+
# against the same OCP branch of the current build.
5+
6+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
7+
8+
echo "updating olm plugin dependencies"
9+
if [[ "$BRANCH" =~ ^master$|^release-\d+\.\d+$ ]]; then
10+
echo "attempting to update cluster-policy-controller"
11+
# needed for staging/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/downstream_csv_namespace_labeler_plugin.go
12+
go get "github.com/openshift/cluster-policy-controller@${BRANCH}"
13+
else
14+
echo "skipping dependency update as branch '$BRANCH' is not recognized"
15+
fi
16+
echo "finished updating olm plugin dependencies"

staging/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_csv_labeler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55
"fmt"
66

77
"github.com/operator-framework/api/pkg/operators/v1alpha1"
8+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
89
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
910
"github.com/sirupsen/logrus"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
)
1213

14+
const CsvLabelerPluginId plugins.PluginID = "csv-labeler-plugin"
1315
const labelSyncerLabelKey = ""
1416

1517
func NewCSVLabelSyncerLabeler(client operatorclient.ClientInterface, logger *logrus.Logger) *CSVLabelSyncerLabeler {

staging/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_plugins.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import (
55
)
66

77
func init() {
8-
operatorPlugInFactoryFuncs = []plugins.OperatorPlugInFactoryFunc{
8+
operatorPlugInFactoryFuncs = plugins.OperatorPlugInFactoryMap{
99
// labels unlabeled non-payload openshift-* csv namespaces with
1010
// security.openshift.io/scc.podSecurityLabelSync: true
11-
plugins.NewCsvNamespaceLabelerPluginFunc,
11+
CsvLabelerPluginId: plugins.NewCsvNamespaceLabelerPluginFunc,
1212
}
1313
}
14+
15+
func IsPluginEnabled(pluginID plugins.PluginID) bool {
16+
_, ok := operatorPlugInFactoryFuncs[pluginID]
17+
return ok
18+
}

staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var (
6464

6565
// this unexported operator plugin slice provides an entrypoint for
6666
// downstream to inject its own plugins to augment the controller behavior
67-
var operatorPlugInFactoryFuncs []plugins.OperatorPlugInFactoryFunc
67+
var operatorPlugInFactoryFuncs plugins.OperatorPlugInFactoryMap
6868

6969
type Operator struct {
7070
queueinformer.Operator

staging/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/downstream_csv_namespace_labeler_plugin_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package plugins
33
import (
44
"context"
55
"errors"
6-
"os/exec"
7-
"strings"
86
"testing"
97
"time"
108

@@ -298,21 +296,3 @@ func Test_SyncDoesNotLabelNamespacesWithCopiedCSVs(t *testing.T) {
298296
assert.NoError(t, err)
299297
assert.NotContains(t, ns.GetLabels(), NamespaceLabelSyncerLabelKey)
300298
}
301-
302-
func Test_OCPVersion(t *testing.T) {
303-
// This test is a maintenance alert that means the next OCP version is now in active development.
304-
// This plugin relies on a list of payload namespaces that comes from the cluster-policy-controller project
305-
// https://github.com/openshift/cluster-policy-controller/tree/master/pkg/psalabelsyncer
306-
// This list is dependent on the OCP version. Please update the dependency version to correspond to the one
307-
// vendored for the new OCP version (or contact the responsible team if it hasn't been updated yet).
308-
// Then, bump the OCP version in the `nextOCPUncutBranchName` constant below
309-
const nextOCPUncutBranchName = "release-4.14"
310-
const errorMessage = "[maintenance alert] new ocp version branch has been cut: please check comments in test for instructions"
311-
312-
// Get branches
313-
branches, err := exec.Command("git", "branch", "-a").Output()
314-
assert.NoError(t, err)
315-
316-
// check if the next uncut branch has been cut and fail if so
317-
assert.False(t, strings.Contains(string(branches), nextOCPUncutBranchName), errorMessage)
318-
}

staging/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/operator_plugin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
type PluginID string
14+
type OperatorPlugInFactoryMap map[PluginID]OperatorPlugInFactoryFunc
15+
1316
// HostOperator is an extensible and observable operator that hosts the plug-in, i.e. which the plug-in is extending
1417
type HostOperator interface {
1518
queueinformer.ObservableOperator

staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99
"github.com/operator-framework/api/pkg/operators/v1alpha1"
10+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm"
1011
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
1112
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
1213
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/util"
@@ -31,6 +32,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
3132
})
3233

3334
It("should not label non openshift- namespaces", func() {
35+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
36+
Skip("csv labeler plugin is disabled")
37+
}
38+
3439
// create namespace with operator group
3540
testNamespace = SetupGeneratedTestNamespace(genName("csv-ns-labeler-"))
3641

@@ -46,6 +51,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
4651
})
4752

4853
It("should label a non-payload openshift- namespace", func() {
54+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
55+
Skip("csv labeler plugin is disabled")
56+
}
57+
4958
// create namespace with operator group
5059
testNamespace = SetupGeneratedTestNamespace(genName("openshift-csv-ns-labeler-"))
5160

@@ -61,6 +70,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
6170
})
6271

6372
It("should relabel a non-payload openshift- namespace containing csvs if the label is deleted", func() {
73+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
74+
Skip("csv labeler plugin is disabled")
75+
}
76+
6477
// create namespace with operator group
6578
testNamespace = SetupGeneratedTestNamespace(genName("openshift-csv-ns-labeler-"))
6679

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_csv_labeler.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_plugins.go

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/operator_plugin.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ github.com/openshift/client-go/config/informers/externalversions/config
632632
github.com/openshift/client-go/config/informers/externalversions/config/v1
633633
github.com/openshift/client-go/config/informers/externalversions/internalinterfaces
634634
github.com/openshift/client-go/config/listers/config/v1
635-
# github.com/openshift/cluster-policy-controller v0.0.0-20220825134653-523e4104074f
636-
## explicit; go 1.18
635+
# github.com/openshift/cluster-policy-controller v0.0.0-20230112143856-3f8efde27bb6
636+
## explicit; go 1.19
637637
github.com/openshift/cluster-policy-controller/pkg/psalabelsyncer/nsexemptions
638638
# github.com/operator-framework/api v0.17.3 => ./staging/api
639639
## explicit; go 1.18

0 commit comments

Comments
 (0)