Skip to content

Commit

Permalink
fix test flake in olm tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ecordell committed Mar 17, 2020
1 parent 0c701ef commit b4517ce
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions test/extended/operators/olm.go
Expand Up @@ -164,17 +164,35 @@ 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.targetNamespaces}").Output()
if err != nil {
e2e.Logf("Failed to get valid operatorgroup, error:%v", err)
return false, err
}
if strings.Contains(output, oc.Namespace()) {
return true, nil
}
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)
Expand Down

0 comments on commit b4517ce

Please sign in to comment.