Пример #1
0
// TODO(jd), this test is falsely passing I think that however we're getting
// logs from Docker doesn't work.
func TestLog(t *testing.T) {
	t.Parallel()
	pipeline := newTestPipeline(t, "log", "commit1", "master", "0-1", true)
	pachfile := `
image ubuntu

run echo "foo"
`
	err := pipeline.runPachFile(strings.NewReader(pachfile))
	require.NoError(t, err)

	log, err := btrfs.ReadFile(path.Join(pipeline.outRepo, "commit1-0", ".log"))
	require.NoError(t, err)
	require.Equal(t, "foo\n", string(log))

	pipeline = newTestPipeline(t, "log", "commit2", "master", "0-1", false)
	pachfile = `
image ubuntu

run echo "bar" >&2
`
	err = pipeline.runPachFile(strings.NewReader(pachfile))
	require.NoError(t, err)

	log, err = btrfs.ReadFile(path.Join(pipeline.outRepo, "commit2-0", ".log"))
	require.NoError(t, err)
	require.Equal(t, "bar\n", string(log))
}
Пример #2
0
// TestPipelines runs a 2 step pipeline.
func TestPipelines(t *testing.T) {
	t.Parallel()
	inRepo := "TestPipelines_in"
	require.NoError(t, btrfs.Init(inRepo))
	outPrefix := "TestPipelines_out"

	// Create a data file:
	require.NoError(t, btrfs.WriteFile(path.Join(inRepo, "master", "data", "foo"), []byte("foo")))

	// Create the Pachfile
	require.NoError(t, btrfs.WriteFile(path.Join(inRepo, "master", "pipeline", "cp"), []byte(`
image ubuntu

input data

run cp /in/data/foo /out/foo
run echo "foo"
`)))
	require.NoError(t, btrfs.Commit(inRepo, "commit", "master"))

	require.NoError(t, RunPipelines("pipeline", inRepo, outPrefix, "commit", "master", "0-1", etcache.NewCache()))

	data, err := btrfs.ReadFile(path.Join(outPrefix, "cp", "commit", "foo"))
	require.NoError(t, err)
	require.Equal(t, "foo", string(data))
}
Пример #3
0
func TestDependency(t *testing.T) {
	t.Parallel()
	inRepo := "TestDependency_in"
	require.NoError(t, btrfs.Init(inRepo))
	p1 := `
image ubuntu

run echo foo >/out/foo
`
	require.NoError(t, btrfs.WriteFile(path.Join(inRepo, "master", "pipeline", "p1"), []byte(p1)))
	p2 := `
image ubuntu

input pps://p1

run cp /in/p1/foo /out/foo
`
	require.NoError(t, btrfs.WriteFile(path.Join(inRepo, "master", "pipeline", "p2"), []byte(p2)))
	require.NoError(t, btrfs.Commit(inRepo, "commit", "master"))

	outPrefix := "TestDependency"
	runner := NewRunner("pipeline", inRepo, outPrefix, "commit", "master", "0-1", etcache.NewCache())
	require.NoError(t, runner.Run())

	res, err := btrfs.ReadFile(path.Join(outPrefix, "p2", "commit", "foo"))
	require.NoError(t, err)
	require.Equal(t, "foo\n", string(res))
}
Пример #4
0
// TestInject tests that s3 injections works
func TestInject(t *testing.T) {
	t.Parallel()
	outRepo := "TestInject_out"
	require.NoError(t, btrfs.Init(outRepo))
	pipeline := newPipeline("output", "", outRepo, "commit", "master", "0-1", "", etcache.NewCache())
	require.NoError(t, pipeline.inject("s3://pachyderm-test/pipeline"))
	require.NoError(t, pipeline.finish())
	res, err := btrfs.ReadFile(path.Join(outRepo, "commit", "file"))
	require.NoError(t, err)
	require.Equal(t, "foo\n", string(res))
}