Skip to content

Commit

Permalink
Improve E2E Aftersuite cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <derek.nola@suse.com>
  • Loading branch information
dereknola committed Mar 8, 2024
1 parent 8d6e6e1 commit 60aba4f
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 50 deletions.
4 changes: 1 addition & 3 deletions tests/e2e/btrfs/btrfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/dualstack/dualstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
5 changes: 1 addition & 4 deletions tests/e2e/embeddedmirror/embeddedmirror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {

if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
r2, err := e2e.RunCmdOnNode("kubectl delete deployment my-webpage-1 my-webpage-2 my-webpage-3", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred(), r2)
Expect(err).NotTo(HaveOccurred())
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/externalip/externalip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
5 changes: 1 addition & 4 deletions tests/e2e/privateregistry/privateregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {

if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
r1, err := e2e.RunCmdOnNode("docker rm -f registry", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred(), r1)
r2, err := e2e.RunCmdOnNode("kubectl delete deployment my-webpage", serverNodeNames[0])
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/rotateca/rotateca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
18 changes: 13 additions & 5 deletions tests/e2e/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,19 @@ var _ = Describe("Verify Create", Ordered, func() {
// https://github.com/rancher/rke2/issues/3714
// Once fixed, ensure that the snapshots list are actually reduced to 2
It("prunes s3 snapshots", func() {
_, err := e2e.RunCmdOnNode("k3s etcd-snapshot prune --snapshot-retention 2", serverNodeNames[0])
_, err := e2e.RunCmdOnNode("k3s etcd-snapshot save", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
_, err = e2e.RunCmdOnNode("k3s etcd-snapshot save", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
res, err := e2e.RunCmdOnNode("k3s etcd-snapshot prune --snapshot-retention 2", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
Expect(res).To(ContainSubstring("Reconciliation of ETCDSnapshotFile resources complete"))

_, err = e2e.RunCmdOnNode("k3s etcd-snapshot ls|grep 'on-demand'|wc -l>count", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
res, err = e2e.RunCmdOnNode("grep '^[4]$' ./count", serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
Expect(strings.TrimSpace(res)).To(Equal("4"))
})
})
})
Expand All @@ -142,10 +153,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {

if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/secretsencryption/secretsencryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/snapshotrestore/snapshotrestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/splitserver/splitserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/startup/startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/tailscale/tailscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/token/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/upgradecluster/upgradecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/validatecluster/validatecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
if !failed || *ci {
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/wasm/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ var _ = AfterSuite(func() {
if failed && !*ci {
fmt.Println("FAILED!")
} else {
Expect(e2e.GetCoverageReport(append(serverNodeNames, agentNodeNames...))).To(Succeed())
Expect(e2e.DestroyCluster()).To(Succeed())
Expect(os.Remove(kubeConfigFile)).To(Succeed())
}
Expand Down

0 comments on commit 60aba4f

Please sign in to comment.