mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use temp dir for integration daemon sockets
Instead of using the bundles dir, which may be mounted in and ultimately break if using b2d/d4mac/d4win. This makes it much easier to collect test daemon logs and more natural for use d4mac/d4win users to run tests. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
b09f280161
commit
4804eb700c
2 changed files with 28 additions and 2 deletions
|
@ -5,9 +5,11 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/cliconfig"
|
"github.com/docker/docker/cliconfig"
|
||||||
|
"github.com/docker/docker/pkg/integration/checker"
|
||||||
"github.com/docker/docker/pkg/reexec"
|
"github.com/docker/docker/pkg/reexec"
|
||||||
"github.com/docker/engine-api/types/swarm"
|
"github.com/docker/engine-api/types/swarm"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
|
@ -186,6 +188,21 @@ func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
|
||||||
s.ds.TearDownTest(c)
|
s.ds.TearDownTest(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerDaemonSuite) TearDownSuite(c *check.C) {
|
||||||
|
err := filepath.Walk(daemonSockRoot, func(path string, fi os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if fi.Mode() == os.ModeSocket {
|
||||||
|
syscall.Unlink(path)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
c.Assert(err, checker.IsNil, check.Commentf("error while cleaning up daemon sockets"))
|
||||||
|
err = os.RemoveAll(daemonSockRoot)
|
||||||
|
c.Assert(err, checker.IsNil, check.Commentf("could not cleanup daemon socket root"))
|
||||||
|
}
|
||||||
|
|
||||||
const defaultSwarmPort = 2477
|
const defaultSwarmPort = 2477
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -22,6 +22,8 @@ import (
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var daemonSockRoot = filepath.Join(os.TempDir(), "docker-integration")
|
||||||
|
|
||||||
// Daemon represents a Docker daemon for the testing framework.
|
// Daemon represents a Docker daemon for the testing framework.
|
||||||
type Daemon struct {
|
type Daemon struct {
|
||||||
GlobalFlags []string
|
GlobalFlags []string
|
||||||
|
@ -54,6 +56,9 @@ func NewDaemon(c *check.C) *Daemon {
|
||||||
dest := os.Getenv("DEST")
|
dest := os.Getenv("DEST")
|
||||||
c.Assert(dest, check.Not(check.Equals), "", check.Commentf("Please set the DEST environment variable"))
|
c.Assert(dest, check.Not(check.Equals), "", check.Commentf("Please set the DEST environment variable"))
|
||||||
|
|
||||||
|
err := os.MkdirAll(daemonSockRoot, 0700)
|
||||||
|
c.Assert(err, checker.IsNil, check.Commentf("could not create daemon socket root"))
|
||||||
|
|
||||||
id := fmt.Sprintf("d%d", time.Now().UnixNano()%100000000)
|
id := fmt.Sprintf("d%d", time.Now().UnixNano()%100000000)
|
||||||
dir := filepath.Join(dest, id)
|
dir := filepath.Join(dest, id)
|
||||||
daemonFolder, err := filepath.Abs(dir)
|
daemonFolder, err := filepath.Abs(dir)
|
||||||
|
@ -108,7 +113,7 @@ func (d *Daemon) getClientConfig() (*clientConfig, error) {
|
||||||
scheme = "http"
|
scheme = "http"
|
||||||
transport = &http.Transport{}
|
transport = &http.Transport{}
|
||||||
} else {
|
} else {
|
||||||
addr = filepath.Join(d.folder, "docker.sock")
|
addr = d.sockPath()
|
||||||
proto = "unix"
|
proto = "unix"
|
||||||
scheme = "http"
|
scheme = "http"
|
||||||
transport = &http.Transport{}
|
transport = &http.Transport{}
|
||||||
|
@ -410,7 +415,11 @@ func (d *Daemon) queryRootDir() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Daemon) sock() string {
|
func (d *Daemon) sock() string {
|
||||||
return fmt.Sprintf("unix://%s/docker.sock", d.folder)
|
return fmt.Sprintf("unix://" + d.sockPath())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Daemon) sockPath() string {
|
||||||
|
return filepath.Join(daemonSockRoot, d.id+".sock")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Daemon) waitRun(contID string) error {
|
func (d *Daemon) waitRun(contID string) error {
|
||||||
|
|
Loading…
Reference in a new issue