Ejemplo n.º 1
0
func NewLeadershipContext(accessor LeadershipSettingsAccessor, tracker leadership.Tracker) LeadershipContext {
	return &leadershipContext{
		accessor:    accessor,
		tracker:     tracker,
		serviceName: tracker.ServiceName(),
	}
}
Ejemplo n.º 2
0
func assertClaimLeader(c *gc.C, tracker leadership.Tracker, expect bool) {
	// Grab a ticket...
	ticket := tracker.ClaimLeader()

	// ...and check that it gives the expected result every time it's checked.
	assertTicket(c, ticket, expect)
	assertTicket(c, ticket, expect)
}
Ejemplo n.º 3
0
func assertWaitMinion(c *gc.C, tracker leadership.Tracker, expect bool) {
	ticket := tracker.WaitMinion()
	if expect {
		assertTicket(c, ticket, false)
		assertTicket(c, ticket, false)
		return
	}
	select {
	case <-time.After(trackerDuration / 4):
		// This wait needs to be small, compared to the resolution we run the
		// tests at, so as not to disturb client timing too much.
	case <-ticket.Ready():
		c.Fatalf("got unexpected readiness: %v", ticket.Wait())
	}
}