本文整理匯總了Golang中github.com/cloudfoundry-incubator/guardian/gqt/runner.RunningGarden.Create方法的典型用法代碼示例。如果您正苦於以下問題:Golang RunningGarden.Create方法的具體用法?Golang RunningGarden.Create怎麽用?Golang RunningGarden.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/guardian/gqt/runner.RunningGarden
的用法示例。
在下文中一共展示了RunningGarden.Create方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
. "github.com/onsi/gomega"
)
var _ = Describe("Properties", func() {
var (
client *runner.RunningGarden
container garden.Container
props garden.Properties
)
BeforeEach(func() {
var err error
client = startGarden()
props = garden.Properties{"somename": "somevalue"}
container, err = client.Create(garden.ContainerSpec{
Properties: props,
})
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
Expect(client.DestroyAndStop()).To(Succeed())
})
It("can get properties", func() {
properties, err := container.Properties()
Expect(err).NotTo(HaveOccurred())
Expect(properties).To(HaveKeyWithValue("somename", "somevalue"))
})
It("can set a single property", func() {
示例2:
subnet string
args []string
)
BeforeEach(func() {
args = []string{}
subnet = fmt.Sprintf("192.168.%d.0/24", 12+GinkgoParallelNode())
})
JustBeforeEach(func() {
var err error
client = startGarden(args...)
container, err = client.Create(garden.ContainerSpec{
Network: subnet,
})
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
Expect(client.DestroyAndStop()).To(Succeed())
})
It("should have a loopback interface", func() {
buffer := gbytes.NewBuffer()
proc, err := container.Run(
garden.ProcessSpec{
Path: "ifconfig",
User: "root",
}, garden.ProcessIO{Stdout: io.MultiWriter(GinkgoWriter, buffer), Stderr: GinkgoWriter},
示例3:
})
JustBeforeEach(func() {
Expect(client.Destroy(container.Handle())).To(Succeed())
})
Context("when running a process", func() {
var (
process garden.Process
initProcPid int
)
BeforeEach(func() {
var err error
container, err = client.Create(garden.ContainerSpec{})
Expect(err).NotTo(HaveOccurred())
initProcPid = initProcessPID(container.Handle())
process, err = container.Run(garden.ProcessSpec{
Path: "/bin/sh",
Args: []string{
"-c", "read x",
},
}, ginkgoIO)
Expect(err).NotTo(HaveOccurred())
})
It("should kill the containers init process", func() {
var killExitCode = func() int {
示例4:
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/types"
)
var _ = Describe("Run", func() {
var client *runner.RunningGarden
AfterEach(func() {
Expect(client.DestroyAndStop()).To(Succeed())
})
DescribeTable("running a process",
func(spec garden.ProcessSpec, matchers ...func(actual interface{})) {
client = startGarden()
container, err := client.Create(garden.ContainerSpec{})
Expect(err).NotTo(HaveOccurred())
out := gbytes.NewBuffer()
proc, err := container.Run(
spec,
garden.ProcessIO{
Stdout: io.MultiWriter(GinkgoWriter, out),
Stderr: io.MultiWriter(GinkgoWriter, out),
})
Expect(err).NotTo(HaveOccurred())
exitCode, err := proc.Wait()
Expect(err).NotTo(HaveOccurred())
for _, m := range matchers {
示例5:
. "github.com/onsi/gomega"
archiver "github.com/pivotal-golang/archiver/extractor/test_helper"
)
var _ = Describe("Streaming", func() {
var (
client *runner.RunningGarden
container garden.Container
)
BeforeEach(func() {
var err error
client = startGarden()
container, err = client.Create(garden.ContainerSpec{})
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
Expect(client.DestroyAndStop()).To(Succeed())
})
Describe("StreamIn", func() {
var tarStream io.Reader
BeforeEach(func() {
tmpdir, err := ioutil.TempDir("", "some-temp-dir-parent")
Expect(err).ToNot(HaveOccurred())
tgzPath := filepath.Join(tmpdir, "some.tgz")
示例6:
)
BeforeEach(func() {
client = startGarden()
})
AfterEach(func() {
Expect(client.DestroyAndStop()).To(Succeed())
})
Context("after creating a container without a specified handle", func() {
var initProcPid int
BeforeEach(func() {
var err error
container, err = client.Create(garden.ContainerSpec{})
Expect(err).NotTo(HaveOccurred())
initProcPid = initProcessPID(container.Handle())
})
It("should create a depot subdirectory based on the container handle", func() {
Expect(container.Handle()).NotTo(BeEmpty())
Expect(filepath.Join(client.DepotDir, container.Handle())).To(BeADirectory())
Expect(filepath.Join(client.DepotDir, container.Handle(), "config.json")).To(BeARegularFile())
})
It("should lookup the right container", func() {
lookupContainer, lookupError := client.Lookup(container.Handle())
Expect(lookupError).NotTo(HaveOccurred())