Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Apply deployments in BeforeAll rather than BeforeEach #11514

Merged
merged 1 commit into from May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions test/k8sT/Services.go
Expand Up @@ -175,9 +175,7 @@ var _ = Describe("K8sServicesTest", func() {
BeforeAll(func() {
demoYAML = helpers.ManifestGet(kubectl.BasePath(), "demo.yaml")
echoSVCYAML = helpers.ManifestGet(kubectl.BasePath(), "echo-svc.yaml")
})

BeforeEach(func() {
res := kubectl.ApplyDefault(demoYAML)
res.ExpectSuccess("unable to apply %s", demoYAML)
res = kubectl.ApplyDefault(echoSVCYAML)
Expand All @@ -191,7 +189,7 @@ var _ = Describe("K8sServicesTest", func() {
Expect(err).Should(BeNil())
})

AfterEach(func() {
AfterAll(func() {
// Explicitly ignore result of deletion of resources to avoid incomplete
// teardown if any step fails.
_ = kubectl.Delete(demoYAML)
Expand Down Expand Up @@ -255,7 +253,7 @@ var _ = Describe("K8sServicesTest", func() {
demoClusterIPv6 := "fd03::100"
echoClusterIPv6 := "fd03::200"

BeforeEach(func() {
BeforeAll(func() {
// Installs the IPv6 equivalent of app1-service (demo.yaml)
httpBackends := ciliumIPv6Backends("-l k8s:id=app1,k8s:io.kubernetes.pod.namespace=default", "80")
ciliumAddService(10080, net.JoinHostPort(demoClusterIPv6, "80"), httpBackends, "ClusterIP", "Cluster")
Expand All @@ -268,7 +266,7 @@ var _ = Describe("K8sServicesTest", func() {
ciliumAddService(20069, net.JoinHostPort(echoClusterIPv6, "69"), tftpBackends, "ClusterIP", "Cluster")
})

AfterEach(func() {
AfterAll(func() {
ciliumDelService(10080)
ciliumDelService(10069)
ciliumDelService(20080)
Expand Down Expand Up @@ -1551,7 +1549,7 @@ var _ = Describe("K8sServicesTest", func() {
policyPath string
)

BeforeEach(func() {
BeforeAll(func() {

bookinfoV1YAML = helpers.ManifestGet(kubectl.BasePath(), "bookinfo-v1.yaml")
bookinfoV2YAML = helpers.ManifestGet(kubectl.BasePath(), "bookinfo-v2.yaml")
Expand All @@ -1570,14 +1568,14 @@ var _ = Describe("K8sServicesTest", func() {
Expect(err).Should(BeNil(), "Pods are not ready after timeout")
})

AfterEach(func() {
AfterAll(func() {

// Explicitly do not check result to avoid having assertions in AfterEach.
// Explicitly do not check result to avoid having assertions in AfterAll.
_ = kubectl.Delete(policyPath)

for _, resourcePath := range resourceYAMLs {
By("Deleting resource %s", resourcePath)
// Explicitly do not check result to avoid having assertions in AfterEach.
// Explicitly do not check result to avoid having assertions in AfterAll.
_ = kubectl.Delete(resourcePath)
}
})
Expand Down