[ARVADOS] updated: c84882514f7943481ff0be5b181dc9bd87cfb300
git at public.curoverse.com
git at public.curoverse.com
Tue Nov 24 15:08:37 EST 2015
Summary of changes:
sdk/go/arvadostest/testing.go | 24 ++++----
services/datamanager/collection/collection_test.go | 66 ++++++++++++++++++++++
2 files changed, 76 insertions(+), 14 deletions(-)
via c84882514f7943481ff0be5b181dc9bd87cfb300 (commit)
from f8192fbfdac74e88ac60dc8c1e652745873471a7 (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 c84882514f7943481ff0be5b181dc9bd87cfb300
Author: radhika <radhika at curoverse.com>
Date: Tue Nov 24 15:02:20 2015 -0500
7253: Write a test that "does not" fail when an invalid manifest text is retrieved during collection.GetCollections(). The expected behavior: GetCollections() raises error in this case and hence datamanager aborts without deleting any blocks.
diff --git a/sdk/go/arvadostest/testing.go b/sdk/go/arvadostest/testing.go
index 7d75952..3a40b3c 100644
--- a/sdk/go/arvadostest/testing.go
+++ b/sdk/go/arvadostest/testing.go
@@ -23,13 +23,11 @@ func (stub *APIStub) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
}
pathResponse := stub.Data[req.URL.Path]
- if pathResponse.ResponseBody != "" {
- if pathResponse.ResponseStatus == -1 {
- http.Redirect(resp, req, "/redirect-loop", http.StatusFound)
- } else {
- resp.WriteHeader(pathResponse.ResponseStatus)
- resp.Write([]byte(pathResponse.ResponseBody))
- }
+ if pathResponse.ResponseStatus == -1 {
+ http.Redirect(resp, req, "/redirect-loop", http.StatusFound)
+ } else if pathResponse.ResponseBody != "" {
+ resp.WriteHeader(pathResponse.ResponseStatus)
+ resp.Write([]byte(pathResponse.ResponseBody))
} else {
resp.WriteHeader(500)
resp.Write([]byte(``))
@@ -49,13 +47,11 @@ func (stub *KeepServerStub) ServeHTTP(resp http.ResponseWriter, req *http.Reques
}
pathResponse := stub.Data[req.URL.Path]
- if pathResponse.ResponseBody != "" {
- if pathResponse.ResponseStatus == -1 {
- http.Redirect(resp, req, "/redirect-loop", http.StatusFound)
- } else {
- resp.WriteHeader(pathResponse.ResponseStatus)
- resp.Write([]byte(pathResponse.ResponseBody))
- }
+ if pathResponse.ResponseStatus == -1 {
+ http.Redirect(resp, req, "/redirect-loop", http.StatusFound)
+ } else if pathResponse.ResponseBody != "" {
+ resp.WriteHeader(pathResponse.ResponseStatus)
+ resp.Write([]byte(pathResponse.ResponseBody))
} else {
resp.WriteHeader(500)
resp.Write([]byte(``))
diff --git a/services/datamanager/collection/collection_test.go b/services/datamanager/collection/collection_test.go
index 07c82e1..3938b2f 100644
--- a/services/datamanager/collection/collection_test.go
+++ b/services/datamanager/collection/collection_test.go
@@ -1,8 +1,12 @@
package collection
import (
+ "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+ "git.curoverse.com/arvados.git/sdk/go/arvadostest"
"git.curoverse.com/arvados.git/sdk/go/blockdigest"
. "gopkg.in/check.v1"
+ "net/http"
+ "net/http/httptest"
"testing"
)
@@ -121,3 +125,65 @@ func (s *MySuite) TestSummarizeOverlapping(checker *C) {
CompareSummarizedReadCollections(checker, rc, expected)
}
+
+type APITestData struct {
+ // path and response map
+ data map[string]arvadostest.StatusAndBody
+
+ // expected error, if any
+ expectedError string
+}
+
+func (s *MySuite) TestGetCollectionsAndSummarize_DiscoveryError(c *C) {
+ testData := APITestData{}
+ testData.expectedError = "arvados API server error: 500.*"
+ testGetCollectionsAndSummarize(c, testData)
+}
+
+func (s *MySuite) TestGetCollectionsAndSummarize_ApiErrorGetCollections(c *C) {
+ dataMap := make(map[string]arvadostest.StatusAndBody)
+ dataMap["/discovery/v1/apis/arvados/v1/rest"] = arvadostest.StatusAndBody{200, `{"defaultCollectionReplication":2}`}
+ dataMap["/arvados/v1/collections"] = arvadostest.StatusAndBody{-1, ``}
+
+ testData := APITestData{}
+ testData.data = dataMap
+ testData.expectedError = "arvados API server error: 302.*"
+
+ testGetCollectionsAndSummarize(c, testData)
+}
+
+func (s *MySuite) TestGetCollectionsAndSummarize_GetCollectionsBadManifest(c *C) {
+ dataMap := make(map[string]arvadostest.StatusAndBody)
+ dataMap["/discovery/v1/apis/arvados/v1/rest"] = arvadostest.StatusAndBody{200, `{"defaultCollectionReplication":2}`}
+ dataMap["/arvados/v1/collections"] = arvadostest.StatusAndBody{200, `{"items_available":1,"items":[{"modified_at":"2015-11-24T15:04:05Z","manifest_text":"thisisnotavalidmanifest"}]}`}
+
+ testData := APITestData{}
+ testData.data = dataMap
+ testData.expectedError = ".*invalid manifest format.*"
+
+ testGetCollectionsAndSummarize(c, testData)
+}
+
+func testGetCollectionsAndSummarize(c *C, testData APITestData) {
+ apiStub := arvadostest.APIStub{testData.data}
+
+ api := httptest.NewServer(&apiStub)
+ defer api.Close()
+
+ arv := arvadosclient.ArvadosClient{
+ Scheme: "http",
+ ApiServer: api.URL[7:],
+ ApiToken: "abc123",
+ Client: &http.Client{Transport: &http.Transport{}},
+ }
+
+ // GetCollectionsAndSummarize
+ results := GetCollectionsAndSummarize(GetCollectionsParams{arv, nil, 10})
+
+ if testData.expectedError == "" {
+ c.Assert(results.Err, IsNil)
+ c.Assert(results, NotNil)
+ } else {
+ c.Assert(results.Err, ErrorMatches, testData.expectedError)
+ }
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list