+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
package arvadosclient
import (
"fmt"
- "git.curoverse.com/arvados.git/sdk/go/arvadostest"
- . "gopkg.in/check.v1"
"net"
"net/http"
"os"
"testing"
"time"
+
+ "git.curoverse.com/arvados.git/sdk/go/arvadostest"
+ . "gopkg.in/check.v1"
)
// Gocheck boilerplate
RetryDelay = 0
}
+func (s *ServerRequiredSuite) TearDownSuite(c *C) {
+ arvadostest.StopKeep(2)
+ arvadostest.StopAPI()
+}
+
func (s *ServerRequiredSuite) SetUpTest(c *C) {
arvadostest.ResetEnv()
}
func (s *ServerRequiredSuite) TestMakeArvadosClientSecure(c *C) {
os.Setenv("ARVADOS_API_HOST_INSECURE", "")
- kc, err := MakeArvadosClient()
+ ac, err := MakeArvadosClient()
c.Assert(err, Equals, nil)
- c.Check(kc.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
- c.Check(kc.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
- c.Check(kc.ApiInsecure, Equals, false)
+ c.Check(ac.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
+ c.Check(ac.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
+ c.Check(ac.ApiInsecure, Equals, false)
}
func (s *ServerRequiredSuite) TestMakeArvadosClientInsecure(c *C) {
os.Setenv("ARVADOS_API_HOST_INSECURE", "true")
- kc, err := MakeArvadosClient()
+ ac, err := MakeArvadosClient()
c.Assert(err, Equals, nil)
- c.Check(kc.ApiInsecure, Equals, true)
- c.Check(kc.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
- c.Check(kc.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
- c.Check(kc.Client.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify, Equals, true)
+ c.Check(ac.ApiInsecure, Equals, true)
+ c.Check(ac.ApiServer, Equals, os.Getenv("ARVADOS_API_HOST"))
+ c.Check(ac.ApiToken, Equals, os.Getenv("ARVADOS_API_TOKEN"))
+ c.Check(ac.Client.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify, Equals, true)
}
func (s *ServerRequiredSuite) TestGetInvalidUUID(c *C) {
Dict{"log": Dict{"bogus_attr": "foo"}},
&getback)
c.Assert(err, ErrorMatches, "arvados API server error: .*")
- c.Assert(err, ErrorMatches, ".*unknown attribute: bogus_attr.*")
+ c.Assert(err, ErrorMatches, ".*unknown attribute(: | ')bogus_attr.*")
c.Assert(err, FitsTypeOf, APIServerError{})
c.Assert(err.(APIServerError).HttpStatusCode, Equals, 422)
}
{
"get", 0, 401, []int{500, 401, 200}, []string{``, ``, `{"ok":"ok"}`},
},
- // Use nil responseBody 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.
+
+ // Response code -1 simulates an HTTP/network error
+ // (i.e., Do() returns an error; there is no HTTP
+ // response status code).
+
+ // Succeed on second retry
{
"get", 0, 200, []int{-1, -1, 200}, []string{``, ``, `{"ok":"ok"}`},
},
+ // "POST" is not safe to retry: fail after one error
{
"create", 0, -1, []int{-1, 200}, []string{``, `{"ok":"ok"}`},
},