dockerfile: add TestCopySocket test + vendor needed continuity fix
Signed-off-by: Tibor Vass <tibor@docker.com>v0.7
parent
77ca4bce2e
commit
bd8f49ed58
|
@ -99,6 +99,7 @@ var fileOpTests = []integration.Test{
|
|||
testCopyChownCreateDest,
|
||||
testCopyThroughSymlinkContext,
|
||||
testCopyThroughSymlinkMultiStage,
|
||||
testCopySocket,
|
||||
testContextChangeDirToFile,
|
||||
testNoSnapshotLeak,
|
||||
testCopySymlinks,
|
||||
|
@ -1013,6 +1014,53 @@ COPY --from=build /sub2/foo bar
|
|||
require.Equal(t, "data", string(dt))
|
||||
}
|
||||
|
||||
func testCopySocket(t *testing.T, sb integration.Sandbox) {
|
||||
f := getFrontend(t, sb)
|
||||
isFileOp := getFileOp(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
FROM scratch
|
||||
COPY . /
|
||||
`)
|
||||
|
||||
dir, err := tmpdir(
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateSocket("socket.sock", 0600),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
c, err := client.New(context.TODO(), sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
destDir, err := ioutil.TempDir("", "buildkit")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(destDir)
|
||||
|
||||
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
|
||||
Exports: []client.ExportEntry{
|
||||
{
|
||||
Type: client.ExporterLocal,
|
||||
OutputDir: destDir,
|
||||
},
|
||||
},
|
||||
FrontendAttrs: map[string]string{
|
||||
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
|
||||
},
|
||||
LocalDirs: map[string]string{
|
||||
builder.DefaultLocalNameDockerfile: dir,
|
||||
builder.DefaultLocalNameContext: dir,
|
||||
},
|
||||
}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
fi, err := os.Lstat(filepath.Join(destDir, "socket.sock"))
|
||||
require.NoError(t, err)
|
||||
// make sure socket is converted to regular file.
|
||||
require.Equal(t, fi.Mode().IsRegular(), true)
|
||||
}
|
||||
|
||||
func testIgnoreEntrypoint(t *testing.T, sb integration.Sandbox) {
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601 // indirect
|
||||
github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
|
||||
github.com/containerd/containerd v1.3.0-beta.2
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02
|
||||
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6
|
||||
github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c // indirect
|
||||
github.com/containerd/go-cni v0.0.0-20190813230227-49fbd9b210f3
|
||||
github.com/containerd/go-runc v0.0.0-20190603165425-9007c2405372
|
||||
|
|
4
go.sum
4
go.sum
|
@ -19,8 +19,8 @@ github.com/containerd/containerd v1.2.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMX
|
|||
github.com/containerd/containerd v1.3.0-beta.2 h1:pNq4VOyEjYN11bpJK0EQkWF31vi5LmWLWwGeSD5MRlo=
|
||||
github.com/containerd/containerd v1.3.0-beta.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
|
||||
github.com/containerd/continuity v0.0.0-20181001140422-bd77b46c8352/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02 h1:tN9D97v5A5QuKdcKHKt+UMKrkQ5YXUnD8iM7IAAjEfI=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
|
||||
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c h1:KFbqHhDeaHM7IfFtXHfUHMDaUStpM2YwBR+iJCIOsKk=
|
||||
github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
|
||||
github.com/containerd/go-cni v0.0.0-20190813230227-49fbd9b210f3 h1:owkX+hC6Inv1XUep/pAjF7qJpnZWjbtETw5r1DVYFPo=
|
||||
|
|
|
@ -80,7 +80,7 @@ func copyDirectory(dst, src string, inodes map[uint64]string, o *copyDirOpts) er
|
|||
return errors.Wrapf(err, "failed to stat %s", src)
|
||||
}
|
||||
if !stat.IsDir() {
|
||||
return errors.Errorf("source is not directory")
|
||||
return errors.Errorf("source %s is not directory", src)
|
||||
}
|
||||
|
||||
if st, err := os.Stat(dst); err != nil {
|
||||
|
|
|
@ -20,9 +20,9 @@ import (
|
|||
"bytes"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -158,11 +158,15 @@ func Link(oldname, newname string) Applier {
|
|||
func CreateSocket(name string, perm os.FileMode) Applier {
|
||||
return applyFn(func(root string) error {
|
||||
fullPath := filepath.Join(root, name)
|
||||
ln, err := net.Listen("unix", fullPath)
|
||||
fd, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_STREAM, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer ln.Close()
|
||||
defer syscall.Close(fd)
|
||||
sa := &syscall.SockaddrUnix{Name: fullPath}
|
||||
if err := syscall.Bind(fd, sa); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Chmod(fullPath, perm)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ var (
|
|||
Symlink("libnothing.so", "/usr/local/lib/libnothing.so.2"),
|
||||
CreateDir("/home", 0755),
|
||||
CreateDir("/home/derek", 0700),
|
||||
CreateDir("/var/run/socket", 0700),
|
||||
// TODO: CreateSocket: how should Sockets be handled in continuity?
|
||||
)
|
||||
|
||||
// basicTest covers basic operations
|
||||
|
|
|
@ -90,7 +90,7 @@ github.com/containerd/containerd/identifiers
|
|||
github.com/containerd/containerd/metadata/boltutil
|
||||
github.com/containerd/containerd/api/types/task
|
||||
github.com/containerd/containerd/events/exchange
|
||||
# github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02
|
||||
# github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6
|
||||
github.com/containerd/continuity/sysx
|
||||
github.com/containerd/continuity/fs
|
||||
github.com/containerd/continuity/syscallx
|
||||
|
|
Loading…
Reference in New Issue