Example #1
0
func (s *ServerRequiredSuite) SetUpSuite(c *C) {
	if *no_server {
		c.Skip("Skipping tests that require server")
		return
	}
	arvadostest.StartAPI()
	arvadostest.StartKeep(2, false)
}
func SetupPullWorkerIntegrationTest(t *testing.T, testData PullWorkIntegrationTestData, wantData bool) PullRequest {
	os.Setenv("ARVADOS_API_HOST_INSECURE", "true")

	// start api and keep servers
	arvadostest.StartAPI()
	arvadostest.StartKeep(2, false)

	// make arvadosclient
	arv, err := arvadosclient.MakeArvadosClient()
	if err != nil {
		t.Error("Error creating arv")
	}

	// keep client
	keepClient = &keepclient.KeepClient{
		Arvados:       &arv,
		Want_replicas: 1,
		Using_proxy:   true,
		Client:        &http.Client{},
	}

	// discover keep services
	var servers []string
	if err := keepClient.DiscoverKeepServers(); err != nil {
		t.Error("Error discovering keep services")
	}
	for _, host := range keepClient.LocalRoots() {
		servers = append(servers, host)
	}

	// Put content if the test needs it
	if wantData {
		locator, _, err := keepClient.PutB([]byte(testData.Content))
		if err != nil {
			t.Errorf("Error putting test data in setup for %s %s %v", testData.Content, locator, err)
		}
		if locator == "" {
			t.Errorf("No locator found after putting test data")
		}
	}

	// Create pullRequest for the test
	pullRequest := PullRequest{
		Locator: testData.Locator,
		Servers: servers,
	}
	return pullRequest
}