Example #1
0
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)
	}
}
Example #2
0
func (s *NoKeepServerSuite) SetUpSuite(c *C) {
	arvadostest.StartAPI()
	// We need API to have some keep services listed, but the
	// services themselves should be unresponsive.
	arvadostest.StartKeep(2, false)
	arvadostest.StopKeep(2)
}
func (s *TestSuite) SetUpTest(c *C) {
	args := []string{"crunch-dispatch-slurm"}
	os.Args = args

	arvadostest.StartAPI()
	os.Setenv("ARVADOS_API_TOKEN", arvadostest.Dispatch1Token)
}
Example #4
0
func (s *ServerRequiredSuite) SetUpSuite(c *C) {
	if *no_server {
		c.Skip("Skipping tests that require server")
		return
	}
	arvadostest.StartAPI()
	arvadostest.StartKeep()
}
Example #5
0
func (s *IntegrationSuite) SetUpSuite(c *check.C) {
	arvadostest.StartAPI()
	arvadostest.StartKeep(2, true)

	arv, err := arvadosclient.MakeArvadosClient()
	c.Assert(err, check.Equals, nil)
	arv.ApiToken = arvadostest.ActiveToken
	kc, err := keepclient.MakeKeepClient(&arv)
	c.Assert(err, check.Equals, nil)
	kc.PutB([]byte("Hello world\n"))
	kc.PutB([]byte("foo"))
	kc.PutB([]byte("foobar"))
}
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()

	// 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
}
Example #7
0
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)
}
Example #8
0
func (s *ServerRequiredSuite) SetUpSuite(c *C) {
	arvadostest.StartAPI()
	arvadostest.StartKeep(2, false)
}
Example #9
0
func (s *ServerRequiredSuite) SetUpSuite(c *C) {
	// Start API server
	arvadostest.StartAPI()
}
Example #10
0
func (s *IntegrationSuite) SetUpSuite(c *check.C) {
	arvadostest.StartAPI()
}
func (s *TestSuite) SetUpSuite(c *C) {
	initialArgs = os.Args
	arvadostest.StartAPI()
	runningCmds = make(map[string]*exec.Cmd)
}
Example #12
0
// Testing keep-rsync needs two sets of keep services: src and dst.
// The test setup hence creates 3 servers instead of the default 2,
// and uses the first 2 as src and the 3rd as dst keep servers.
func setupRsync(c *C, enforcePermissions bool, replications int) {
	// srcConfig
	var srcConfig apiConfig
	srcConfig.APIHost = os.Getenv("ARVADOS_API_HOST")
	srcConfig.APIToken = os.Getenv("ARVADOS_API_TOKEN")
	srcConfig.APIHostInsecure = matchTrue.MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE"))

	// dstConfig
	var dstConfig apiConfig
	dstConfig.APIHost = os.Getenv("ARVADOS_API_HOST")
	dstConfig.APIToken = os.Getenv("ARVADOS_API_TOKEN")
	dstConfig.APIHostInsecure = matchTrue.MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE"))

	if enforcePermissions {
		blobSigningKey = "zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc"
	}

	// Start Keep servers
	arvadostest.StartAPI()
	arvadostest.StartKeepWithParams(3, enforcePermissions)

	// setup keepclients
	var err error
	kcSrc, err = setupKeepClient(srcConfig, srcKeepServicesJSON, false, 0)
	c.Check(err, IsNil)

	kcDst, err = setupKeepClient(dstConfig, dstKeepServicesJSON, true, replications)
	c.Check(err, IsNil)

	for uuid := range kcSrc.LocalRoots() {
		if strings.HasSuffix(uuid, "02") {
			delete(kcSrc.LocalRoots(), uuid)
		}
	}
	for uuid := range kcSrc.GatewayRoots() {
		if strings.HasSuffix(uuid, "02") {
			delete(kcSrc.GatewayRoots(), uuid)
		}
	}
	for uuid := range kcSrc.WritableLocalRoots() {
		if strings.HasSuffix(uuid, "02") {
			delete(kcSrc.WritableLocalRoots(), uuid)
		}
	}

	for uuid := range kcDst.LocalRoots() {
		if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
			delete(kcDst.LocalRoots(), uuid)
		}
	}
	for uuid := range kcDst.GatewayRoots() {
		if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
			delete(kcDst.GatewayRoots(), uuid)
		}
	}
	for uuid := range kcDst.WritableLocalRoots() {
		if strings.HasSuffix(uuid, "00") || strings.HasSuffix(uuid, "01") {
			delete(kcDst.WritableLocalRoots(), uuid)
		}
	}

	if replications == 0 {
		// Must have got default replications value of 2 from dst discovery document
		c.Assert(kcDst.Want_replicas, Equals, 2)
	} else {
		// Since replications value is provided, it is used
		c.Assert(kcDst.Want_replicas, Equals, replications)
	}
}