X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/aabea703ee77ca91da710dd9bce9716e5d35d7b2..e805640e7904dc282f00be82a2edb53d496a87bb:/lib/crunchrun/executor_test.go diff --git a/lib/crunchrun/executor_test.go b/lib/crunchrun/executor_test.go index 393cfff09b..f1a873ae8d 100644 --- a/lib/crunchrun/executor_test.go +++ b/lib/crunchrun/executor_test.go @@ -6,6 +6,7 @@ package crunchrun import ( "bytes" + "context" "fmt" "io" "io/ioutil" @@ -15,37 +16,12 @@ import ( "strings" "time" + "git.arvados.org/arvados.git/lib/diagnostics" "git.arvados.org/arvados.git/sdk/go/arvados" - "golang.org/x/net/context" + "git.arvados.org/arvados.git/sdk/go/arvadostest" . "gopkg.in/check.v1" ) -func busyboxDockerImage(c *C) string { - fnm := "busybox_uclibc.tar" - cachedir := c.MkDir() - cachefile := cachedir + "/" + fnm - if _, err := os.Stat(cachefile); err == nil { - return cachefile - } - - f, err := ioutil.TempFile(cachedir, "") - c.Assert(err, IsNil) - defer f.Close() - defer os.Remove(f.Name()) - - resp, err := http.Get("https://cache.arvados.org/" + fnm) - c.Assert(err, IsNil) - defer resp.Body.Close() - _, err = io.Copy(f, resp.Body) - c.Assert(err, IsNil) - err = f.Close() - c.Assert(err, IsNil) - err = os.Rename(f.Name(), cachefile) - c.Assert(err, IsNil) - - return cachefile -} - type nopWriteCloser struct{ io.Writer } func (nopWriteCloser) Close() error { return nil } @@ -73,7 +49,7 @@ func (s *executorSuite) SetUpTest(c *C) { Stdout: nopWriteCloser{&s.stdout}, Stderr: nopWriteCloser{&s.stderr}, } - err := s.executor.LoadImage("", busyboxDockerImage(c), arvados.Container{}, "", nil) + err := s.executor.LoadImage("", arvadostest.BusyboxDockerImage(c), arvados.Container{}, "", nil) c.Assert(err, IsNil) } @@ -82,12 +58,28 @@ func (s *executorSuite) TearDownTest(c *C) { } func (s *executorSuite) TestExecTrivialContainer(c *C) { + c.Logf("Using container runtime: %s", s.executor.Runtime()) s.spec.Command = []string{"echo", "ok"} s.checkRun(c, 0) c.Check(s.stdout.String(), Equals, "ok\n") c.Check(s.stderr.String(), Equals, "") } +func (s *executorSuite) TestDiagnosticsImage(c *C) { + s.newExecutor(c) + imagefile := c.MkDir() + "/hello-world.tar" + err := ioutil.WriteFile(imagefile, diagnostics.HelloWorldDockerImage, 0777) + c.Assert(err, IsNil) + err = s.executor.LoadImage("", imagefile, arvados.Container{}, "", nil) + c.Assert(err, IsNil) + + c.Logf("Using container runtime: %s", s.executor.Runtime()) + s.spec.Image = "hello-world" + s.spec.Command = []string{"/hello"} + s.checkRun(c, 0) + c.Check(s.stdout.String(), Matches, `(?ms)\nHello from Docker!\n.*`) +} + func (s *executorSuite) TestExitStatus(c *C) { s.spec.Command = []string{"false"} s.checkRun(c, 1)