Permalink
Browse files

Fix for provisioner testing under load.

  • Loading branch information...
1 parent 7543047 commit aeb9acf964cbdb04abd957f49e2303a65cc5d240 @dooferlad committed Jun 17, 2015
Showing with 19 additions and 10 deletions.
  1. +19 −10 worker/provisioner/provisioner_test.go
@@ -71,16 +71,25 @@ func (s *CommonProvisionerSuite) assertProvisionerObservesConfigChanges(c *gc.C,
s.BackingState.StartSync()
- // Wait for the PA to load the new configuration.
- select {
- case newCfg := <-cfgObserver:
- c.Assert(
- newCfg.ProvisionerHarvestMode().String(),
- gc.Equals,
- config.HarvestAll.String(),
- )
- case <-time.After(coretesting.LongWait):
- c.Fatalf("PA did not action config change")
+ // Wait for the PA to load the new configuration. We wait for the change we expect
+ // like this because sometimes we pick up the initial harvest config (destroyed)
+ // rather than the one we change to (all).
+ received := []string{}
+ for {
+ select {
+ case newCfg := <-cfgObserver:
+ if newCfg.ProvisionerHarvestMode().String() == config.HarvestAll.String() {
+ return
+ }
+ received = append(received, newCfg.ProvisionerHarvestMode().String())
+ case <-time.After(coretesting.LongWait):
+ if len(received) == 0 {
+ c.Fatalf("PA did not action config change")
+ } else {
+ c.Fatalf("timed out waiting for config to change to '%s', received %+v",
+ config.HarvestAll.String(), received)
+ }
+ }
}
}

0 comments on commit aeb9acf

Please sign in to comment.