Exemple #1
0
func (s *WrapAgentSuite) TestWraps(c *gc.C) {
	agent, err := model.WrapAgent(&mockAgent{}, coretesting.ModelTag.Id())
	c.Assert(err, jc.ErrorIsNil)
	config := agent.CurrentConfig()

	c.Check(config.Model(), gc.Equals, coretesting.ModelTag)
	c.Check(config.OldPassword(), gc.Equals, "")

	apiInfo, ok := config.APIInfo()
	c.Assert(ok, jc.IsTrue)
	c.Check(apiInfo, gc.DeepEquals, &api.Info{
		Addrs:    []string{"here", "there"},
		CACert:   "trust-me",
		ModelTag: coretesting.ModelTag,
		Tag:      names.NewMachineTag("123"),
		Password: "******",
		Nonce:    "11111",
	})
}
Exemple #2
0
			return nil, err
		}
		var apiCaller base.APICaller
		if err := getResource(config.APICallerName, &apiCaller); err != nil {
			return nil, err
		}
		return newManifoldWorker(agent, apiCaller, config.LeadershipGuarantee)
	}
}

// newManifoldWorker wraps NewTrackerWorker for the convenience of startFunc. It
// exists primarily to be patched out via NewManifoldWorker for ease of testing,
// and is not itself directly tested; once all NewTrackerWorker clients have been
// replaced with manifolds, the tests can be tidied up a bit.
var newManifoldWorker = func(agent agent.Agent, apiCaller base.APICaller, guarantee time.Duration) (worker.Worker, error) {
	tag := agent.CurrentConfig().Tag()
	unitTag, ok := tag.(names.UnitTag)
	if !ok {
		return nil, fmt.Errorf("expected a unit tag; got %q", tag)
	}
	claimer := leadership.NewClient(apiCaller)
	return NewTrackerWorker(unitTag, claimer, guarantee), nil
}

// outputFunc extracts the Tracker from a *tracker passed in as a Worker.
func outputFunc(in worker.Worker, out interface{}) error {
	inWorker, _ := in.(*tracker)
	outPointer, _ := out.(*Tracker)
	if inWorker == nil || outPointer == nil {
		return errors.Errorf("expected %T->%T; got %T->%T", inWorker, outPointer, in, out)
	}
Exemple #3
0
func (s *UpgradeSuite) assertUpgradeSteps(c *gc.C, job state.MachineJob) {
	agent, stopFunc := s.createAgentAndStartUpgrade(c, job)
	defer stopFunc()
	waitForUpgradeToFinish(c, agent.CurrentConfig())
}