Merge pull request #25 from tiborvass/3960-add-file-hangs
adding test for hanging ADD src .
This commit is contained in:
commit
04e357d09f
2 changed files with 39 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue