Skip to content

Commit 79dc489

Browse files
camilamacedo86ci-robot
authored andcommitted
UPSTREAM: <carry>: OTE add logs and dumps for olmv1 test and fix helper for clusterextensions
1 parent 644da89 commit 79dc489

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

openshift/tests-extension/pkg/helpers/dump.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ func DescribeAllClusterExtensions(ctx context.Context, namespace string) {
105105
return
106106
}
107107

108-
for _, n := range names {
109-
subHeader("describe %s", n)
110-
RunAndPrint(ctx, "describe", "clusterextension", strings.TrimPrefix(n, "clusterextension/"), "-n", namespace)
108+
for _, nm := range names {
109+
subHeader("describe %s", nm)
110+
RunAndPrint(ctx, "describe", nm, "-n", namespace)
111111
}
112112
fmt.Fprintln(GinkgoWriter)
113113
}

openshift/tests-extension/test/olmv1-incompatible.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,23 @@ import (
3737
)
3838

3939
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 operator installation", func() {
40+
var unique, nsName, ccName, rbName, opName string
4041
BeforeEach(func() {
4142
helpers.RequireOLMv1CapabilityOnOpenshift()
43+
unique = rand.String(8)
44+
nsName = "install-test-ns-" + unique
45+
ccName = "install-test-cc-" + unique
46+
rbName = "install-test-rb-" + unique
47+
opName = "install-test-op-" + unique
48+
})
49+
50+
AfterEach(func(ctx SpecContext) {
51+
if CurrentSpecReport().Failed() {
52+
By("dumping for debugging")
53+
helpers.DescribeAllClusterCatalogs(context.Background())
54+
helpers.DescribeAllClusterExtensions(context.Background(), nsName)
55+
}
4256
})
43-
unique := rand.String(8)
44-
nsName := "install-test-ns-" + unique
45-
ccName := "install-test-cc-" + unique
46-
rbName := "install-test-rb-" + unique
47-
opName := "install-test-op-" + unique
4857
It("should block cluster upgrades if an incompatible operator is installed", func(ctx SpecContext) {
4958
if !env.Get().IsOpenShift {
5059
Skip("Requires OCP APIs: not OpenShift")
@@ -316,6 +325,15 @@ func waitForBuildToFinish(ctx SpecContext, name, namespace string) {
316325
g.Expect(cond).ToNot(BeNil())
317326
g.Expect(cond.Status).To(Equal(corev1.ConditionTrue))
318327
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
328+
329+
DeferCleanup(func() {
330+
if CurrentSpecReport().Failed() {
331+
if CurrentSpecReport().Failed() {
332+
helpers.RunAndPrint(context.Background(), "get", "build", name, "-n", namespace, "-oyaml")
333+
helpers.RunAndPrint(context.Background(), "logs", fmt.Sprintf("build/%s", name), "-n", namespace, "--tail=200")
334+
}
335+
}
336+
})
319337
}
320338

321339
func waitForClusterCatalogServing(ctx context.Context, name string) {

openshift/tests-extension/test/olmv1.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
7676
namespace string
7777
k8sClient client.Client
7878
)
79+
7980
BeforeEach(func() {
8081
helpers.RequireOLMv1CapabilityOnOpenshift()
8182
k8sClient = env.Get().K8sClient
8283
namespace = "install-test-ns-" + rand.String(4)
83-
8484
By(fmt.Sprintf("creating namespace %s", namespace))
8585
ns := &corev1.Namespace{
8686
ObjectMeta: metav1.ObjectMeta{
@@ -89,10 +89,19 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
8989
}
9090
Expect(k8sClient.Create(context.Background(), ns)).To(Succeed(), "failed to create test namespace")
9191
DeferCleanup(func() {
92+
By(fmt.Sprintf("deleting namespace %s", namespace))
9293
_ = k8sClient.Delete(context.Background(), ns)
9394
})
9495
})
9596

97+
AfterEach(func(ctx SpecContext) {
98+
if CurrentSpecReport().Failed() {
99+
By("dumping for debugging")
100+
helpers.DescribeAllClusterCatalogs(context.Background())
101+
helpers.DescribeAllClusterExtensions(context.Background(), namespace)
102+
}
103+
})
104+
96105
It("should install a cluster extension", func(ctx SpecContext) {
97106
if !env.Get().IsOpenShift {
98107
Skip("Requires OCP Catalogs: not OpenShift")

0 commit comments

Comments
 (0)