X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2376a805daae84c5e899f190485d7d7ac96e3f20..bd471a9eadaf564fb4beafd7db995b7762942c1d:/sdk/go/keepclient/discover_test.go?ds=sidebyside diff --git a/sdk/go/keepclient/discover_test.go b/sdk/go/keepclient/discover_test.go index b145ee67e9..92d66a949c 100644 --- a/sdk/go/keepclient/discover_test.go +++ b/sdk/go/keepclient/discover_test.go @@ -1,40 +1,32 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 + package keepclient import ( "crypto/md5" "fmt" - "gopkg.in/check.v1" "net/http" "os" - "time" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/arvadostest" -) + "gopkg.in/check.v1" -func ExampleKeepClient_RefreshServices() { - arv, err := arvadosclient.MakeArvadosClient() - if err != nil { - panic(err) - } - kc, err := MakeKeepClient(&arv) - if err != nil { - panic(err) - } - go kc.RefreshServices(5*time.Minute, 3*time.Second) - fmt.Printf("LocalRoots: %#v\n", kc.LocalRoots()) -} + "git.arvados.org/arvados.git/sdk/go/arvadosclient" + "git.arvados.org/arvados.git/sdk/go/arvadostest" +) func (s *ServerRequiredSuite) TestOverrideDiscovery(c *check.C) { defer os.Setenv("ARVADOS_KEEP_SERVICES", "") - hash := fmt.Sprintf("%x+3", md5.Sum([]byte("TestOverrideDiscovery"))) + data := []byte("TestOverrideDiscovery") + hash := fmt.Sprintf("%x+%d", md5.Sum(data), len(data)) st := StubGetHandler{ c, hash, arvadostest.ActiveToken, http.StatusOK, - []byte("TestOverrideDiscovery")} + data} ks := RunSomeFakeKeepServers(st, 2) os.Setenv("ARVADOS_KEEP_SERVICES", "") @@ -42,7 +34,7 @@ func (s *ServerRequiredSuite) TestOverrideDiscovery(c *check.C) { c.Assert(err, check.IsNil) arv1.ApiToken = arvadostest.ActiveToken - os.Setenv("ARVADOS_KEEP_SERVICES", ks[0].url+" "+ks[1].url) + os.Setenv("ARVADOS_KEEP_SERVICES", ks[0].url+" "+ks[1].url+" ") arv2, err := arvadosclient.MakeArvadosClient() c.Assert(err, check.IsNil) arv2.ApiToken = arvadostest.ActiveToken @@ -53,9 +45,9 @@ func (s *ServerRequiredSuite) TestOverrideDiscovery(c *check.C) { // arv2 should use our stub servers, but one created for arv1 // should not. - kc1, err := MakeKeepClient(&arv1) + kc1, err := MakeKeepClient(arv1) c.Assert(err, check.IsNil) - kc2, err := MakeKeepClient(&arv2) + kc2, err := MakeKeepClient(arv2) c.Assert(err, check.IsNil) _, _, _, err = kc1.Get(hash)