diff options
-rw-r--r-- | kokoro/continuous.cfg | 2 | ||||
-rw-r--r-- | kokoro/presubmit.cfg | 1 | ||||
-rwxr-xr-x | kokoro/run_tests.sh | 3 | ||||
-rw-r--r-- | runsc/test/testutil/docker.go | 23 |
4 files changed, 27 insertions, 2 deletions
diff --git a/kokoro/continuous.cfg b/kokoro/continuous.cfg index a834db198..8da47736a 100644 --- a/kokoro/continuous.cfg +++ b/kokoro/continuous.cfg @@ -7,5 +7,7 @@ action { define_artifacts { regex: "**/sponge_log.xml" regex: "**/sponge_log.log" + regex: "**/outputs.zip" + regex: "**/runsc-logs.tar.gz" } } diff --git a/kokoro/presubmit.cfg b/kokoro/presubmit.cfg index 2d8ab76d6..8da47736a 100644 --- a/kokoro/presubmit.cfg +++ b/kokoro/presubmit.cfg @@ -8,5 +8,6 @@ action { regex: "**/sponge_log.xml" regex: "**/sponge_log.log" regex: "**/outputs.zip" + regex: "**/runsc-logs.tar.gz" } } diff --git a/kokoro/run_tests.sh b/kokoro/run_tests.sh index 08f678e39..c5c6a7780 100755 --- a/kokoro/run_tests.sh +++ b/kokoro/run_tests.sh @@ -183,6 +183,9 @@ upload_test_artifacts() { find -L "bazel-testlogs" -name "test.xml" -o -name "test.log" -o -name "outputs.zip" | tar --create --files-from - --transform 's/test\./sponge_log./' | tar --extract --directory ${KOKORO_ARTIFACTS_DIR} + if [[ -d "/tmp/${RUNTIME}/logs" ]]; then + tar --create --gzip "--file=${KOKORO_ARTIFACTS_DIR}/runsc-logs.tar.gz" -C /tmp/ ${RUNTIME}/logs + fi } # Finish runs at exit, even in the event of an error, and uploads all test diff --git a/runsc/test/testutil/docker.go b/runsc/test/testutil/docker.go index 29ef505b4..ecd66dc77 100644 --- a/runsc/test/testutil/docker.go +++ b/runsc/test/testutil/docker.go @@ -120,7 +120,7 @@ func getLocalPath(file string) string { // do executes docker command. func do(args ...string) (string, error) { - fmt.Printf("Running: docker %s\n", args) + log.Printf("Running: docker %s\n", args) cmd := exec.Command("docker", args...) out, err := cmd.CombinedOutput() if err != nil { @@ -131,7 +131,7 @@ func do(args ...string) (string, error) { // doWithPty executes docker command with stdio attached to a pty. func doWithPty(args ...string) (*exec.Cmd, *os.File, error) { - fmt.Printf("Running with pty: docker %s\n", args) + log.Printf("Running with pty: docker %s\n", args) cmd := exec.Command("docker", args...) ptmx, err := pty.Start(cmd) if err != nil { @@ -160,11 +160,23 @@ func MakeDocker(namePrefix string) Docker { return Docker{Name: RandomName(namePrefix), Runtime: getRuntime()} } +// logDockerID logs a container id, which is needed to find container runsc logs. +func (d *Docker) logDockerID() { + id, err := d.ID() + if err != nil { + log.Printf("%v\n", err) + } + log.Printf("Name: %s ID: %v\n", d.Name, id) +} + // Create calls 'docker create' with the arguments provided. func (d *Docker) Create(args ...string) error { a := []string{"create", "--runtime", d.Runtime, "--name", d.Name} a = append(a, args...) _, err := do(a...) + if err == nil { + d.logDockerID() + } return err } @@ -190,6 +202,9 @@ func (d *Docker) Run(args ...string) error { a := []string{"run", "--runtime", d.Runtime, "--name", d.Name, "-d"} a = append(a, args...) _, err := do(a...) + if err == nil { + d.logDockerID() + } return err } @@ -206,6 +221,9 @@ func (d *Docker) RunFg(args ...string) (string, error) { a := []string{"run", "--runtime", d.Runtime, "--name", d.Name} a = append(a, args...) out, err := do(a...) + if err == nil { + d.logDockerID() + } return string(out), err } @@ -255,6 +273,7 @@ func (d *Docker) Remove() error { // CleanUp kills and deletes the container (best effort). func (d *Docker) CleanUp() { + d.logDockerID() if _, err := do("kill", d.Name); err != nil { log.Printf("error killing container %q: %v", d.Name, err) } |