Skip to content

Commit

Permalink
Don't timeout on commands we need to finish
Browse files Browse the repository at this point in the history
[#149731737]

Signed-off-by: Tiago Scolari <[email protected]>
  • Loading branch information
Craig Furman authored and tscolari committed Dec 18, 2017
1 parent 1922d4f commit 329facb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
cmd/guardian/guardian
cmd/init/init
rundmc/nstar/nstar

*.o

gqt/--action
gqt/down
gqt/up
15 changes: 4 additions & 11 deletions gqt/create_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gqt_test

import (
"bytes"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -646,19 +645,13 @@ func runInContainer(container garden.Container, path string, args []string) {
}

func numOpenSockets(pid int) (num int) {
sess, err := gexec.Start(exec.Command("sh", "-c", fmt.Sprintf("lsof -p %d | grep sock", pid)), GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))

return bytes.Count(sess.Out.Contents(), []byte{'\n'})
stdout := runCommand(exec.Command("sh", "-c", fmt.Sprintf("lsof -p %d | grep sock", pid)))
return strings.Count(stdout, "\n")
}

func numPipes(pid int) (num int) {
sess, err := gexec.Start(exec.Command("sh", "-c", fmt.Sprintf("lsof -p %d | grep pipe", pid)), GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
Eventually(sess).Should(gexec.Exit(0))

return bytes.Count(sess.Out.Contents(), []byte{'\n'})
stdout := runCommand(exec.Command("sh", "-c", fmt.Sprintf("lsof -p %d | grep pipe", pid)))
return strings.Count(stdout, "\n")
}

func findCgroupPath(pid int, cgroupToFind string) string {
Expand Down
10 changes: 6 additions & 4 deletions gqt/gqt_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ func initGrootStore(grootBin, storePath string, idMappings []string) {
Expect(initStore.Run()).To(Succeed())
}

func runCommandInDir(cmd *exec.Cmd, workingDir string) {
func runCommandInDir(cmd *exec.Cmd, workingDir string) string {
var stdout bytes.Buffer
cmd.Dir = workingDir
cmd.Stdout = GinkgoWriter
cmd.Stdout = io.MultiWriter(&stdout, GinkgoWriter)
cmd.Stderr = GinkgoWriter
Expect(cmd.Run()).To(Succeed())
return stdout.String()
}

func runCommand(cmd *exec.Cmd) {
runCommandInDir(cmd, "")
func runCommand(cmd *exec.Cmd) string {
return runCommandInDir(cmd, "")
}

func defaultConfig() runner.GdnRunnerConfig {
Expand Down

0 comments on commit 329facb

Please sign in to comment.