status := <-upload_status
c.Check(status, DeepEquals, uploadStatus{nil, fmt.Sprintf("%s/%s", url, st.expectPath), 200, 1, ""})
})
-
- log.Printf("TestUploadToStubKeepServer done")
}
func (s *StandaloneSuite) TestUploadToStubKeepServerBufferReader(c *C) {
- log.Printf("TestUploadToStubKeepServerBufferReader")
-
st := StubPutHandler{
c,
"acbd18db4cc2f85cedef654fccc4a4d8",
status := <-upload_status
c.Check(status, DeepEquals, uploadStatus{nil, fmt.Sprintf("%s/%s", url, st.expectPath), 200, 1, ""})
})
-
- log.Printf("TestUploadToStubKeepServerBufferReader done")
}
type FailHandler struct {
}
func (s *StandaloneSuite) TestFailedUploadToStubKeepServer(c *C) {
- log.Printf("TestFailedUploadToStubKeepServer")
-
st := FailHandler{
make(chan string)}
c.Check(status.url, Equals, fmt.Sprintf("%s/%s", url, hash))
c.Check(status.statusCode, Equals, 500)
})
- log.Printf("TestFailedUploadToStubKeepServer done")
}
type KeepServer struct {
}
func (s *StandaloneSuite) TestPutB(c *C) {
- log.Printf("TestPutB")
-
hash := Md5String("foo")
st := StubPutHandler{
(s1 == shuff[1] && s2 == shuff[0]),
Equals,
true)
-
- log.Printf("TestPutB done")
}
func (s *StandaloneSuite) TestPutHR(c *C) {
- log.Printf("TestPutHR")
-
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubPutHandler{
kc.PutHR(hash, reader, 3)
shuff := NewRootSorter(kc.LocalRoots(), hash).GetSortedRoots()
- log.Print(shuff)
s1 := <-st.handled
s2 := <-st.handled
(s1 == shuff[1] && s2 == shuff[0]),
Equals,
true)
-
- log.Printf("TestPutHR done")
}
func (s *StandaloneSuite) TestPutWithFail(c *C) {
- log.Printf("TestPutWithFail")
-
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubPutHandler{
shuff := NewRootSorter(
kc.LocalRoots(), Md5String("foo")).GetSortedRoots()
+ c.Logf("%+v", shuff)
phash, replicas, err := kc.PutB([]byte("foo"))
}
func (s *StandaloneSuite) TestPutWithTooManyFail(c *C) {
- log.Printf("TestPutWithTooManyFail")
-
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubPutHandler{
c.Check(err, Equals, InsufficientReplicasError)
c.Check(replicas, Equals, 1)
c.Check(<-st.handled, Equals, ks1[0].url)
-
- log.Printf("TestPutWithTooManyFail done")
}
type StubGetHandler struct {
}
func (s *StandaloneSuite) TestGet(c *C) {
- log.Printf("TestGet")
-
hash := fmt.Sprintf("%x", md5.Sum([]byte("foo")))
st := StubGetHandler{
content, err2 := ioutil.ReadAll(r)
c.Check(err2, Equals, nil)
c.Check(content, DeepEquals, []byte("foo"))
-
- log.Printf("TestGet done")
}
func (s *StandaloneSuite) TestGet404(c *C) {
}
func (s *StandaloneSuite) TestPutProxy(c *C) {
- log.Printf("TestPutProxy")
-
st := StubProxyHandler{make(chan string, 1)}
arv, err := arvadosclient.MakeArvadosClient()
c.Check(err, Equals, nil)
c.Check(replicas, Equals, 2)
-
- log.Printf("TestPutProxy done")
}
func (s *StandaloneSuite) TestPutProxyInsufficientReplicas(c *C) {
- log.Printf("TestPutProxy")
-
st := StubProxyHandler{make(chan string, 1)}
arv, err := arvadosclient.MakeArvadosClient()
c.Check(err, Equals, InsufficientReplicasError)
c.Check(replicas, Equals, 2)
-
- log.Printf("TestPutProxy done")
}
func (s *StandaloneSuite) TestMakeLocator(c *C) {
"git.curoverse.com/arvados.git/sdk/go/streamer"
"io"
"io/ioutil"
- "log"
"math/rand"
"net"
"net/http"
var err error
var url = fmt.Sprintf("%s/%s", host, hash)
if req, err = http.NewRequest("PUT", url, nil); err != nil {
- log.Printf("[%08x] Error creating request PUT %v error: %v", requestID, url, err.Error())
+ DebugPrintf("DEBUG: [%08x] Error creating request PUT %v error: %v", requestID, url, err.Error())
upload_status <- uploadStatus{err, url, 0, 0, ""}
body.Close()
return
var resp *http.Response
if resp, err = this.Client.Do(req); err != nil {
- log.Printf("[%08x] Upload failed %v error: %v", requestID, url, err.Error())
+ DebugPrintf("DEBUG: [%08x] Upload failed %v error: %v", requestID, url, err.Error())
upload_status <- uploadStatus{err, url, 0, 0, ""}
return
}
respbody, err2 := ioutil.ReadAll(&io.LimitedReader{R: resp.Body, N: 4096})
response := strings.TrimSpace(string(respbody))
if err2 != nil && err2 != io.EOF {
- log.Printf("[%08x] Upload %v error: %v response: %v", requestID, url, err2.Error(), response)
+ DebugPrintf("DEBUG: [%08x] Upload %v error: %v response: %v", requestID, url, err2.Error(), response)
upload_status <- uploadStatus{err2, url, resp.StatusCode, rep, response}
} else if resp.StatusCode == http.StatusOK {
- log.Printf("[%08x] Upload %v success", requestID, url)
+ DebugPrintf("DEBUG: [%08x] Upload %v success", requestID, url)
upload_status <- uploadStatus{nil, url, resp.StatusCode, rep, response}
} else {
- log.Printf("[%08x] Upload %v error: %v response: %v", requestID, url, resp.StatusCode, response)
+ DebugPrintf("DEBUG: [%08x] Upload %v error: %v response: %v", requestID, url, resp.StatusCode, response)
upload_status <- uploadStatus{errors.New(resp.Status), url, resp.StatusCode, rep, response}
}
}
for active*replicasPerThread < remaining_replicas {
// Start some upload requests
if next_server < len(sv) {
- log.Printf("[%08x] Begin upload %s to %s", requestID, hash, sv[next_server])
+ DebugPrintf("DEBUG: [%08x] Begin upload %s to %s", requestID, hash, sv[next_server])
go this.uploadToKeepServer(sv[next_server], hash, tr.MakeStreamReader(), upload_status, expectedLength, requestID)
next_server += 1
active += 1
}
}
}
- log.Printf("[%08x] Replicas remaining to write: %v active uploads: %v",
+ DebugPrintf("DEBUG: [%08x] Replicas remaining to write: %v active uploads: %v",
requestID, remaining_replicas, active)
// Now wait for something to happen.