本文整理汇总了Golang中github.com/juju/juju/juju/testing.StartInstanceWithParams函数的典型用法代码示例。如果您正苦于以下问题:Golang StartInstanceWithParams函数的具体用法?Golang StartInstanceWithParams怎么用?Golang StartInstanceWithParams使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartInstanceWithParams函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:25,代码来源:local_test.go
示例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)
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:environ_whitebox_test.go
示例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
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:local_test.go
示例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"))
}
开发者ID:xushiwei,项目名称:juju,代码行数:26,代码来源:maas2_environ_whitebox_test.go
示例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.*")
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:environ_whitebox_test.go
示例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"))
}
开发者ID:xushiwei,项目名称:juju,代码行数:8,代码来源:maas2_environ_whitebox_test.go
示例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
}
开发者ID:bac,项目名称:juju,代码行数:9,代码来源:environ_whitebox_test.go
示例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
}
开发者ID:klyachin,项目名称:juju,代码行数:10,代码来源:local_test.go
示例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))
}
开发者ID:bac,项目名称:juju,代码行数:11,代码来源:environ_whitebox_test.go
示例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
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:12,代码来源:local_test.go
示例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,
},
},
})
}
开发者ID:bac,项目名称:juju,代码行数:52,代码来源:environ_whitebox_test.go
示例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)
}
开发者ID:pmatulis,项目名称:juju,代码行数:15,代码来源:local_test.go
示例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)
}
开发者ID:pmatulis,项目名称:juju,代码行数:16,代码来源:local_test.go
示例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\]`)
}
开发者ID:pmatulis,项目名称:juju,代码行数:17,代码来源:local_test.go
示例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)
}
开发者ID:xushiwei,项目名称:juju,代码行数:17,代码来源:environ_whitebox_test.go
示例16: TestSpaceConstraintsSpaceNotInPlacementZone
func (t *localServerSuite) TestSpaceConstraintsSpaceNotInPlacementZone(c *gc.C) {
c.Skip("temporarily disabled")
env := t.prepareAndBootstrap(c)
subIDs := t.addTestingSubnets(c)
// Expect an error because zone test-available isn't in SubnetsToZones
params := environs.StartInstanceParams{
Placement: "zone=test-available",
Constraints: constraints.MustParse("spaces=aaaaaaaaaa"),
SubnetsToZones: map[network.Id][]string{
subIDs[0]: []string{"zone2"},
subIDs[1]: []string{"zone3"},
subIDs[2]: []string{"zone4"},
},
}
_, 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\]`)
}
开发者ID:pmatulis,项目名称:juju,代码行数:18,代码来源:local_test.go
示例17: TestStartInstanceDistributionErrors
func (s *environSuite) TestStartInstanceDistributionErrors(c *gc.C) {
env := s.bootstrap(c)
mock := mockAvailabilityZoneAllocations{
err: errors.New("AvailabilityZoneAllocations failed"),
}
s.PatchValue(&availabilityZoneAllocations, mock.AvailabilityZoneAllocations)
_, _, _, err := testing.StartInstance(env, "1")
c.Assert(err, gc.ErrorMatches, "cannot get availability zone allocations: AvailabilityZoneAllocations failed")
mock.err = nil
dgErr := errors.New("DistributionGroup failed")
params := environs.StartInstanceParams{
DistributionGroup: func() ([]instance.Id, error) {
return nil, dgErr
},
}
_, err = testing.StartInstanceWithParams(env, "1", params)
c.Assert(err, gc.ErrorMatches, "cannot get distribution group: DistributionGroup failed")
}
开发者ID:xushiwei,项目名称:juju,代码行数:19,代码来源:environ_whitebox_test.go
示例18: TestStartInstanceDistributionErrors
func (t *localServerSuite) TestStartInstanceDistributionErrors(c *gc.C) {
env := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
mock := mockAvailabilityZoneAllocations{
err: fmt.Errorf("AvailabilityZoneAllocations failed"),
}
t.PatchValue(ec2.AvailabilityZoneAllocations, mock.AvailabilityZoneAllocations)
_, _, _, err = testing.StartInstance(env, "1")
c.Assert(errors.Cause(err), gc.Equals, mock.err)
mock.err = nil
dgErr := fmt.Errorf("DistributionGroup failed")
params := environs.StartInstanceParams{
DistributionGroup: func() ([]instance.Id, error) {
return nil, dgErr
},
}
_, err = testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(errors.Cause(err), gc.Equals, dgErr)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:22,代码来源:local_test.go
示例19: TestStartInstanceDistributionErrors
func (t *localServerSuite) TestStartInstanceDistributionErrors(c *gc.C) {
env := t.Prepare(c)
envtesting.UploadFakeTools(c, env.Storage())
err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
mock := mockBestAvailabilityZoneAllocations{
err: fmt.Errorf("BestAvailabilityZoneAllocations failed"),
}
t.PatchValue(openstack.BestAvailabilityZoneAllocations, mock.BestAvailabilityZoneAllocations)
_, _, _, err = testing.StartInstance(env, "1")
c.Assert(err, gc.Equals, mock.err)
mock.err = nil
dgErr := fmt.Errorf("DistributionGroup failed")
params := environs.StartInstanceParams{
DistributionGroup: func() ([]instance.Id, error) {
return nil, dgErr
},
}
_, _, _, err = testing.StartInstanceWithParams(env, "1", params, nil)
c.Assert(err, gc.Equals, dgErr)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:23,代码来源:local_test.go
示例20: TestStartInstanceDistributionParams
func (t *localServerSuite) TestStartInstanceDistributionParams(c *gc.C) {
env := t.Prepare(c)
envtesting.UploadFakeTools(c, env.Storage())
err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
var mock mockAvailabilityZoneAllocations
t.PatchValue(openstack.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, gc.IsNil)
c.Assert(mock.group, gc.DeepEquals, expectedInstances)
}
开发者ID:klyachin,项目名称:juju,代码行数:24,代码来源:local_test.go
注:本文中的github.com/juju/juju/juju/testing.StartInstanceWithParams函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论