[ARVADOS] updated: f54333c878b8d6bd5f78061b3ba406bee6abad36

git at public.curoverse.com git at public.curoverse.com
Fri Mar 6 15:19:54 EST 2015


Summary of changes:
 services/keepstore/pull_worker.go      |  5 ++-
 services/keepstore/pull_worker_test.go | 72 ++++++++++++++++++----------------
 2 files changed, 42 insertions(+), 35 deletions(-)

       via  f54333c878b8d6bd5f78061b3ba406bee6abad36 (commit)
       via  2a4c56d2a0eead4c2863ff12882dc6512d4bf803 (commit)
      from  c7200a367392801491134e97192840b8b20fc90b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit f54333c878b8d6bd5f78061b3ba406bee6abad36
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Fri Mar 6 15:19:27 2015 -0500

    3761: update GetContent function to use read_content test data info.

diff --git a/services/keepstore/pull_worker_test.go b/services/keepstore/pull_worker_test.go
index eb74850..820f951 100644
--- a/services/keepstore/pull_worker_test.go
+++ b/services/keepstore/pull_worker_test.go
@@ -29,8 +29,6 @@ var putContent []byte
 var putError error
 var currentTestData PullWorkerTestData
 
-const READ_CONTENT = "Hi!"
-
 func (s *PullWorkerTestSuite) SetUpTest(c *C) {
 	readContent = ""
 	readError = nil
@@ -38,7 +36,8 @@ func (s *PullWorkerTestSuite) SetUpTest(c *C) {
 	putError = nil
 
 	// When a new pull request arrives, the old one will be overwritten.
-	// This behavior is verified using these maps in the "TestPullWorker_pull_list_with_two_items_latest_replacing_old"
+	// This behavior is verified using these two maps in the
+	// "TestPullWorker_pull_list_with_two_items_latest_replacing_old"
 	testPullLists = make(map[string]string)
 	processedPullLists = make(map[string]string)
 }
@@ -168,7 +167,7 @@ func (s *PullWorkerTestSuite) TestPullWorker_error_on_put_one_locator(c *C) {
 		req:           RequestTester{"/pull", data_manager_token, "PUT", second_pull_list},
 		response_code: http.StatusOK,
 		response_body: "Received 1 pull requests\n",
-		read_content:  "unused",
+		read_content:  "hello hello",
 		read_error:    false,
 		put_error:     true,
 	}
@@ -185,7 +184,7 @@ func (s *PullWorkerTestSuite) TestPullWorker_error_on_put_two_locators(c *C) {
 		req:           RequestTester{"/pull", data_manager_token, "PUT", first_pull_list},
 		response_code: http.StatusOK,
 		response_body: "Received 2 pull requests\n",
-		read_content:  "unused",
+		read_content:  "hello again",
 		read_error:    false,
 		put_error:     true,
 	}
@@ -211,7 +210,7 @@ func (s *PullWorkerTestSuite) TestPullWorker_pull_list_with_two_items_latest_rep
 		req:           RequestTester{"/pull", data_manager_token, "PUT", second_pull_list},
 		response_code: http.StatusOK,
 		response_body: "Received 1 pull requests\n",
-		read_content:  "hola",
+		read_content:  "hola de nuevo",
 		read_error:    false,
 		put_error:     false,
 	}
@@ -235,11 +234,11 @@ func performTest(testData PullWorkerTestData, c *C) {
 			readError = err
 			return nil, 0, "", err
 		} else {
-			readContent = READ_CONTENT
-			cb := &ClosingBuffer{bytes.NewBufferString(readContent)}
+			readContent = testData.read_content
+			cb := &ClosingBuffer{bytes.NewBufferString(testData.read_content)}
 			var rc io.ReadCloser
 			rc = cb
-			return rc, int64(len(READ_CONTENT)), "", nil
+			return rc, int64(len(testData.read_content)), "", nil
 		}
 	}
 
@@ -279,12 +278,12 @@ func performTest(testData PullWorkerTestData, c *C) {
 		c.Assert(readError, NotNil)
 	} else {
 		c.Assert(readError, IsNil)
-		c.Assert(readContent, Equals, READ_CONTENT)
+		c.Assert(readContent, Equals, testData.read_content)
 		if testData.put_error {
 			c.Assert(putError, NotNil)
 		} else {
 			c.Assert(putError, IsNil)
-			c.Assert(string(putContent), Equals, READ_CONTENT)
+			c.Assert(string(putContent), Equals, testData.read_content)
 		}
 	}
 

commit 2a4c56d2a0eead4c2863ff12882dc6512d4bf803
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Fri Mar 6 14:21:58 2015 -0500

    3761: move test assertions from teardown method into performTest function for better readability of code.

diff --git a/services/keepstore/pull_worker.go b/services/keepstore/pull_worker.go
index 46b933c..5a631e0 100644
--- a/services/keepstore/pull_worker.go
+++ b/services/keepstore/pull_worker.go
@@ -40,6 +40,9 @@ func RunPullWorker(pullq *WorkQueue, keepClient keepclient.KeepClient) {
 		Write to storage
 */
 func Pull(pullRequest PullRequest, keepClient keepclient.KeepClient) (err error) {
+	token := GenerateRandomApiToken()
+	keepClient.Arvados.ApiToken = token
+
 	service_roots := make(map[string]string)
 	for _, addr := range pullRequest.Servers {
 		service_roots[addr] = addr
@@ -48,7 +51,7 @@ func Pull(pullRequest PullRequest, keepClient keepclient.KeepClient) (err error)
 
 	// Generate signature with a random token
 	expires_at := time.Now().Add(60 * time.Second)
-	signedLocator := SignLocator(pullRequest.Locator, GenerateRandomApiToken(), expires_at)
+	signedLocator := SignLocator(pullRequest.Locator, token, expires_at)
 
 	reader, contentLen, _, err := GetContent(signedLocator, keepClient)
 	if err != nil {
diff --git a/services/keepstore/pull_worker_test.go b/services/keepstore/pull_worker_test.go
index 8c99a14..eb74850 100644
--- a/services/keepstore/pull_worker_test.go
+++ b/services/keepstore/pull_worker_test.go
@@ -43,31 +43,6 @@ func (s *PullWorkerTestSuite) SetUpTest(c *C) {
 	processedPullLists = make(map[string]string)
 }
 
-func (s *PullWorkerTestSuite) TearDownTest(c *C) {
-	expectWorkerChannelEmpty(c, pullq.NextItem)
-
-	if currentTestData.name == "TestPullWorker_pull_list_with_two_items_latest_replacing_old" {
-		c.Assert(len(testPullLists), Equals, 2)
-		c.Assert(len(processedPullLists), Equals, 1)
-		c.Assert(testPullLists["Added_before_actual_test_item"], NotNil)
-		c.Assert(testPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil)
-		c.Assert(processedPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil)
-	}
-
-	if currentTestData.read_error {
-		c.Assert(readError, NotNil)
-	} else {
-		c.Assert(readError, IsNil)
-		c.Assert(readContent, Equals, READ_CONTENT)
-		if currentTestData.put_error {
-			c.Assert(putError, NotNil)
-		} else {
-			c.Assert(putError, IsNil)
-			c.Assert(string(putContent), Equals, READ_CONTENT)
-		}
-	}
-}
-
 // Since keepstore does not come into picture in tests,
 // we need to explicitly start the goroutine in tests.
 func RunTestPullWorker(c *C) {
@@ -283,6 +258,36 @@ func performTest(testData PullWorkerTestData, c *C) {
 	response := IssueRequest(&testData.req)
 	c.Assert(testData.response_code, Equals, response.Code)
 	c.Assert(testData.response_body, Equals, response.Body.String())
+
+	expectWorkerChannelEmpty(c, pullq.NextItem)
+
+	pullq.Close()
+
+	if testData.name == "TestPullWorker_pull_list_with_two_items_latest_replacing_old" {
+		c.Assert(len(testPullLists), Equals, 2)
+		c.Assert(len(processedPullLists), Equals, 1)
+		c.Assert(testPullLists["Added_before_actual_test_item"], NotNil)
+		c.Assert(testPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil)
+		c.Assert(processedPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil)
+	} else {
+		c.Assert(len(testPullLists), Equals, 1)
+		c.Assert(len(processedPullLists), Equals, 1)
+		c.Assert(testPullLists[testData.name], NotNil)
+	}
+
+	if testData.read_error {
+		c.Assert(readError, NotNil)
+	} else {
+		c.Assert(readError, IsNil)
+		c.Assert(readContent, Equals, READ_CONTENT)
+		if testData.put_error {
+			c.Assert(putError, NotNil)
+		} else {
+			c.Assert(putError, IsNil)
+			c.Assert(string(putContent), Equals, READ_CONTENT)
+		}
+	}
+
 }
 
 type ClosingBuffer struct {

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list