Skip to content

Commit 95286aa

Browse files
author
Per Goncalves da Silva
committed
Add e2e tests for unsupported bundles
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent 590722d commit 95286aa

1 file changed

Lines changed: 123 additions & 0 deletions

File tree

test/e2e/bundle_support_test.go

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package e2e
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
apimeta "k8s.io/apimachinery/pkg/api/meta"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"k8s.io/apimachinery/pkg/types"
12+
13+
ocv1 "github.com/operator-framework/operator-controller/api/v1"
14+
utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils"
15+
)
16+
17+
func TestClusterExtensionInstall_SingleNamespaceInstall_Fails(t *testing.T) {
18+
t.Log("Check bundles with only SingleNamespace install mode support don't install")
19+
clusterExtension, extensionCatalog, sa, ns := testInit(t)
20+
defer testCleanup(t, extensionCatalog, clusterExtension, sa, ns)
21+
defer utils.CollectTestArtifacts(t, artifactName, c, cfg)
22+
23+
clusterExtension.Spec = ocv1.ClusterExtensionSpec{
24+
Source: ocv1.SourceConfig{
25+
SourceType: "Catalog",
26+
Catalog: &ocv1.CatalogFilter{
27+
PackageName: "single-operator",
28+
Selector: &metav1.LabelSelector{
29+
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
30+
},
31+
},
32+
},
33+
Namespace: ns.Name,
34+
ServiceAccount: ocv1.ServiceAccountReference{
35+
Name: sa.Name,
36+
},
37+
}
38+
39+
t.Log("By creating the ClusterExtension resource for the single-operator")
40+
require.NoError(t, c.Create(context.Background(), clusterExtension))
41+
42+
t.Log("By eventually getting an error in the Progressing condition")
43+
require.EventuallyWithT(t, func(ct *assert.CollectT) {
44+
require.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
45+
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
46+
require.NotNil(ct, cond)
47+
require.Equal(ct, metav1.ConditionTrue, cond.Status)
48+
require.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
49+
require.Contains(ct, cond.Message, "bundle does not support AllNamespaces install mode")
50+
}, pollDuration, pollInterval)
51+
}
52+
53+
func TestClusterExtensionInstall_OwnNamespaceInstall_Fails(t *testing.T) {
54+
t.Log("Check bundles with only OwnNamespace install mode support don't install")
55+
clusterExtension, extensionCatalog, sa, ns := testInit(t)
56+
defer testCleanup(t, extensionCatalog, clusterExtension, sa, ns)
57+
defer utils.CollectTestArtifacts(t, artifactName, c, cfg)
58+
59+
clusterExtension.Spec = ocv1.ClusterExtensionSpec{
60+
Source: ocv1.SourceConfig{
61+
SourceType: "Catalog",
62+
Catalog: &ocv1.CatalogFilter{
63+
PackageName: "own-operator",
64+
Selector: &metav1.LabelSelector{
65+
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
66+
},
67+
},
68+
},
69+
Namespace: ns.Name,
70+
ServiceAccount: ocv1.ServiceAccountReference{
71+
Name: sa.Name,
72+
},
73+
}
74+
75+
t.Log("By creating the ClusterExtension resource for the own-operator")
76+
require.NoError(t, c.Create(context.Background(), clusterExtension))
77+
78+
t.Log("By eventually getting an error in the Progressing condition")
79+
require.EventuallyWithT(t, func(ct *assert.CollectT) {
80+
require.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
81+
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
82+
require.NotNil(ct, cond)
83+
require.Equal(ct, metav1.ConditionTrue, cond.Status)
84+
require.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
85+
require.Contains(ct, cond.Message, "bundle does not support AllNamespaces install mode")
86+
}, pollDuration, pollInterval)
87+
}
88+
89+
func TestClusterExtensionInstall_BundlesWithWebhooks_Fail(t *testing.T) {
90+
t.Log("Check bundles with webhook definitions don't install")
91+
clusterExtension, extensionCatalog, sa, ns := testInit(t)
92+
defer testCleanup(t, extensionCatalog, clusterExtension, sa, ns)
93+
defer utils.CollectTestArtifacts(t, artifactName, c, cfg)
94+
95+
clusterExtension.Spec = ocv1.ClusterExtensionSpec{
96+
Source: ocv1.SourceConfig{
97+
SourceType: "Catalog",
98+
Catalog: &ocv1.CatalogFilter{
99+
PackageName: "webhook-operator",
100+
Selector: &metav1.LabelSelector{
101+
MatchLabels: map[string]string{"olm.operatorframework.io/metadata.name": extensionCatalog.Name},
102+
},
103+
},
104+
},
105+
Namespace: ns.Name,
106+
ServiceAccount: ocv1.ServiceAccountReference{
107+
Name: sa.Name,
108+
},
109+
}
110+
111+
t.Log("By creating the ClusterExtension resource for the webhook-operator")
112+
require.NoError(t, c.Create(context.Background(), clusterExtension))
113+
114+
t.Log("By eventually getting an error in the Progressing condition")
115+
require.EventuallyWithT(t, func(ct *assert.CollectT) {
116+
require.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
117+
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
118+
require.NotNil(ct, cond)
119+
require.Equal(ct, metav1.ConditionTrue, cond.Status)
120+
require.Equal(ct, ocv1.ReasonRetrying, cond.Reason)
121+
require.Contains(ct, cond.Message, "webhookDefinitions are not supported")
122+
}, pollDuration, pollInterval)
123+
}

0 commit comments

Comments
 (0)