X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d0f91b34eedec9af266ec4877a3005dd627ad38e..ba57b6537679889b42693ecd839a94d59c716aaf:/services/keepstore/pull_worker_test.go diff --git a/services/keepstore/pull_worker_test.go b/services/keepstore/pull_worker_test.go index c6a4195384..43a6de6844 100644 --- a/services/keepstore/pull_worker_test.go +++ b/services/keepstore/pull_worker_test.go @@ -8,20 +8,13 @@ import ( . "gopkg.in/check.v1" "io" "net/http" - "testing" "time" ) -type PullWorkerTestSuite struct{} - -// Gocheck boilerplate -func TestPullWorker(t *testing.T) { - TestingT(t) -} - -// Gocheck boilerplate var _ = Suite(&PullWorkerTestSuite{}) +type PullWorkerTestSuite struct{} + var testPullLists map[string]string var readContent string var readError error @@ -46,7 +39,7 @@ func (s *PullWorkerTestSuite) SetUpTest(c *C) { func RunTestPullWorker(c *C) { arv, err := arvadosclient.MakeArvadosClient() c.Assert(err, Equals, nil) - keepClient, err := keepclient.MakeKeepClient(&arv) + keepClient, err := keepclient.MakeKeepClient(arv) c.Assert(err, Equals, nil) pullq = NewWorkQueue() @@ -91,10 +84,10 @@ type PullWorkerTestData struct { func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_two_locators(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorkerPullList_with_two_locators", - req: RequestTester{"/pull", dataManagerToken, "PUT", firstPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", firstPullList}, responseCode: http.StatusOK, responseBody: "Received 2 pull requests\n", readContent: "hello", @@ -108,10 +101,10 @@ func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_two_locators(c *C) { func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_one_locator(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorkerPullList_with_one_locator", - req: RequestTester{"/pull", dataManagerToken, "PUT", secondPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", secondPullList}, responseCode: http.StatusOK, responseBody: "Received 1 pull requests\n", readContent: "hola", @@ -125,10 +118,10 @@ func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_one_locator(c *C) { func (s *PullWorkerTestSuite) TestPullWorker_error_on_get_one_locator(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorker_error_on_get_one_locator", - req: RequestTester{"/pull", dataManagerToken, "PUT", secondPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", secondPullList}, responseCode: http.StatusOK, responseBody: "Received 1 pull requests\n", readContent: "unused", @@ -142,10 +135,10 @@ func (s *PullWorkerTestSuite) TestPullWorker_error_on_get_one_locator(c *C) { func (s *PullWorkerTestSuite) TestPullWorker_error_on_get_two_locators(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorker_error_on_get_two_locators", - req: RequestTester{"/pull", dataManagerToken, "PUT", firstPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", firstPullList}, responseCode: http.StatusOK, responseBody: "Received 2 pull requests\n", readContent: "unused", @@ -159,10 +152,10 @@ func (s *PullWorkerTestSuite) TestPullWorker_error_on_get_two_locators(c *C) { func (s *PullWorkerTestSuite) TestPullWorker_error_on_put_one_locator(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorker_error_on_put_one_locator", - req: RequestTester{"/pull", dataManagerToken, "PUT", secondPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", secondPullList}, responseCode: http.StatusOK, responseBody: "Received 1 pull requests\n", readContent: "hello hello", @@ -176,10 +169,10 @@ func (s *PullWorkerTestSuite) TestPullWorker_error_on_put_one_locator(c *C) { func (s *PullWorkerTestSuite) TestPullWorker_error_on_put_two_locators(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorker_error_on_put_two_locators", - req: RequestTester{"/pull", dataManagerToken, "PUT", firstPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", firstPullList}, responseCode: http.StatusOK, responseBody: "Received 2 pull requests\n", readContent: "hello again", @@ -202,10 +195,10 @@ func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_two_items_latest_repla pullq.ReplaceQueue(makeTestWorkList(firstInput)) testPullLists["Added_before_actual_test_item"] = string(1) - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorkerPullList_with_two_items_latest_replacing_old", - req: RequestTester{"/pull", dataManagerToken, "PUT", secondPullList}, + req: RequestTester{"/pull", theConfig.systemAuthToken, "PUT", secondPullList}, responseCode: http.StatusOK, responseBody: "Received 1 pull requests\n", readContent: "hola de nuevo", @@ -217,14 +210,14 @@ func (s *PullWorkerTestSuite) TestPullWorkerPullList_with_two_items_latest_repla } // In this case, the item will not be placed on pullq -func (s *PullWorkerTestSuite) TestPullWorker_invalid_dataManagerToken(c *C) { +func (s *PullWorkerTestSuite) TestPullWorker_invalidToken(c *C) { defer teardown() - dataManagerToken = "DATA MANAGER TOKEN" + theConfig.systemAuthToken = "DATA MANAGER TOKEN" testData := PullWorkerTestData{ name: "TestPullWorkerPullList_with_two_locators", - req: RequestTester{"/pull", "invalid_dataManagerToken", "PUT", firstPullList}, + req: RequestTester{"/pull", "invalidToken", "PUT", firstPullList}, responseCode: http.StatusUnauthorized, responseBody: "Unauthorized\n", readContent: "hello",