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.
This commit is contained in:
parent
1ff724f333
commit
6f41a80b3a
|
@ -863,6 +863,14 @@ func TestPlan_shutdown(t *testing.T) {
|
||||||
shutdownCh <- struct{}{}
|
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{
|
return &terraform.InstanceDiff{
|
||||||
Attributes: map[string]*terraform.ResourceAttrDiff{
|
Attributes: map[string]*terraform.ResourceAttrDiff{
|
||||||
"ami": &terraform.ResourceAttrDiff{
|
"ami": &terraform.ResourceAttrDiff{
|
||||||
|
@ -878,7 +886,7 @@ func TestPlan_shutdown(t *testing.T) {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-cancelled:
|
case <-cancelled:
|
||||||
case <-time.After(5 * time.Second):
|
default:
|
||||||
t.Fatal("command not cancelled")
|
t.Fatal("command not cancelled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue