當前位置: 首頁>>代碼示例>>Golang>>正文


Golang arvadostest.ResetEnv函數代碼示例

本文整理匯總了Golang中git/curoverse/com/arvados/git/sdk/go/arvadostest.ResetEnv函數的典型用法代碼示例。如果您正苦於以下問題:Golang ResetEnv函數的具體用法?Golang ResetEnv怎麽用?Golang ResetEnv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ResetEnv函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SetupDataManagerTest

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)
	}
}
開發者ID:aflyhorse,項目名稱:arvados,代碼行數:31,代碼來源:datamanager_test.go

示例2: SetUpTest

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)
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:8,代碼來源:server_test.go

示例3: SetUpTest

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")
}
開發者ID:Kunde21,項目名稱:arvados,代碼行數:47,代碼來源:integration_test.go

示例4: SetUpSuite

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)
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:19,代碼來源:integration_test.go

示例5: runProxy

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
}
開發者ID:brainstorm,項目名稱:arvados,代碼行數:37,代碼來源:keepproxy_test.go

示例6: SetUpTest

func (s *NoKeepServerSuite) SetUpTest(c *C) {
	arvadostest.ResetEnv()
}
開發者ID:Kunde21,項目名稱:arvados,代碼行數:3,代碼來源:keepproxy_test.go

示例7: TearDownSuite

func (s *ServerRequiredSuite) TearDownSuite(c *C) {
	arvadostest.StopAPI()
	arvadostest.ResetEnv()
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:4,代碼來源:keep-rsync_test.go

示例8: SetUpTest

func (s *MockArvadosServerSuite) SetUpTest(c *C) {
	arvadostest.ResetEnv()
}
開發者ID:Kunde21,項目名稱:arvados,代碼行數:3,代碼來源:arvadosclient_test.go

示例9: TearDownTest

func (s *MockArvadosServerSuite) TearDownTest(c *C) {
	arvadostest.ResetEnv()
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:3,代碼來源:crunch-dispatch-local_test.go

示例10: integrationTest

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
}
開發者ID:pombredanne,項目名稱:arvados,代碼行數:71,代碼來源:crunch-dispatch-slurm_test.go


注:本文中的git/curoverse/com/arvados/git/sdk/go/arvadostest.ResetEnv函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。