[ARVADOS] updated: 070fdce365074a76d4da2e118574fd1d4f3515c5

git at public.curoverse.com git at public.curoverse.com
Sat Feb 13 22:51:11 EST 2016


Summary of changes:
 services/crunch-run/crunchrun_test.go              |  2 +-
 .../crunch-run}/upload_test.go                     | 46 +++++++++++-----------
 2 files changed, 23 insertions(+), 25 deletions(-)
 copy {sdk/go/crunchrunner => services/crunch-run}/upload_test.go (75%)

       via  070fdce365074a76d4da2e118574fd1d4f3515c5 (commit)
      from  faf5784b78844e5da0b4c63860323eb1ee06bd2f (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 070fdce365074a76d4da2e118574fd1d4f3515c5
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Sat Feb 13 22:51:05 2016 -0500

    8015: Test WriteTree

diff --git a/services/crunch-run/crunchrun_test.go b/services/crunch-run/crunchrun_test.go
index eaa16d1..763c391 100644
--- a/services/crunch-run/crunchrun_test.go
+++ b/services/crunch-run/crunchrun_test.go
@@ -266,7 +266,7 @@ func (this ArvErrorTestClient) Update(resourceType string, uuid string, paramete
 }
 
 func (this KeepErrorTestClient) PutHB(hash string, buf []byte) (string, int, error) {
-	return "", 0, nil
+	return "", 0, errors.New("KeepError")
 }
 
 func (this KeepErrorTestClient) ManifestFileReader(m manifest.Manifest, filename string) (keepclient.ReadCloserWithLen, error) {
diff --git a/services/crunch-run/upload_test.go b/services/crunch-run/upload_test.go
new file mode 100644
index 0000000..d66d9de
--- /dev/null
+++ b/services/crunch-run/upload_test.go
@@ -0,0 +1,138 @@
+package main
+
+import (
+	. "gopkg.in/check.v1"
+	"io/ioutil"
+	"log"
+	"os"
+	"sync"
+)
+
+type UploadTestSuite struct{}
+
+// Gocheck boilerplate
+var _ = Suite(&UploadTestSuite{})
+
+func (s *TestSuite) TestSimpleUpload(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+	c.Check(err, IsNil)
+	c.Check(str, Equals, ". acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:file1.txt\n")
+}
+
+func (s *TestSuite) TestSimpleUploadTwofiles(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600)
+	ioutil.WriteFile(tmpdir+"/"+"file2.txt", []byte("bar"), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, IsNil)
+	c.Check(str, Equals, ". 3858f62230ac3c915f300c664312c63f+6 0:3:file1.txt 3:3:file2.txt\n")
+}
+
+func (s *TestSuite) TestSimpleUploadSubdir(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	os.Mkdir(tmpdir+"/subdir", 0700)
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600)
+	ioutil.WriteFile(tmpdir+"/subdir/file2.txt", []byte("bar"), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, IsNil)
+	c.Check(str, Equals, `. acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:file1.txt
+./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:file2.txt
+`)
+}
+
+func (s *TestSuite) TestSimpleUploadLarge(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	file, _ := os.Create(tmpdir + "/" + "file1.txt")
+	data := make([]byte, 1024*1024-1)
+	for i := range data {
+		data[i] = byte(i % 10)
+	}
+	for i := 0; i < 65; i++ {
+		file.Write(data)
+	}
+	file.Close()
+
+	ioutil.WriteFile(tmpdir+"/"+"file2.txt", []byte("bar"), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, IsNil)
+	c.Check(str, Equals, ". 00ecf01e0d93385115c9f8bed757425d+67108864 485cd630387b6b1846fe429f261ea05f+1048514 0:68157375:file1.txt 68157375:3:file2.txt\n")
+}
+
+func (s *TestSuite) TestUploadEmptySubdir(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	os.Mkdir(tmpdir+"/subdir", 0700)
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, IsNil)
+	c.Check(str, Equals, `. acbd18db4cc2f85cedef654fccc4a4d8+3 0:3:file1.txt
+`)
+}
+
+func (s *TestSuite) TestUploadEmptyFile(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte(""), 0600)
+
+	cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, IsNil)
+	c.Check(str, Equals, `. d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1.txt
+`)
+}
+
+func (s *TestSuite) TestUploadError(c *C) {
+	tmpdir, _ := ioutil.TempDir("", "")
+	defer func() {
+		os.RemoveAll(tmpdir)
+	}()
+
+	ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600)
+
+	cw := CollectionWriter{&KeepErrorTestClient{}, nil, sync.Mutex{}}
+	str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0))
+
+	c.Check(err, NotNil)
+	c.Check(str, Equals, "")
+}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list