[ARVADOS] updated: 4c00b4c7c670abe7da5c61e437887a53bbcaadf9
git at public.curoverse.com
git at public.curoverse.com
Mon Nov 9 08:39:42 EST 2015
Summary of changes:
sdk/go/arvadosclient/arvadosclient_test.go | 39 ++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 10 deletions(-)
via 4c00b4c7c670abe7da5c61e437887a53bbcaadf9 (commit)
from 4517ed5d2c28870422faf8057d4f6708242cc5a0 (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 4c00b4c7c670abe7da5c61e437887a53bbcaadf9
Author: radhika <radhika at curoverse.com>
Date: Mon Nov 9 08:38:29 2015 -0500
5538: add a test that simulates error during requesting server so that we can test the error path as well.
diff --git a/sdk/go/arvadosclient/arvadosclient_test.go b/sdk/go/arvadosclient/arvadosclient_test.go
index 3746ad0..f5ce338 100644
--- a/sdk/go/arvadosclient/arvadosclient_test.go
+++ b/sdk/go/arvadosclient/arvadosclient_test.go
@@ -251,17 +251,17 @@ func RunFakeArvadosServer(st http.Handler) (api APIServer, err error) {
}
type APIStub struct {
- method string
- count int
- expected int
- respStatus []int
- responseBody []string
+ method string
+ retryAttempts int
+ expected int
+ respStatus []int
+ responseBody []string
}
func (h *APIStub) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
- resp.WriteHeader(h.respStatus[h.count])
- resp.Write([]byte(h.responseBody[h.count]))
- h.count++
+ resp.WriteHeader(h.respStatus[h.retryAttempts])
+ resp.Write([]byte(h.responseBody[h.retryAttempts]))
+ h.retryAttempts++
}
func (s *MockArvadosServerSuite) TestWithRetries(c *C) {
@@ -314,6 +314,14 @@ func (s *MockArvadosServerSuite) TestWithRetries(c *C) {
{
"get", 0, 401, []int{500, 401, 200}, []string{``, ``, `{"ok":"ok"}`},
},
+ // Use expected = 0 to simulate error during request processing
+ // Even though retryable, the simulated error applies during reties also, and hence "get" also eventually fails in this test.
+ {
+ "get", 0, 0, []int{500, 500, 500}, []string{``, ``, ``},
+ },
+ {
+ "create", 0, 0, []int{500, 500, 500}, []string{``, ``, ``},
+ },
} {
api, err := RunFakeArvadosServer(&stub)
c.Check(err, IsNil)
@@ -328,6 +336,12 @@ func (s *MockArvadosServerSuite) TestWithRetries(c *C) {
Client: &http.Client{Transport: &http.Transport{}},
Retries: 2}
+ // We use expected = 0 to look for errors during request processing
+ // Simulate an error using https (but the arv.Client transport used does not support it)
+ if stub.expected == 0 {
+ arv.Scheme = "https"
+ }
+
getback := make(Dict)
switch stub.method {
case "get":
@@ -349,8 +363,13 @@ func (s *MockArvadosServerSuite) TestWithRetries(c *C) {
c.Assert(getback["ok"], Equals, "ok")
} else {
c.Check(err, NotNil)
- c.Check(strings.Contains(err.Error(), fmt.Sprintf("%s%d", "arvados API server error: ", stub.expected)), Equals, true)
- c.Assert(err.(APIServerError).HttpStatusCode, Equals, stub.expected)
+
+ if stub.expected == 0 { // test uses 0 to look for errors during request processing
+ c.Check(strings.Contains(err.Error(), fmt.Sprintf("%s", "tls: oversized record received")), Equals, true)
+ } else {
+ c.Check(strings.Contains(err.Error(), fmt.Sprintf("%s%d", "arvados API server error: ", stub.expected)), Equals, true)
+ c.Assert(err.(APIServerError).HttpStatusCode, Equals, stub.expected)
+ }
}
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list