func SetupDataManagerTest(t *testing.T) { os.Setenv("ARVADOS_API_HOST_INSECURE", "true") // start api and keep servers arvadostest.ResetEnv() arvadostest.StartAPI() arvadostest.StartKeep(2, false) var err error arv, err = arvadosclient.MakeArvadosClient() if err != nil { t.Fatalf("Error making arvados client: %s", err) } arv.ApiToken = arvadostest.DataManagerToken // keep client keepClient = &keepclient.KeepClient{ Arvados: &arv, Want_replicas: 2, Client: &http.Client{}, } // discover keep services if err = keepClient.DiscoverKeepServers(); err != nil { t.Fatalf("Error discovering keep services: %s", err) } keepServers = []string{} for _, host := range keepClient.LocalRoots() { keepServers = append(keepServers, host) } }
func (s *IntegrationSuite) SetUpTest(c *check.C) { arvadostest.ResetEnv() s.testServer = &server{} var err error address = "127.0.0.1:0" err = s.testServer.Start() c.Assert(err, check.Equals, nil) }
func (s *IntegrationSuite) SetUpTest(c *check.C) { arvadostest.ResetEnv() s.testServer = &server{} var err error if s.tmpRepoRoot == "" { s.tmpRepoRoot, err = ioutil.TempDir("", "arv-git-httpd") c.Assert(err, check.Equals, nil) } s.tmpWorkdir, err = ioutil.TempDir("", "arv-git-httpd") c.Assert(err, check.Equals, nil) _, err = exec.Command("git", "init", "--bare", s.tmpRepoRoot+"/zzzzz-s0uqq-382brsig8rp3666.git").Output() c.Assert(err, check.Equals, nil) _, err = exec.Command("git", "init", s.tmpWorkdir).Output() c.Assert(err, check.Equals, nil) _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo initial >initial && git add initial && git -c user.name=Initial -c user.email=Initial commit -am 'foo: initial commit'").CombinedOutput() c.Assert(err, check.Equals, nil) _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && git push "+s.tmpRepoRoot+"/zzzzz-s0uqq-382brsig8rp3666.git master:master").CombinedOutput() c.Assert(err, check.Equals, nil) _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo work >work && git add work && git -c user.name=Foo -c user.email=Foo commit -am 'workdir: test'").CombinedOutput() c.Assert(err, check.Equals, nil) _, err = exec.Command("git", "config", "--file", s.tmpWorkdir+"/.git/config", "credential.http://"+s.testServer.Addr+"/.helper", "!cred(){ cat >/dev/null; if [ \"$1\" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred").Output() c.Assert(err, check.Equals, nil) _, err = exec.Command("git", "config", "--file", s.tmpWorkdir+"/.git/config", "credential.http://"+s.testServer.Addr+"/.username", "none").Output() c.Assert(err, check.Equals, nil) if s.Config == nil { s.Config = &config{ Addr: ":0", GitCommand: "/usr/bin/git", Root: s.tmpRepoRoot, } } theConfig = s.Config err = s.testServer.Start() c.Assert(err, check.Equals, nil) // Clear ARVADOS_API_TOKEN after starting up the server, to // make sure arv-git-httpd doesn't use it. os.Setenv("ARVADOS_API_TOKEN", "unused-token-placates-client-library") }
func (s *integrationSuite) SetUpSuite(c *check.C) { if testing.Short() { c.Skip("-short") } arvadostest.ResetEnv() arvadostest.StartAPI() arvadostest.StartKeep(4, true) arv, err := arvadosclient.MakeArvadosClient() arv.ApiToken = arvadostest.DataManagerToken c.Assert(err, check.IsNil) s.keepClient = &keepclient.KeepClient{ Arvados: &arv, Client: &http.Client{}, } c.Assert(s.keepClient.DiscoverKeepServers(), check.IsNil) s.putReplicas(c, "foo", 4) s.putReplicas(c, "bar", 1) }
func runProxy(c *C, args []string, port int, bogusClientToken bool) keepclient.KeepClient { if bogusClientToken { os.Setenv("ARVADOS_API_TOKEN", "bogus-token") } arv, err := arvadosclient.MakeArvadosClient() c.Assert(err, Equals, nil) kc := keepclient.KeepClient{ Arvados: &arv, Want_replicas: 2, Using_proxy: true, Client: &http.Client{}, } locals := map[string]string{ "proxy": fmt.Sprintf("http://localhost:%v", port), } writableLocals := map[string]string{ "proxy": fmt.Sprintf("http://localhost:%v", port), } kc.SetServiceRoots(locals, writableLocals, nil) c.Check(kc.Using_proxy, Equals, true) c.Check(len(kc.LocalRoots()), Equals, 1) for _, root := range kc.LocalRoots() { c.Check(root, Equals, fmt.Sprintf("http://localhost:%v", port)) } log.Print("keepclient created") if bogusClientToken { arvadostest.ResetEnv() } { os.Args = append(args, fmt.Sprintf("-listen=:%v", port)) listener = nil go main() } return kc }
func (s *NoKeepServerSuite) SetUpTest(c *C) { arvadostest.ResetEnv() }
func (s *ServerRequiredSuite) SetUpTest(c *C) { arvadostest.ResetEnv() }
func (s *ServerRequiredSuite) TearDownSuite(c *C) { arvadostest.StopAPI() arvadostest.ResetEnv() }
func (s *MockArvadosServerSuite) SetUpTest(c *C) { arvadostest.ResetEnv() }
func (s *MockArvadosServerSuite) TearDownTest(c *C) { arvadostest.ResetEnv() }
func (s *TestSuite) TearDownTest(c *C) { arvadostest.ResetEnv() os.Args = initialArgs }
func (s *TestSuite) integrationTest(c *C, newSqueueCmd func() *exec.Cmd, sbatchCmdComps []string, runContainer func(*dispatch.Dispatcher, dispatch.Container)) dispatch.Container { arvadostest.ResetEnv() arv, err := arvadosclient.MakeArvadosClient() c.Assert(err, IsNil) var sbatchCmdLine []string // Override sbatchCmd defer func(orig func(dispatch.Container) *exec.Cmd) { sbatchCmd = orig }(sbatchCmd) sbatchCmd = func(container dispatch.Container) *exec.Cmd { sbatchCmdLine = sbatchFunc(container).Args return exec.Command("sh") } // Override squeueCmd defer func(orig func() *exec.Cmd) { squeueCmd = orig }(squeueCmd) squeueCmd = newSqueueCmd // There should be no queued containers now params := arvadosclient.Dict{ "filters": [][]string{[]string{"state", "=", "Queued"}}, } var containers dispatch.ContainerList err = arv.List("containers", params, &containers) c.Check(err, IsNil) c.Check(len(containers.Items), Equals, 1) echo := "echo" crunchRunCommand = &echo doneProcessing := make(chan struct{}) dispatcher := dispatch.Dispatcher{ Arv: arv, PollInterval: time.Duration(1) * time.Second, RunContainer: func(dispatcher *dispatch.Dispatcher, container dispatch.Container, status chan dispatch.Container) { go runContainer(dispatcher, container) run(dispatcher, container, status) doneProcessing <- struct{}{} }, DoneProcessing: doneProcessing} squeueUpdater.StartMonitor(time.Duration(500) * time.Millisecond) err = dispatcher.RunDispatcher() c.Assert(err, IsNil) squeueUpdater.Done() c.Check(sbatchCmdLine, DeepEquals, sbatchCmdComps) // There should be no queued containers now err = arv.List("containers", params, &containers) c.Check(err, IsNil) c.Check(len(containers.Items), Equals, 0) // Previously "Queued" container should now be in "Complete" state var container dispatch.Container err = arv.Get("containers", "zzzzz-dz642-queuedcontainer", nil, &container) c.Check(err, IsNil) return container }