projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '18947-githttpd'
[arvados.git]
/
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 6ec31b1737f5a21004226f4bad31bf8fc504a970..e5ce5c66c5eb3f1d60ac2ae91edc54d14b68b71d 100644
(file)
--- a/
services/crunch-dispatch-local/crunch-dispatch-local_test.go
+++ b/
services/crunch-dispatch-local/crunch-dispatch-local_test.go
@@
-19,8
+19,8
@@
import (
"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/arvados"
"git.arvados.org/arvados.git/sdk/go/arvadosclient"
"git.arvados.org/arvados.git/sdk/go/arvadostest"
+ "git.arvados.org/arvados.git/sdk/go/ctxlog"
"git.arvados.org/arvados.git/sdk/go/dispatch"
"git.arvados.org/arvados.git/sdk/go/dispatch"
- "github.com/sirupsen/logrus"
. "gopkg.in/check.v1"
)
. "gopkg.in/check.v1"
)
@@
-39,22
+39,19
@@
var initialArgs []string
func (s *TestSuite) SetUpSuite(c *C) {
initialArgs = os.Args
func (s *TestSuite) SetUpSuite(c *C) {
initialArgs = os.Args
- arvadostest.StartAPI()
runningCmds = make(map[string]*exec.Cmd)
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) {
}
func (s *TestSuite) SetUpTest(c *C) {
+ arvadostest.ResetDB(c)
+ arvadostest.ResetEnv()
args := []string{"crunch-dispatch-local"}
os.Args = args
}
func (s *TestSuite) TearDownTest(c *C) {
arvadostest.ResetEnv()
args := []string{"crunch-dispatch-local"}
os.Args = args
}
func (s *TestSuite) TearDownTest(c *C) {
arvadostest.ResetEnv()
+ arvadostest.ResetDB(c)
os.Args = initialArgs
}
os.Args = initialArgs
}
@@
-67,9
+64,9
@@
func (s *TestSuite) TestIntegration(c *C) {
c.Assert(err, IsNil)
echo := "echo"
c.Assert(err, IsNil)
echo := "echo"
- crunchRunCommand =
&
echo
+ crunchRunCommand = echo
- ctx, cancel := context.WithCancel(c
ontext.Background(
))
+ ctx, cancel := context.WithCancel(c
txlog.Context(context.Background(), ctxlog.TestLogger(c)
))
dispatcher := dispatch.Dispatcher{
Arv: arv,
PollPeriod: time.Second,
dispatcher := dispatch.Dispatcher{
Arv: arv,
PollPeriod: time.Second,
@@
-81,9
+78,11
@@
func (s *TestSuite) TestIntegration(c *C) {
return cmd.Start()
}
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()
dispatcher.RunContainer = func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) error {
defer cancel()
- return (&LocalRun{startCmd, make(chan bool, 8), ctx}).run(d, c, s)
+ return (&LocalRun{startCmd, make(chan bool, 8), ctx
, &cl
}).run(d, c, s)
}
err = dispatcher.Run(ctx)
}
err = dispatcher.Run(ctx)
@@
-167,15
+166,17
@@
func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
}
buf := bytes.NewBuffer(nil)
}
buf := bytes.NewBuffer(nil)
- log
rus.SetOutput(io.MultiWriter(buf, os.Stderr)
)
-
defer logrus.SetOutput(os.Stderr
)
+ log
ger := ctxlog.TestLogger(c
)
+
logger.SetOutput(io.MultiWriter(buf, logger.Out)
)
-
*
crunchRunCommand = crunchCmd
+ crunchRunCommand = crunchCmd
- ctx, cancel := context.WithCancel(context.Background())
+ ctx, cancel := context.WithCancel(ctxlog.Context(context.Background(), logger))
+ defer cancel()
dispatcher := dispatch.Dispatcher{
dispatcher := dispatch.Dispatcher{
+ Logger: logger,
Arv: arv,
Arv: arv,
- PollPeriod: time.Second
/ 20
,
+ PollPeriod: time.Second,
}
startCmd := func(container arvados.Container, cmd *exec.Cmd) error {
}
startCmd := func(container arvados.Container, cmd *exec.Cmd) error {
@@
-184,9
+185,11
@@
func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
return cmd.Start()
}
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()
dispatcher.RunContainer = func(d *dispatch.Dispatcher, c arvados.Container, s <-chan arvados.Container) error {
defer cancel()
- return (&LocalRun{startCmd, make(chan bool, 8), ctx}).run(d, c, s)
+ return (&LocalRun{startCmd, make(chan bool, 8), ctx
, &cl
}).run(d, c, s)
}
re := regexp.MustCompile(`(?ms).*` + expected + `.*`)
}
re := regexp.MustCompile(`(?ms).*` + expected + `.*`)
@@
-199,9
+202,8
@@
func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
err := dispatcher.Run(ctx)
c.Assert(err, Equals, context.Canceled)
err := dispatcher.Run(ctx)
c.Assert(err, Equals, context.Canceled)
+ c.Check(buf.String(), Matches, `(?ms).*`+expected+`.*`)
- // Wait for all running crunch jobs to complete / terminate
+ c.Logf("test finished, waiting for running crunch jobs to complete / terminate")
waitGroup.Wait()
waitGroup.Wait()
-
- c.Check(buf.String(), Matches, `(?ms).*`+expected+`.*`)
}
}