mirror of https://github.com/docker/docs.git
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:
parent
3d78c49aab
commit
1ce5457d57
|
@ -0,0 +1,2 @@
|
||||||
|
FROM busybox
|
||||||
|
ADD test_file .
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildCacheADD(t *testing.T) {
|
func TestBuildCacheADD(t *testing.T) {
|
||||||
|
@ -77,6 +78,42 @@ func TestAddSingleFileToRoot(t *testing.T) {
|
||||||
logDone("build - add single file to root")
|
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) {
|
func TestAddSingleFileToExistDir(t *testing.T) {
|
||||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
||||||
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToExistDir")
|
buildCmd := exec.Command(dockerBinary, "build", "-t", "testaddimg", "SingleFileToExistDir")
|
||||||
|
|
Loading…
Reference in New Issue