Skip to content

Commit 60b4508

Browse files
committed
NE-2097: e2e - Add custom catalog source
1 parent 694d439 commit 60b4508

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

test/e2e/gateway_api_upgrade_test.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,34 @@ func TestOSSMOperatorUpgradeViaIntermediateVersions(t *testing.T) {
4545
})
4646

4747
var (
48-
initialOSSMVersion = "servicemeshoperator3.v3.0.0"
49-
initialIstioVersion = "v1.24.3"
50-
upgradeOSSMVersion = "servicemeshoperator3.v3.1.0"
51-
upgradeIstioVersion = "v1.26.2"
48+
// CatalogSource image saved before the release of servicemeshoperator 3.1.0.
49+
// This image is useful because it includes intermediate versions in the
50+
// servicemeshoperator3 upgrade graph. After 3.1.0 was released, all
51+
// upgrades from 3.0.z were changed to jump directly to 3.1.0, skipping
52+
// intermediate versions.
53+
customCatalogSourceImage = "registry.redhat.io/redhat/redhat-operator-index@sha256:069050dbf2970f0762b816a054342e551802c45fb77417c216aed70cec5e843c"
54+
customCatalogSourceName = "custom-redhat-operators-4-19"
55+
initialOSSMVersion = "servicemeshoperator3.v3.0.0"
56+
initialIstioVersion = "v1.24.3"
57+
upgradeOSSMVersion = "servicemeshoperator3.v3.0.3"
58+
upgradeIstioVersion = "v1.24.6"
5259
)
5360

61+
// Create custom catalog source with expected upgrade graph for servicemeshoperator3.
62+
t.Log("Creating custom CatalogSource...")
63+
if err := createCatalogSource(t, "openshift-marketplace", customCatalogSourceName, customCatalogSourceImage); err != nil {
64+
t.Fatalf("Failed to create CatalogSource %q: %v", customCatalogSourceName, err)
65+
}
66+
t.Log("Checking for the CatalogSource...")
67+
if err := assertCatalogSourceWithConfig(t, "openshift-marketplace", customCatalogSourceName, 2*time.Second, 2*time.Minute); err != nil {
68+
t.Fatalf("Failed to find expected CatalogSource %q: %v", customCatalogSourceName, err)
69+
}
70+
5471
// Installation.
5572
t.Logf("Creating GatewayClass with OSSMversion %q ans Istio version %q...", initialOSSMVersion, initialIstioVersion)
5673
gatewayClass := buildGatewayClass("openshift-default", "openshift.io/gateway-controller/v1")
5774
gatewayClass.Annotations = map[string]string{
75+
"unsupported.do-not-use.openshift.io/ossm-catalog": customCatalogSourceName,
5876
"unsupported.do-not-use.openshift.io/ossm-version": initialOSSMVersion,
5977
"unsupported.do-not-use.openshift.io/istio-version": initialIstioVersion,
6078
}
@@ -65,10 +83,6 @@ func TestOSSMOperatorUpgradeViaIntermediateVersions(t *testing.T) {
6583
if err := assertSubscription(t, openshiftOperatorsNamespace, expectedSubscriptionName); err != nil {
6684
t.Fatalf("Failed to find expected Subscription %s: %v", expectedSubscriptionName, err)
6785
}
68-
t.Log("Checking for the CatalogSource...")
69-
if err := assertCatalogSource(t, expectedCatalogSourceNamespace, expectedCatalogSourceName); err != nil {
70-
t.Fatalf("Failed to find expected CatalogSource %s: %v", expectedCatalogSourceName, err)
71-
}
7286
t.Log("Checking for the OSSM operator deployment...")
7387
if err := assertOSSMOperatorWithConfig(t, initialOSSMVersion, 2*time.Second, 2*time.Minute); err != nil {
7488
t.Fatalf("Failed to find expected Istio operator: %v", err)
@@ -91,6 +105,7 @@ func TestOSSMOperatorUpgradeViaIntermediateVersions(t *testing.T) {
91105
return false, nil
92106
}
93107
gc.Annotations = map[string]string{
108+
"unsupported.do-not-use.openshift.io/ossm-catalog": customCatalogSourceName,
94109
"unsupported.do-not-use.openshift.io/ossm-version": upgradeOSSMVersion,
95110
"unsupported.do-not-use.openshift.io/istio-version": upgradeIstioVersion,
96111
}

test/e2e/util_gatewayapi_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,33 @@ func createCRD(name string) (*apiextensionsv1.CustomResourceDefinition, error) {
414414
return crd, nil
415415
}
416416

417+
// createCatalogSource creates a CatalogSource with the given name and image.
418+
// It returns an error if creation fails after retries.
419+
func createCatalogSource(t *testing.T, namespace, name, image string) error {
420+
t.Helper()
421+
422+
cs := &operatorsv1alpha1.CatalogSource{
423+
ObjectMeta: metav1.ObjectMeta{
424+
Namespace: namespace,
425+
Name: name,
426+
},
427+
Spec: operatorsv1alpha1.CatalogSourceSpec{
428+
Image: image,
429+
SourceType: operatorsv1alpha1.SourceTypeGrpc,
430+
DisplayName: name,
431+
Publisher: "Custom Red Hat",
432+
},
433+
}
434+
435+
return wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 30*time.Second, false, func(context context.Context) (bool, error) {
436+
if err := kclient.Create(context, cs); err != nil && !kerrors.IsAlreadyExists(err) {
437+
t.Logf("Failed to create CatalogSource %q: %v, retrying...", name, err)
438+
return false, nil
439+
}
440+
return true, nil
441+
})
442+
}
443+
417444
// buildGatewayClass initializes the GatewayClass and returns its address.
418445
func buildGatewayClass(name, controllerName string) *gatewayapiv1.GatewayClass {
419446
return &gatewayapiv1.GatewayClass{

0 commit comments

Comments
 (0)