From f40f45abc159b2e410683718178ea08ae9afd5e2 Mon Sep 17 00:00:00 2001 From: Nick Sardo Date: Tue, 23 May 2017 10:11:46 -0700 Subject: [PATCH] Defer test stop & cleanup --- test/e2e/chaosmonkey/chaosmonkey.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/e2e/chaosmonkey/chaosmonkey.go b/test/e2e/chaosmonkey/chaosmonkey.go index 97e37e3a03d..9acb5af46ed 100644 --- a/test/e2e/chaosmonkey/chaosmonkey.go +++ b/test/e2e/chaosmonkey/chaosmonkey.go @@ -98,14 +98,17 @@ func (cm *chaosmonkey) Do() { sem.waitForReadyOrDone() } + defer func() { + close(stopCh) + By("Waiting for async validations to complete") + for _, sem := range sems { + sem.waitForDone() + } + }() + By("Starting disruption") cm.disruption() By("Disruption complete; stopping async validations") - close(stopCh) - By("Waiting for async validations to complete") - for _, sem := range sems { - sem.waitForDone() - } } // Semaphore is taken by a Test and provides: Ready(), for the Test to call when it's ready for the