21578: Merge branch 'main' into 21578-mount-debug
[arvados.git] / lib / controller / integration_test.go
index 0557aa3fddde824ea6f3cd1f7c1f8e09a974da2b..53e6a90b8f2fee1d18237c157ccef0474b703227 100644 (file)
@@ -971,8 +971,8 @@ func (s *IntegrationSuite) TestSetupUserWithVM(c *check.C) {
                        "hostname": "example",
                },
                })
+       c.Assert(err, check.IsNil)
        c.Check(outVM.UUID[0:5], check.Equals, "z3333")
-       c.Check(err, check.IsNil)
 
        // Make sure z3333 user list is up to date
        _, err = conn3.UserList(rootctx3, arvados.ListOptions{Limit: 1000})
@@ -1149,15 +1149,6 @@ 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)
@@ -1240,12 +1231,35 @@ 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
+       var status, lastStatus arvados.ContainerStatus
+       var allStatus string
+       checkstatus := func() {
+               err := ac.RequestAndDecode(&status, "GET", "/arvados/v1/container_requests/"+cr.UUID+"/container_status", nil, nil)
+               c.Assert(err, check.IsNil)
+               if status != lastStatus {
+                       c.Logf("container status: %s, %s", status.State, status.SchedulingStatus)
+                       allStatus += fmt.Sprintf("%s, %s\n", status.State, status.SchedulingStatus)
+                       lastStatus = status
+               }
+       }
        deadline := time.Now().Add(time.Minute)
-       for cr.State != arvados.ContainerRequestStateFinal {
+       for cr.State != arvados.ContainerRequestStateFinal || (lastStatus.State != arvados.ContainerStateComplete && lastStatus.State != arvados.ContainerStateCancelled) {
                err = ac.RequestAndDecode(&cr, "GET", "/arvados/v1/container_requests/"+cr.UUID, nil, nil)
                c.Assert(err, check.IsNil)
+               checkstatus()
                err = ac.RequestAndDecode(&ctr, "GET", "/arvados/v1/containers/"+cr.ContainerUUID, nil, nil)
                if err != nil {
                        c.Logf("error getting container state: %s", err)
@@ -1265,6 +1279,7 @@ func (s *IntegrationSuite) runContainer(c *check.C, clusterID string, token stri
                        time.Sleep(time.Second / 2)
                }
        }
+       checkstatus()
        c.Logf("cr.CumulativeCost == %f", cr.CumulativeCost)
        c.Check(cr.CumulativeCost, check.Not(check.Equals), 0.0)
        if expectExitCode >= 0 {
@@ -1272,7 +1287,15 @@ func (s *IntegrationSuite) runContainer(c *check.C, clusterID string, token stri
                c.Check(ctr.ExitCode, check.Equals, expectExitCode)
                err = ac.RequestAndDecode(&outcoll, "GET", "/arvados/v1/collections/"+cr.OutputUUID, nil, nil)
                c.Assert(err, check.IsNil)
+               c.Check(allStatus, check.Matches, `Queued, waiting for dispatch\n`+
+                       `(Queued, waiting.*\n)*`+
+                       `(Locked, waiting for dispatch\n)?`+
+                       `(Locked, waiting for new instance to be ready\n)?`+
+                       `(Locked, preparing runtime environment\n)?`+
+                       `(Running, \n)?`+
+                       `Complete, \n`)
        }
        logcfs = showlogs(cr.LogUUID)
+       checkwebdavlogs(cr)
        return outcoll, logcfs
 }