本文整理汇总了Golang中github.com/juju/juju/juju/testing.StartInstanceWithParams函数的典型用法代码示例。如果您正苦于以下问题:Golang StartInstanceWithParams函数的具体用法?Golang StartInstanceWithParams怎么用?Golang StartInstanceWithParams使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartInstanceWithParams函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestStartInstanceDistributionParams
func (t *localServerSuite) TestStartInstanceDistributionParams(c *gc.C) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
mock := mockAvailabilityZoneAllocations{
result: []common.AvailabilityZoneInstances{{ZoneName: "az1"}},
}
t.PatchValue(ec2.AvailabilityZoneAllocations, mock.AvailabilityZoneAllocations)
// no distribution group specified
testing.AssertStartInstance(c, env, "1")
c.Assert(mock.group, gc.HasLen, 0)
// distribution group specified: ensure it's passed through to AvailabilityZone.
expectedInstances := []instance.Id{"i-0", "i-1"}
params := environs.StartInstanceParams{
DistributionGroup: func() ([]instance.Id, error) {
return expectedInstances, nil
},
}
_, err = testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(err, jc.ErrorIsNil)
c.Assert(mock.group, gc.DeepEquals, expectedInstances)
}
示例2: TestStartInstanceDistributionParams
func (s *environSuite) TestStartInstanceDistributionParams(c *gc.C) {
env := s.bootstrap(c)
var mock mockAvailabilityZoneAllocations
s.PatchValue(&availabilityZoneAllocations, mock.AvailabilityZoneAllocations)
// no distribution group specified
s.newNode(c, "node1", "host1", nil)
s.addSubnet(c, 1, 1, "node1")
testing.AssertStartInstance(c, env, s.controllerUUID, "1")
c.Assert(mock.group, gc.HasLen, 0)
// distribution group specified: ensure it's passed through to AvailabilityZone.
s.newNode(c, "node2", "host2", nil)
s.addSubnet(c, 2, 2, "node2")
expectedInstances := []instance.Id{"i-0", "i-1"}
params := environs.StartInstanceParams{
ControllerUUID: s.controllerUUID,
DistributionGroup: func() ([]instance.Id, error) {
return expectedInstances, nil
},
}
_, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(mock.group, gc.DeepEquals, expectedInstances)
}
示例3: bootstrapAndStartWithParams
func (t *localServerSuite) bootstrapAndStartWithParams(c *gc.C, params environs.StartInstanceParams) error {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
_, err = testing.StartInstanceWithParams(env, "1", params, nil)
return err
}
示例4: TestStartInstanceParams
func (suite *maas2EnvironSuite) TestStartInstanceParams(c *gc.C) {
var env *maasEnviron
suite.injectController(&fakeController{
allocateMachineArgsCheck: func(args gomaasapi.AllocateMachineArgs) {
c.Assert(args, gc.DeepEquals, gomaasapi.AllocateMachineArgs{
AgentName: env.ecfg().maasAgentName(),
Zone: "foo",
MinMemory: 8192,
})
},
allocateMachine: newFakeMachine("Bruce Sterling", arch.HostArch(), ""),
allocateMachineMatches: gomaasapi.ConstraintMatches{
Storage: map[string][]gomaasapi.BlockDevice{},
},
zones: []gomaasapi.Zone{&fakeZone{name: "foo"}},
})
suite.setupFakeTools(c)
env = suite.makeEnviron(c, nil)
params := environs.StartInstanceParams{
Placement: "zone=foo",
Constraints: constraints.MustParse("mem=8G"),
}
result, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Instance.Id(), gc.Equals, instance.Id("Bruce Sterling"))
}
示例5: TestStartInstanceUnmetConstraints
func (s *environSuite) TestStartInstanceUnmetConstraints(c *gc.C) {
env := s.bootstrap(c)
s.newNode(c, "thenode1", "host1", nil)
s.addSubnet(c, 1, 1, "thenode1")
params := environs.StartInstanceParams{ControllerUUID: s.controllerUUID, Constraints: constraints.MustParse("mem=8G")}
_, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, gc.ErrorMatches, "cannot run instances:.* 409.*")
}
示例6: TestStartInstance
func (suite *maas2EnvironSuite) TestStartInstance(c *gc.C) {
env := suite.injectControllerWithSpacesAndCheck(c, nil, gomaasapi.AllocateMachineArgs{})
params := environs.StartInstanceParams{}
result, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Instance.Id(), gc.Equals, instance.Id("Bruce Sterling"))
}
示例7: testStartInstanceAvailZone
func (s *environSuite) testStartInstanceAvailZone(c *gc.C, zone string) (instance.Instance, error) {
env := s.bootstrap(c)
params := environs.StartInstanceParams{ControllerUUID: s.controllerUUID, Placement: "zone=" + zone}
result, err := testing.StartInstanceWithParams(env, "1", params)
if err != nil {
return nil, err
}
return result.Instance, nil
}
示例8: testStartInstanceAvailZone
func (t *localServerSuite) testStartInstanceAvailZone(c *gc.C, zone string) (instance.Instance, error) {
env := t.Prepare(c)
envtesting.UploadFakeTools(c, env.Storage())
err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
params := environs.StartInstanceParams{Placement: "zone=" + zone}
inst, _, _, err := testing.StartInstanceWithParams(env, "1", params, nil)
return inst, err
}
示例9: TestStartInstanceConstraints
func (s *environSuite) TestStartInstanceConstraints(c *gc.C) {
env := s.bootstrap(c)
s.newNode(c, "thenode1", "host1", nil)
s.addSubnet(c, 1, 1, "thenode1")
s.newNode(c, "thenode2", "host2", map[string]interface{}{"memory": 8192})
s.addSubnet(c, 2, 2, "thenode2")
params := environs.StartInstanceParams{ControllerUUID: s.controllerUUID, Constraints: constraints.MustParse("mem=8G")}
result, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(*result.Hardware.Mem, gc.Equals, uint64(8192))
}
示例10: testStartInstanceAvailZone
func (t *localServerSuite) testStartInstanceAvailZone(c *gc.C, zone string) (instance.Instance, error) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
params := environs.StartInstanceParams{Placement: "zone=" + zone}
result, err := testing.StartInstanceWithParams(env, "1", params, nil)
if err != nil {
return nil, err
}
return result.Instance, nil
}
示例11: TestStartInstanceStorage
func (s *environSuite) TestStartInstanceStorage(c *gc.C) {
env := s.bootstrap(c)
s.newNode(c, "thenode1", "host1", map[string]interface{}{
"memory": 8192,
"physicalblockdevice_set": nodeStorageAttrs,
"constraint_map": storageConstraintAttrs,
})
s.addSubnet(c, 1, 1, "thenode1")
params := environs.StartInstanceParams{ControllerUUID: s.controllerUUID,
Volumes: []storage.VolumeParams{
{Tag: names.NewVolumeTag("1"), Size: 2000000},
{Tag: names.NewVolumeTag("3"), Size: 2000000},
}}
result, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, jc.ErrorIsNil)
c.Check(result.Volumes, jc.DeepEquals, []storage.Volume{
{
names.NewVolumeTag("1"),
storage.VolumeInfo{
Size: 238475,
VolumeId: "volume-1",
HardwareId: "id_for_sda",
},
},
{
names.NewVolumeTag("3"),
storage.VolumeInfo{
Size: 238475,
VolumeId: "volume-3",
HardwareId: "",
},
},
})
c.Assert(result.VolumeAttachments, jc.DeepEquals, []storage.VolumeAttachment{
{
names.NewVolumeTag("1"),
names.NewMachineTag("1"),
storage.VolumeAttachmentInfo{
DeviceName: "",
ReadOnly: false,
},
},
{
names.NewVolumeTag("3"),
names.NewMachineTag("1"),
storage.VolumeAttachmentInfo{
DeviceName: "sdc",
ReadOnly: false,
},
},
})
}
示例12: TestSpaceConstraintsNoPlacement
func (t *localServerSuite) TestSpaceConstraintsNoPlacement(c *gc.C) {
env := t.prepareAndBootstrap(c)
subIDs := t.addTestingSubnets(c)
// Shoule work because zone is not specified so we can resolve the constraints
params := environs.StartInstanceParams{
Constraints: constraints.MustParse("spaces=aaaaaaaaaa"),
SubnetsToZones: map[network.Id][]string{
subIDs[0]: []string{"test-available"},
subIDs[1]: []string{"zone3"},
},
}
_, err := testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(err, jc.ErrorIsNil)
}
示例13: TestSpaceConstraintsSpaceInPlacementZone
func (t *localServerSuite) TestSpaceConstraintsSpaceInPlacementZone(c *gc.C) {
env := t.prepareAndBootstrap(c)
subIDs := t.addTestingSubnets(c)
// Should work - test-available is in SubnetsToZones and in myspace.
params := environs.StartInstanceParams{
Placement: "zone=test-available",
Constraints: constraints.MustParse("spaces=aaaaaaaaaa"),
SubnetsToZones: map[network.Id][]string{
subIDs[0]: []string{"test-available"},
subIDs[1]: []string{"zone3"},
},
}
_, err := testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(err, jc.ErrorIsNil)
}
示例14: TestSpaceConstraintsNoAvailableSubnets
func (t *localServerSuite) TestSpaceConstraintsNoAvailableSubnets(c *gc.C) {
c.Skip("temporarily disabled")
env := t.prepareAndBootstrap(c)
subIDs := t.addTestingSubnets(c)
// We requested a space, but there are no subnets in SubnetsToZones, so we can't resolve
// the constraints
params := environs.StartInstanceParams{
Constraints: constraints.MustParse("spaces=aaaaaaaaaa"),
SubnetsToZones: map[network.Id][]string{
subIDs[0]: []string{""},
},
}
_, err := testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(err, gc.ErrorMatches, `unable to resolve constraints: space and/or subnet unavailable in zones \[test-available\]`)
}
示例15: TestStartInstanceUnsupportedStorage
func (s *environSuite) TestStartInstanceUnsupportedStorage(c *gc.C) {
env := s.bootstrap(c)
s.newNode(c, "thenode1", "host1", map[string]interface{}{
"memory": 8192,
})
s.addSubnet(c, 1, 1, "thenode1")
params := environs.StartInstanceParams{Volumes: []storage.VolumeParams{
{Tag: names.NewVolumeTag("1"), Size: 2000000},
{Tag: names.NewVolumeTag("3"), Size: 2000000},
}}
_, err := testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, gc.ErrorMatches, "requested 2 storage volumes. 0 returned.")
operations := s.testMAASObject.TestServer.NodesOperations()
c.Check(operations, gc.DeepEquals, []string{"acquire", "acquire", "release"})
c.Assert(s.testMAASObject.TestServer.OwnedNodes()["node0"], jc.IsTrue)
c.Assert(s.testMAASObject.TestServer.OwnedNodes()["thenode1"], jc.IsFalse)
}