Beispiel #1
0
func waitForUnitStarted(stateConn *state.State, unit *state.Unit, c *C) {
	timeout := time.After(5 * time.Second)

	for {
		select {
		case <-timeout:
			c.Fatalf("no activity detected")
		case <-time.After(testing.ShortWait):
			err := unit.Refresh()
			c.Assert(err, IsNil)
			st, info, err := unit.Status()
			c.Assert(err, IsNil)
			switch st {
			case params.StatusPending, params.StatusInstalled:
				c.Logf("waiting...")
				continue
			case params.StatusStarted:
				c.Logf("started!")
				return
			case params.StatusDown:
				stateConn.StartSync()
				c.Logf("unit is still down")
			default:
				c.Fatalf("unexpected status %s %s", st, info)
			}
		}
	}
}
Beispiel #2
0
func assertUnitRemoved(c *C, unit *state.Unit) {
	err := unit.Refresh()
	c.Assert(err, checkers.Satisfies, errors.IsNotFoundError)
	err = unit.Destroy()
	c.Assert(err, IsNil)
	err = unit.EnsureDead()
	c.Assert(err, IsNil)
	err = unit.Remove()
	c.Assert(err, IsNil)
}
Beispiel #3
0
func assertUnitLife(c *C, unit *state.Unit, life state.Life) {
	c.Assert(unit.Refresh(), IsNil)
	c.Assert(unit.Life(), Equals, life)
}