20647: Fix duplicate response headers via reverse proxy.
[arvados.git] / lib / controller / integration_test.go
index 4c49c007eb2b2233bed13dfa9e654a1a018a6eee..cd0e5f9480940314056888ec6dfab5388874ab36 100644 (file)
@@ -72,6 +72,8 @@ func (s *IntegrationSuite) SetUpSuite(c *check.C) {
       Insecure: true
     SystemLogs:
       Format: text
+    API:
+      MaxConcurrentRequests: 128
     Containers:
       CloudVMs:
         Enable: true
@@ -499,6 +501,7 @@ func (s *IntegrationSuite) TestCreateContainerRequestWithFedToken(c *check.C) {
        req.Header.Set("Authorization", "OAuth2 "+ac2.AuthToken)
        resp, err = arvados.InsecureHTTPClient.Do(req)
        c.Assert(err, check.IsNil)
+       defer resp.Body.Close()
        err = json.NewDecoder(resp.Body).Decode(&cr)
        c.Check(err, check.IsNil)
        c.Check(cr.UUID, check.Matches, "z2222-.*")
@@ -536,8 +539,10 @@ func (s *IntegrationSuite) TestCreateContainerRequestWithBadToken(c *check.C) {
                c.Assert(err, check.IsNil)
                req.Header.Set("Content-Type", "application/json")
                resp, err := ac1.Do(req)
-               c.Assert(err, check.IsNil)
-               c.Assert(resp.StatusCode, check.Equals, tt.expectedCode)
+               if c.Check(err, check.IsNil) {
+                       c.Assert(resp.StatusCode, check.Equals, tt.expectedCode)
+                       resp.Body.Close()
+               }
        }
 }
 
@@ -605,9 +610,11 @@ func (s *IntegrationSuite) TestRequestIDHeader(c *check.C) {
                        var jresp httpserver.ErrorResponse
                        err := json.NewDecoder(resp.Body).Decode(&jresp)
                        c.Check(err, check.IsNil)
-                       c.Assert(jresp.Errors, check.HasLen, 1)
-                       c.Check(jresp.Errors[0], check.Matches, `.*\(`+respHdr+`\).*`)
+                       if c.Check(jresp.Errors, check.HasLen, 1) {
+                               c.Check(jresp.Errors[0], check.Matches, `.*\(`+respHdr+`\).*`)
+                       }
                }
+               resp.Body.Close()
        }
 }
 
@@ -1133,7 +1140,7 @@ func (s *IntegrationSuite) TestRunTrivialContainer(c *check.C) {
                "environment":         map[string]string{},
                "mounts":              map[string]arvados.Mount{"/out": {Kind: "tmp", Capacity: 10000}},
                "output_path":         "/out",
-               "runtime_constraints": arvados.RuntimeConstraints{RAM: 100000000, VCPUs: 1},
+               "runtime_constraints": arvados.RuntimeConstraints{RAM: 100000000, VCPUs: 1, KeepCacheRAM: 1 << 26},
                "priority":            1,
                "state":               arvados.ContainerRequestStateCommitted,
        }, 0)
@@ -1142,6 +1149,15 @@ func (s *IntegrationSuite) TestRunTrivialContainer(c *check.C) {
 }
 
 func (s *IntegrationSuite) TestContainerInputOnDifferentCluster(c *check.C) {
+       // As of Arvados 2.6.2 (April 2023), this test was going down the
+       // `if outcoll.UUID == ""` branch, checking that FUSE reports a specific
+       // error.
+       // With increased PySDK/FUSE retries from #12684, this test now trips up
+       // on #20425. The test times out as FUSE spends a long time retrying a
+       // request that will never succeed.
+       // This early skip can be removed after #20425 is fixed.
+       c.Skip("blocked by <https://dev.arvados.org/issues/20425>")
+       return
        conn := s.super.Conn("z1111")
        rootctx, _, _ := s.super.RootClients("z1111")
        userctx, ac, _, _ := s.super.UserClients("z1111", rootctx, c, conn, s.oidcprovider.AuthEmail, true)
@@ -1160,7 +1176,7 @@ func (s *IntegrationSuite) TestContainerInputOnDifferentCluster(c *check.C) {
                        "/out": {Kind: "tmp", Capacity: 10000},
                },
                "output_path":         "/out",
-               "runtime_constraints": arvados.RuntimeConstraints{RAM: 100000000, VCPUs: 1},
+               "runtime_constraints": arvados.RuntimeConstraints{RAM: 100000000, VCPUs: 1, KeepCacheRAM: 1 << 26},
                "priority":            1,
                "state":               arvados.ContainerRequestStateCommitted,
                "container_count_max": 1,
@@ -1224,6 +1240,17 @@ func (s *IntegrationSuite) runContainer(c *check.C, clusterID string, token stri
                return cfs
        }
 
+       checkwebdavlogs := func(cr arvados.ContainerRequest) {
+               req, err := http.NewRequest("OPTIONS", "https://"+ac.APIHost+"/arvados/v1/container_requests/"+cr.UUID+"/log/"+cr.ContainerUUID+"/", nil)
+               c.Assert(err, check.IsNil)
+               req.Header.Set("Origin", "http://example.example")
+               resp, err := ac.Do(req)
+               c.Assert(err, check.IsNil)
+               c.Check(resp.StatusCode, check.Equals, http.StatusOK)
+               // Check for duplicate headers -- must use Header[], not Header.Get()
+               c.Check(resp.Header["Access-Control-Allow-Origin"], check.DeepEquals, []string{"*"})
+       }
+
        var ctr arvados.Container
        var lastState arvados.ContainerState
        deadline := time.Now().Add(time.Minute)
@@ -1239,7 +1266,11 @@ func (s *IntegrationSuite) runContainer(c *check.C, clusterID string, token stri
                } else {
                        if time.Now().After(deadline) {
                                c.Errorf("timed out, container state is %q", cr.State)
-                               showlogs(ctr.Log)
+                               if ctr.Log == "" {
+                                       c.Logf("=== NO LOG COLLECTION saved for container")
+                               } else {
+                                       showlogs(ctr.Log)
+                               }
                                c.FailNow()
                        }
                        time.Sleep(time.Second / 2)
@@ -1254,5 +1285,6 @@ func (s *IntegrationSuite) runContainer(c *check.C, clusterID string, token stri
                c.Assert(err, check.IsNil)
        }
        logcfs = showlogs(cr.LogUUID)
+       checkwebdavlogs(cr)
        return outcoll, logcfs
 }