adding test for hanging ADD src .

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
Tibor Vass 2014-05-22 15:12:41 -07:00
parent 3d78c49aab
commit 1ce5457d57
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,2 @@
FROM busybox
ADD test_file .

View File

@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"
)
func TestBuildCacheADD(t *testing.T) {
@ -77,6 +78,42 @@ func TestAddSingleFileToRoot(t *testing.T) {
logDone("build - add single file to root")
}
// Issue #3960: "ADD src ." hangs
func TestAddSingleFileToWorkdir(t *testing.T) {
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd", "SingleFileToWorkdir")
f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644)
if err != nil {
t.Fatal(err)
}
f.Close()
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", ".")
buildCmd.Dir = buildDirectory
done := make(chan error)
go func() {
out, exitCode, err := runCommandWithOutput(buildCmd)
if err != nil || exitCode != 0 {
done <- fmt.Errorf("build failed to complete: %s %v", out, err)
return
}
done <- nil
}()
select {
case <-time.After(5 * time.Second):
if err := buildCmd.Process.Kill(); err != nil {
fmt.Printf("could not kill build (pid=%d): %v\n", buildCmd.Process.Pid, err)
}
t.Fatal("build timed out")
case err := <-done:
if err != nil {
t.Fatal(err)
}
}
deleteImages("testaddimg")
logDone("build - add single file to workdir")
}
func TestAddSingleFileToExistDir(t *testing.T) {
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToExistDir")