[ARVADOS] created: 2.1.0-2300-g8953bb09c

Git user git at public.arvados.org
Wed Apr 13 18:16:33 UTC 2022


        at  8953bb09c63894d79896a15c3b276136cdf4332b (commit)


commit 8953bb09c63894d79896a15c3b276136cdf4332b
Author: Tom Clegg <tom at curii.com>
Date:   Wed Apr 13 14:15:45 2022 -0400

    18947: Improve logging in test cases.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/crunch-dispatch-local/crunch-dispatch-local_test.go b/services/crunch-dispatch-local/crunch-dispatch-local_test.go
index 7e8c42c25..5d6176b04 100644
--- 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/ctxlog"
 	"git.arvados.org/arvados.git/sdk/go/dispatch"
-	"github.com/sirupsen/logrus"
 	. "gopkg.in/check.v1"
 )
 
@@ -40,16 +40,18 @@ var initialArgs []string
 func (s *TestSuite) SetUpSuite(c *C) {
 	initialArgs = os.Args
 	runningCmds = make(map[string]*exec.Cmd)
-	logrus.SetFormatter(&logrus.TextFormatter{DisableColors: true})
 }
 
 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()
+	arvadostest.ResetDB(c)
 	os.Args = initialArgs
 }
 
@@ -64,7 +66,7 @@ func (s *TestSuite) TestIntegration(c *C) {
 	echo := "echo"
 	crunchRunCommand = &echo
 
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(ctxlog.Context(context.Background(), ctxlog.TestLogger(c)))
 	dispatcher := dispatch.Dispatcher{
 		Arv:        arv,
 		PollPeriod: time.Second,
@@ -164,15 +166,17 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
 	}
 
 	buf := bytes.NewBuffer(nil)
-	logrus.SetOutput(io.MultiWriter(buf, os.Stderr))
-	defer logrus.SetOutput(os.Stderr)
+	logger := ctxlog.TestLogger(c)
+	logger.SetOutput(io.MultiWriter(buf, logger.Out))
 
 	*crunchRunCommand = crunchCmd
 
-	ctx, cancel := context.WithCancel(context.Background())
+	ctx, cancel := context.WithCancel(ctxlog.Context(context.Background(), logger))
+	defer cancel()
 	dispatcher := dispatch.Dispatcher{
+		Logger:     logger,
 		Arv:        arv,
-		PollPeriod: time.Second / 20,
+		PollPeriod: time.Second,
 	}
 
 	startCmd := func(container arvados.Container, cmd *exec.Cmd) error {
@@ -198,9 +202,8 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
 
 	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()
-
-	c.Check(buf.String(), Matches, `(?ms).*`+expected+`.*`)
 }

commit b95fa95f78e46523ad21e5d9f5cc1f7b50d5a04a
Author: Tom Clegg <tom at curii.com>
Date:   Wed Apr 13 14:13:26 2022 -0400

    18947: Close trackers before existing dispatch goroutine.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/dispatch/dispatch.go b/sdk/go/dispatch/dispatch.go
index a0a61f2b6..d34ea68d7 100644
--- a/sdk/go/dispatch/dispatch.go
+++ b/sdk/go/dispatch/dispatch.go
@@ -98,6 +98,11 @@ func (d *Dispatcher) Run(ctx context.Context) error {
 		case <-poll.C:
 			break
 		case <-ctx.Done():
+			d.mtx.Lock()
+			defer d.mtx.Unlock()
+			for _, tracker := range d.trackers {
+				tracker.close()
+			}
 			return ctx.Err()
 		}
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list