Skip to content

Commit

Permalink
Synchronises access to machine agent central hub in racing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Jun 21, 2021
1 parent af77719 commit a2d898c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions cmd/jujud/agent/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,31 @@ func (s *MachineSuite) TestDyingMachine(c *gc.C) {
func (s *MachineSuite) TestManageModelRunsInstancePoller(c *gc.C) {
s.AgentSuite.PatchValue(&instancepoller.ShortPoll, 500*time.Millisecond)
s.AgentSuite.PatchValue(&instancepoller.ShortPollCap, 500*time.Millisecond)

stream := s.Environ.Config().AgentStream()
usefulVersion := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Release: "ubuntu",
}
envtesting.AssertUploadFakeToolsVersions(
c, s.DefaultToolsStorage,
s.Environ.Config().AgentStream(),
s.Environ.Config().AgentStream(),
usefulVersion,
)
envtesting.AssertUploadFakeToolsVersions(c, s.DefaultToolsStorage, stream, stream, usefulVersion)

m, _, _ := s.primeAgent(c, state.JobManageModel)
a := s.newAgent(c, m)
defer a.Stop()
defer func() { _ = a.Stop() }()
go func() {
c.Check(a.Run(cmdtesting.Context(c)), jc.ErrorIsNil)
}()

// Wait for the workers to start. This ensures that the central
// hub referred to in startAddressPublisher has been assigned,
// and we will will not fail race tests with concurrent access.
select {
case <-a.WorkersStarted():
case <-time.After(testing.LongWait):
c.Fatalf("timed out waiting for agent workers to start")
}

startAddressPublisher(s, c, a)

// Add one unit to an application;
Expand Down

0 comments on commit a2d898c

Please sign in to comment.