Artifact transfer
This commit is contained in:
parent
490c9b8e6f
commit
d3f089aaf4
2 changed files with 35 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package disttest
|
package disttest
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -69,8 +70,8 @@ func TestJobCaching(t *testing.T) {
|
||||||
|
|
||||||
var sourceFilesGraph = build.Graph{
|
var sourceFilesGraph = build.Graph{
|
||||||
SourceFiles: map[build.ID]string{
|
SourceFiles: map[build.ID]string{
|
||||||
build.ID{'a'}: "a.txt",
|
{'a'}: "a.txt",
|
||||||
build.ID{'c'}: "b/c.txt",
|
{'c'}: "b/c.txt",
|
||||||
},
|
},
|
||||||
Jobs: []build.Job{
|
Jobs: []build.Job{
|
||||||
{
|
{
|
||||||
|
@ -98,3 +99,34 @@ func TestSourceFiles(t *testing.T) {
|
||||||
assert.Len(t, recorder.Jobs, 1)
|
assert.Len(t, recorder.Jobs, 1)
|
||||||
assert.Equal(t, &JobResult{Stdout: "foo", Stderr: "bar", Code: new(int)}, recorder.Jobs[build.ID{'a'}])
|
assert.Equal(t, &JobResult{Stdout: "foo", Stderr: "bar", Code: new(int)}, recorder.Jobs[build.ID{'a'}])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var artifactTransferGraph = build.Graph{
|
||||||
|
Jobs: []build.Job{
|
||||||
|
{
|
||||||
|
ID: build.ID{'a'},
|
||||||
|
Name: "write",
|
||||||
|
Cmds: []build.Cmd{
|
||||||
|
{CatTemplate: "OK", CatOutput: "{{.OutputDir}}/out.txt"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: build.ID{'b'},
|
||||||
|
Name: "cat",
|
||||||
|
Cmds: []build.Cmd{
|
||||||
|
{Exec: []string{"cat", fmt.Sprintf("{{index .Deps %q}}/out.txt", build.ID{'a'})}},
|
||||||
|
},
|
||||||
|
Deps: []build.ID{{'a'}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestArtifactTransfer(t *testing.T) {
|
||||||
|
env, cancel := newEnv(t)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
recorder := NewRecorder()
|
||||||
|
require.NoError(t, env.Client.Build(env.Ctx, artifactTransferGraph, recorder))
|
||||||
|
|
||||||
|
assert.Len(t, recorder.Jobs, 2)
|
||||||
|
assert.Equal(t, &JobResult{Stdout: "OK", Code: new(int)}, recorder.Jobs[build.ID{'b'}])
|
||||||
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func (w *Worker) Run(ctx context.Context) error {
|
||||||
for _, spec := range rsp.JobsToRun {
|
for _, spec := range rsp.JobsToRun {
|
||||||
result, err := w.runJob(ctx, &spec)
|
result, err := w.runJob(ctx, &spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errStr := err.Error()
|
errStr := fmt.Sprintf("job %s failed: %v", spec.Job.ID, err)
|
||||||
w.jobFinished(&proto.JobResult{ID: spec.Job.ID, Error: &errStr})
|
w.jobFinished(&proto.JobResult{ID: spec.Job.ID, Error: &errStr})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue