X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5b8dfb5d5f4b34fa730e69c45c517f0cfb3fdc9f..89cab1faedd4c4209ac642ffd442b0085d9da593:/services/crunch-dispatch-local/crunch-dispatch-local_test.go diff --git a/services/crunch-dispatch-local/crunch-dispatch-local_test.go b/services/crunch-dispatch-local/crunch-dispatch-local_test.go index 6da17ea86c..7e8c42c25c 100644 --- a/services/crunch-dispatch-local/crunch-dispatch-local_test.go +++ b/services/crunch-dispatch-local/crunch-dispatch-local_test.go @@ -16,11 +16,11 @@ import ( "testing" "time" - "git.curoverse.com/arvados.git/sdk/go/arvados" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" - "git.curoverse.com/arvados.git/sdk/go/dispatch" - "github.com/Sirupsen/logrus" + "git.arvados.org/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvadosclient" + "git.arvados.org/arvados.git/sdk/go/arvadostest" + "git.arvados.org/arvados.git/sdk/go/dispatch" + "github.com/sirupsen/logrus" . "gopkg.in/check.v1" ) @@ -39,15 +39,10 @@ var initialArgs []string func (s *TestSuite) SetUpSuite(c *C) { initialArgs = os.Args - arvadostest.StartAPI() runningCmds = make(map[string]*exec.Cmd) logrus.SetFormatter(&logrus.TextFormatter{DisableColors: true}) } -func (s *TestSuite) TearDownSuite(c *C) { - arvadostest.StopAPI() -} - func (s *TestSuite) SetUpTest(c *C) { args := []string{"crunch-dispatch-local"} os.Args = args @@ -73,18 +68,21 @@ func (s *TestSuite) TestIntegration(c *C) { dispatcher := dispatch.Dispatcher{ Arv: arv, PollPeriod: time.Second, - RunContainer: func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) { - run(d, c, s) - cancel() - }, } - startCmd = func(container arvados.Container, cmd *exec.Cmd) error { + startCmd := func(container arvados.Container, cmd *exec.Cmd) error { dispatcher.UpdateState(container.UUID, "Running") dispatcher.UpdateState(container.UUID, "Complete") return cmd.Start() } + cl := arvados.Cluster{Containers: arvados.ContainersConfig{RuntimeEngine: "docker"}} + + dispatcher.RunContainer = func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) error { + defer cancel() + return (&LocalRun{startCmd, make(chan bool, 8), ctx, &cl}).run(d, c, s) + } + err = dispatcher.Run(ctx) c.Assert(err, Equals, context.Canceled) @@ -175,18 +173,21 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon dispatcher := dispatch.Dispatcher{ Arv: arv, PollPeriod: time.Second / 20, - RunContainer: func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) { - run(d, c, s) - cancel() - }, } - startCmd = func(container arvados.Container, cmd *exec.Cmd) error { + startCmd := func(container arvados.Container, cmd *exec.Cmd) error { dispatcher.UpdateState(container.UUID, "Running") dispatcher.UpdateState(container.UUID, "Complete") return cmd.Start() } + cl := arvados.Cluster{Containers: arvados.ContainersConfig{RuntimeEngine: "docker"}} + + dispatcher.RunContainer = func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) error { + defer cancel() + return (&LocalRun{startCmd, make(chan bool, 8), ctx, &cl}).run(d, c, s) + } + re := regexp.MustCompile(`(?ms).*` + expected + `.*`) go func() { for i := 0; i < 80 && !re.MatchString(buf.String()); i++ {