1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
13 "git.arvados.org/arvados.git/lib/controller/router"
14 "git.arvados.org/arvados.git/lib/controller/rpc"
15 "git.arvados.org/arvados.git/sdk/go/arvados"
16 "git.arvados.org/arvados.git/sdk/go/arvadostest"
17 "git.arvados.org/arvados.git/sdk/go/auth"
18 "git.arvados.org/arvados.git/sdk/go/ctxlog"
19 "git.arvados.org/arvados.git/sdk/go/httpserver"
20 check "gopkg.in/check.v1"
23 // Gocheck boilerplate
24 func Test(t *testing.T) {
28 // FederationSuite does some generic setup/teardown. Don't add Test*
29 // methods to FederationSuite itself.
30 type FederationSuite struct {
31 cluster *arvados.Cluster
36 func (s *FederationSuite) SetUpTest(c *check.C) {
37 s.cluster = &arvados.Cluster{
39 SystemRootToken: arvadostest.SystemRootToken,
40 RemoteClusters: map[string]arvados.RemoteCluster{
42 Host: os.Getenv("ARVADOS_API_HOST"),
46 arvadostest.SetServiceURL(&s.cluster.Services.RailsAPI, "https://"+os.Getenv("ARVADOS_TEST_API_HOST"))
47 s.cluster.TLS.Insecure = true
48 s.cluster.API.MaxItemsPerResponse = 3
50 ctx := context.Background()
51 ctx = ctxlog.Context(ctx, ctxlog.TestLogger(c))
52 ctx = auth.NewContext(ctx, &auth.Credentials{Tokens: []string{arvadostest.ActiveTokenV2}})
55 s.fed = New(s.cluster)
58 func (s *FederationSuite) addDirectRemote(c *check.C, id string, backend backend) {
59 s.cluster.RemoteClusters[id] = arvados.RemoteCluster{
60 Host: "in-process.local",
62 s.fed.remotes[id] = backend
65 func (s *FederationSuite) addHTTPRemote(c *check.C, id string, backend backend) {
66 srv := httpserver.Server{Addr: ":"}
67 srv.Handler = router.New(backend, nil)
68 c.Check(srv.Start(), check.IsNil)
69 s.cluster.RemoteClusters[id] = arvados.RemoteCluster{
74 s.fed.remotes[id] = rpc.NewConn(id, &url.URL{Scheme: "http", Host: srv.Addr}, true, saltedTokenProvider(s.fed.local, id))