Skip to content

Commit

Permalink
Merge pull request #16274 from bparees/postgres
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

better failure reporting in postgres test (use offset, dump pods)
  • Loading branch information
openshift-merge-robot authored Sep 11, 2017
2 parents d6b9e3c + 809ac3c commit 37bf502
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/extended/image_ecosystem/mysql_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func CreateMySQLReplicationHelpers(c kcoreclient.PodInterface, masterDeployment,
}

func cleanup(oc *exutil.CLI) {
exutil.DumpImageStreams(oc)
//exutil.DumpImageStreams(oc)
oc.AsAdmin().Run("delete").Args("all", "--all", "-n", oc.Namespace()).Execute()
exutil.DumpImageStreams(oc)
//exutil.DumpImageStreams(oc)
oc.AsAdmin().Run("delete").Args("pvc", "--all", "-n", oc.Namespace()).Execute()
exutil.CleanupHostPathVolumes(oc.AdminKubeClient().CoreV1().PersistentVolumes(), oc.Namespace())
}
Expand Down
21 changes: 19 additions & 2 deletions test/extended/image_ecosystem/postgresql_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func PostgreSQLReplicationTestFactory(oc *exutil.CLI, image string) func() {
exutil.DumpApplicationPodLogs("postgresql-master", oc)
exutil.DumpApplicationPodLogs("postgresql-slave", oc)
}
o.Expect(err).NotTo(o.HaveOccurred())
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())
}

tableCounter++
Expand All @@ -110,7 +110,7 @@ func PostgreSQLReplicationTestFactory(oc *exutil.CLI, image string) func() {
exutil.DumpApplicationPodLogs("postgresql-master", oc)
exutil.DumpApplicationPodLogs("postgresql-helper", oc)
}
o.Expect(err).NotTo(o.HaveOccurred())
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred())

err = exutil.WaitUntilAllHelpersAreUp(oc, slaves)
check(err)
Expand Down Expand Up @@ -153,19 +153,32 @@ func PostgreSQLReplicationTestFactory(oc *exutil.CLI, image string) func() {
err = oc.Run("env").Args("dc", "postgresql-master", "POSTGRESQL_ADMIN_PASSWORD=newpass").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitUntilPodIsGone(oc.KubeClient().CoreV1().Pods(oc.Namespace()), master.PodName(), 1*time.Minute)
if err != nil {
e2e.Logf("Checking if pod %s still exists", master.PodName())
oc.Run("get").Args("pod", master.PodName(), "-o", "yaml")
}
o.Expect(err).NotTo(o.HaveOccurred())
master, _, _ = assertReplicationIsWorking("postgresql-master-2", "postgresql-slave-1", 1)

g.By("after master is restarted by deleting the pod")
err = oc.Run("delete").Args("pod", "-l", "deployment=postgresql-master-2").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitUntilPodIsGone(oc.KubeClient().CoreV1().Pods(oc.Namespace()), master.PodName(), 1*time.Minute)
if err != nil {
e2e.Logf("Checking if pod %s still exists", master.PodName())
oc.Run("get").Args("pod", master.PodName(), "-o", "yaml")
}
o.Expect(err).NotTo(o.HaveOccurred())
_, slaves, _ := assertReplicationIsWorking("postgresql-master-2", "postgresql-slave-1", 1)

g.By("after slave is restarted by deleting the pod")
err = oc.Run("delete").Args("pod", "-l", "deployment=postgresql-slave-1").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitUntilPodIsGone(oc.KubeClient().CoreV1().Pods(oc.Namespace()), slaves[0].PodName(), 1*time.Minute)
if err != nil {
e2e.Logf("Checking if pod %s still exists", slaves[0].PodName())
oc.Run("get").Args("pod", slaves[0].PodName(), "-o", "yaml")
}
o.Expect(err).NotTo(o.HaveOccurred())
assertReplicationIsWorking("postgresql-master-2", "postgresql-slave-1", 1)

Expand All @@ -177,6 +190,10 @@ func PostgreSQLReplicationTestFactory(oc *exutil.CLI, image string) func() {
err = oc.Run("scale").Args("dc", "postgresql-slave", "--replicas=0").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitUntilPodIsGone(oc.KubeClient().CoreV1().Pods(oc.Namespace()), pods.Items[0].Name, 1*time.Minute)
if err != nil {
e2e.Logf("Checking if pod %s still exists", pods.Items[0].Name)
oc.Run("get").Args("pod", pods.Items[0].Name, "-o", "yaml")
}
o.Expect(err).NotTo(o.HaveOccurred())
err = oc.Run("scale").Args("dc", "postgresql-slave", "--replicas=4").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down

0 comments on commit 37bf502

Please sign in to comment.