当前位置: 首页>>代码示例>>Golang>>正文


Golang fake_command_runner.FakeCommandRunner类代码示例

本文整理汇总了Golang中github.com/cloudfoundry/gunk/command_runner/fake_command_runner.FakeCommandRunner的典型用法代码示例。如果您正苦于以下问题:Golang FakeCommandRunner类的具体用法?Golang FakeCommandRunner怎么用?Golang FakeCommandRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FakeCommandRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

	"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_network_statisticser"
	"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_quota_manager"
	"github.com/cloudfoundry-incubator/garden-linux/linux_container/fake_watcher"
	networkFakes "github.com/cloudfoundry-incubator/garden-linux/network/fakes"
	"github.com/cloudfoundry-incubator/garden-linux/port_pool/fake_port_pool"
	"github.com/cloudfoundry-incubator/garden-linux/process_tracker/fake_process_tracker"
	wfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)

var _ = Describe("Linux containers", func() {
	var fakeCgroups *fake_cgroups_manager.FakeCgroupsManager
	var fakeQuotaManager *fake_quota_manager.FakeQuotaManager
	var fakeBandwidthManager *fake_bandwidth_manager.FakeBandwidthManager
	var fakeRunner *fake_command_runner.FakeCommandRunner
	var containerResources *linux_backend.Resources
	var container *linux_container.LinuxContainer
	var fakePortPool *fake_port_pool.FakePortPool
	var fakeProcessTracker *fake_process_tracker.FakeProcessTracker
	var fakeFilter *networkFakes.FakeFilter
	var fakeOomWatcher *fake_watcher.FakeWatcher
	var containerDir string
	var containerProps map[string]string

	BeforeEach(func() {
		fakeRunner = fake_command_runner.New()

		fakeCgroups = fake_cgroups_manager.New("/cgroups", "some-id")

		fakeQuotaManager = new(fake_quota_manager.FakeQuotaManager)
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:31,代码来源:linux_container_test.go

示例2:

	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"

	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/ginkgo/extensions/table"
	. "github.com/onsi/gomega"
)

var _ = Describe("Create", func() {
	var (
		fakeRunner *fake_command_runner.FakeCommandRunner
		creator    *iptables.InstanceChainCreator
		bridgeName string
		ip         net.IP
		network    *net.IPNet
		logger     lager.Logger
		handle     string
	)

	BeforeEach(func() {
		var err error

		fakeRunner = fake_command_runner.New()
		logger = lagertest.NewTestLogger("test")

		handle = "some-handle-that-is-longer-than-29-characters-long"
		bridgeName = "some-bridge"
		ip, network, err = net.ParseCIDR("1.2.3.4/28")
		Expect(err).NotTo(HaveOccurred())
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:instance_chain_creator_test.go

示例3:

	"code.cloudfoundry.org/lager/lagertest"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RunAndLog", func() {
	const logs string = `time="2016-03-02T13:56:38Z" level=warning msg="signal: potato"
				time="2016-03-02T13:56:38Z" level=error msg="fork/exec POTATO: no such file or directory"
				time="2016-03-02T13:56:38Z" level=fatal msg="Container start failed: [10] System error: fork/exec POTATO: no such file or directory"`

	var (
		commandRunner *fake_command_runner.FakeCommandRunner
		logRunner     runrunc.RuncCmdRunner
		logger        *lagertest.TestLogger

		logFile *os.File
	)

	BeforeEach(func() {
		commandRunner = fake_command_runner.New()
		logger = lagertest.NewTestLogger("test")

		var err error
		logFile, err = ioutil.TempFile("", "runandlog")
		Expect(err).NotTo(HaveOccurred())

		logRunner = runrunc.NewLogRunner(commandRunner, func() (*os.File, error) {
			return logFile, nil
		})
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:log_test.go

示例4:

	"io"
	"io/ioutil"
	"os/exec"

	"code.cloudfoundry.org/guardian/rundmc"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("Nstar", func() {
	var (
		fakeCommandRunner *fake_command_runner.FakeCommandRunner
		nstar             rundmc.NstarRunner
	)

	BeforeEach(func() {
		fakeCommandRunner = fake_command_runner.New()
		nstar = rundmc.NewNstarRunner(
			"path-to-nstar",
			"path-to-tar",
			fakeCommandRunner,
		)
	})

	Describe("StreamIn", func() {
		var someStream io.Reader

		BeforeEach(func() {
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:nstar_test.go

示例5:

	"code.cloudfoundry.org/lager/lagertest"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"code.cloudfoundry.org/garden"
	"code.cloudfoundry.org/guardian/rundmc/runrunc"
	fakes "code.cloudfoundry.org/guardian/rundmc/runrunc/runruncfakes"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)

var _ = Describe("Stats", func() {
	var (
		commandRunner *fake_command_runner.FakeCommandRunner
		runner        *fakes.FakeRuncCmdRunner
		runcBinary    *fakes.FakeRuncBinary
		logger        *lagertest.TestLogger

		statser *runrunc.Statser
	)

	BeforeEach(func() {
		runcBinary = new(fakes.FakeRuncBinary)
		commandRunner = fake_command_runner.New()
		runner = new(fakes.FakeRuncCmdRunner)
		logger = lagertest.NewTestLogger("test")

		statser = runrunc.NewStatser(runner, runcBinary)

		runcBinary.StatsCommandStub = func(id string, logFile string) *exec.Cmd {
			return exec.Command("funC-stats", "--log", logFile, id)
		}
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:stats_test.go

示例6:

	"os/exec"

	"code.cloudfoundry.org/lager/lagertest"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"code.cloudfoundry.org/guardian/rundmc/runrunc"
	fakes "code.cloudfoundry.org/guardian/rundmc/runrunc/runruncfakes"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
)

var _ = Describe("Watching for Events", func() {
	var (
		commandRunner *fake_command_runner.FakeCommandRunner
		runcBinary    *fakes.FakeRuncBinary
		logger        *lagertest.TestLogger

		runner *runrunc.OomWatcher
	)

	BeforeEach(func() {
		runcBinary = new(fakes.FakeRuncBinary)
		commandRunner = fake_command_runner.New()
		logger = lagertest.NewTestLogger("test")

		runner = runrunc.NewOomWatcher(commandRunner, runcBinary)

		runcBinary.EventsCommandStub = func(handle string) *exec.Cmd {
			return exec.Command("funC-events", "events", handle)
		}
	})
开发者ID:cloudfoundry,项目名称:guardian,代码行数:31,代码来源:watch_test.go

示例7:

	"errors"
	"io/ioutil"
	"os"
	"os/exec"
	"path/filepath"

	"github.com/cloudfoundry-incubator/garden-linux/containerizer"

	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("ShellRunnerStep", func() {
	var runner *fake_command_runner.FakeCommandRunner

	BeforeEach(func() {
		runner = fake_command_runner.New()
	})

	Context("when a given path exists", func() {
		var path string

		BeforeEach(func() {
			tmpdir, err := ioutil.TempDir("", "")
			Expect(err).ToNot(HaveOccurred())

			path = filepath.Join(tmpdir, "whatever.sh")
			Expect(ioutil.WriteFile(path, []byte(""), 0700)).To(Succeed())
		})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:shell_runner_step_test.go

示例8:

import (
	"errors"
	"fmt"
	"os/exec"

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

	"github.com/cloudfoundry-incubator/garden/warden"
	"github.com/cloudfoundry-incubator/warden-linux/linux_backend/bandwidth_manager"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)

var fakeRunner *fake_command_runner.FakeCommandRunner
var bandwidthManager *bandwidth_manager.ContainerBandwidthManager

var _ = Describe("setting rate limits", func() {
	BeforeEach(func() {
		fakeRunner = fake_command_runner.New()
		bandwidthManager = bandwidth_manager.New("/depot/some-id", "some-id", fakeRunner)
	})

	It("executes net_rate.sh with the appropriate environment", func() {
		limits := warden.BandwidthLimits{
			RateInBytesPerSecond:      128,
			BurstRateInBytesPerSecond: 256,
		}

		err := bandwidthManager.SetLimits(limits)
开发者ID:vito,项目名称:warden-docker,代码行数:30,代码来源:bandwidth_manager_test.go

示例9:

	"github.com/cloudfoundry-incubator/garden-linux/layercake/fake_cake"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("BtrfsCleaningCake", func() {
	var (
		cleaner              *layercake.BtrfsCleaningCake
		runner               *fake_command_runner.FakeCommandRunner
		fakeCake             *fake_cake.FakeCake
		listSubvolumesOutput string
		layerId              = layercake.DockerImageID("the-layer")
		btrfsMountPoint      = "/absolute/btrfs_mount"

		listSubVolumeErr error
		graphDriverErr   error

		removedDirectories []string
	)

	BeforeEach(func() {
		graphDriverErr = nil
		listSubVolumeErr = nil
		removedDirectories = []string{}

		runner = fake_command_runner.New()
		fakeCake = new(fake_cake.FakeCake)
		cleaner = &layercake.BtrfsCleaningCake{
开发者ID:guanglinlv,项目名称:garden-linux,代码行数:31,代码来源:btrfs_test.go

示例10:

	"net"
	"os/exec"

	"github.com/cloudfoundry-incubator/garden"
	. "github.com/cloudfoundry-incubator/garden-linux/network/iptables"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	"github.com/pivotal-golang/lager/lagertest"

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

var _ = Describe("Iptables", func() {
	Describe("Chain", func() {
		var fakeRunner *fake_command_runner.FakeCommandRunner
		var subject Chain
		var useKernelLogging bool

		JustBeforeEach(func() {
			fakeRunner = fake_command_runner.New()
			subject = NewLoggingChain("foo-bar-baz", useKernelLogging, fakeRunner, lagertest.NewTestLogger("test"))
		})

		Describe("Setup", func() {
			Context("when kernel logging is not enabled", func() {
				It("creates the log chain using iptables", func() {
					Expect(subject.Setup("logPrefix")).To(Succeed())
					Expect(fakeRunner).To(HaveExecutedSerially(
						fake_command_runner.CommandSpec{
							Path: "/sbin/iptables",
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:iptables_test.go

示例11:

	"github.com/cloudfoundry-incubator/garden-linux/process_tracker"
	"github.com/cloudfoundry-incubator/garden-linux/process_tracker/fake_process_tracker"
	wfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
)

var _ = Describe("Linux containers", func() {
	var (
		fakeCgroups          *fake_cgroups_manager.FakeCgroupsManager
		fakeQuotaManager     *fake_quota_manager.FakeQuotaManager
		fakeBandwidthManager *fake_bandwidth_manager.FakeBandwidthManager
		fakeRunner           *fake_command_runner.FakeCommandRunner
		containerResources   *linux_backend.Resources
		container            *linux_container.LinuxContainer
		fakePortPool         *fake_port_pool.FakePortPool
		fakeProcessTracker   *fake_process_tracker.FakeProcessTracker
		fakeFilter           *networkFakes.FakeFilter
		fakeOomWatcher       *fake_watcher.FakeWatcher
		containerDir         string
		containerProps       map[string]string
		containerVersion     semver.Version
		fakeIPTablesManager  *fake_iptables_manager.FakeIPTablesManager
	)

	netOutRule1 := garden.NetOutRule{
		Protocol: garden.ProtocolUDP,
		Networks: []garden.IPRange{garden.IPRangeFromIP(net.ParseIP("1.2.3.4"))},
		Ports:    []garden.PortRange{{Start: 12, End: 24}},
		ICMPs:    &garden.ICMPControl{Type: 3, Code: garden.ICMPControlCode(12)},
		Log:      true,
	}
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:32,代码来源:snapshotting_test.go

示例12:

				BeforeEach(func() {
					cake.PathReturns("", testError)
				})

				It("should return the error", func() {
					Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Equal(testError))
				})

				It("should not unmount the parent", func() {
					Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Equal(testError))
					Expect(cake.UnmountCallCount()).To(Equal(0))
				})
			})

			Context("when getting parent's path succeeds", func() {
				var succeedingRunner *fake_command_runner.FakeCommandRunner

				BeforeEach(func() {
					succeedingRunner = fake_command_runner.New()
					succeedingRunner.WhenRunning(fake_command_runner.CommandSpec{}, func(cmd *exec.Cmd) error {
						return nil
					})
				})

				It("should unmount the parentID", func() {
					aufsCake.Runner = succeedingRunner
					Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Succeed())
					Expect(cake.UnmountCallCount()).To(Equal(1))
					Expect(cake.UnmountArgsForCall(0)).To(Equal(parentID))
				})
开发者ID:cloudfoundry,项目名称:garden-shed,代码行数:30,代码来源:aufs_test.go

示例13:

	"errors"
	"fmt"
	"os"
	"os/exec"

	"code.cloudfoundry.org/guardian/kawasaki/iptables"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Setup", func() {
	var (
		fakeRunner                 *fake_command_runner.FakeCommandRunner
		denyNetworks               []string
		destroyContainersOnStartup bool
		starter                    *iptables.Starter
	)

	BeforeEach(func() {
		fakeRunner = fake_command_runner.New()
		destroyContainersOnStartup = false
	})

	JustBeforeEach(func() {
		fakeLocksmith := NewFakeLocksmith()
		starter = iptables.NewStarter(
			iptables.New("/sbin/iptables", "/sbin/iptables-restore", fakeRunner, fakeLocksmith, "prefix-"),
			true,
			"the-nic-prefix",
			denyNetworks,
开发者ID:cloudfoundry,项目名称:guardian,代码行数:32,代码来源:global_chains_test.go

示例14:

	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"

	"os"

	"net"

	networkFakes "github.com/cloudfoundry-incubator/garden-linux/network/fakes"
	"github.com/cloudfoundry-incubator/garden-linux/process"
	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Hooks", func() {
	var hooks hook.HookSet
	var fakeRunner *fake_command_runner.FakeCommandRunner
	var config process.Env
	var fakeNetworkConfigurer *networkFakes.FakeConfigurer

	BeforeEach(func() {
		hooks = make(hook.HookSet)
		fakeRunner = fake_command_runner.New()
		config = process.Env{
			"id":                      "someID",
			"network_cidr":            "1.2.3.4/8",
			"container_iface_mtu":     "5000",
			"network_container_ip":    "1.6.6.6",
			"network_host_ip":         "1.2.3.5",
			"network_host_iface":      "hostIfc",
			"network_container_iface": "containerIfc",
			"bridge_iface":            "bridgeName",
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:hooks_test.go

示例15:

	"path/filepath"

	"github.com/cloudfoundry-incubator/guardian/kawasaki"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"

	. "github.com/cloudfoundry/gunk/command_runner/fake_command_runner/matchers"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("NetnsMgr", func() {
	var (
		fakeRunner *fake_command_runner.FakeCommandRunner
		netnsDir   string
		mgr        kawasaki.NetnsMgr
		logger     lager.Logger
	)

	BeforeEach(func() {
		netnsDir = tmpDir()
		logger = lagertest.NewTestLogger("test")
	})

	JustBeforeEach(func() {
		fakeRunner = fake_command_runner.New()
		mgr = kawasaki.NewManager(fakeRunner, netnsDir)
	})

	AfterEach(func() {
		os.RemoveAll(netnsDir)
开发者ID:digideskio,项目名称:guardian,代码行数:32,代码来源:netnsmgr_test.go


注:本文中的github.com/cloudfoundry/gunk/command_runner/fake_command_runner.FakeCommandRunner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。