From 6f41a80b3a99b081102dd823c94a7a2bffaec97b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 31 Jan 2018 15:24:07 -0500 Subject: [PATCH] slow down the plan shutdown tests for slow hosts The plan shutdown test often fail on slow CI hosts, becase the plan completes befor the main thread can cancel it. Since attempting to make the MockProvider concurrent proved too invasive for now, just slow the test down a bit to help ensure Stop gets called. --- command/plan_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/command/plan_test.go b/command/plan_test.go index 3e97fdd476..e9cfd6dbb2 100644 --- a/command/plan_test.go +++ b/command/plan_test.go @@ -863,6 +863,14 @@ func TestPlan_shutdown(t *testing.T) { shutdownCh <- struct{}{} }) + // Because of the internal lock in the MockProvider, we can't + // coordiante directly with the calling of Stop, and making the + // MockProvider concurrent is disruptive to a lot of existing tests. + // Wait here a moment to help make sure the main goroutine gets to the + // Stop call before we exit, or the plan may finish before it can be + // canceled. + time.Sleep(200 * time.Millisecond) + return &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ "ami": &terraform.ResourceAttrDiff{ @@ -878,7 +886,7 @@ func TestPlan_shutdown(t *testing.T) { select { case <-cancelled: - case <-time.After(5 * time.Second): + default: t.Fatal("command not cancelled") } }