Skip to content

Commit cecd003

Browse files
authored
fix install and upgrade e2es (#1983)
- make upgrade-e2e pass again - fix ClusterExtensionInstallReResolvesWhenCatalogIsPatched
1 parent 84cb9b5 commit cecd003

File tree

8 files changed

+208
-16
lines changed

8 files changed

+208
-16
lines changed

test/e2e/cluster_extension_install_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
377377
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
378378
}
379379
}, pollDuration, pollInterval)
380-
381-
t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
382-
cm := corev1.ConfigMap{}
383-
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
384-
require.Contains(t, cm.Annotations, "shouldNotTemplate")
385-
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
386380
})
387381
}
388382
}
@@ -718,7 +712,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
718712

719713
// patch imageRef tag on test-catalog image with v2 image
720714
t.Log("By patching the catalog ImageRef to point to the v2 catalog")
721-
updatedCatalogImage := fmt.Sprintf("%s/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
715+
updatedCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
722716
err := patchTestCatalog(context.Background(), testCatalogName, updatedCatalogImage)
723717
require.NoError(t, err)
724718
require.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -730,15 +724,23 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
730724
}
731725
}, pollDuration, pollInterval)
732726

733-
t.Log("By eventually reporting a successful resolution and bundle path")
727+
t.Log("By eventually installing the package successfully")
734728
require.EventuallyWithT(t, func(ct *assert.CollectT) {
735729
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
736-
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
730+
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled)
737731
if assert.NotNil(ct, cond) {
738732
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
739733
assert.Equal(ct, ocv1.ReasonSucceeded, cond.Reason)
734+
assert.Contains(ct, cond.Message, "Installed bundle")
735+
assert.Contains(ct, clusterExtension.Status.Install.Bundle.Version, "2.0.0")
740736
}
741737
}, pollDuration, pollInterval)
738+
739+
t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
740+
cm := corev1.ConfigMap{}
741+
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
742+
require.Contains(t, cm.Annotations, "shouldNotTemplate")
743+
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
742744
}
743745

744746
func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {

testdata/images/bundles/test-operator/v1.0.0/manifests/bundle.configmap.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: test-configmap
5-
annotations:
6-
shouldNotTemplate: >
7-
The namespace is {{ $labels.namespace }}. The templated
8-
$labels.namespace is NOT expected to be processed by OLM's
9-
rendering engine for registry+v1 bundles.
105
data:
116
version: "v1.0.0"
127
name: "test-configmap"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: test-configmap
5+
annotations:
6+
shouldNotTemplate: >
7+
The namespace is {{ $labels.namespace }}. The templated
8+
$labels.namespace is NOT expected to be processed by OLM's
9+
rendering engine for registry+v1 bundles.
10+
data:
11+
version: "v2.0.0"
12+
name: "test-configmap"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.1
7+
name: olme2etests.olm.operatorframework.io
8+
spec:
9+
group: olm.operatorframework.io
10+
names:
11+
kind: OLME2ETest
12+
listKind: OLME2ETestList
13+
plural: olme2etests
14+
singular: olme2etest
15+
scope: Cluster
16+
versions:
17+
- name: v1
18+
served: true
19+
storage: true
20+
schema:
21+
openAPIV3Schema:
22+
type: object
23+
properties:
24+
spec:
25+
type: object
26+
properties:
27+
testField:
28+
type: string
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: ClusterServiceVersion
3+
metadata:
4+
annotations:
5+
alm-examples: |-
6+
[
7+
{
8+
"apiVersion": "olme2etests.olm.operatorframework.io/v1",
9+
"kind": "OLME2ETests",
10+
"metadata": {
11+
"labels": {
12+
"app.kubernetes.io/managed-by": "kustomize",
13+
"app.kubernetes.io/name": "test"
14+
},
15+
"name": "test-sample"
16+
},
17+
"spec": null
18+
}
19+
]
20+
capabilities: Basic Install
21+
createdAt: "2024-10-24T19:21:40Z"
22+
operators.operatorframework.io/builder: operator-sdk-v1.34.1
23+
operators.operatorframework.io/project_layout: go.kubebuilder.io/v4
24+
name: testoperator.v2.0.0
25+
namespace: placeholder
26+
spec:
27+
apiservicedefinitions: {}
28+
customresourcedefinitions:
29+
owned:
30+
- description: Configures subsections of Alertmanager configuration specific to each namespace
31+
displayName: OLME2ETest
32+
kind: OLME2ETest
33+
name: olme2etests.olm.operatorframework.io
34+
version: v1
35+
description: OLM E2E Testing Operator
36+
displayName: test-operator
37+
icon:
38+
- base64data: ""
39+
mediatype: ""
40+
install:
41+
spec:
42+
deployments:
43+
- label:
44+
app.kubernetes.io/component: controller
45+
app.kubernetes.io/name: test-operator
46+
app.kubernetes.io/version: 2.0.0
47+
name: test-operator
48+
spec:
49+
replicas: 1
50+
selector:
51+
matchLabels:
52+
app: olme2etest
53+
template:
54+
metadata:
55+
labels:
56+
app: olme2etest
57+
spec:
58+
terminationGracePeriodSeconds: 0
59+
containers:
60+
- name: busybox
61+
image: busybox
62+
command:
63+
- 'sleep'
64+
- '1000'
65+
securityContext:
66+
runAsUser: 1000
67+
runAsNonRoot: true
68+
serviceAccountName: simple-bundle-manager
69+
clusterPermissions:
70+
- rules:
71+
- apiGroups:
72+
- authentication.k8s.io
73+
resources:
74+
- tokenreviews
75+
verbs:
76+
- create
77+
- apiGroups:
78+
- authorization.k8s.io
79+
resources:
80+
- subjectaccessreviews
81+
verbs:
82+
- create
83+
serviceAccountName: simple-bundle-manager
84+
permissions:
85+
- rules:
86+
- apiGroups:
87+
- ""
88+
resources:
89+
- configmaps
90+
- serviceaccounts
91+
verbs:
92+
- get
93+
- list
94+
- watch
95+
- create
96+
- update
97+
- patch
98+
- delete
99+
- apiGroups:
100+
- coordination.k8s.io
101+
resources:
102+
- leases
103+
verbs:
104+
- get
105+
- list
106+
- watch
107+
- create
108+
- update
109+
- patch
110+
- delete
111+
- apiGroups:
112+
- ""
113+
resources:
114+
- events
115+
verbs:
116+
- create
117+
- patch
118+
serviceAccountName: simple-bundle-manager
119+
strategy: deployment
120+
installModes:
121+
- supported: false
122+
type: OwnNamespace
123+
- supported: false
124+
type: SingleNamespace
125+
- supported: false
126+
type: MultiNamespace
127+
- supported: true
128+
type: AllNamespaces
129+
keywords:
130+
- registry
131+
links:
132+
- name: simple-bundle
133+
url: https://simple-bundle.domain
134+
maintainers:
135+
- email: main#simple-bundle.domain
136+
name: Simple Bundle
137+
maturity: beta
138+
provider:
139+
name: Simple Bundle
140+
url: https://simple-bundle.domain
141+
version: 2.0.0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
annotations:
2+
# Core bundle annotations.
3+
operators.operatorframework.io.bundle.mediatype.v1: registry+v1
4+
operators.operatorframework.io.bundle.manifests.v1: manifests/
5+
operators.operatorframework.io.bundle.metadata.v1: metadata/
6+
operators.operatorframework.io.bundle.package.v1: test
7+
operators.operatorframework.io.bundle.channels.v1: beta
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.28.0
9+
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
10+
operators.operatorframework.io.metrics.project_layout: unknown

testdata/images/catalogs/test-catalog/v2/configs/catalog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ entries:
1313
schema: olm.bundle
1414
name: test-operator.2.0.0
1515
package: test
16-
image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/test-operator:v1.0.0
16+
image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/test-operator:v2.0.0
1717
properties:
1818
- type: olm.package
1919
value:

testdata/push/push.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ func main() {
4545
}
4646
// Push the images
4747
for name, image := range bundles {
48-
if err := crane.Push(image, fmt.Sprintf("%s/%s", registryAddr, name)); err != nil {
48+
dest := fmt.Sprintf("%s/%s", registryAddr, name)
49+
log.Printf("pushing bundle %s to %s", name, dest)
50+
if err := crane.Push(image, dest); err != nil {
4951
log.Fatalf("failed to push bundle images: %s", err.Error())
5052
}
5153
}
5254
for name, image := range catalogs {
55+
dest := fmt.Sprintf("%s/%s", registryAddr, name)
56+
log.Printf("pushing catalog %s to %s", name, dest)
5357
if err := crane.Push(image, fmt.Sprintf("%s/%s", registryAddr, name)); err != nil {
5458
log.Fatalf("failed to push catalog images: %s", err.Error())
5559
}

0 commit comments

Comments
 (0)