Skip to content
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
77 changes: 47 additions & 30 deletions openshift/tests-extension/test/qe/specs/olmv1_cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,11 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif

g.It("PolarionID:73289-[OTP][Skipped:Disconnected]Check the deprecation conditions and messages", func() {
var (
caseID = "73289"
labelValue = caseID
baseDir = exutil.FixturePath("testdata", "olm")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml")
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
ns = "ns-73289"
sa = "sa73289"
Expand All @@ -659,9 +661,10 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Template: saClusterRoleBindingTemplate,
}
clustercatalog = olmv1util.ClusterCatalogDescription{
Name: "clustercatalog-73289",
Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm73289",
Template: clustercatalogTemplate,
Name: "clustercatalog-73289",
Imageref: "quay.io/olmqe/olmtest-operator-index:nginxolm73289",
LabelValue: labelValue,
Template: clustercatalogTemplate,
}
clusterextension = olmv1util.ClusterExtensionDescription{
Name: "clusterextension-73289",
Expand All @@ -670,6 +673,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Channel: "candidate-v1.0",
Version: "1.0.1",
SaName: sa,
LabelValue: labelValue,
Template: clusterextensionTemplate,
}
)
Expand Down Expand Up @@ -783,9 +787,11 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif

g.It("PolarionID:74948-[OTP][Skipped:Disconnected]catalog offer the operator content through https server", func() {
var (
caseID = "74948"
labelValue = caseID
baseDir = exutil.FixturePath("testdata", "olm")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml")
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
ns = "ns-74948"
sa = "sa74948"
Expand All @@ -795,9 +801,10 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Template: saClusterRoleBindingTemplate,
}
clustercatalog = olmv1util.ClusterCatalogDescription{
Name: "clustercatalog-74948",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74948",
Template: clustercatalogTemplate,
Name: "clustercatalog-74948",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74948",
LabelValue: labelValue,
Template: clustercatalogTemplate,
}
clusterextension = olmv1util.ClusterExtensionDescription{
Name: "clusterextension-74948",
Expand All @@ -806,6 +813,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Channel: "candidate-v1.0",
Version: "1.0.3",
SaName: sa,
LabelValue: labelValue,
Template: clusterextensionTemplate,
}
)
Expand Down Expand Up @@ -858,9 +866,11 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif

g.It("PolarionID:74978-[OTP][Level0][Skipped:Disconnected]CRD upgrade will be prevented if the Scope is switched between Namespaced and Cluster", func() {
var (
caseID = "74978"
labelValue = caseID
baseDir = exutil.FixturePath("testdata", "olm")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml")
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
ns = "ns-74978"
sa = "sa74978"
Expand All @@ -870,9 +880,10 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Template: saClusterRoleBindingTemplate,
}
clustercatalog = olmv1util.ClusterCatalogDescription{
Name: "clustercatalog-74978",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74978",
Template: clustercatalogTemplate,
Name: "clustercatalog-74978",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm74978",
LabelValue: labelValue,
Template: clustercatalogTemplate,
}
clusterextension = olmv1util.ClusterExtensionDescription{
Name: "clusterextension-74978",
Expand All @@ -881,6 +892,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Channel: "candidate-v1.0",
Version: "1.0.1",
SaName: sa,
LabelValue: labelValue,
Template: clusterextensionTemplate,
}
)
Expand Down Expand Up @@ -929,9 +941,11 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif

g.It("PolarionID:75218-[OTP][Skipped:Disconnected]Disabling the CRD Upgrade Safety preflight checks", func() {
var (
caseID = "75218"
labelValue = caseID
baseDir = exutil.FixturePath("testdata", "olm")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml")
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
ns = "ns-75218"
sa = "sa75218"
Expand All @@ -941,9 +955,10 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Template: saClusterRoleBindingTemplate,
}
clustercatalog = olmv1util.ClusterCatalogDescription{
Name: "clustercatalog-75218",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75218",
Template: clustercatalogTemplate,
Name: "clustercatalog-75218",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm75218",
LabelValue: labelValue,
Template: clustercatalogTemplate,
}
clusterextension = olmv1util.ClusterExtensionDescription{
Name: "clusterextension-75218",
Expand All @@ -952,6 +967,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
Channel: "candidate-v1.0",
Version: "1.0.1",
SaName: sa,
LabelValue: labelValue,
Template: clusterextensionTemplate,
}
)
Expand Down Expand Up @@ -993,17 +1009,16 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
var message string
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 18*time.Second, false, func(ctx context.Context) (bool, error) {
message = clusterextension.GetClusterExtensionMessage(oc, "Progressing")
if !strings.Contains(message, `spec.scope: Invalid value: "Cluster": field is immutable`) {
if !strings.Contains(message, `field is immutable`) || strings.Contains(message, `type changed`) || strings.Contains(message, `existingFieldRemoval`) {
return false, nil
}

return true, nil
})
if errWait != nil {
_, _ = olmv1util.GetNoEmpty(oc, "clustercatalog", clustercatalog.Name, "-o=jsonpath-as-json={.status}")
}
exutil.AssertWaitPollNoErr(errWait, fmt.Sprintf("Unexpected results message: %v", message))
clusterextension.CheckClusterExtensionNotCondition(oc, "Progressing", "message", `type changed`, 10, 60, 0)
clusterextension.CheckClusterExtensionNotCondition(oc, "Progressing", "message", `existingFieldRemoval`, 10, 60, 0)

g.By("disabled crd upgrade safety check An existing stored version of the CRD is removed")
err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}, "install":{"preflight":{"crdUpgradeSafety":{"enforcement":"None"}}}}}`, "--type=merge").Execute()
Expand Down Expand Up @@ -1091,13 +1106,15 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clustercatalog", g.Label("NonHyperShif
g.By("upgrade will be allowed if A new version of the CRD is added with no modifications to existing versions")
err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.3","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
clusterextension.CheckClusterExtensionCondition(oc, "Progressing", "reason", "Succeeded", 3, 150, 0)
clusterextension.WaitClusterExtensionCondition(oc, "Installed", "True", 0)
clusterextension.GetBundleResource(oc)
o.Expect(clusterextension.InstalledBundle).To(o.ContainSubstring("v1.0.3"))

clusterextension.CheckClusterExtensionCondition(oc, "Installed", "message",
"Installed bundle quay.io/openshifttest/nginxolm-operator-bundle:v1.0.3-nginxolm75122 successfully", 10, 60, 0)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
clusterextension.GetBundleResource(oc)
if strings.Contains(clusterextension.InstalledBundle, "1.0.3") {
e2e.Logf("InstalledBundle is %s", clusterextension.InstalledBundle)
return true, nil
}
return false, nil
})
exutil.AssertWaitPollNoErr(errWait, "nginx75122 1.0.3 is not installed")

g.By("upgrade will be prevented if An existing served version of the CRD is removed")
err = oc.AsAdmin().Run("patch").Args("clusterextension", clusterextension.Name, "-p", `{"spec":{"source":{"catalog":{"version":"1.0.6","upgradeConstraintPolicy":"SelfCertified"}}}}`, "--type=merge").Execute()
Expand Down
56 changes: 28 additions & 28 deletions openshift/tests-extension/test/qe/specs/olmv1_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,24 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
g.It("PolarionID:70723-[OTP][Skipped:Disconnected]olmv1 downgrade version", func() {
olmv1util.ValidateAccessEnvironment(oc)
var (
caseID = "70723"
labelValue = caseID
ns = "ns-70723"
sa = "sa70723"
baseDir = exutil.FixturePath("testdata", "olm")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension.yaml")
clustercatalogTemplate = filepath.Join(baseDir, "clustercatalog-withlabel.yaml")
clusterextensionTemplate = filepath.Join(baseDir, "clusterextension-withselectorlabel.yaml")
saClusterRoleBindingTemplate = filepath.Join(baseDir, "sa-admin.yaml")
saCrb = olmv1util.SaCLusterRolebindingDescription{
Name: sa,
Namespace: ns,
Template: saClusterRoleBindingTemplate,
}
clustercatalog = olmv1util.ClusterCatalogDescription{
Name: "clustercatalog-70723",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm70723",
Template: clustercatalogTemplate,
Name: "clustercatalog-70723",
Imageref: "quay.io/openshifttest/nginxolm-operator-index:nginxolm70723",
LabelValue: labelValue,
Template: clustercatalogTemplate,
}
clusterextension = olmv1util.ClusterExtensionDescription{
Name: "clusterextension-70723",
Expand All @@ -366,6 +369,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
Channel: "candidate-v2",
Version: "2.2.1",
SaName: sa,
LabelValue: labelValue,
Template: clusterextensionTemplate,
}
)
Expand Down Expand Up @@ -1860,9 +1864,6 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
_, _ = olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, "clusterextension resolvedBundle is not v1.0.2")
}
conditions, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.conditions}")
o.Expect(strings.ToLower(conditions)).To(o.ContainSubstring("desired state reached"))
o.Expect(conditions).NotTo(o.ContainSubstring("error"))

g.By("update channel to be candidate-v1.1")
clusterextension.Patch(oc, `{"spec":{"source":{"catalog":{"channels": ["candidate-v1.1"]}}}}`)
Expand Down Expand Up @@ -2238,13 +2239,15 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
_ = clusterextension2.CreateWithoutCheck(oc)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension2.Name, "-o", "jsonpath={.status.conditions[*].message}")
if !strings.Contains(message, "already exists in namespace") {
if strings.Contains(message, "already exists") || strings.Contains(message, "Conflicting") {
e2e.Logf("status is %s", message)
return false, nil
return true, nil
}
return true, nil
e2e.Logf("status is %s", message)
return false, nil
Comment on lines +2242 to +2247
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep these conflict checks tied to the actual conflict.

Line 2242 and Line 2957 now accept any generic already exists, and Lines 2280-2281 only require Installed to be Failed/False. That can make the tests pass on unrelated failures (stale leftovers, RBAC issues, image pull failures) even if the ownership-conflict path regresses. Please keep a conflict-specific marker in the assertion as well, such as Conflicting plus the conflicting object/CRD name.

Also applies to: 2280-2281, 2957-2962

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openshift/tests-extension/test/qe/specs/olmv1_ce.go` around lines 2242 -
2247, The current checks use generic substrings like "already exists" or just
"Installed" which can match unrelated failures; update the predicate(s) that
inspect the variable message (the strings.Contains(...) branches) to require a
conflict-specific marker such as the word "Conflicting" combined with the
specific conflicting object or CRD name (e.g., "Conflicting:
<CRD/ResourceName>") instead of accepting any "already exists" or only
"Installed"==Failed/False; change all occurrences that use
strings.Contains(message, "already exists") or only check for "Installed"
(including the blocks referencing message and the other occurrences you noted
around the second block and lines 2957-2962) to assert strings.Contains(message,
"Conflicting") && strings.Contains(message, "<expected-CRD-or-resource>") or
equivalent exact-match logic so the test only passes on true ownership
conflicts.

})
exutil.AssertWaitPollNoErr(errWait, "clusterextension2 should not be installed")

clusterextension2.Delete(oc)
clusterextension1.Delete(oc)
errWait = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
Expand Down Expand Up @@ -2274,15 +2277,8 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
exutil.AssertWaitPollNoErr(errWait, "crd nginxolm74923s.cache.example.com is not deleted")

_ = clusterextension1.CreateWithoutCheck(oc)
errWait = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension1.Name, "-o", "jsonpath={.status.conditions[*].message}")
if !strings.Contains(message, "already exists in namespace") {
e2e.Logf("status is %s", message)
return false, nil
}
return true, nil
})
exutil.AssertWaitPollNoErr(errWait, "clusterextension1 should not be installed")
clusterextension1.CheckClusterExtensionCondition(oc, "Installed", "reason", "Failed", 3, 150, 0)
clusterextension1.WaitClusterExtensionCondition(oc, "Installed", "False", 0)

})

Expand Down Expand Up @@ -2835,11 +2831,11 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
_ = clusterextension.CreateWithoutCheck(oc)
errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.conditions[*].message}")
if !strings.Contains(message, "failed to create resource") {
if strings.Contains(message, "failed to create resource") || strings.Contains(message, "ns-80117-watch") {
e2e.Logf("status is %s", message)
return false, nil
return true, nil
}
return true, nil
return false, nil
Comment on lines 2833 to +2838
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

This missing-watch-namespace predicate is too broad.

Line 2834 will pass on any error that merely mentions ns-80117-watch, so the test can go green without proving the expected namespace not found path.

Suggested tightening
 		errWait := wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
 			message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.conditions[*].message}")
-			if strings.Contains(message, "failed to create resource") || strings.Contains(message, "ns-80117-watch") {
+			lowerMessage := strings.ToLower(message)
+			if strings.Contains(message, "ns-80117-watch") &&
+				(strings.Contains(message, "failed to create resource") || strings.Contains(lowerMessage, "not found")) {
 				e2e.Logf("status is %s", message)
 				return true, nil
 			}
 			return false, nil
 		})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.conditions[*].message}")
if !strings.Contains(message, "failed to create resource") {
if strings.Contains(message, "failed to create resource") || strings.Contains(message, "ns-80117-watch") {
e2e.Logf("status is %s", message)
return false, nil
return true, nil
}
return true, nil
return false, nil
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o", "jsonpath={.status.conditions[*].message}")
lowerMessage := strings.ToLower(message)
if strings.Contains(message, "ns-80117-watch") &&
(strings.Contains(message, "failed to create resource") || strings.Contains(lowerMessage, "not found")) {
e2e.Logf("status is %s", message)
return true, nil
}
return false, nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openshift/tests-extension/test/qe/specs/olmv1_ce.go` around lines 2833 -
2838, The predicate is too permissive because it returns success on any message
that mentions "ns-80117-watch"; update the check around the variable message
(from the call to olmv1util.GetNoEmpty) to require the specific "namespace not
found" failure (or the exact phrase the controller emits, e.g. `namespace
"ns-80117-watch" not found`) rather than any mention of the namespace; replace
the current strings.Contains(message, "ns-80117-watch") condition with a
stricter test (for example require both strings.Contains(message,
"ns-80117-watch") && strings.Contains(message, "not found") or a regex match for
the exact error phrase) so that return true only when the expected
namespace-not-found path is observed.

})
exutil.AssertWaitPollNoErr(errWait, "status is not correct")
clusterextension.Delete(oc)
Expand Down Expand Up @@ -2948,7 +2944,7 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
InstallNamespace: ns2,
PackageName: "nginx80117",
SaName: sa2,
Version: "1.0.1",
Version: "2.0.0",
WatchNamespace: nsWatch2,
LabelKey: "olmv1-test",
LabelValue: labelValue,
Expand All @@ -2958,11 +2954,12 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
_ = clusterextension2.CreateWithoutCheck(oc)
errWait = wait.PollUntilContextTimeout(context.TODO(), 3*time.Second, 150*time.Second, false, func(ctx context.Context) (bool, error) {
message, _ := olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension2.Name, "-o", "jsonpath={.status.conditions[*].message}")
if !strings.Contains(message, "already exists") {
if strings.Contains(message, "already exists") || strings.Contains(message, "Conflicting") {
e2e.Logf("status is %s", message)
return false, nil
return true, nil
}
return true, nil
e2e.Logf("status is %s", message)
return false, nil
})
exutil.AssertWaitPollNoErr(errWait, "status is not correct")

Expand Down Expand Up @@ -3235,7 +3232,10 @@ var _ = g.Describe("[sig-olmv1][Jira:OLM] clusterextension", g.Label("NonHyperSh
}
return false, nil
})
exutil.AssertWaitPollNoErr(errWait, "nginx82136 2.2.0 is not installed")
if errWait != nil {
_, _ = olmv1util.GetNoEmpty(oc, "clusterextension", clusterextension.Name, "-o=jsonpath-as-json={.status}")
exutil.AssertWaitPollNoErr(errWait, "nginx82136 2.2.0 is not installed")
}
networkpolicies, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("networkpolicy", "-n", ns).Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(networkpolicies).To(o.ContainSubstring("No resources found"))
Expand Down