[ARVADOS] updated: 2.1.0-1098-g91f7e961f

Git user git at public.arvados.org
Tue Jul 27 19:22:57 UTC 2021


Summary of changes:
 lib/controller/integration_test.go | 49 +++++++++++++++++++++++++++++++-------
 lib/controller/router/response.go  |  1 -
 lib/controller/router/router.go    |  1 +
 3 files changed, 42 insertions(+), 9 deletions(-)

       via  91f7e961f18c0ef8ae584d1c8a53d322b617efee (commit)
      from  5ae9c613aadadb918c5cfb1c22e37e16a3a3c7fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 91f7e961f18c0ef8ae584d1c8a53d322b617efee
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date:   Tue Jul 27 16:22:26 2021 -0300

    17830: Adds test cases & fixes one more issue.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>

diff --git a/lib/controller/integration_test.go b/lib/controller/integration_test.go
index bd910aab4..26f0dbb0d 100644
--- a/lib/controller/integration_test.go
+++ b/lib/controller/integration_test.go
@@ -26,6 +26,7 @@ import (
 	"git.arvados.org/arvados.git/sdk/go/arvados"
 	"git.arvados.org/arvados.git/sdk/go/arvadostest"
 	"git.arvados.org/arvados.git/sdk/go/ctxlog"
+	"git.arvados.org/arvados.git/sdk/go/httpserver"
 	check "gopkg.in/check.v1"
 )
 
@@ -435,16 +436,30 @@ func (s *IntegrationSuite) TestCreateContainerRequestWithBadToken(c *check.C) {
 func (s *IntegrationSuite) TestRequestIDHeader(c *check.C) {
 	conn1 := s.testClusters["z1111"].Conn()
 	rootctx1, _, _ := s.testClusters["z1111"].RootClients()
-	_, ac1, _, _ := s.testClusters["z1111"].UserClients(rootctx1, c, conn1, "user at example.com", true)
+	userctx1, ac1, _, _ := s.testClusters["z1111"].UserClients(rootctx1, c, conn1, "user at example.com", true)
+
+	coll, err := conn1.CollectionCreate(userctx1, arvados.CreateOptions{})
+	c.Check(err, check.IsNil)
+	specimen, err := conn1.SpecimenCreate(userctx1, arvados.CreateOptions{})
+	c.Check(err, check.IsNil)
 
 	tests := []struct {
-		path          string
-		reqIdProvided bool
+		path            string
+		reqIdProvided   bool
+		notFoundRequest bool
 	}{
-		{"/arvados/v1/container_requests", false},
-		{"/arvados/v1/container_requests", true},
-		{"/arvados/v1/links", false},
-		{"/arvados/v1/links", true},
+		{"/arvados/v1/collections", false, false},
+		{"/arvados/v1/collections", true, false},
+		{"/arvados/v1/nonexistant", false, true},
+		{"/arvados/v1/nonexistant", true, true},
+		{"/arvados/v1/collections/" + coll.UUID, false, false},
+		{"/arvados/v1/collections/" + coll.UUID, true, false},
+		{"/arvados/v1/specimens/" + specimen.UUID, false, false},
+		{"/arvados/v1/specimens/" + specimen.UUID, true, false},
+		{"/arvados/v1/collections/z1111-4zz18-0123456789abcde", false, true},
+		{"/arvados/v1/collections/z1111-4zz18-0123456789abcde", true, true},
+		{"/arvados/v1/specimens/z1111-j58dm-0123456789abcde", false, true},
+		{"/arvados/v1/specimens/z1111-j58dm-0123456789abcde", true, true},
 	}
 
 	for _, tt := range tests {
@@ -459,11 +474,29 @@ func (s *IntegrationSuite) TestRequestIDHeader(c *check.C) {
 		}
 		resp, err := ac1.Do(req)
 		c.Assert(err, check.IsNil)
-		c.Check(resp.StatusCode, check.Equals, http.StatusOK)
+		if tt.notFoundRequest {
+			c.Check(resp.StatusCode, check.Equals, http.StatusNotFound)
+		} else {
+			c.Check(resp.StatusCode, check.Equals, http.StatusOK)
+		}
 		if !tt.reqIdProvided {
 			c.Check(resp.Header.Get("X-Request-Id"), check.Matches, "^req-[0-9a-zA-Z]{20}$")
+			if tt.notFoundRequest {
+				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, "^.*(req-[0-9a-zA-Z]{20}).*$")
+			}
 		} else {
 			c.Check(resp.Header.Get("X-Request-Id"), check.Equals, customReqId)
+			if tt.notFoundRequest {
+				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, "^.*("+customReqId+").*$")
+			}
 		}
 	}
 }
diff --git a/lib/controller/router/response.go b/lib/controller/router/response.go
index 35a4e5f1b..03cdcf18d 100644
--- a/lib/controller/router/response.go
+++ b/lib/controller/router/response.go
@@ -67,7 +67,6 @@ func (rtr *router) sendResponse(w http.ResponseWriter, req *http.Request, resp i
 		return
 	}
 
-	w.Header().Set("X-Request-Id", req.Header.Get("X-Request-Id"))
 	err := rtr.transcode(resp, &tmp)
 	if err != nil {
 		rtr.sendError(w, err)
diff --git a/lib/controller/router/router.go b/lib/controller/router/router.go
index 5ceabbfb1..0325e0c98 100644
--- a/lib/controller/router/router.go
+++ b/lib/controller/router/router.go
@@ -506,6 +506,7 @@ func (rtr *router) addRoute(endpoint arvados.APIEndpoint, defaultOpts func() int
 		}
 		ctx := auth.NewContext(req.Context(), creds)
 		ctx = arvados.ContextWithRequestID(ctx, req.Header.Get("X-Request-Id"))
+		w.Header().Set("X-Request-Id", req.Header.Get("X-Request-Id"))
 		logger.WithFields(logrus.Fields{
 			"apiEndpoint": endpoint,
 			"apiOptsType": fmt.Sprintf("%T", opts),

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list