當前位置: 首頁>>代碼示例>>Golang>>正文


Golang warden.Container類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/garden/warden.Container的典型用法代碼示例。如果您正苦於以下問題:Golang Container類的具體用法?Golang Container怎麽用?Golang Container使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Container類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

package lifecycle_test

import (
	"time"

	"github.com/cloudfoundry-incubator/garden/warden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("A container with a grace time", func() {
	var container warden.Container

	BeforeEach(func() {
		err := runner.Stop()
		Expect(err).ToNot(HaveOccurred())

		err = runner.Start("--containerGraceTime", "5s")
		Expect(err).ToNot(HaveOccurred())

		container, err = client.Create(warden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := runner.Stop()
		Expect(err).ToNot(HaveOccurred())

		err = runner.Start()
		Expect(err).ToNot(HaveOccurred())
	})
開發者ID:vito,項目名稱:warden-linux,代碼行數:31,代碼來源:grace_time_test.go

示例2:

package lifecycle_test

import (
	"github.com/cloudfoundry-incubator/garden/warden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("A container with properties", func() {
	var container warden.Container

	BeforeEach(func() {
		var err error

		container, err = client.Create(warden.ContainerSpec{
			Properties: warden.Properties{
				"foo": "bar",
				"a":   "b",
			},
		})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := client.Destroy(container.Handle())
		Expect(err).ToNot(HaveOccurred())
	})

	Describe("when reporting the container's info", func() {
		It("includes the properties", func() {
			info, err := container.Info()
開發者ID:vito,項目名稱:warden-linux,代碼行數:31,代碼來源:properties_test.go

示例3:

import (
	"fmt"
	"runtime"
	"sync/atomic"
	"time"

	"github.com/cloudfoundry-incubator/garden/warden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("The Warden server", func() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	Describe("streaming output from a chatty job", func() {
		var container warden.Container

		BeforeEach(func() {
			var err error

			container, err = client.Create(warden.ContainerSpec{})
			Expect(err).ToNot(HaveOccurred())
		})

		streamCounts := []int{0}

		for i := 1; i <= 128; i *= 2 {
			streamCounts = append(streamCounts, i)
		}

		for _, streams := range streamCounts {
開發者ID:vito,項目名稱:warden-linux,代碼行數:31,代碼來源:stream_measure_test.go

示例4: reapContainer

func (s *WardenServer) reapContainer(container warden.Container) {
	log.Printf("reaping %s (idle for %s)\n", container.Handle(), s.backend.GraceTime(container))
	s.backend.Destroy(container.Handle())
}
開發者ID:vito,項目名稱:warden-docker,代碼行數:4,代碼來源:server.go

示例5:

	"compress/gzip"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"time"

	"github.com/cloudfoundry-incubator/garden/warden"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	archiver "github.com/pivotal-golang/archiver/extractor/test_helper"
)

var _ = Describe("Creating a container", func() {
	var container warden.Container

	BeforeEach(func() {
		var err error

		container, err = client.Create(warden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := client.Destroy(container.Handle())
		Expect(err).ToNot(HaveOccurred())
	})

	It("sources /etc/seed", func() {
		_, stream, err := container.Run(warden.ProcessSpec{
開發者ID:vito,項目名稱:warden-linux,代碼行數:31,代碼來源:lifecycle_test.go

示例6:

			_, err := linuxBackend.Create(warden.ContainerSpec{})
			Expect(err).To(HaveOccurred())

			containers, err := linuxBackend.Containers(nil)
			Expect(err).ToNot(HaveOccurred())

			Expect(containers).To(BeEmpty())
		})
	})
})

var _ = Describe("Destroy", func() {
	var fakeContainerPool *fake_container_pool.FakeContainerPool
	var linuxBackend *linux_backend.LinuxBackend

	var container warden.Container

	BeforeEach(func() {
		fakeContainerPool = fake_container_pool.New()
		fakeSystemInfo := fake_system_info.NewFakeProvider()
		linuxBackend = linux_backend.New(fakeContainerPool, fakeSystemInfo, "")

		newContainer, err := linuxBackend.Create(warden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())

		container = newContainer
	})

	It("removes the given container from the pool", func() {
		Expect(fakeContainerPool.DestroyedContainers).To(BeEmpty())
開發者ID:vito,項目名稱:warden-docker,代碼行數:30,代碼來源:linux_backend_test.go

示例7:

	"errors"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"io"
	"io/ioutil"
	"strings"

	. "github.com/cloudfoundry-incubator/garden/client"
	"github.com/cloudfoundry-incubator/garden/client/connection"
	"github.com/cloudfoundry-incubator/garden/client/connection/fake_connection"
	"github.com/cloudfoundry-incubator/garden/warden"
)

var _ = Describe("Container", func() {
	var connectionProvider ConnectionProvider
	var container warden.Container

	var fakeConnection *fake_connection.FakeConnection

	BeforeEach(func() {
		fakeConnection = fake_connection.New()

		connectionProvider = &FakeConnectionProvider{
			Connection: fakeConnection,
		}
	})

	JustBeforeEach(func() {
		var err error

		client := New(connectionProvider)
開發者ID:vito,項目名稱:warden-linux,代碼行數:31,代碼來源:container_test.go

示例8:

	"strings"

	"github.com/cloudfoundry-incubator/garden/warden"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Placing limits on containers", func() {
	Describe("denying access to network ranges", func() {
		var (
			blockedListener   warden.Container
			blockedListenerIP string

			unblockedListener   warden.Container
			unblockedListenerIP string

			allowedListener   warden.Container
			allowedListenerIP string

			sender warden.Container
		)

		BeforeEach(func() {
			var err error

			// create a listener to which we deny network access
			blockedListener, err = client.Create(warden.ContainerSpec{})
			Expect(err).ToNot(HaveOccurred())
			info, err := blockedListener.Info()
			Expect(err).ToNot(HaveOccurred())
			blockedListenerIP = info.ContainerIP
開發者ID:vito,項目名稱:warden-linux,代碼行數:32,代碼來源:security_test.go

示例9:

			stdout += string(payload.Data)

		case warden.ProcessStreamSourceStderr:
			stderr += string(payload.Data)
		}

		if payload.ExitStatus != nil {
			exitStatus = *payload.ExitStatus
		}
	}

	return stdout, stderr, exitStatus
}

var _ = Describe("Through a restart", func() {
	var container warden.Container

	BeforeEach(func() {
		var err error

		container, err = client.Create(warden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := runner.Stop()
		Expect(err).ToNot(HaveOccurred())

		err = runner.DestroyContainers()
		Expect(err).ToNot(HaveOccurred())
開發者ID:vito,項目名稱:warden-linux,代碼行數:30,代碼來源:drain_test.go


注:本文中的github.com/cloudfoundry-incubator/garden/warden.Container類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。