added a test that fails to prove rpc.Conn is not DTRT
authorNico Cesar <nico@nicocesar.com>
Fri, 4 Dec 2020 20:25:28 +0000 (15:25 -0500)
committerNico Cesar <nico@nicocesar.com>
Fri, 4 Dec 2020 20:25:28 +0000 (15:25 -0500)
Arvados-DCO-1.1-Signed-off-by: Nico Cesar <nico@curii.com>

lib/controller/federation/conn.go
lib/controller/integration_test.go
lib/controller/rpc/conn.go

index e99afc251f21d48dc07341148189e022811d0314..30c15b57c1fb0331197c3fd38492b53430c79ad5 100644 (file)
@@ -10,6 +10,7 @@ import (
        "encoding/json"
        "errors"
        "fmt"
+       "log"
        "net/http"
        "net/url"
        "regexp"
@@ -342,6 +343,7 @@ func (conn *Conn) ContainerRequestList(ctx context.Context, options arvados.List
 
 func (conn *Conn) ContainerRequestCreate(ctx context.Context, options arvados.CreateOptions) (arvados.ContainerRequest, error) {
        be := conn.chooseBackend(options.ClusterID)
+       log.Printf("THIS IS THE federation.Conn.ContainerRequestCreate() for %s we are %s", options.ClusterID, conn.cluster.ClusterID)
        if be == conn.local {
                return be.ContainerRequestCreate(ctx, options)
        }
index a479e4476daa96b18112f53365b71d1c41c1260c..e75e996f48a3a35b8291be223e0cfd667ba061bf 100644 (file)
@@ -478,6 +478,8 @@ func (s *IntegrationSuite) dbConn(c *check.C, clusterID string) (*sql.DB, *sql.C
        return db, conn
 }
 
+// TestRuntimeTokenInCR will test several different tokens in the runtime attribute
+// and check the expected retualts
 func (s *IntegrationSuite) TestRuntimeTokenInCR(c *check.C) {
        db, dbconn := s.dbConn(c, "z1111")
        defer db.Close()
@@ -530,6 +532,42 @@ func (s *IntegrationSuite) TestRuntimeTokenInCR(c *check.C) {
        }
 }
 
+// TestIntermediateCluster will send a container request to
+// one cluster with another cluster as the destination
+// and check the tokens are being handled properly
+func (s *IntegrationSuite) TestIntermediateCluster(c *check.C) {
+       conn1 := s.conn("z1111")
+       rootctx1, _, _ := s.rootClients("z1111")
+       _, ac1, _, _ := s.userClients(rootctx1, c, conn1, "z1111", true)
+       //conn2 := s.conn("z2222")
+       //rootctx2, _, _ := s.rootClients("z2222")
+       //_, ac2, _, _ := s.userClients(rootctx2, c, conn2, "z2222", true)
+
+       tests := []struct {
+               name  string
+               token string
+       }{
+               {"Good token z1111 user sending a CR to z2222", ac1.AuthToken},
+       }
+
+       for _, tt := range tests {
+               c.Log(c.TestName() + " " + tt.name)
+               rq := map[string]interface{}{
+                       "command":         []string{"echo"},
+                       "container_image": "d41d8cd98f00b204e9800998ecf8427e+0",
+                       "cwd":             "/",
+                       "output_path":     "/",
+                       "runtime_token":   tt.token,
+               }
+               cr, err := conn1.ContainerRequestCreate(rootctx1, arvados.CreateOptions{ClusterID: "z2222", Attrs: rq})
+
+               c.Check(err, check.IsNil)
+               c.Check(cr, check.NotNil)
+               c.Check(cr.UUID, check.Not(check.Equals), "")
+
+       }
+}
+
 // Test for bug #16263
 func (s *IntegrationSuite) TestListUsers(c *check.C) {
        rootctx1, _, _ := s.rootClients("z1111")
index 5ffa668010e911398ba4f9a8c3cd583a86c0336f..b3fd541bbb28672d12b1f97e756d6af5897d5bff 100644 (file)
@@ -12,6 +12,7 @@ import (
        "errors"
        "fmt"
        "io"
+       "log"
        "net"
        "net/http"
        "net/url"
@@ -287,6 +288,7 @@ func (conn *Conn) ContainerUnlock(ctx context.Context, options arvados.GetOption
 }
 
 func (conn *Conn) ContainerRequestCreate(ctx context.Context, options arvados.CreateOptions) (arvados.ContainerRequest, error) {
+       log.Printf("THIS IS THE rcp.Conn.ContainerRequestCreate(): %s", options.ClusterID)
        ep := arvados.EndpointContainerRequestCreate
        var resp arvados.ContainerRequest
        err := conn.requestAndDecode(ctx, &resp, ep, nil, options)