Skip to content

🌱 Change from using prometheus operator to a custom test operator for e2e #1457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024
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
5 changes: 3 additions & 2 deletions hack/test/pre-upgrade-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ rules:
- apiGroups:
- ""
resources:
- "configmaps"
- "secrets"
- "services"
- "serviceaccounts"
Expand Down Expand Up @@ -127,7 +128,7 @@ roleRef:
EOF

kubectl apply -f - << EOF
apiVersion: olm.operatorframework.io/v1alpha1
apiVersion: olm.operatorframework.io/v1
kind: ClusterExtension
metadata:
name: ${TEST_CLUSTER_EXTENSION_NAME}
Expand All @@ -138,7 +139,7 @@ spec:
source:
sourceType: Catalog
catalog:
packageName: prometheus
packageName: test
version: 1.0.0
EOF

Expand Down
45 changes: 28 additions & 17 deletions test/e2e/cluster_extension_install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func createClusterRoleAndBindingForSA(ctx context.Context, name string, sa *core
"",
},
Resources: []string{
"configmaps",
"secrets", // for helm
"services",
"serviceaccounts",
Expand Down Expand Up @@ -289,15 +290,15 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
for _, tc := range []testCase{
{
name: "no registry configuration necessary",
packageName: "prometheus",
packageName: "test",
},
{
// NOTE: This test requires an extra configuration in /etc/containers/registries.conf, which is mounted
// for this e2e via the ./config/components/registries-conf kustomize component as part of the e2e overlay.
// The goal here is to prove that "mirrored-registry.operator-controller-e2e.svc.cluster.local:5000" is
// mapped to the "real" registry hostname ("docker-registry.operator-controller-e2e.svc.cluster.local:5000").
name: "package requires mirror registry configuration in /etc/containers/registries.conf",
packageName: "prometheus-mirrored",
packageName: "test-mirrored",
},
} {
t.Run(tc.name, func(t *testing.T) {
Expand Down Expand Up @@ -361,14 +362,24 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) {
t.Log("When a cluster extension is installed from a catalog")

clusterExtension, extensionCatalog, sa, ns := testInit(t)
extraCatalog, err := createTestCatalog(context.Background(), "extra-test-catalog", os.Getenv(testCatalogRefEnvVar))
require.NoError(t, err)

defer testCleanup(t, extensionCatalog, clusterExtension, sa, ns)
defer getArtifactsOutput(t)
defer func(cat *catalogd.ClusterCatalog) {
require.NoError(t, c.Delete(context.Background(), cat))
require.Eventually(t, func() bool {
err := c.Get(context.Background(), types.NamespacedName{Name: cat.Name}, &catalogd.ClusterCatalog{})
return errors.IsNotFound(err)
}, pollDuration, pollInterval)
}(extraCatalog)

clusterExtension.Spec = ocv1.ClusterExtensionSpec{
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
},
},
Namespace: ns.Name,
Expand All @@ -392,7 +403,7 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) {
if assert.NotNil(ct, cond) {
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
assert.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [operatorhubio test-catalog]")
assert.Contains(ct, cond.Message, "in multiple catalogs with the same priority [extra-test-catalog test-catalog]")
}
}, pollDuration, pollInterval)
}
Expand All @@ -410,7 +421,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Version: "1.0.0",
// No Selector since this is an exact version match
},
Expand All @@ -426,7 +437,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
assert.Equal(ct,
&ocv1.ClusterExtensionInstallStatus{Bundle: ocv1.BundleMetadata{
Name: "prometheus-operator.1.0.0",
Name: "test-operator.1.0.0",
Version: "1.0.0",
}},
clusterExtension.Status.Install,
Expand Down Expand Up @@ -455,7 +466,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) {
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
if assert.NotNil(ct, cond) {
assert.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
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)
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)
}
}, pollDuration, pollInterval)
}
Expand All @@ -473,7 +484,7 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) {
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Version: "1.0.0",
},
},
Expand Down Expand Up @@ -522,7 +533,7 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) {
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Version: "1.0.0",
},
},
Expand Down Expand Up @@ -569,7 +580,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Selector: &metav1.LabelSelector{
MatchExpressions: []metav1.LabelSelectorRequirement{
{
Expand Down Expand Up @@ -656,7 +667,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
},
Expand Down Expand Up @@ -717,7 +728,7 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
},
Expand All @@ -744,17 +755,17 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T
}, pollDuration, pollInterval)

t.Log("By deleting a managed resource")
prometheusService := &corev1.Service{
testConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "prometheus-operator",
Name: "test-configmap",
Namespace: clusterExtension.Spec.Namespace,
},
}
require.NoError(t, c.Delete(context.Background(), prometheusService))
require.NoError(t, c.Delete(context.Background(), testConfigMap))

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

Expand All @@ -780,7 +791,7 @@ func TestClusterExtensionRecoversFromInitialInstallFailedWhenFailureFixed(t *tes
Source: ocv1.SourceConfig{
SourceType: "Catalog",
Catalog: &ocv1.CatalogSource{
PackageName: "prometheus",
PackageName: "test",
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
},
Expand Down
1 change: 1 addition & 0 deletions test/extension-developer-e2e/extension_developer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestExtensionDeveloper(t *testing.T) {
"",
},
Resources: []string{
"configmaps",
"services",
"serviceaccounts",
},
Expand Down
2 changes: 1 addition & 1 deletion test/upgrade-e2e/post_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestClusterExtensionAfterOLMUpgrade(t *testing.T) {
}
assert.Equal(ct, ocv1.ReasonSucceeded, cond.Reason)
assert.Contains(ct, cond.Message, "Installed bundle")
assert.Equal(ct, ocv1.BundleMetadata{Name: "prometheus-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle)
assert.Equal(ct, ocv1.BundleMetadata{Name: "test-operator.1.0.1", Version: "1.0.1"}, clusterExtension.Status.Install.Bundle)
assert.NotEqual(ct, previousVersion, clusterExtension.Status.Install.Bundle.Version)
}, time.Minute, time.Second)
}
Expand Down
2 changes: 1 addition & 1 deletion testdata/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gcr.io/distroless/static:nonroot
FROM gcr.io/distroless/static:nonroot

WORKDIR /

Expand Down
Loading