Add a Cleanup function that cleans exec root and swarm files
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
25ff68a80f
commit
3b01e92c9a
3 changed files with 9 additions and 17 deletions
|
@ -350,14 +350,7 @@ func (s *DockerSwarmSuite) TearDownTest(c *check.C) {
|
|||
for _, d := range s.daemons {
|
||||
if d != nil {
|
||||
d.Stop(c)
|
||||
// FIXME(vdemeester) should be handled by SwarmDaemon ?
|
||||
// raft state file is quite big (64MB) so remove it after every test
|
||||
walDir := filepath.Join(d.Root, "swarm/raft/wal")
|
||||
if err := os.RemoveAll(walDir); err != nil {
|
||||
c.Logf("error removing %v: %v", walDir, err)
|
||||
}
|
||||
|
||||
d.CleanupExecRoot(c)
|
||||
d.Cleanup(c)
|
||||
}
|
||||
}
|
||||
s.daemons = nil
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -810,10 +809,6 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) {
|
|||
if err := daemon.StopWithError(); err != nil {
|
||||
errs <- err
|
||||
}
|
||||
// FIXME(vdemeester) This is duplicated…
|
||||
if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
|
||||
daemon.Root = filepath.Dir(daemon.Root)
|
||||
}
|
||||
}(d)
|
||||
}
|
||||
wg.Wait()
|
||||
|
|
|
@ -176,8 +176,13 @@ func (d *Daemon) NewClientT(t assert.TestingT) *client.Client {
|
|||
return c
|
||||
}
|
||||
|
||||
// CleanupExecRoot cleans the daemon exec root (network namespaces, ...)
|
||||
func (d *Daemon) CleanupExecRoot(t testingT) {
|
||||
// Cleanup cleans the daemon files : exec root (network namespaces, ...), swarmkit files
|
||||
func (d *Daemon) Cleanup(t testingT) {
|
||||
// Cleanup swarmkit wal files if present
|
||||
walDir := filepath.Join(d.Root, "swarm/raft/wal")
|
||||
if err := os.RemoveAll(walDir); err != nil {
|
||||
t.Logf("error removing %v: %v", walDir, err)
|
||||
}
|
||||
cleanupExecRoot(t, d.execRoot)
|
||||
}
|
||||
|
||||
|
@ -201,6 +206,7 @@ func (d *Daemon) StartWithError(args ...string) error {
|
|||
|
||||
// StartWithLogFile will start the daemon and attach its streams to a given file.
|
||||
func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
||||
d.handleUserns()
|
||||
dockerdBinary, err := exec.LookPath(d.dockerdBinary)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id)
|
||||
|
@ -446,7 +452,6 @@ out2:
|
|||
// If an error occurs while starting the daemon, the test will fail.
|
||||
func (d *Daemon) Restart(t testingT, args ...string) {
|
||||
d.Stop(t)
|
||||
d.handleUserns()
|
||||
d.Start(t, args...)
|
||||
}
|
||||
|
||||
|
@ -455,7 +460,6 @@ func (d *Daemon) RestartWithError(arg ...string) error {
|
|||
if err := d.StopWithError(); err != nil {
|
||||
return err
|
||||
}
|
||||
d.handleUserns()
|
||||
return d.StartWithError(arg...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue