func TestWinswPipe(t *testing.T) {
	BeforeSuite(func() {
		var err error
		pathToPipeCLI, err = gexec.Build("github.com/cloudfoundry/bosh-agent/jobsupervisor/pipe")
		Expect(err).To(Succeed())

		GoSequencePath, err = gexec.Build("./testdata/gosequence/gosequence.go")
		Expect(err).To(Succeed())
		PrintPidsPath, err = gexec.Build("./testdata/printpids/printpids.go")
		Expect(err).To(Succeed())
		ExitRunnerPath, err = gexec.Build("./testdata/exitrunner/exitrunner.go")
		Expect(err).To(Succeed())
	})

	BeforeEach(func() {
		if runtime.GOOS == "windows" {
			shell = "powershell"
			echoCmdArgs = []string{shell, "-c", "echo", echoOutput}
			SetDefaultEventuallyTimeout(5 * time.Second)
		} else {
			echoCmdArgs = []string{"echo", echoOutput}
			shell = "bash"
		}
	})

	AfterSuite(func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "WinswPipe Suite")
}
func BuildExecutables() {
	var err error
	BmpExec, err = gexec.Build("./../../main/bmp")
	Expect(err).NotTo(HaveOccurred())

	StemcellsExec, err = gexec.Build("./../../main/stemcells")
	Expect(err).NotTo(HaveOccurred())
}
Example #3
0
func startGarden(argv ...string) *runner.RunningGarden {
	gardenBin, err := gexec.Build("github.com/cloudfoundry-incubator/guardian/cmd/guardian")
	Expect(err).NotTo(HaveOccurred())

	iodaemonBin, err := gexec.Build("github.com/cloudfoundry-incubator/guardian/rundmc/iodaemon/cmd/iodaemon")
	Expect(err).NotTo(HaveOccurred())

	return runner.Start(gardenBin, iodaemonBin, argv...)
}
Example #4
0
func CompileTestedExecutables() world.BuiltExecutables {
	var err error

	builtExecutables := world.BuiltExecutables{}

	builtExecutables["garden-linux"], err = gexec.BuildIn(os.Getenv("GARDEN_LINUX_GOPATH"), "github.com/cloudfoundry-incubator/garden-linux", "-race", "-a", "-tags", "daemon")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["auctioneer"], err = gexec.BuildIn(os.Getenv("AUCTIONEER_GOPATH"), "github.com/cloudfoundry-incubator/auctioneer/cmd/auctioneer", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["converger"], err = gexec.BuildIn(os.Getenv("CONVERGER_GOPATH"), "github.com/cloudfoundry-incubator/converger/cmd/converger", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["rep"], err = gexec.BuildIn(os.Getenv("REP_GOPATH"), "github.com/cloudfoundry-incubator/rep/cmd/rep", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["stager"], err = gexec.BuildIn(os.Getenv("STAGER_GOPATH"), "github.com/cloudfoundry-incubator/stager/cmd/stager", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["bbs"], err = gexec.BuildIn(os.Getenv("BBS_GOPATH"), "github.com/cloudfoundry-incubator/bbs/cmd/bbs", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["receptor"], err = gexec.BuildIn(os.Getenv("RECEPTOR_GOPATH"), "github.com/cloudfoundry-incubator/receptor/cmd/receptor", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["nsync-listener"], err = gexec.BuildIn(os.Getenv("NSYNC_GOPATH"), "github.com/cloudfoundry-incubator/nsync/cmd/nsync-listener", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["nsync-bulker"], err = gexec.BuildIn(os.Getenv("NSYNC_GOPATH"), "github.com/cloudfoundry-incubator/nsync/cmd/nsync-bulker", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["file-server"], err = gexec.BuildIn(os.Getenv("FILE_SERVER_GOPATH"), "github.com/cloudfoundry-incubator/file-server/cmd/file-server", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["route-emitter"], err = gexec.BuildIn(os.Getenv("ROUTE_EMITTER_GOPATH"), "github.com/cloudfoundry-incubator/route-emitter/cmd/route-emitter", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["tps-listener"], err = gexec.BuildIn(os.Getenv("TPS_GOPATH"), "github.com/cloudfoundry-incubator/tps/cmd/tps-listener", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["router"], err = gexec.BuildIn(os.Getenv("ROUTER_GOPATH"), "github.com/cloudfoundry/gorouter", "-race")
	Expect(err).NotTo(HaveOccurred())

	builtExecutables["ssh-proxy"], err = gexec.Build("github.com/cloudfoundry-incubator/diego-ssh/cmd/ssh-proxy", "-race")
	Expect(err).NotTo(HaveOccurred())

	os.Setenv("CGO_ENABLED", "0")
	builtExecutables["sshd"], err = gexec.Build("github.com/cloudfoundry-incubator/diego-ssh/cmd/sshd", "-a", "-installsuffix", "static")
	os.Unsetenv("CGO_ENABLED")
	Expect(err).NotTo(HaveOccurred())

	return builtExecutables
}
Example #5
0
func TestGqt(t *testing.T) {
	RegisterFailHandler(Fail)

	SynchronizedBeforeSuite(func() []byte {
		var err error
		bins := make(map[string]string)

		bins["oci_runtime_path"] = os.Getenv("OCI_RUNTIME")
		if bins["oci_runtime_path"] == "" {
			bins["oci_runtime_path"] = defaultRuntime[runtime.GOOS]
		}

		if bins["oci_runtime_path"] != "" {
			bins["garden_bin_path"], err = gexec.Build("github.com/cloudfoundry-incubator/guardian/cmd/guardian", "-tags", "daemon")
			Expect(err).NotTo(HaveOccurred())

			bins["iodaemon_bin_path"], err = gexec.Build("github.com/cloudfoundry-incubator/guardian/rundmc/iodaemon/cmd/iodaemon")
			Expect(err).NotTo(HaveOccurred())

			cmd := exec.Command("make")
			cmd.Dir = "../rundmc/nstar"
			cmd.Stdout = GinkgoWriter
			cmd.Stderr = GinkgoWriter
			Expect(cmd.Run()).To(Succeed())
			bins["nstar_bin_path"] = "../rundmc/nstar/nstar"
		}

		data, err := json.Marshal(bins)
		Expect(err).NotTo(HaveOccurred())

		return data
	}, func(data []byte) {
		bins := make(map[string]string)
		Expect(json.Unmarshal(data, &bins)).To(Succeed())

		ociRuntimeBin = bins["oci_runtime_path"]
		gardenBin = bins["garden_bin_path"]
		iodaemonBin = bins["iodaemon_bin_path"]
		nstarBin = bins["nstar_bin_path"]
	})

	BeforeEach(func() {
		if ociRuntimeBin == "" {
			Skip("No OCI Runtime for Platform: " + runtime.GOOS)
		}
	})

	SetDefaultEventuallyTimeout(5 * time.Second)
	RunSpecs(t, "GQT Suite")
}
func TestSystem(t *testing.T) {
	var beforeSuite struct {
		FakeMounterPath   string
		FakeContainerPath string
		TempDirPath       string
	}

	SynchronizedBeforeSuite(func() []byte {
		var err error
		beforeSuite.FakeMounterPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/containerizer/system/fake_mounter", "-race")
		Expect(err).ToNot(HaveOccurred())

		beforeSuite.FakeContainerPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/containerizer/system/fake_container", "-race")
		Expect(err).ToNot(HaveOccurred())

		beforeSuite.TempDirPath, err = ioutil.TempDir("", "system-tempdir")
		Expect(err).NotTo(HaveOccurred())

		b, err := json.Marshal(beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		return b
	}, func(paths []byte) {
		err := json.Unmarshal(paths, &beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		fakeMounterBin = beforeSuite.FakeMounterPath
		Expect(fakeMounterBin).NotTo(BeEmpty())

		fakeContainerBin = beforeSuite.FakeContainerPath
		Expect(fakeContainerBin).NotTo(BeEmpty())

		tempDirPath = beforeSuite.TempDirPath
		Expect(tempDirPath).NotTo(BeEmpty())
	})

	SynchronizedAfterSuite(func() {
		//noop
	}, func() {
		gexec.CleanupBuildArtifacts()

		// Cleaning up this directoy causes the VM to hang occasionally.
		// Expect(os.RemoveAll(tempDirPath)).To(Succeed())
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "System Suite")
}
func launchExternalHTTPReps() map[string]rep.SimClient {
	repNodeBinary, err := gexec.Build("github.com/cloudfoundry-incubator/auction/simulation/repnode")
	Expect(err).NotTo(HaveOccurred())

	cells := map[string]rep.SimClient{}

	client := &http.Client{
		Timeout: timeout,
	}
	for i := 0; i < numCells; i++ {
		repGuid := cellGuid(i)
		httpAddr := fmt.Sprintf("127.0.0.1:%d", 30000+i)

		serverCmd := exec.Command(
			repNodeBinary,
			"-repGuid", repGuid,
			"-httpAddr", httpAddr,
			"-memoryMB", fmt.Sprintf("%d", repResources.MemoryMB),
			"-diskMB", fmt.Sprintf("%d", repResources.DiskMB),
			"-containers", fmt.Sprintf("%d", repResources.Containers),
			"-stack", linuxStack,
			"-zone", zone(i),
		)

		sess, err := gexec.Start(serverCmd, GinkgoWriter, GinkgoWriter)
		Expect(err).NotTo(HaveOccurred())
		sessionsToTerminate = append(sessionsToTerminate, sess)
		Eventually(sess).Should(gbytes.Say("listening"))

		cells[cellGuid(i)] = rep.NewClient(client, "http://"+httpAddr).(rep.SimClient)
	}

	return cells
}
Example #8
0
func BuildExecutable(sourcePath string) string {
	executable, err := gexec.Build(sourcePath)
	if err != nil {
		log.Fatalf("executable %s could not be built: %s", sourcePath, err)
	}
	return executable
}
func startAgent() *gexec.Session {
	config := &agentconfig.Config{
		DefaultConfPath:     helpers.AssetPath("redis.conf.default"),
		ConfPath:            redisConfPath,
		MonitExecutablePath: helpers.AssetPath("fake_monit"),
		Port:                "9876",
		AuthConfiguration: agentconfig.AuthConfiguration{
			Username: "******",
			Password: "******",
		},
	}

	configFile, err := ioutil.TempFile("", "config.yml")
	Expect(err).ToNot(HaveOccurred())

	encoder := candiedyaml.NewEncoder(configFile)
	err = encoder.Encode(config)
	Ω(err).ShouldNot(HaveOccurred())
	configFile.Close()

	agentPath, err := gexec.Build("github.com/pivotal-cf/cf-redis-broker/cmd/agent")
	Ω(err).ShouldNot(HaveOccurred())

	session, err := gexec.Start(
		exec.Command(agentPath, fmt.Sprintf("-agentConfig=%s", configFile.Name())),
		GinkgoWriter,
		GinkgoWriter,
	)
	Ω(err).ShouldNot(HaveOccurred())

	Expect(helpers.ServiceAvailable(9876)).To(BeTrue())
	return session
}
func TestIntegration(t *testing.T) {
	var beforeSuite struct {
		RabbitMQCeBinPath string
	}

	SynchronizedBeforeSuite(func() []byte {
		var err error

		beforeSuite.RabbitMQCeBinPath, err = gexec.Build("github.com/glestaris/gofigure/integration/rabbitmq_chan_echo")
		Ω(err).ShouldNot(HaveOccurred())

		b, err := json.Marshal(beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		return b
	}, func(data []byte) {
		err := json.Unmarshal(data, &beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		RabbitMQCeBinPath = beforeSuite.RabbitMQCeBinPath
		Expect(RabbitMQCeBinPath).NotTo(BeEmpty())
	})

	SynchronizedAfterSuite(func() {
		//noop
	}, func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Integration Suite")
}
func TestLifecycle(t *testing.T) {
	SynchronizedBeforeSuite(func() []byte {
		shmPath, err := gexec.Build("github.com/cloudfoundry-incubator/garden-linux/integration/lifecycle/shm_test")
		Expect(err).ToNot(HaveOccurred())
		return []byte(shmPath)
	}, func(path []byte) {
		Expect(string(path)).NotTo(BeEmpty())
		shmTestBin = string(path)
	})

	BeforeEach(func() {
		if os.Getenv("GARDEN_TEST_ROOTFS") == "" {
			Skip("GARDEN_TEST_ROOTFS undefined")
		}
	})

	AfterEach(func() {
		err := client.DestroyAndStop()
		Expect(err).NotTo(HaveOccurred())
		client.Cleanup()
	})

	SynchronizedAfterSuite(func() {
		//noop
	}, func() {
		gexec.CleanupBuildArtifacts()
	})

	SetDefaultEventuallyTimeout(5 * time.Second) // CI is sometimes slow

	RegisterFailHandler(Fail)
	RunSpecs(t, "Lifecycle Suite")
}
Example #12
0
func TestExperiment(t *testing.T) {
	RegisterFailHandler(Fail)

	var _ = SynchronizedBeforeSuite(func() []byte {
		var s sbsState

		path, err := gexec.Build(
			"github.com/ice-stuff/clique/cmd/clique-agent",
		)
		Expect(err).NotTo(HaveOccurred())
		s.CliqueAgentBin = path

		c, err := json.Marshal(s)
		Expect(err).NotTo(HaveOccurred())

		return c
	}, func(c []byte) {
		var s sbsState

		Expect(json.Unmarshal(c, &s)).To(Succeed())

		cliqueAgentBin = s.CliqueAgentBin
	})

	var _ = SynchronizedAfterSuite(func() {
	}, func() {
		gexec.CleanupBuildArtifacts()
	})

	RunSpecs(t, "Control script Suite")
}
Example #13
0
func TestProcess_tracker(t *testing.T) {
	var beforeSuite struct {
		IodaemonPath        string
		TestPrintSignalPath string
	}

	SynchronizedBeforeSuite(func() []byte {
		var err error
		beforeSuite.IodaemonPath, err = gexec.Build("github.com/cloudfoundry-incubator/guardian/rundmc/iodaemon/cmd/iodaemon")
		Expect(err).ToNot(HaveOccurred())

		b, err := json.Marshal(beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		return b
	}, func(paths []byte) {
		err := json.Unmarshal(paths, &beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		iodaemonBin = beforeSuite.IodaemonPath
		Expect(iodaemonBin).NotTo(BeEmpty())
	})

	SynchronizedAfterSuite(func() {
		//noop
	}, func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Process Tracker Suite")
}
func buildPipeExe() error {
	pathToPipeCLI, err := gexec.Build("github.com/cloudfoundry/bosh-agent/jobsupervisor/pipe")
	if err != nil {
		return err
	}
	SetPipeExePath(pathToPipeCLI)
	return nil
}
func StartGeneratorWithArgs(args ...string) *gexec.Session {
	generatePath, err := gexec.Build("generate")
	Expect(err).NotTo(HaveOccurred())
	command := exec.Command(generatePath, args...)
	session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
	Expect(err).NotTo(HaveOccurred())
	return session
}
Example #16
0
func Cf(args ...string) *gexec.Session {
	path, err := gexec.Build("github.com/cloudfoundry/cli/main", "-ldflags", "-X github.com/cloudfoundry/cli/cf.Version=6.13.0+abc123")
	Expect(err).NotTo(HaveOccurred())

	session, err := gexec.Start(exec.Command(path, args...), GinkgoWriter, GinkgoWriter)
	Expect(err).NotTo(HaveOccurred())

	return session
}
Example #17
0
func (depot *ContainerDepot) Create() (string, error) {
	containerDir := path.Join(depot.Dir, guid())
	runDir := path.Join(containerDir, "run")
	binDir := path.Join(containerDir, "bin")
	processesDir := path.Join(containerDir, "processes")
	os.MkdirAll(runDir, 0700)
	os.MkdirAll(processesDir, 0700)

	if err := os.MkdirAll(binDir, 0777); err != nil {
		panic(err)
	}

	// FIXME(jz) remove all this hackery and just re-exec
	iodaemonPath, err := gexec.Build("github.com/cloudfoundry-incubator/garden-linux/iodaemon")
	if err != nil {
		return "", fmt.Errorf("build iodaemon: %s", err)
	}

	doshPath, err := gexec.Build("github.com/julz/garden-runc/cmd/dosh")
	if err != nil {
		return "", fmt.Errorf("build dosh: %s", err)
	}

	cp := exec.Command("cp", iodaemonPath, path.Join(binDir, "iodaemon"))
	cp.Stderr = os.Stderr
	if err := cp.Run(); err != nil {
		return "", fmt.Errorf("copy iodaemon: %s", err)
	}

	cp = exec.Command("cp", doshPath, path.Join(binDir, "dosh"))
	cp.Stderr = os.Stderr
	if err := cp.Run(); err != nil {
		return "", fmt.Errorf("copy dosh: %s", err)
	}

	cp = exec.Command("chmod", "u+x", path.Join(binDir, "dosh"))
	cp.Stderr = os.Stderr
	if err := cp.Run(); err != nil {
		return "", fmt.Errorf("chmod dosh: %s", err)
	}

	return containerDir, nil
}
Example #18
0
func setupMetron() *gexec.Session {
	pathToMetronExecutable, err := gexec.Build("metron")
	Expect(err).ShouldNot(HaveOccurred())

	command := exec.Command(pathToMetronExecutable, "--config=fixtures/metron.json", "--debug")
	metronSession, err := gexec.Start(command, gexec.NewPrefixedWriter("[o][metron]", GinkgoWriter), gexec.NewPrefixedWriter("[e][metron]", GinkgoWriter))
	Expect(err).ShouldNot(HaveOccurred())

	return metronSession
}
Example #19
0
func startGarden(argv ...string) garden.Client {
	gardenBin, err := gexec.Build("github.com/cloudfoundry-incubator/guardian/cmd/guardian")
	Expect(err).NotTo(HaveOccurred())

	gardenAddr := fmt.Sprintf("/tmp/garden_%d.sock", GinkgoParallelNode())
	gardenRunner := runner.New("unix", gardenAddr, gardenBin, argv...)
	ifrit.Invoke(gardenRunner)

	return gardenRunner.NewClient()
}
Example #20
0
func CfWith_CF_HOME(cfHome string, args ...string) *gexec.Session {
	path, err := gexec.Build("github.com/cloudfoundry/cli/main", "-ldflags", "-X github.com/cloudfoundry/cli/cf.Version=6.13.0+abc123")
	Expect(err).NotTo(HaveOccurred())

	cmd := exec.Command(path, args...)
	cmd.Env = append(cmd.Env, "CF_HOME="+cfHome)
	session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
	Expect(err).NotTo(HaveOccurred())

	return session
}
func setupMetron() *gexec.Session {
	pathToMetronExecutable, err := gexec.Build("metron")
	Expect(err).ShouldNot(HaveOccurred())

	command := exec.Command(pathToMetronExecutable, "--config=fixtures/metron.json", "--debug")
	metronSession, err := gexec.Start(command, gexec.NewPrefixedWriter("[o][metron]", GinkgoWriter), gexec.NewPrefixedWriter("[e][metron]", GinkgoWriter))
	Expect(err).ShouldNot(HaveOccurred())

	Eventually(metronSession.Buffer).Should(gbytes.Say("Chose protocol"))
	Consistently(metronSession.Exited).ShouldNot(BeClosed())

	return metronSession
}
func TestContainerDeamon(t *testing.T) {
	var beforeSuite struct {
		WshPath         string
		ProcStarterPath string
	}

	SynchronizedBeforeSuite(func() []byte {
		var err error
		beforeSuite.WshPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/container_daemon/wsh", "-race")
		Expect(err).ToNot(HaveOccurred())

		beforeSuite.ProcStarterPath, err = gexec.Build("github.com/cloudfoundry-incubator/garden-linux/container_daemon/proc_starter", "-race")
		Expect(err).ToNot(HaveOccurred())

		b, err := json.Marshal(beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		return b
	}, func(paths []byte) {
		err := json.Unmarshal(paths, &beforeSuite)
		Expect(err).ToNot(HaveOccurred())

		wshBin = beforeSuite.WshPath
		Expect(wshBin).NotTo(BeNil())

		procStarterBin = beforeSuite.ProcStarterPath
		Expect(procStarterBin).NotTo(BeNil())
	})

	SynchronizedAfterSuite(func() {
		//noop
	}, func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "ContainerDeamon Suite")
}
Example #23
0
func TestGexec(t *testing.T) {
	BeforeSuite(func() {
		var err error
		fireflyPath, err = gexec.Build("./_fixture/firefly")
		Ω(err).ShouldNot(HaveOccurred())
	})

	AfterSuite(func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Gexec Suite")
}
func TestNocs(t *testing.T) {
	RegisterFailHandler(Fail)

	SynchronizedBeforeSuite(func() []byte {
		nocsPath, err := gexec.Build("github.com/cloudfoundry-incubator/nocs")
		Expect(err).ToNot(HaveOccurred())
		return []byte(nocsPath)
	}, func(path []byte) {
		Expect(string(path)).NotTo(BeEmpty())
		nocsBin = string(path)
	})

	RunSpecs(t, "nOCS Suite")
}
Example #25
0
func Test(t *testing.T) {
	BeforeSuite(func() {
		var err error
		spiff, err = gexec.Build("github.com/cloudfoundry-incubator/spiff")
		Ω(err).ShouldNot(HaveOccurred())
	})

	AfterSuite(func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Executable")
}
func TestSteganogify(t *testing.T) {

	BeforeSuite(func() {
		var err error
		steganogifyPath, err = gexec.Build("github.com/topherbullock/steganogify")
		Expect(err).ShouldNot(HaveOccurred())
	})

	AfterSuite(func() {
		gexec.CleanupBuildArtifacts()
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Steganogify Suite")
}
Example #27
0
func GoServerApp() []archive_helper.ArchiveFile {
	serverPath, err := gexec.Build("github.com/cloudfoundry-incubator/inigo/fixtures/go-server")
	Expect(err).NotTo(HaveOccurred())

	contents, err := ioutil.ReadFile(serverPath)
	Expect(err).NotTo(HaveOccurred())
	return []archive_helper.ArchiveFile{
		{
			Name: "go-server",
			Body: string(contents),
		}, {
			Name: "staging_info.yml",
			Body: `detected_buildpack: Doesn't Matter
start_command: go-server`,
		},
	}
}
Example #28
0
func startAuctioneers(numAuctioneers int) {
	auctioneerNodeBinary, err := gexec.Build("github.com/onsi/auction/auctioneernode")
	Ω(err).ShouldNot(HaveOccurred())

	for i := 0; i < numAuctioneers; i++ {
		auctioneerCmd := exec.Command(
			auctioneerNodeBinary,
			"-natsAddr", fmt.Sprintf("127.0.0.1:%d", natsPort),
			"-timeout", fmt.Sprintf("%s", timeout),
		)

		sess, err := gexec.Start(auctioneerCmd, GinkgoWriter, GinkgoWriter)
		Ω(err).ShouldNot(HaveOccurred())
		Eventually(sess).Should(gbytes.Say("auctioneering"))
		sessionsToTerminate = append(sessionsToTerminate, sess)
	}
}
func setupMetron() *gexec.Session {
	pathToMetronExecutable, err := gexec.Build("metron")
	Expect(err).ShouldNot(HaveOccurred())

	command := exec.Command(pathToMetronExecutable, "--config=fixtures/metron.json", "--debug")
	metronSession, err := gexec.Start(command, gexec.NewPrefixedWriter("[o][metron]", GinkgoWriter), gexec.NewPrefixedWriter("[e][metron]", GinkgoWriter))
	Expect(err).ShouldNot(HaveOccurred())

	localIPAddress, _ := localip.LocalIP()

	// wait for server to be up
	Eventually(func() error {
		_, err := http.Get("http://" + localIPAddress + ":1234")
		return err
	}, 3).ShouldNot(HaveOccurred())

	return metronSession
}
Example #30
0
func CfWithIo(command string, args string) *gexec.Session {
	path, err := gexec.Build("github.com/cloudfoundry/cli/main", "-ldflags", "-X github.com/cloudfoundry/cli/cf.Version=6.13.0+abc123")
	Expect(err).NotTo(HaveOccurred())

	cmd := exec.Command(path, command)

	stdin, err := cmd.StdinPipe()
	Expect(err).ToNot(HaveOccurred())

	buffer := bufio.NewWriter(stdin)
	buffer.WriteString(args)
	buffer.Flush()

	session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
	Expect(err).NotTo(HaveOccurred())

	return session
}