Example #1
0
func (s *ManifoldSuite) TestMachineNotModelManagerErrors(c *gc.C) {
	config := toolsversionchecker.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		toolsversionchecker.Manifold(config),
		&fakeAgent{tag: names.NewMachineTag("42")},
		mockAPICaller(multiwatcher.JobHostUnits))
	c.Assert(err, gc.Equals, dependency.ErrMissing)
	c.Assert(s.newCalled, jc.IsFalse)
}
Example #2
0
func (s *ManifoldSuite) TestNonMachineAgent(c *gc.C) {
	config := toolsversionchecker.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		toolsversionchecker.Manifold(config),
		&fakeAgent{tag: names.NewUnitTag("foo/0")},
		mockAPICaller(""))
	c.Assert(err, gc.ErrorMatches, "this manifold may only be used inside a machine agent")
	c.Assert(s.newCalled, jc.IsFalse)
}
Example #3
0
func (s *ManifoldSuite) TestNonAgentErrors(c *gc.C) {
	config := resumer.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		resumer.Manifold(config),
		&fakeAgent{tag: names.NewUserTag("foo")},
		&fakeAPIConn{})
	c.Assert(err, gc.ErrorMatches, "this manifold may only be used inside a machine agent")
	c.Assert(s.newCalled, jc.IsFalse)
}
Example #4
0
func (s *ManifoldSuite) TestMachine(c *gc.C) {
	config := toolsversionchecker.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		toolsversionchecker.Manifold(config),
		&fakeAgent{tag: names.NewMachineTag("42")},
		mockAPICaller(multiwatcher.JobManageModel))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.newCalled, jc.IsTrue)
}
Example #5
0
func (s *ManifoldSuite) TestMachineNonManagerErrors(c *gc.C) {
	config := resumer.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		resumer.Manifold(config),
		&fakeAgent{tag: names.NewMachineTag("42")},
		&fakeAPIConn{machineJob: multiwatcher.JobHostUnits})
	c.Assert(err, gc.Equals, dependency.ErrMissing)
	c.Assert(s.newCalled, jc.IsFalse)
}
Example #6
0
func (s *ManifoldSuite) TestMachine(c *gc.C) {
	config := resumer.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		resumer.Manifold(config),
		&fakeAgent{tag: names.NewMachineTag("42")},
		&fakeAPIConn{machineJob: multiwatcher.JobManageModel})
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.newCalled, jc.IsTrue)
}
Example #7
0
func (s *ManifoldSuite) TestNonAgent(c *gc.C) {
	config := proxyup.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		proxyup.Manifold(config),
		&fakeAgent{tag: names.NewUserTag("foo")},
		nil)
	c.Assert(err, gc.ErrorMatches, "unknown agent type:.+")
	c.Assert(s.newCalled, jc.IsFalse)
}
Example #8
0
func (s *ManifoldSuite) TestUnit(c *gc.C) {
	config := proxyup.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		proxyup.Manifold(config),
		&fakeAgent{tag: names.NewUnitTag("foo/0")},
		nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.newCalled, jc.IsTrue)
}
Example #9
0
func (s *ManifoldSuite) TestMachineShouldntWrite(c *gc.C) {
	config := proxyup.ManifoldConfig(workertesting.AgentApiManifoldTestConfig())
	_, err := workertesting.RunAgentApiManifold(
		proxyup.Manifold(config),
		&fakeAgent{tag: names.NewMachineTag("42")},
		nil)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(s.newCalled, jc.IsTrue)
}
Example #10
0
func (s *MachineManifoldSuite) SetUpTest(c *gc.C) {
	s.newCalled = false
	s.PatchValue(&storageprovisioner.NewStorageProvisioner,
		func(config storageprovisioner.Config) (worker.Worker, error) {
			s.newCalled = true
			return nil, nil
		},
	)
	config := workertesting.AgentApiManifoldTestConfig()
	s.config = storageprovisioner.MachineManifoldConfig{
		AgentName:     config.AgentName,
		APICallerName: config.APICallerName,
		Clock:         coretesting.NewClock(defaultClockStart),
	}
}