X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e5ee153a56578d13a025cde47fd0c07e21fd975f..eae1286badb67ee63888633ff59bda9cb736131e:/services/crunch-run/upload_test.go diff --git a/services/crunch-run/upload_test.go b/services/crunch-run/upload_test.go index b4b1efd107..96ea2b1190 100644 --- a/services/crunch-run/upload_test.go +++ b/services/crunch-run/upload_test.go @@ -1,11 +1,17 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( - . "gopkg.in/check.v1" "io/ioutil" "log" "os" "sync" + "syscall" + + . "gopkg.in/check.v1" ) type UploadTestSuite struct{} @@ -21,26 +27,32 @@ func (s *TestSuite) TestSimpleUpload(c *C) { ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600) - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, 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) { +func (s *TestSuite) TestSimpleUploadThreefiles(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) + for _, err := range []error{ + ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600), + ioutil.WriteFile(tmpdir+"/"+"file2.txt", []byte("bar"), 0600), + os.Symlink("./file2.txt", tmpdir+"/file3.txt"), + syscall.Mkfifo(tmpdir+"/ignore.fifo", 0600), + } { + c.Assert(err, IsNil) + } - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, 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") + c.Check(str, Equals, ". aa65a413921163458c52fea478d5d3ee+9 0:3:file1.txt 3:3:file2.txt 6:3:file3.txt\n") } func (s *TestSuite) TestSimpleUploadSubdir(c *C) { @@ -54,7 +66,7 @@ func (s *TestSuite) TestSimpleUploadSubdir(c *C) { ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600) ioutil.WriteFile(tmpdir+"/subdir/file2.txt", []byte("bar"), 0600) - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, nil, sync.Mutex{}} str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0)) c.Check(err, IsNil) @@ -88,7 +100,7 @@ func (s *TestSuite) TestSimpleUploadLarge(c *C) { ioutil.WriteFile(tmpdir+"/"+"file2.txt", []byte("bar"), 0600) - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, nil, sync.Mutex{}} str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0)) c.Check(err, IsNil) @@ -105,7 +117,7 @@ func (s *TestSuite) TestUploadEmptySubdir(c *C) { ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600) - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, nil, sync.Mutex{}} str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0)) c.Check(err, IsNil) @@ -121,7 +133,7 @@ func (s *TestSuite) TestUploadEmptyFile(c *C) { ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte(""), 0600) - cw := CollectionWriter{&KeepTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepTestClient{}, nil, nil, sync.Mutex{}} str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0)) c.Check(err, IsNil) @@ -137,7 +149,7 @@ func (s *TestSuite) TestUploadError(c *C) { ioutil.WriteFile(tmpdir+"/"+"file1.txt", []byte("foo"), 0600) - cw := CollectionWriter{&KeepErrorTestClient{}, nil, sync.Mutex{}} + cw := CollectionWriter{0, &KeepErrorTestClient{}, nil, nil, sync.Mutex{}} str, err := cw.WriteTree(tmpdir, log.New(os.Stdout, "", 0)) c.Check(err, NotNil)