Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petemoore committed May 9, 2018
1 parent 1734209 commit 07b552a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 6 additions & 1 deletion mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,12 @@ func (f *FileMount) Mount(task *TaskRun) error {
task.Infof("[mounts] Copying cached version of %v to %v", fsContent.String(), file)
err = copyFileContents(cacheFile, file)
if err != nil {
panic(fmt.Errorf("Could not copy file %v to %v due to:\n%v", cacheFile, file, err))
// this could be a system error, but it can also be that e.g. the task
// specified an invalid path, so resolve as malformed payload rather
// than panic
task.Errorf("[mounts] Not able to mount content from %v at path %v", fsContent.String(), file)
task.Infof("%v", err)
return err
}
return nil
}
Expand Down
19 changes: 12 additions & 7 deletions mounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,12 @@ func TestValidSHA256(t *testing.T) {
"[mounts] Downloading task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Downloaded 4220 bytes of content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip",
"[mounts] Content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip matched required SHA256 (625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e)",
"[mounts] Extracting zip file from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
},
// Required text from second task when download is already cached
[]string{
"[mounts] Found existing download for artifact:LK1Rz2UtT16d-HBSqyCtuA:public/build/unknown_issuer_app_1.zip with (correct) SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e",
"[mounts] Extracting zip file from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
},
},
},
Expand Down Expand Up @@ -398,10 +400,12 @@ func TestFileMountNoSHA256(t *testing.T) {
"[mounts] Downloading task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Downloaded 4220 bytes of content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip",
"[mounts] Content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip has SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e but task payload does not declare a required value, so content authenticity cannot be verified",
"[mounts] Copying cached version of task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
},
// Required text from second task when download is already cached
[]string{
"[mounts] Found existing download for artifact:LK1Rz2UtT16d-HBSqyCtuA:public/build/unknown_issuer_app_1.zip with SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e, but since no required SHA256 is specified in task mounts, it is not possible to verify the integrity of this file",
"[mounts] Copying cached version of task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
},
},
},
Expand All @@ -423,24 +427,24 @@ func TestMountFileAtCWD(t *testing.T) {
}`),
},
},
TaskRunResolutionState: "completed",
TaskRunReasonResolved: "completed",
TaskRunResolutionState: "failed",
TaskRunReasonResolved: "failed",
PerTaskRunLogExcerpts: [][]string{
// Required text from first task with no cached value
[]string{
"[mounts] No existing writable directory cache 'banana-cache' - creating...",
"[mounts] Downloading task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Downloaded 4220 bytes of content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip",
"[mounts] Content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip has SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e but task payload does not declare a required value, so content authenticity cannot be verified",
"[mounts] Copying cached version of task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Not able to mount content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip at path ",
},
// Required text from second task when download is already cached
[]string{
"[mounts] Mounting existing writable directory cache banana-cache at path '",
"[mounts] Granting task user full control of '",
"[mounts] Successfully mounted writable directory cache '",
"[mounts] Found existing download for artifact:LK1Rz2UtT16d-HBSqyCtuA:public/build/unknown_issuer_app_1.zip with SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e, but since no required SHA256 is specified in task mounts, it is not possible to verify the integrity of this file",
"[mounts] Copying cached version of task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Not able to mount content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip at path ",
},
},
Scopes: []string{"generic-worker:cache:banana-cache"},
},
)
}
Expand Down Expand Up @@ -470,6 +474,7 @@ func TestWritableDirectoryCacheNoSHA256(t *testing.T) {
"[mounts] Downloading task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
"[mounts] Downloaded 4220 bytes of content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip",
"[mounts] Content from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip has SHA256 625554ec8ce731e486a5fb904f3331d18cf84a944dd9e40c19550686d4e8492e but task payload does not declare a required value, so content authenticity cannot be verified",
"[mounts] Extracting zip file from task LK1Rz2UtT16d-HBSqyCtuA artifact public/build/unknown_issuer_app_1.zip to ",
},
// Required text from second task when download is already cached
[]string{
Expand Down

0 comments on commit 07b552a

Please sign in to comment.