fix test flake in olm tests
if the operatrgroup is not ready by the time the CSV is created, the CSV
may temporarily make the CSV go unhealthy. This emits an alert, which
can make the prometheus test ensuring no alerts fail.
@@ -164,17 +164,36 @@ var _ = g.Describe("[sig-operator] an end user use OLM", func() {
etcdSub = filepath.Join(buildPruningBaseDir, "etcd-subscription.yaml")
)
- files := []string{operatorGroup, etcdSub}
+ files := []string{etcdSub}
g.It("can subscribe to the etcd operator", func() {
g.By("Cluster-admin user subscribe the operator resource")
+
+ // configure OperatorGroup before tests
+ configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", operatorGroup, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace()), "SOURCENAME=community-operators", "SOURCENAMESPACE=openshift-marketplace").OutputToFile("config.json")
+ o.Expect(err).NotTo(o.HaveOccurred())
+ err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
+ o.Expect(err).NotTo(o.HaveOccurred())
+ err = wait.Poll(10*time.Second, operatorWait, func() (bool, error) {
+ output, err := oc.AsAdmin().Run("get").Args("-n", oc.Namespace(), "operatorgroup", "test-operator", "-o=jsonpath={.status.namespaces}").Output()
+ if err != nil {
+ e2e.Logf("Failed to get valid operatorgroup, error:%v", err)
+ return false, nil
+ }
+ if strings.Contains(output, oc.Namespace()) {
+ return true, nil
+ }
+ e2e.Logf("%#v", output)
+ return false, nil
+ })
+ o.Expect(err).NotTo(o.HaveOccurred())
+
for _, v := range files {
configFile, err := oc.AsAdmin().Run("process").Args("--ignore-unknown-parameters=true", "-f", v, "-p", "NAME=test-operator", fmt.Sprintf("NAMESPACE=%s", oc.Namespace()), "SOURCENAME=community-operators", "SOURCENAMESPACE=openshift-marketplace").OutputToFile("config.json")
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", configFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
-
}
- err := wait.Poll(10*time.Second, operatorWait, func() (bool, error) {
+ err = wait.Poll(10*time.Second, operatorWait, func() (bool, error) {
output, err := oc.AsAdmin().Run("get").Args("-n", oc.Namespace(), "csv", "etcdoperator.v0.9.4", "-o=jsonpath={.status.phase}").Output()
if err != nil {
e2e.Logf("Failed to check etcdoperator.v0.9.4, error:%v, try next round", err)
