X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6c7c27f15f02cac915023590b4dfde6c4fd0af0b..28aa75d2683d5f0472335ecef3b2ff505e72f30d:/services/keep-web/handler_test.go diff --git a/services/keep-web/handler_test.go b/services/keep-web/handler_test.go index 42bfd80fa5..07c7016d3a 100644 --- a/services/keep-web/handler_test.go +++ b/services/keep-web/handler_test.go @@ -60,6 +60,7 @@ func (s *UnitSuite) SetUpTest(c *check.C) { logger: logger, registry: prometheus.NewRegistry(), }, + metrics: newMetrics(prometheus.NewRegistry()), } } @@ -209,6 +210,10 @@ func (s *UnitSuite) TestWebdavPrefixAndSource(c *check.C) { } func (s *UnitSuite) TestEmptyResponse(c *check.C) { + // Ensure we start with an empty cache + defer os.Setenv("HOME", os.Getenv("HOME")) + os.Setenv("HOME", c.MkDir()) + for _, trial := range []struct { dataExists bool sendIMSHeader bool @@ -1277,7 +1282,7 @@ func (s *IntegrationSuite) testDirectoryListing(c *check.C) { cutDirs: 3, }, } { - comment := check.Commentf("HTML: %q => %q", trial.uri, trial.expect) + comment := check.Commentf("HTML: %q redir %q => %q", trial.uri, trial.redirect, trial.expect) resp := httptest.NewRecorder() u := mustParseURL("//" + trial.uri) req := &http.Request{ @@ -1346,6 +1351,12 @@ func (s *IntegrationSuite) testDirectoryListing(c *check.C) { } resp = httptest.NewRecorder() s.handler.ServeHTTP(resp, req) + // This check avoids logging a big XML document in the + // event webdav throws a 500 error after sending + // headers for a 207. + if !c.Check(strings.HasSuffix(resp.Body.String(), "Internal Server Error"), check.Equals, false) { + continue + } if trial.expect == nil { c.Check(resp.Code, check.Equals, http.StatusUnauthorized, comment) } else { @@ -1463,20 +1474,14 @@ func (s *IntegrationSuite) TestFileContentType(c *check.C) { } } -func (s *IntegrationSuite) TestKeepClientBlockCache(c *check.C) { - s.handler.Cluster.Collections.WebDAVCache.MaxBlockEntries = 42 - c.Check(keepclient.DefaultBlockCache.MaxBlocks, check.Not(check.Equals), 42) - u := mustParseURL("http://keep-web.example/c=" + arvadostest.FooCollection + "/t=" + arvadostest.ActiveToken + "/foo") - req := &http.Request{ - Method: "GET", - Host: u.Host, - URL: u, - RequestURI: u.RequestURI(), - } +func (s *IntegrationSuite) TestCacheSize(c *check.C) { + req, err := http.NewRequest("GET", "http://"+arvadostest.FooCollection+".example.com/foo", nil) + req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveTokenV2) + c.Assert(err, check.IsNil) resp := httptest.NewRecorder() s.handler.ServeHTTP(resp, req) - c.Check(resp.Code, check.Equals, http.StatusOK) - c.Check(keepclient.DefaultBlockCache.MaxBlocks, check.Equals, 42) + c.Assert(resp.Code, check.Equals, http.StatusOK) + c.Check(s.handler.Cache.sessions[arvadostest.ActiveTokenV2].client.DiskCacheSize.Percent(), check.Equals, int64(10)) } // Writing to a collection shouldn't affect its entry in the