9308: Add test for KeepTmpOutput flag.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 5 Oct 2016 17:52:23 +0000 (13:52 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 5 Oct 2016 17:52:23 +0000 (13:52 -0400)
sdk/go/crunchrunner/crunchrunner.go
sdk/go/crunchrunner/crunchrunner_test.go

index 114c49c34982c08143d57d578aa9663624f6c12a..8dffd4594f1393e87dae91d1a0ee12c285826a25 100644 (file)
@@ -28,7 +28,7 @@ type TaskDef struct {
        SuccessCodes       []int             `json:"task.successCodes"`
        PermanentFailCodes []int             `json:"task.permanentFailCodes"`
        TemporaryFailCodes []int             `json:"task.temporaryFailCodes"`
-       keepTmpOutput      bool              `json:"task.keepTmpOutput"`
+       KeepTmpOutput      bool              `json:"task.keepTmpOutput"`
 }
 
 type Tasks struct {
@@ -114,7 +114,7 @@ func setupCommand(cmd *exec.Cmd, taskp TaskDef, outdir string, replacements map[
                        if err != nil {
                                return "", "", "", err
                        }
-                       if taskp.keepTmpOutput {
+                       if taskp.KeepTmpOutput {
                                // Is there an os.Copy?
                                copyFile(v, outdir+"/"+k)
                        } else {
@@ -264,7 +264,7 @@ func runner(api IArvadosClient,
        }
 
        var tmpdir, outdir string
-       tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUuid, taskp.keepTmpOutput)
+       tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUuid, taskp.KeepTmpOutput)
        if err != nil {
                return TempFail{err}
        }
@@ -360,7 +360,7 @@ func runner(api IArvadosClient,
 
        // Upload output directory
        var manifest string
-       if taskp.keepTmpOutput {
+       if taskp.KeepTmpOutput {
                manifest, err = getKeepTmp(outdir)
        } else {
                manifest, err = WriteTree(kc, outdir)
index 9805412d13fd5fb53d6809eee9a7e9d379ef74eb..f4c8193696104be204b525b20a8a57ef01e13082 100644 (file)
@@ -443,3 +443,31 @@ func (s *TestSuite) TestQuoting(c *C) {
                Task{Sequence: 0})
        c.Check(err, IsNil)
 }
+
+func (s *TestSuite) TestKeepTmp(c *C) {
+       tmpdir, _ := ioutil.TempDir("", "")
+       defer func() {
+               os.RemoveAll(tmpdir)
+       }()
+
+       os.Setenv("TASK_KEEPMOUNT_TMP", tmpdir)
+       defer os.Setenv("TASK_KEEPMOUNT_TMP", "")
+
+       fn, err := os.Create(tmpdir + "/.arvados#collection")
+       fn.Write([]byte("{\"manifest_text\":\". unparsed 0:3:foo\\n\",\"uuid\":null}"))
+       defer fn.Close()
+
+       err = runner(ArvTestClient{c,
+               ". unparsed 0:3:foo\n", true},
+               KeepTestClient{},
+               "zzzz-8i9sb-111111111111111",
+               "zzzz-ot0gb-111111111111111",
+               tmpdir,
+               "",
+               Job{Script_parameters: Tasks{[]TaskDef{{
+                       Command:       []string{"echo", "foo"},
+                       KeepTmpOutput: true}}}},
+               Task{Sequence: 0})
+       c.Check(err, IsNil)
+
+}