X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7337b18bf7b6996a7fe4df0aba5356a03bda452d..b05be6e2d1db4e63074fc28e978c40a271376f1f:/lib/controller/federation_test.go diff --git a/lib/controller/federation_test.go b/lib/controller/federation_test.go index c935e20be6..62916acd2a 100644 --- a/lib/controller/federation_test.go +++ b/lib/controller/federation_test.go @@ -19,6 +19,7 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/arvadostest" + "git.curoverse.com/arvados.git/sdk/go/ctxlog" "git.curoverse.com/arvados.git/sdk/go/httpserver" "git.curoverse.com/arvados.git/sdk/go/keepclient" "github.com/sirupsen/logrus" @@ -29,7 +30,7 @@ import ( var _ = check.Suite(&FederationSuite{}) type FederationSuite struct { - log *logrus.Logger + log logrus.FieldLogger // testServer and testHandler are the controller being tested, // "zhome". testServer *httpserver.Server @@ -44,9 +45,7 @@ type FederationSuite struct { } func (s *FederationSuite) SetUpTest(c *check.C) { - s.log = logrus.New() - s.log.Formatter = &logrus.JSONFormatter{} - s.log.Out = &logWriter{c.Log} + s.log = ctxlog.TestLogger(c) s.remoteServer = newServerFromIntegrationTestEnv(c) c.Assert(s.remoteServer.Start(), check.IsNil) @@ -555,16 +554,20 @@ func (s *FederationSuite) TestGetRemoteContainerRequest(c *check.C) { func (s *FederationSuite) TestUpdateRemoteContainerRequest(c *check.C) { defer s.localServiceReturns404(c).Close() - req := httptest.NewRequest("PATCH", "/arvados/v1/container_requests/"+arvadostest.QueuedContainerRequestUUID, - strings.NewReader(`{"container_request": {"priority": 696}}`)) - req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveToken) - req.Header.Set("Content-type", "application/json") - resp := s.testRequest(req) - c.Check(resp.StatusCode, check.Equals, http.StatusOK) - var cr arvados.ContainerRequest - c.Check(json.NewDecoder(resp.Body).Decode(&cr), check.IsNil) - c.Check(cr.UUID, check.Equals, arvadostest.QueuedContainerRequestUUID) - c.Check(cr.Priority, check.Equals, 696) + setPri := func(pri int) { + req := httptest.NewRequest("PATCH", "/arvados/v1/container_requests/"+arvadostest.QueuedContainerRequestUUID, + strings.NewReader(fmt.Sprintf(`{"container_request": {"priority": %d}}`, pri))) + req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveToken) + req.Header.Set("Content-type", "application/json") + resp := s.testRequest(req) + c.Check(resp.StatusCode, check.Equals, http.StatusOK) + var cr arvados.ContainerRequest + c.Check(json.NewDecoder(resp.Body).Decode(&cr), check.IsNil) + c.Check(cr.UUID, check.Equals, arvadostest.QueuedContainerRequestUUID) + c.Check(cr.Priority, check.Equals, pri) + } + setPri(696) + setPri(1) // Reset fixture so side effect doesn't break other tests. } func (s *FederationSuite) TestCreateRemoteContainerRequest(c *check.C) {