本文整理汇总了Golang中github.com/juju/juju/container/testing.CreateContainer函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateContainer函数的具体用法?Golang CreateContainer怎么用?Golang CreateContainer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateContainer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestCreateContainerEvents
func (s *LxcSuite) TestCreateContainerEvents(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
id := string(instance.Id())
s.AssertEvent(c, <-s.events, mock.Created, id)
s.AssertEvent(c, <-s.events, mock.Started, id)
}
开发者ID:kapilt,项目名称:juju,代码行数:7,代码来源:lxc_test.go
示例2: TestDestroyContainerRemovesAutostartLink
func (s *LxcSuite) TestDestroyContainerRemovesAutostartLink(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
err := manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
autostartLink := lxc.RestartSymlink(string(instance.Id()))
c.Assert(autostartLink, jc.SymlinkDoesNotExist)
}
开发者ID:kapilt,项目名称:juju,代码行数:8,代码来源:lxc_test.go
示例3: TestDestroyContainerNoRestartDir
func (s *LxcSuite) TestDestroyContainerNoRestartDir(c *gc.C) {
err := os.Remove(s.RestartDir)
c.Assert(err, gc.IsNil)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
err = manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
}
开发者ID:kapilt,项目名称:juju,代码行数:9,代码来源:lxc_test.go
示例4: TestListContainers
func (s *LxcSuite) TestListContainers(c *gc.C) {
foo := s.makeManager(c, "foo")
bar := s.makeManager(c, "bar")
foo1 := containertesting.CreateContainer(c, foo, "1/lxc/0")
foo2 := containertesting.CreateContainer(c, foo, "1/lxc/1")
foo3 := containertesting.CreateContainer(c, foo, "1/lxc/2")
bar1 := containertesting.CreateContainer(c, bar, "1/lxc/0")
bar2 := containertesting.CreateContainer(c, bar, "1/lxc/1")
result, err := foo.ListContainers()
c.Assert(err, gc.IsNil)
instancetest.MatchInstances(c, result, foo1, foo2, foo3)
result, err = bar.ListContainers()
c.Assert(err, gc.IsNil)
instancetest.MatchInstances(c, result, bar1, bar2)
}
开发者ID:kapilt,项目名称:juju,代码行数:19,代码来源:lxc_test.go
示例5: TestCreateContainerEventsWithCloneExistingTemplate
func (s *LxcSuite) TestCreateContainerEventsWithCloneExistingTemplate(c *gc.C) {
s.createTemplate(c)
s.PatchValue(&s.useClone, true)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
name := string(instance.Id())
cloned := <-s.events
s.AssertEvent(c, cloned, mock.Cloned, "juju-quantal-lxc-template")
c.Assert(cloned.Args, gc.IsNil)
s.AssertEvent(c, <-s.events, mock.Started, name)
}
开发者ID:kapilt,项目名称:juju,代码行数:11,代码来源:lxc_test.go
示例6: TestCreateContainerEventsWithCloneExistingTemplateBtrfs
func (s *LxcSuite) TestCreateContainerEventsWithCloneExistingTemplateBtrfs(c *gc.C) {
s.HookCommandOutput(&lxc.FsCommandOutput, []byte("Type\nbtrfs\n"), nil)
s.createTemplate(c)
s.PatchValue(&s.useClone, true)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
name := string(instance.Id())
cloned := <-s.events
s.AssertEvent(c, cloned, mock.Cloned, "juju-quantal-lxc-template")
c.Assert(cloned.Args, gc.DeepEquals, []string{"--snapshot"})
s.AssertEvent(c, <-s.events, mock.Started, name)
}
开发者ID:makyo,项目名称:juju,代码行数:12,代码来源:lxc_test.go
示例7: TestDestroyContainer
func (s *KVMSuite) TestDestroyContainer(c *gc.C) {
instance := containertesting.CreateContainer(c, s.manager, "1/lxc/0")
err := s.manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
name := string(instance.Id())
// Check that the container dir is no longer in the container dir
c.Assert(filepath.Join(s.ContainerDir, name), jc.DoesNotExist)
// but instead, in the removed container dir
c.Assert(filepath.Join(s.RemovedDir, name), jc.IsDirectory)
}
开发者ID:klyachin,项目名称:juju,代码行数:12,代码来源:kvm_test.go
示例8: TestCreateContainerEventsWithCloneExistingTemplateAUFS
func (s *LxcSuite) TestCreateContainerEventsWithCloneExistingTemplateAUFS(c *gc.C) {
s.createTemplate(c)
s.PatchValue(&s.useClone, true)
s.PatchValue(&s.useAUFS, true)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
name := string(instance.Id())
cloned := <-s.events
s.AssertEvent(c, cloned, mock.Cloned, "juju-quantal-lxc-template")
c.Assert(cloned.Args, gc.DeepEquals, []string{"--snapshot", "--backingstore", "aufs"})
s.AssertEvent(c, <-s.events, mock.Started, name)
}
开发者ID:kapilt,项目名称:juju,代码行数:12,代码来源:lxc_test.go
示例9: TestContainerState
func (s *LxcSuite) TestContainerState(c *gc.C) {
manager := s.makeManager(c, "test")
c.Logf("%#v", manager)
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
// The mock container will be immediately "running".
c.Assert(instance.Status(), gc.Equals, string(golxc.StateRunning))
// DestroyContainer stops and then destroys the container, putting it
// into "unknown" state.
err := manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
c.Assert(instance.Status(), gc.Equals, string(golxc.StateUnknown))
}
开发者ID:kapilt,项目名称:juju,代码行数:14,代码来源:lxc_test.go
示例10: TestCreateContainerWithCloneMountsAndAutostarts
func (s *LxcSuite) TestCreateContainerWithCloneMountsAndAutostarts(c *gc.C) {
s.createTemplate(c)
s.PatchValue(&s.useClone, true)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
name := string(instance.Id())
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, gc.IsNil)
mountLine := "lxc.mount.entry=/var/log/juju var/log/juju none defaults,bind 0 0"
c.Assert(string(config), jc.Contains, mountLine)
c.Assert(autostartLink, jc.IsSymlink)
}
开发者ID:kapilt,项目名称:juju,代码行数:14,代码来源:lxc_test.go
示例11: TestCreateContainerEventsWithClone
func (s *LxcSuite) TestCreateContainerEventsWithClone(c *gc.C) {
s.PatchValue(&s.useClone, true)
// The template containers are created with an upstart job that
// stops them once cloud init has finished. We emulate that here.
template := "juju-series-template"
s.ensureTemplateStopped(template)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
id := string(instance.Id())
s.AssertEvent(c, <-s.events, mock.Created, template)
s.AssertEvent(c, <-s.events, mock.Started, template)
s.AssertEvent(c, <-s.events, mock.Stopped, template)
s.AssertEvent(c, <-s.events, mock.Cloned, template)
s.AssertEvent(c, <-s.events, mock.Started, id)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:15,代码来源:lxc_test.go
示例12: TestContainerState
func (s *LxcSuite) TestContainerState(c *gc.C) {
// TODO(perrito666) refactor state reporting to return a proper state.
manager := s.makeManager(c, "test")
c.Logf("%#v", manager)
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
// The mock container will be immediately "running".
c.Assert(instance.Status().Message, gc.Equals, string(golxc.StateRunning))
// DestroyContainer stops and then destroys the container, putting it
// into "unknown" state.
err := manager.DestroyContainer(instance.Id())
c.Assert(err, jc.ErrorIsNil)
c.Assert(instance.Status().Message, gc.Equals, string(golxc.StateUnknown))
}
开发者ID:makyo,项目名称:juju,代码行数:15,代码来源:lxc_test.go
示例13: TestDestroyContainerNameClash
func (s *LxcSuite) TestDestroyContainerNameClash(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
name := string(instance.Id())
targetDir := filepath.Join(s.RemovedDir, name)
err := os.MkdirAll(targetDir, 0755)
c.Assert(err, gc.IsNil)
err = manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
// Check that the container dir is no longer in the container dir
c.Assert(filepath.Join(s.ContainerDir, name), jc.DoesNotExist)
// but instead, in the removed container dir with a ".1" suffix as there was already a directory there.
c.Assert(filepath.Join(s.RemovedDir, fmt.Sprintf("%s.1", name)), jc.IsDirectory)
}
开发者ID:kapilt,项目名称:juju,代码行数:17,代码来源:lxc_test.go
示例14: TestDestroyContainer
func (s *LxcSuite) TestDestroyContainer(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
err := manager.DestroyContainer(instance.Id())
c.Assert(err, jc.ErrorIsNil)
name := string(instance.Id())
// Check that the container dir is no longer in the container dir
c.Assert(filepath.Join(s.ContainerDir, name), jc.DoesNotExist)
// but instead, in the removed container dir
c.Assert(filepath.Join(s.RemovedDir, name), jc.IsDirectory)
c.Assert(s.loopDeviceManager.detachLoopDevicesArgs, jc.DeepEquals, [][]string{
{filepath.Join(s.LxcDir, name, "rootfs"), "/"},
})
}
开发者ID:makyo,项目名称:juju,代码行数:17,代码来源:lxc_test.go
示例15: TestCreateContainer
func (s *LxcSuite) TestCreateContainer(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
name := string(instance.Id())
// Check our container config files: initial lxc.conf, the
// run-time effective config, and cloud-init userdata.
lxcConfContents, err := ioutil.ReadFile(filepath.Join(s.ContainerDir, name, "lxc.conf"))
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(lxcConfContents), jc.Contains, "lxc.network.link = nic42")
lxcConfContents, err = ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(lxcConfContents), jc.Contains, "lxc.network.link = nic42")
cloudInitFilename := filepath.Join(s.ContainerDir, name, "cloud-init")
data := containertesting.AssertCloudInit(c, cloudInitFilename)
x := make(map[interface{}]interface{})
err = goyaml.Unmarshal(data, &x)
c.Assert(err, jc.ErrorIsNil)
var scripts []string
for _, s := range x["runcmd"].([]interface{}) {
scripts = append(scripts, s.(string))
}
c.Assert(scripts[len(scripts)-3:], gc.DeepEquals, []string{
"start jujud-machine-1-lxc-0",
"rm $bin/tools.tar.gz && rm $bin/juju2.3.4-quantal-amd64.sha256",
"ifconfig",
})
// Check the mount point has been created inside the container.
c.Assert(filepath.Join(s.LxcDir, name, "rootfs", agent.DefaultPaths.LogDir), jc.IsDirectory)
// Check that the config file is linked in the restart dir.
expectedLinkLocation := filepath.Join(s.RestartDir, name+".conf")
expectedTarget := filepath.Join(s.LxcDir, name, "config")
linkInfo, err := os.Lstat(expectedLinkLocation)
c.Assert(err, jc.ErrorIsNil)
c.Assert(linkInfo.Mode()&os.ModeSymlink, gc.Equals, os.ModeSymlink)
location, err := symlink.Read(expectedLinkLocation)
c.Assert(err, jc.ErrorIsNil)
c.Assert(location, gc.Equals, expectedTarget)
}
开发者ID:makyo,项目名称:juju,代码行数:45,代码来源:lxc_test.go
示例16: TestCreateContainerNoRestartDir
func (s *LxcSuite) TestCreateContainerNoRestartDir(c *gc.C) {
err := os.Remove(s.RestartDir)
c.Assert(err, gc.IsNil)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
name := string(instance.Id())
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, gc.IsNil)
expected := `
lxc.network.type = veth
lxc.network.link = nic42
lxc.network.flags = up
lxc.start.auto = 1
lxc.mount.entry=/var/log/juju var/log/juju none defaults,bind 0 0
`
c.Assert(string(config), gc.Equals, expected)
c.Assert(autostartLink, jc.DoesNotExist)
}
开发者ID:kapilt,项目名称:juju,代码行数:20,代码来源:lxc_test.go
示例17: TestDestroyRemovesContainers
func (s *localJujuTestSuite) TestDestroyRemovesContainers(c *gc.C) {
env := s.testBootstrap(c, minimalConfig(c))
s.makeAgentsDir(c, env)
s.PatchValue(local.CheckIfRoot, func() bool { return true })
namespace := env.Config().AllAttrs()["namespace"].(string)
manager, err := lxc.NewContainerManager(container.ManagerConfig{
container.ConfigName: namespace,
container.ConfigLogDir: "logdir",
"use-clone": "false",
}, nil, nil)
c.Assert(err, jc.ErrorIsNil)
machine1 := containertesting.CreateContainer(c, manager, "1")
err = env.Destroy()
c.Assert(err, jc.ErrorIsNil)
container := s.ContainerFactory.New(string(machine1.Id()))
c.Assert(container.IsConstructed(), jc.IsFalse)
}
开发者ID:pmatulis,项目名称:juju,代码行数:21,代码来源:environ_test.go
示例18: TestCreateContainerAutostarts
func (s *LxcSuite) TestCreateContainerAutostarts(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
autostartLink := lxc.RestartSymlink(string(instance.Id()))
c.Assert(autostartLink, jc.IsSymlink)
}
开发者ID:kapilt,项目名称:juju,代码行数:6,代码来源:lxc_test.go
示例19: TestNamedManagerPrefix
func (s *LxcSuite) TestNamedManagerPrefix(c *gc.C) {
manager := s.makeManager(c, "eric")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
c.Assert(string(instance.Id()), gc.Equals, "eric-machine-1-lxc-0")
}
开发者ID:kapilt,项目名称:juju,代码行数:5,代码来源:lxc_test.go
示例20: TestCreateContainer
func (s *KVMSuite) TestCreateContainer(c *gc.C) {
instance := containertesting.CreateContainer(c, s.manager, "1/kvm/0")
name := string(instance.Id())
cloudInitFilename := filepath.Join(s.ContainerDir, name, "cloud-init")
containertesting.AssertCloudInit(c, cloudInitFilename)
}
开发者ID:klyachin,项目名称:juju,代码行数:6,代码来源:kvm_test.go
注:本文中的github.com/juju/juju/container/testing.CreateContainer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论