Skip to content

Commit 293cd7f

Browse files
authored
Change from using prometheus operator to a custom test operator. (#1457)
Signed-off-by: dtfranz <[email protected]>
1 parent 6d79092 commit 293cd7f

25 files changed

+250
-38967
lines changed

hack/test/pre-upgrade-setup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ rules:
4949
- apiGroups:
5050
- ""
5151
resources:
52+
- "configmaps"
5253
- "secrets"
5354
- "services"
5455
- "serviceaccounts"
@@ -138,7 +139,7 @@ spec:
138139
source:
139140
sourceType: Catalog
140141
catalog:
141-
packageName: prometheus
142+
packageName: test
142143
version: 1.0.0
143144
EOF
144145

test/e2e/cluster_extension_install_test.go

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func createClusterRoleAndBindingForSA(ctx context.Context, name string, sa *core
9191
"",
9292
},
9393
Resources: []string{
94+
"configmaps",
9495
"secrets", // for helm
9596
"services",
9697
"serviceaccounts",
@@ -289,15 +290,15 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
289290
for _, tc := range []testCase{
290291
{
291292
name: "no registry configuration necessary",
292-
packageName: "prometheus",
293+
packageName: "test",
293294
},
294295
{
295296
// NOTE: This test requires an extra configuration in /etc/containers/registries.conf, which is mounted
296297
// for this e2e via the ./config/components/registries-conf kustomize component as part of the e2e overlay.
297298
// The goal here is to prove that "mirrored-registry.operator-controller-e2e.svc.cluster.local:5000" is
298299
// mapped to the "real" registry hostname ("docker-registry.operator-controller-e2e.svc.cluster.local:5000").
299300
name: "package requires mirror registry configuration in /etc/containers/registries.conf",
300-
packageName: "prometheus-mirrored",
301+
packageName: "test-mirrored",
301302
},
302303
} {
303304
t.Run(tc.name, func(t *testing.T) {
@@ -361,14 +362,24 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) {
361362
t.Log("When a cluster extension is installed from a catalog")
362363

363364
clusterExtension, extensionCatalog, sa, ns := testInit(t)
365+
extraCatalog, err := createTestCatalog(context.Background(), "extra-test-catalog", os.Getenv(testCatalogRefEnvVar))
366+
require.NoError(t, err)
367+
364368
defer testCleanup(t, extensionCatalog, clusterExtension, sa, ns)
365369
defer getArtifactsOutput(t)
370+
defer func(cat *catalogd.ClusterCatalog) {
371+
require.NoError(t, c.Delete(context.Background(), cat))
372+
require.Eventually(t, func() bool {
373+
err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.ClusterCatalog{})
374+
return errors.IsNotFound(err)
375+
}, pollDuration, pollInterval)
376+
}(extraCatalog)
366377

367378
clusterExtension.Spec = ocv1.ClusterExtensionSpec{
368379
Source: ocv1.SourceConfig{
369380
SourceType: "Catalog",
370381
Catalog: &ocv1.CatalogSource{
371-
PackageName: "prometheus",
382+
PackageName: "test",
372383
},
373384
},
374385
Namespace: ns.Name,
@@ -392,7 +403,7 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) {
392403
if assert.NotNil(ct, cond) {
393404
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
394405
assert.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
395-
assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [operatorhubio test-catalog]")
406+
assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [extra-test-catalog test-catalog]")
396407
}
397408
}, pollDuration, pollInterval)
398409
}
@@ -410,7 +421,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
410421
Source: ocv1.SourceConfig{
411422
SourceType: "Catalog",
412423
Catalog: &ocv1.CatalogSource{
413-
PackageName: "prometheus",
424+
PackageName: "test",
414425
Version: "1.0.0",
415426
// No Selector since this is an exact version match
416427
},
@@ -426,7 +437,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
426437
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
427438
assert.Equal(ct,
428439
&ocv1.ClusterExtensionInstallStatus{Bundle: ocv1.BundleMetadata{
429-
Name: "prometheus-operator.1.0.0",
440+
Name: "test-operator.1.0.0",
430441
Version: "1.0.0",
431442
}},
432443
clusterExtension.Status.Install,
@@ -455,7 +466,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
455466
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
456467
if assert.NotNil(ct, cond) {
457468
assert.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
458-
assert.Equal(ct, "error upgrading from currently installed version \"1.0.0\": no bundles found for package \"prometheus\" matching version \"1.2.0\"", cond.Message)
469+
assert.Equal(ct, "error upgrading from currently installed version \"1.0.0\": no bundles found for package \"test\" matching version \"1.2.0\"", cond.Message)
459470
}
460471
}, pollDuration, pollInterval)
461472
}
@@ -473,7 +484,7 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) {
473484
Source: ocv1.SourceConfig{
474485
SourceType: "Catalog",
475486
Catalog: &ocv1.CatalogSource{
476-
PackageName: "prometheus",
487+
PackageName: "test",
477488
Version: "1.0.0",
478489
},
479490
},
@@ -522,7 +533,7 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) {
522533
Source: ocv1.SourceConfig{
523534
SourceType: "Catalog",
524535
Catalog: &ocv1.CatalogSource{
525-
PackageName: "prometheus",
536+
PackageName: "test",
526537
Version: "1.0.0",
527538
},
528539
},
@@ -569,7 +580,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
569580
Source: ocv1.SourceConfig{
570581
SourceType: "Catalog",
571582
Catalog: &ocv1.CatalogSource{
572-
PackageName: "prometheus",
583+
PackageName: "test",
573584
Selector: &metav1.LabelSelector{
574585
MatchExpressions: []metav1.LabelSelectorRequirement{
575586
{
@@ -656,7 +667,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {
656667
Source: ocv1.SourceConfig{
657668
SourceType: "Catalog",
658669
Catalog: &ocv1.CatalogSource{
659-
PackageName: "prometheus",
670+
PackageName: "test",
660671
Selector: &metav1.LabelSelector{
661672
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
662673
},
@@ -717,7 +728,7 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T
717728
Source: ocv1.SourceConfig{
718729
SourceType: "Catalog",
719730
Catalog: &ocv1.CatalogSource{
720-
PackageName: "prometheus",
731+
PackageName: "test",
721732
Selector: &metav1.LabelSelector{
722733
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
723734
},
@@ -744,17 +755,17 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T
744755
}, pollDuration, pollInterval)
745756

746757
t.Log("By deleting a managed resource")
747-
prometheusService := &corev1.Service{
758+
testConfigMap := &corev1.ConfigMap{
748759
ObjectMeta: metav1.ObjectMeta{
749-
Name: "prometheus-operator",
760+
Name: "test-configmap",
750761
Namespace: clusterExtension.Spec.Namespace,
751762
},
752763
}
753-
require.NoError(t, c.Delete(context.Background(), prometheusService))
764+
require.NoError(t, c.Delete(context.Background(), testConfigMap))
754765

755766
t.Log("By eventually re-creating the managed resource")
756767
require.EventuallyWithT(t, func(ct *assert.CollectT) {
757-
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: prometheusService.Name, Namespace: prometheusService.Namespace}, prometheusService))
768+
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: testConfigMap.Name, Namespace: testConfigMap.Namespace}, testConfigMap))
758769
}, pollDuration, pollInterval)
759770
}
760771

@@ -780,7 +791,7 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes
780791
Source: ocv1.SourceConfig{
781792
SourceType: "Catalog",
782793
Catalog: &ocv1.CatalogSource{
783-
PackageName: "prometheus",
794+
PackageName: "test",
784795
Selector: &metav1.LabelSelector{
785796
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
786797
},

test/extension-developer-e2e/extension_developer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func TestExtensionDeveloper(t *testing.T) {
104104
"",
105105
},
106106
Resources: []string{
107+
"configmaps",
107108
"services",
108109
"serviceaccounts",
109110
},

test/upgrade-e2e/post_upgrade_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) {
107107
}
108108
assert.Equal(ct, ocv1.ReasonSucceeded, cond.Reason)
109109
assert.Contains(ct, cond.Message, "Installed bundle")
110-
assert.Equal(ct, ocv1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle)
110+
assert.Equal(ct, ocv1.BundleMetadata{Name: "test-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle)
111111
assert.NotEqual(ct, previousVersion, clusterExtension.Status.Install.Bundle.Version)
112112
}, time.Minute, time.Second)
113113
}

testdata/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from gcr.io/distroless/static:nonroot
1+
FROM gcr.io/distroless/static:nonroot
22

33
WORKDIR /
44

0 commit comments

Comments
 (0)