topgun/k8s: update worklifecycle tests to be more succint

We had few places where `JustBeforeEach` could be replaced by performing
the whole action in an `It` as there was no need for such segregation
(having a single test).

Signed-off-by: Ciro S. Costa <cscosta@pivotal.io>
This commit is contained in:
Ciro S. Costa 2019-05-07 12:56:32 -04:00
parent 101abf1e3d
commit dab1fe054f
1 changed files with 5 additions and 8 deletions

View File

@ -65,6 +65,10 @@ var _ = Describe("Worker lifecycle", func() {
return false
}, 2*time.Minute, 10*time.Second).
Should(BeTrue())
Run(nil, "kubectl", "scale", "--namespace", namespace,
"statefulset", releaseName+"-worker", "--replicas=0",
)
})
AfterEach(func() {
@ -72,18 +76,13 @@ var _ = Describe("Worker lifecycle", func() {
})
Context("terminating the worker", func() {
JustBeforeEach(func() {
Run(nil, "kubectl", "scale", "--namespace", namespace,
"statefulset", releaseName+"-worker", "--replicas=0",
)
})
Context("gracefully", func() {
BeforeEach(func() {
gracePeriod = "600"
})
JustBeforeEach(func() {
It("finishes tasks gracefully with termination", func() {
By("seeing that the worker state is retiring")
Eventually(func() string {
workers := fly.GetWorkers()
@ -97,9 +96,7 @@ var _ = Describe("Worker lifecycle", func() {
"--", "/bin/sh", "-ce",
`touch /tmp/stop-waiting`,
)
})
It("finishes tasks gracefully with termination", func() {
By("seeing that there are no workers")
Eventually(func() []Worker {
return getRunningWorkers(fly.GetWorkers())