Ejemplo n.º 1
0
func (s *lxcBrokerSuite) startInstance(c *gc.C, machineId string) instance.Instance {
	stateInfo := jujutesting.FakeStateInfo(machineId)
	apiInfo := jujutesting.FakeAPIInfo(machineId)

	series := "series"
	nonce := "fake-nonce"
	cons := constraints.Value{}
	lxc, _, err := s.broker.StartInstance(machineId, nonce, series, cons, stateInfo, apiInfo)
	c.Assert(err, gc.IsNil)
	return lxc
}
Ejemplo n.º 2
0
func StartContainer(c *gc.C, manager lxc.ContainerManager, machineId string) instance.Instance {
	config := testing.EnvironConfig(c)
	stateInfo := jujutesting.FakeStateInfo(machineId)
	apiInfo := jujutesting.FakeAPIInfo(machineId)

	series := "series"
	nonce := "fake-nonce"
	tools := &tools.Tools{
		Binary: version.MustParseBinary("2.3.4-foo-bar"),
		URL:    "http://tools.testing.invalid/2.3.4-foo-bar.tgz",
	}

	inst, err := manager.StartContainer(machineId, series, nonce, tools, config, stateInfo, apiInfo)
	c.Assert(err, gc.IsNil)
	return inst
}
Ejemplo n.º 3
0
func (t *LiveTests) TestStartInstanceConstraints(c *C) {
	cons := constraints.MustParse("mem=2G")
	inst, hc, err := t.Env.StartInstance("31", "fake_nonce", config.DefaultSeries, cons, testing.FakeStateInfo("31"), testing.FakeAPIInfo("31"))
	c.Assert(err, IsNil)
	defer t.Env.StopInstances([]instance.Instance{inst})
	ec2inst := ec2.InstanceEC2(inst)
	c.Assert(ec2inst.InstanceType, Equals, "m1.medium")
	c.Assert(*hc.Arch, Equals, "amd64")
	c.Assert(*hc.Mem, Equals, uint64(3840))
	c.Assert(*hc.CpuCores, Equals, uint64(1))
	c.Assert(*hc.CpuPower, Equals, uint64(200))
}
Ejemplo n.º 4
0
// Check that we can't start an instance with an empty nonce value.
func (t *LiveTests) TestStartInstanceWithEmptyNonceFails(c *C) {
	inst, _, err := t.Env.StartInstance("4", "", config.DefaultSeries, constraints.Value{}, testing.FakeStateInfo("4"), testing.FakeAPIInfo("4"))
	if inst != nil {
		err := t.Env.StopInstances([]instance.Instance{inst})
		c.Check(err, IsNil)
	}
	c.Assert(inst, IsNil)
	c.Assert(err, ErrorMatches, ".*missing machine nonce")
}
Ejemplo n.º 5
0
// Check that we can't start an instance running tools that correspond with no
// available platform.  The first thing start instance should do is find
// appropriate tools.
func (t *LiveTests) TestStartInstanceOnUnknownPlatform(c *C) {
	inst, _, err := t.Env.StartInstance("4", "fake_nonce", "unknownseries", constraints.Value{}, testing.FakeStateInfo("4"), testing.FakeAPIInfo("4"))
	if inst != nil {
		err := t.Env.StopInstances([]instance.Instance{inst})
		c.Check(err, IsNil)
	}
	c.Assert(inst, IsNil)
	var notFoundError *errors.NotFoundError
	c.Assert(err, FitsTypeOf, notFoundError)
	c.Assert(err, ErrorMatches, "no matching tools available")
}