Skip to content

Commit f8ef892

Browse files
UPSTREAM: <carry>: [OTE] add catalog tests from openshift/origin
This commit migrates the olmv1_catalog set of tests from openshift/origin to OTE as part the broad effort to migrate all tests. Assisted-by: Gemini
1 parent 56f527a commit f8ef892

File tree

3 files changed

+437
-0
lines changed

3 files changed

+437
-0
lines changed

openshift/tests-extension/.openshift-tests-extension/openshift_payload_olmv1.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,104 @@
11
[
2+
{
3+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 Catalogs should be installed",
4+
"labels": {},
5+
"resources": {
6+
"isolation": {}
7+
},
8+
"source": "openshift:payload:olmv1",
9+
"lifecycle": "blocking",
10+
"environmentSelector": {}
11+
},
12+
{
13+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-community-operators Catalog should serve FBC via the /v1/api/all endpoint",
14+
"labels": {},
15+
"resources": {
16+
"isolation": {}
17+
},
18+
"source": "openshift:payload:olmv1",
19+
"lifecycle": "blocking",
20+
"environmentSelector": {}
21+
},
22+
{
23+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-certified-operators Catalog should serve FBC via the /v1/api/all endpoint",
24+
"labels": {},
25+
"resources": {
26+
"isolation": {}
27+
},
28+
"source": "openshift:payload:olmv1",
29+
"lifecycle": "blocking",
30+
"environmentSelector": {}
31+
},
32+
{
33+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-redhat-marketplace Catalog should serve FBC via the /v1/api/all endpoint",
34+
"labels": {},
35+
"resources": {
36+
"isolation": {}
37+
},
38+
"source": "openshift:payload:olmv1",
39+
"lifecycle": "blocking",
40+
"environmentSelector": {}
41+
},
42+
{
43+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-redhat-operators Catalog should serve FBC via the /v1/api/all endpoint",
44+
"labels": {},
45+
"resources": {
46+
"isolation": {}
47+
},
48+
"source": "openshift:payload:olmv1",
49+
"lifecycle": "blocking",
50+
"environmentSelector": {}
51+
},
52+
{
53+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMCatalogdAPIV1Metas][Skipped:Disconnected] OLMv1 openshift-community-operators Catalog should serve FBC via the /v1/api/metas endpoint",
54+
"labels": {},
55+
"resources": {
56+
"isolation": {}
57+
},
58+
"source": "openshift:payload:olmv1",
59+
"lifecycle": "blocking",
60+
"environmentSelector": {}
61+
},
62+
{
63+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMCatalogdAPIV1Metas][Skipped:Disconnected] OLMv1 openshift-certified-operators Catalog should serve FBC via the /v1/api/metas endpoint",
64+
"labels": {},
65+
"resources": {
66+
"isolation": {}
67+
},
68+
"source": "openshift:payload:olmv1",
69+
"lifecycle": "blocking",
70+
"environmentSelector": {}
71+
},
72+
{
73+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMCatalogdAPIV1Metas][Skipped:Disconnected] OLMv1 openshift-redhat-marketplace Catalog should serve FBC via the /v1/api/metas endpoint",
74+
"labels": {},
75+
"resources": {
76+
"isolation": {}
77+
},
78+
"source": "openshift:payload:olmv1",
79+
"lifecycle": "blocking",
80+
"environmentSelector": {}
81+
},
82+
{
83+
"name": "[sig-olmv1][OCPFeatureGate:NewOLMCatalogdAPIV1Metas][Skipped:Disconnected] OLMv1 openshift-redhat-operators Catalog should serve FBC via the /v1/api/metas endpoint",
84+
"labels": {},
85+
"resources": {
86+
"isolation": {}
87+
},
88+
"source": "openshift:payload:olmv1",
89+
"lifecycle": "blocking",
90+
"environmentSelector": {}
91+
},
92+
{
93+
"name": "[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 New Catalog Install should fail to install if it has an invalid reference",
94+
"labels": {},
95+
"resources": {
96+
"isolation": {}
97+
},
98+
"source": "openshift:payload:olmv1",
99+
"lifecycle": "blocking",
100+
"environmentSelector": {}
101+
},
2102
{
3103
"name": "[sig-olmv1] OLMv1 should pass a trivial sanity check",
4104
"labels": {},
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package helpers
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"time"
7+
8+
//nolint:staticcheck // ST1001: dot-imports for readability
9+
. "github.com/onsi/ginkgo/v2"
10+
//nolint:staticcheck // ST1001: dot-imports for readability
11+
. "github.com/onsi/gomega"
12+
13+
"k8s.io/apimachinery/pkg/api/errors"
14+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
"sigs.k8s.io/controller-runtime/pkg/client"
16+
17+
olmv1 "github.com/operator-framework/operator-controller/api/v1"
18+
19+
"github/operator-framework-operator-controller/openshift/tests-extension/pkg/env"
20+
)
21+
22+
// CreateClusterCatalog creates a ClusterCatalog with the specified name and image reference
23+
// Returns a cleanup function to delete the catalog after use.
24+
func CreateClusterCatalog(ctx context.Context, name, imageRef string) (func(), error) {
25+
k8sClient := env.Get().K8sClient
26+
27+
catalog := &olmv1.ClusterCatalog{
28+
ObjectMeta: metav1.ObjectMeta{
29+
Name: name,
30+
},
31+
Spec: olmv1.ClusterCatalogSpec{
32+
Source: olmv1.CatalogSource{
33+
Type: olmv1.SourceTypeImage,
34+
Image: &olmv1.ImageSource{
35+
Ref: imageRef,
36+
},
37+
},
38+
},
39+
}
40+
41+
if err := k8sClient.Create(ctx, catalog); err != nil {
42+
return nil, fmt.Errorf("failed to create ClusterCatalog: %w", err)
43+
}
44+
45+
return func() {
46+
ctx := context.TODO()
47+
k := env.Get().K8sClient
48+
obj := &olmv1.ClusterCatalog{ObjectMeta: metav1.ObjectMeta{Name: name}}
49+
50+
_ = k.Delete(ctx, obj)
51+
EnsureCleanupClusterCatalog(ctx, name)
52+
}, nil
53+
}
54+
55+
func EnsureCleanupClusterCatalog(ctx context.Context, name string) {
56+
k8s := env.Get().K8sClient
57+
cc := &olmv1.ClusterCatalog{}
58+
key := client.ObjectKey{Name: name}
59+
60+
if err := k8s.Get(ctx, key, cc); err != nil {
61+
if !errors.IsNotFound(err) {
62+
fmt.Fprintf(GinkgoWriter, "Warning: failed to get ClusterCatalog %q during cleanup: %v\n", name, err)
63+
}
64+
return
65+
}
66+
67+
By(fmt.Sprintf("deleting lingering ClusterCatalog %q", name))
68+
if err := k8s.Delete(ctx, cc); err != nil && !errors.IsNotFound(err) {
69+
fmt.Fprintf(GinkgoWriter, "Warning: failed to delete ClusterCatalog %q: %v\n", name, err)
70+
}
71+
72+
Eventually(func() bool {
73+
err := k8s.Get(ctx, key, &olmv1.ClusterCatalog{})
74+
return errors.IsNotFound(err)
75+
}).WithTimeout(3*time.Minute).WithPolling(2*time.Second).
76+
Should(BeTrue(), "ClusterCatalog %q failed to delete", name)
77+
}

0 commit comments

Comments
 (0)