Skip to content

Commit

Permalink
Merge pull request juju#16453 from manadart/3.1-modelcache-add-machin…
Browse files Browse the repository at this point in the history
…e-test

juju#16453

The model cache test for adding a machine underwent some changes to fix failures on 3.2+ branches, but now we're seeing similar failures on 3.1.

Here we accrue said changes into this back-port.

## QA steps

`TestAddMachine` in _worker/modelcache_ passes consistently.
  • Loading branch information
jujubot authored Oct 18, 2023
2 parents 6e47f51 + 9d1fc21 commit 4506515
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion worker/modelcache/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,20 @@ func (s *WorkerSuite) TestAddMachine(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Check(cachedMachine, gc.NotNil)

change = s.nextChange(c, changes)
// We don't know how many events we will get because `MakeMachine`
// above runs multiple operations, but is not transactional.
// Drain the events for a short time then assert that the machine
// appears as though provisioned.
done := time.After(2 * testing.ShortWait)
loop:
for {
select {
case change = <-changes:
case <-done:
break loop
}
}

obtained, ok = change.(cache.MachineChange)
c.Assert(ok, jc.IsTrue)
c.Check(obtained.Id, gc.Equals, machine.Id())
Expand Down

0 comments on commit 4506515

Please sign in to comment.