… to make sure it doesn't fail. It also introduce StartWithError,
StopWithError and RestartWithError in case we care about the
error (and want the error to happen).
This removes the need to check for error and make the intent more
clear : I want a deamon with busybox loaded on it — if an error occur
it should fail the test, but it's not the test code that has the
responsability to check that.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
| ... | ... |
@@ -84,7 +84,7 @@ func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
|
| 84 | 84 |
s.reg.Close() |
| 85 | 85 |
} |
| 86 | 86 |
if s.d != nil {
|
| 87 |
- s.d.Stop() |
|
| 87 |
+ s.d.Stop(c) |
|
| 88 | 88 |
} |
| 89 | 89 |
s.ds.TearDownTest(c) |
| 90 | 90 |
} |
| ... | ... |
@@ -118,7 +118,7 @@ func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
|
| 118 | 118 |
s.reg.Close() |
| 119 | 119 |
} |
| 120 | 120 |
if s.d != nil {
|
| 121 |
- s.d.Stop() |
|
| 121 |
+ s.d.Stop(c) |
|
| 122 | 122 |
} |
| 123 | 123 |
s.ds.TearDownTest(c) |
| 124 | 124 |
} |
| ... | ... |
@@ -154,7 +154,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) {
|
| 154 | 154 |
s.reg.Close() |
| 155 | 155 |
} |
| 156 | 156 |
if s.d != nil {
|
| 157 |
- s.d.Stop() |
|
| 157 |
+ s.d.Stop(c) |
|
| 158 | 158 |
} |
| 159 | 159 |
s.ds.TearDownTest(c) |
| 160 | 160 |
} |
| ... | ... |
@@ -189,7 +189,7 @@ func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
|
| 189 | 189 |
s.reg.Close() |
| 190 | 190 |
} |
| 191 | 191 |
if s.d != nil {
|
| 192 |
- s.d.Stop() |
|
| 192 |
+ s.d.Stop(c) |
|
| 193 | 193 |
} |
| 194 | 194 |
s.ds.TearDownTest(c) |
| 195 | 195 |
} |
| ... | ... |
@@ -226,7 +226,7 @@ func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
|
| 226 | 226 |
func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
|
| 227 | 227 |
testRequires(c, DaemonIsLinux) |
| 228 | 228 |
if s.d != nil {
|
| 229 |
- s.d.Stop() |
|
| 229 |
+ s.d.Stop(c) |
|
| 230 | 230 |
} |
| 231 | 231 |
s.ds.TearDownTest(c) |
| 232 | 232 |
} |
| ... | ... |
@@ -283,8 +283,7 @@ func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemo |
| 283 | 283 |
} |
| 284 | 284 |
d.ListenAddr = fmt.Sprintf("0.0.0.0:%d", d.Port)
|
| 285 | 285 |
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} // avoid networking conflicts
|
| 286 |
- err := d.StartWithBusybox(args...) |
|
| 287 |
- c.Assert(err, check.IsNil) |
|
| 286 |
+ d.StartWithBusybox(c, args...) |
|
| 288 | 287 |
|
| 289 | 288 |
if joinSwarm == true {
|
| 290 | 289 |
if len(s.daemons) > 0 {
|
| ... | ... |
@@ -315,7 +314,7 @@ func (s *DockerSwarmSuite) TearDownTest(c *check.C) {
|
| 315 | 315 |
s.daemonsLock.Lock() |
| 316 | 316 |
for _, d := range s.daemons {
|
| 317 | 317 |
if d != nil {
|
| 318 |
- d.Stop() |
|
| 318 |
+ d.Stop(c) |
|
| 319 | 319 |
// FIXME(vdemeester) should be handled by SwarmDaemon ? |
| 320 | 320 |
// raft state file is quite big (64MB) so remove it after every test |
| 321 | 321 |
walDir := filepath.Join(d.Root, "swarm/raft/wal") |
| ... | ... |
@@ -34,6 +34,8 @@ import ( |
| 34 | 34 |
// SockRoot holds the path of the default docker integration daemon socket |
| 35 | 35 |
var SockRoot = filepath.Join(os.TempDir(), "docker-integration") |
| 36 | 36 |
|
| 37 |
+var errDaemonNotStarted = errors.New("daemon not started")
|
|
| 38 |
+ |
|
| 37 | 39 |
// Daemon represents a Docker daemon for the testing framework. |
| 38 | 40 |
type Daemon struct {
|
| 39 | 41 |
GlobalFlags []string |
| ... | ... |
@@ -171,9 +173,14 @@ func (d *Daemon) getClientConfig() (*clientConfig, error) {
|
| 171 | 171 |
}, nil |
| 172 | 172 |
} |
| 173 | 173 |
|
| 174 |
-// Start will start the daemon and return once it is ready to receive requests. |
|
| 175 |
-// You can specify additional daemon flags. |
|
| 176 |
-func (d *Daemon) Start(args ...string) error {
|
|
| 174 |
+// Start starts the daemon and return once it is ready to receive requests. |
|
| 175 |
+func (d *Daemon) Start(c *check.C, args ...string) {
|
|
| 176 |
+ c.Assert(d.StartWithError(args...), checker.IsNil, check.Commentf("Error starting daemon with arguments: %v", args))
|
|
| 177 |
+} |
|
| 178 |
+ |
|
| 179 |
+// StartWithError starts the daemon and return once it is ready to receive requests. |
|
| 180 |
+// It returns an error in case it couldn't start. |
|
| 181 |
+func (d *Daemon) StartWithError(args ...string) error {
|
|
| 177 | 182 |
logFile, err := os.OpenFile(filepath.Join(d.Folder, "docker.log"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0600) |
| 178 | 183 |
if err != nil {
|
| 179 | 184 |
return errors.Wrapf(err, "[%s] Could not create %s/docker.log", d.id, d.Folder) |
| ... | ... |
@@ -295,17 +302,15 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
| 295 | 295 |
|
| 296 | 296 |
// StartWithBusybox will first start the daemon with Daemon.Start() |
| 297 | 297 |
// then save the busybox image from the main daemon and load it into this Daemon instance. |
| 298 |
-func (d *Daemon) StartWithBusybox(arg ...string) error {
|
|
| 299 |
- if err := d.Start(arg...); err != nil {
|
|
| 300 |
- return err |
|
| 301 |
- } |
|
| 302 |
- return d.LoadBusybox() |
|
| 298 |
+func (d *Daemon) StartWithBusybox(c *check.C, arg ...string) {
|
|
| 299 |
+ d.Start(c, arg...) |
|
| 300 |
+ c.Assert(d.LoadBusybox(), checker.IsNil, check.Commentf("Error loading busybox image to current daeom: %s", d.id))
|
|
| 303 | 301 |
} |
| 304 | 302 |
|
| 305 | 303 |
// Kill will send a SIGKILL to the daemon |
| 306 | 304 |
func (d *Daemon) Kill() error {
|
| 307 | 305 |
if d.cmd == nil || d.Wait == nil {
|
| 308 |
- return errors.New("daemon not started")
|
|
| 306 |
+ return errDaemonNotStarted |
|
| 309 | 307 |
} |
| 310 | 308 |
|
| 311 | 309 |
defer func() {
|
| ... | ... |
@@ -337,7 +342,7 @@ func (d *Daemon) Interrupt() error {
|
| 337 | 337 |
// Signal sends the specified signal to the daemon if running |
| 338 | 338 |
func (d *Daemon) Signal(signal os.Signal) error {
|
| 339 | 339 |
if d.cmd == nil || d.Wait == nil {
|
| 340 |
- return errors.New("daemon not started")
|
|
| 340 |
+ return errDaemonNotStarted |
|
| 341 | 341 |
} |
| 342 | 342 |
return d.cmd.Process.Signal(signal) |
| 343 | 343 |
} |
| ... | ... |
@@ -353,12 +358,28 @@ func (d *Daemon) DumpStackAndQuit() {
|
| 353 | 353 |
} |
| 354 | 354 |
|
| 355 | 355 |
// Stop will send a SIGINT every second and wait for the daemon to stop. |
| 356 |
+// If it times out, a SIGKILL is sent. |
|
| 357 |
+// Stop will not delete the daemon directory. If a purged daemon is needed, |
|
| 358 |
+// instantiate a new one with NewDaemon. |
|
| 359 |
+// If an error occurs while starting the daemon, the test will fail. |
|
| 360 |
+func (d *Daemon) Stop(c *check.C) {
|
|
| 361 |
+ err := d.StopWithError() |
|
| 362 |
+ if err != nil {
|
|
| 363 |
+ if err != errDaemonNotStarted {
|
|
| 364 |
+ c.Fatalf("Error while stopping the daemon %s : %v", d.id, err)
|
|
| 365 |
+ } else {
|
|
| 366 |
+ c.Logf("Daemon %s is not started", d.id)
|
|
| 367 |
+ } |
|
| 368 |
+ } |
|
| 369 |
+} |
|
| 370 |
+ |
|
| 371 |
+// StopWithError will send a SIGINT every second and wait for the daemon to stop. |
|
| 356 | 372 |
// If it timeouts, a SIGKILL is sent. |
| 357 | 373 |
// Stop will not delete the daemon directory. If a purged daemon is needed, |
| 358 | 374 |
// instantiate a new one with NewDaemon. |
| 359 |
-func (d *Daemon) Stop() error {
|
|
| 375 |
+func (d *Daemon) StopWithError() error {
|
|
| 360 | 376 |
if d.cmd == nil || d.Wait == nil {
|
| 361 |
- return errors.New("daemon not started")
|
|
| 377 |
+ return errDaemonNotStarted |
|
| 362 | 378 |
} |
| 363 | 379 |
|
| 364 | 380 |
defer func() {
|
| ... | ... |
@@ -370,6 +391,9 @@ func (d *Daemon) Stop() error {
|
| 370 | 370 |
tick := time.Tick(time.Second) |
| 371 | 371 |
|
| 372 | 372 |
if err := d.cmd.Process.Signal(os.Interrupt); err != nil {
|
| 373 |
+ if strings.Contains(err.Error(), "os: process already finished") {
|
|
| 374 |
+ return errDaemonNotStarted |
|
| 375 |
+ } |
|
| 373 | 376 |
return errors.Errorf("could not send signal: %v", err)
|
| 374 | 377 |
} |
| 375 | 378 |
out1: |
| ... | ... |
@@ -414,9 +438,24 @@ out2: |
| 414 | 414 |
return nil |
| 415 | 415 |
} |
| 416 | 416 |
|
| 417 |
-// Restart will restart the daemon by first stopping it and then starting it. |
|
| 418 |
-func (d *Daemon) Restart(arg ...string) error {
|
|
| 419 |
- d.Stop() |
|
| 417 |
+// Restart will restart the daemon by first stopping it and the starting it. |
|
| 418 |
+// If an error occurs while starting the daemon, the test will fail. |
|
| 419 |
+func (d *Daemon) Restart(c *check.C, args ...string) {
|
|
| 420 |
+ d.Stop(c) |
|
| 421 |
+ d.handleUserns() |
|
| 422 |
+ d.Start(c, args...) |
|
| 423 |
+} |
|
| 424 |
+ |
|
| 425 |
+// RestartWithError will restart the daemon by first stopping it and then starting it. |
|
| 426 |
+func (d *Daemon) RestartWithError(arg ...string) error {
|
|
| 427 |
+ if err := d.StopWithError(); err != nil {
|
|
| 428 |
+ return err |
|
| 429 |
+ } |
|
| 430 |
+ d.handleUserns() |
|
| 431 |
+ return d.StartWithError(arg...) |
|
| 432 |
+} |
|
| 433 |
+ |
|
| 434 |
+func (d *Daemon) handleUserns() {
|
|
| 420 | 435 |
// in the case of tests running a user namespace-enabled daemon, we have resolved |
| 421 | 436 |
// d.Root to be the actual final path of the graph dir after the "uid.gid" of |
| 422 | 437 |
// remapped root is added--we need to subtract it from the path before calling |
| ... | ... |
@@ -425,7 +464,6 @@ func (d *Daemon) Restart(arg ...string) error {
|
| 425 | 425 |
if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
|
| 426 | 426 |
d.Root = filepath.Dir(d.Root) |
| 427 | 427 |
} |
| 428 |
- return d.Start(arg...) |
|
| 429 | 428 |
} |
| 430 | 429 |
|
| 431 | 430 |
// LoadBusybox will load the stored busybox into a newly started daemon |
| ... | ... |
@@ -51,15 +51,11 @@ func (s *DockerSwarmSuite) TestAPISwarmInit(c *check.C) {
|
| 51 | 51 |
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateActive) |
| 52 | 52 |
|
| 53 | 53 |
// Current state restoring after restarts |
| 54 |
- err = d1.Stop() |
|
| 55 |
- c.Assert(err, checker.IsNil) |
|
| 56 |
- err = d2.Stop() |
|
| 57 |
- c.Assert(err, checker.IsNil) |
|
| 54 |
+ d1.Stop(c) |
|
| 55 |
+ d2.Stop(c) |
|
| 58 | 56 |
|
| 59 |
- err = d1.Start() |
|
| 60 |
- c.Assert(err, checker.IsNil) |
|
| 61 |
- err = d2.Start() |
|
| 62 |
- c.Assert(err, checker.IsNil) |
|
| 57 |
+ d1.Start(c) |
|
| 58 |
+ d2.Start(c) |
|
| 63 | 59 |
|
| 64 | 60 |
info, err = d1.SwarmInfo() |
| 65 | 61 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -240,7 +236,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesMultipleAgents(c *check.C) {
|
| 240 | 240 |
waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances) |
| 241 | 241 |
|
| 242 | 242 |
// reconciliation on d2 node down |
| 243 |
- c.Assert(d2.Stop(), checker.IsNil) |
|
| 243 |
+ d2.Stop(c) |
|
| 244 | 244 |
|
| 245 | 245 |
waitAndAssert(c, defaultReconciliationTimeout, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d3.CheckActiveContainerCount), checker.Equals, instances) |
| 246 | 246 |
|
| ... | ... |
@@ -629,7 +625,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
|
| 629 | 629 |
c.Assert(d1.GetNode(c, d2.NodeID).ManagerStatus.Leader, checker.False) |
| 630 | 630 |
c.Assert(d1.GetNode(c, d3.NodeID).ManagerStatus.Leader, checker.False) |
| 631 | 631 |
|
| 632 |
- d1.Stop() // stop the leader |
|
| 632 |
+ d1.Stop(c) |
|
| 633 | 633 |
|
| 634 | 634 |
var ( |
| 635 | 635 |
leader *daemon.Swarm // keep track of leader |
| ... | ... |
@@ -666,7 +662,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *check.C) {
|
| 666 | 666 |
stableleader := leader |
| 667 | 667 |
|
| 668 | 668 |
// add the d1, the initial leader, back |
| 669 |
- d1.Start() |
|
| 669 |
+ d1.Start(c) |
|
| 670 | 670 |
|
| 671 | 671 |
// TODO(stevvooe): may need to wait for rejoin here |
| 672 | 672 |
|
| ... | ... |
@@ -688,7 +684,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
|
| 688 | 688 |
|
| 689 | 689 |
d1.CreateService(c, simpleTestService) |
| 690 | 690 |
|
| 691 |
- c.Assert(d2.Stop(), checker.IsNil) |
|
| 691 |
+ d2.Stop(c) |
|
| 692 | 692 |
|
| 693 | 693 |
// make sure there is a leader |
| 694 | 694 |
waitAndAssert(c, defaultReconciliationTimeout, d1.CheckLeader, checker.IsNil) |
| ... | ... |
@@ -697,7 +693,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
|
| 697 | 697 |
s.Spec.Name = "top1" |
| 698 | 698 |
}) |
| 699 | 699 |
|
| 700 |
- c.Assert(d3.Stop(), checker.IsNil) |
|
| 700 |
+ d3.Stop(c) |
|
| 701 | 701 |
|
| 702 | 702 |
// make sure there is a leader |
| 703 | 703 |
waitAndAssert(c, defaultReconciliationTimeout, d1.CheckLeader, checker.IsNil) |
| ... | ... |
@@ -709,7 +705,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *check.C) {
|
| 709 | 709 |
c.Assert(err, checker.IsNil) |
| 710 | 710 |
c.Assert(status, checker.Equals, http.StatusInternalServerError, check.Commentf("deadline exceeded", string(out)))
|
| 711 | 711 |
|
| 712 |
- c.Assert(d2.Start(), checker.IsNil) |
|
| 712 |
+ d2.Start(c) |
|
| 713 | 713 |
|
| 714 | 714 |
// make sure there is a leader |
| 715 | 715 |
waitAndAssert(c, defaultReconciliationTimeout, d1.CheckLeader, checker.IsNil) |
| ... | ... |
@@ -771,8 +767,7 @@ func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *check.C) {
|
| 771 | 771 |
c.Assert(len(nodes), checker.Equals, 2, check.Commentf("nodes: %#v", nodes))
|
| 772 | 772 |
|
| 773 | 773 |
// Restart the node that was removed |
| 774 |
- err = d2.Restart() |
|
| 775 |
- c.Assert(err, checker.IsNil) |
|
| 774 |
+ d2.Restart(c) |
|
| 776 | 775 |
|
| 777 | 776 |
// Give some time for the node to rejoin |
| 778 | 777 |
time.Sleep(1 * time.Second) |
| ... | ... |
@@ -899,8 +894,8 @@ func (s *DockerSwarmSuite) TestAPISwarmRestoreOnPendingJoin(c *check.C) {
|
| 899 | 899 |
|
| 900 | 900 |
waitAndAssert(c, defaultReconciliationTimeout, d.CheckLocalNodeState, checker.Equals, swarm.LocalNodeStatePending) |
| 901 | 901 |
|
| 902 |
- c.Assert(d.Stop(), checker.IsNil) |
|
| 903 |
- c.Assert(d.Start(), checker.IsNil) |
|
| 902 |
+ d.Stop(c) |
|
| 903 |
+ d.Start(c) |
|
| 904 | 904 |
|
| 905 | 905 |
info, err := d.SwarmInfo() |
| 906 | 906 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -914,25 +909,25 @@ func (s *DockerSwarmSuite) TestAPISwarmManagerRestore(c *check.C) {
|
| 914 | 914 |
id := d1.CreateService(c, simpleTestService, setInstances(instances)) |
| 915 | 915 |
|
| 916 | 916 |
d1.GetService(c, id) |
| 917 |
- d1.Stop() |
|
| 918 |
- d1.Start() |
|
| 917 |
+ d1.Stop(c) |
|
| 918 |
+ d1.Start(c) |
|
| 919 | 919 |
d1.GetService(c, id) |
| 920 | 920 |
|
| 921 | 921 |
d2 := s.AddDaemon(c, true, true) |
| 922 | 922 |
d2.GetService(c, id) |
| 923 |
- d2.Stop() |
|
| 924 |
- d2.Start() |
|
| 923 |
+ d2.Stop(c) |
|
| 924 |
+ d2.Start(c) |
|
| 925 | 925 |
d2.GetService(c, id) |
| 926 | 926 |
|
| 927 | 927 |
d3 := s.AddDaemon(c, true, true) |
| 928 | 928 |
d3.GetService(c, id) |
| 929 |
- d3.Stop() |
|
| 930 |
- d3.Start() |
|
| 929 |
+ d3.Stop(c) |
|
| 930 |
+ d3.Start(c) |
|
| 931 | 931 |
d3.GetService(c, id) |
| 932 | 932 |
|
| 933 | 933 |
d3.Kill() |
| 934 | 934 |
time.Sleep(1 * time.Second) // time to handle signal |
| 935 |
- d3.Start() |
|
| 935 |
+ d3.Start(c) |
|
| 936 | 936 |
d3.GetService(c, id) |
| 937 | 937 |
} |
| 938 | 938 |
|
| ... | ... |
@@ -993,7 +988,7 @@ func (s *DockerSwarmSuite) TestAPISwarmForceNewCluster(c *check.C) {
|
| 993 | 993 |
waitAndAssert(c, defaultReconciliationTimeout, d1.CheckActiveContainerCount, checker.Equals, instances) |
| 994 | 994 |
waitAndAssert(c, defaultReconciliationTimeout, d2.CheckActiveContainerCount, checker.Equals, 0) |
| 995 | 995 |
|
| 996 |
- c.Assert(d2.Stop(), checker.IsNil) |
|
| 996 |
+ d2.Stop(c) |
|
| 997 | 997 |
|
| 998 | 998 |
c.Assert(d1.Init(swarm.InitRequest{
|
| 999 | 999 |
ForceNewCluster: true, |
| ... | ... |
@@ -1210,7 +1205,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) {
|
| 1210 | 1210 |
for _, d := range nodes {
|
| 1211 | 1211 |
go func(daemon *daemon.Swarm) {
|
| 1212 | 1212 |
defer wg.Done() |
| 1213 |
- if err := daemon.Stop(); err != nil {
|
|
| 1213 |
+ if err := daemon.StopWithError(); err != nil {
|
|
| 1214 | 1214 |
errs <- err |
| 1215 | 1215 |
} |
| 1216 | 1216 |
// FIXME(vdemeester) This is duplicated… |
| ... | ... |
@@ -1235,7 +1230,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *check.C) {
|
| 1235 | 1235 |
for _, d := range nodes {
|
| 1236 | 1236 |
go func(daemon *daemon.Swarm) {
|
| 1237 | 1237 |
defer wg.Done() |
| 1238 |
- if err := daemon.Start("--iptables=false"); err != nil {
|
|
| 1238 |
+ if err := daemon.StartWithError("--iptables=false"); err != nil {
|
|
| 1239 | 1239 |
errs <- err |
| 1240 | 1240 |
} |
| 1241 | 1241 |
}(d) |
| ... | ... |
@@ -35,12 +35,12 @@ func (s *DockerAuthzV2Suite) SetUpTest(c *check.C) {
|
| 35 | 35 |
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
| 36 | 36 |
Experimental: experimentalDaemon, |
| 37 | 37 |
}) |
| 38 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 38 |
+ s.d.Start(c) |
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 | 41 |
func (s *DockerAuthzV2Suite) TearDownTest(c *check.C) {
|
| 42 | 42 |
if s.d != nil {
|
| 43 |
- s.d.Stop() |
|
| 43 |
+ s.d.Stop(c) |
|
| 44 | 44 |
s.ds.TearDownTest(c) |
| 45 | 45 |
} |
| 46 | 46 |
} |
| ... | ... |
@@ -52,12 +52,12 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginAllowNonVolumeRequest(c *check.C) {
|
| 52 | 52 |
c.Assert(err, checker.IsNil) |
| 53 | 53 |
// start the daemon with the plugin and load busybox, --net=none build fails otherwise |
| 54 | 54 |
// because it needs to pull busybox |
| 55 |
- c.Assert(s.d.Restart("--authorization-plugin="+authzPluginNameWithTag), check.IsNil)
|
|
| 55 |
+ s.d.Restart(c, "--authorization-plugin="+authzPluginNameWithTag) |
|
| 56 | 56 |
c.Assert(s.d.LoadBusybox(), check.IsNil) |
| 57 | 57 |
|
| 58 | 58 |
// defer disabling the plugin |
| 59 | 59 |
defer func() {
|
| 60 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 60 |
+ s.d.Restart(c) |
|
| 61 | 61 |
_, err = s.d.Cmd("plugin", "disable", authzPluginNameWithTag)
|
| 62 | 62 |
c.Assert(err, checker.IsNil) |
| 63 | 63 |
_, err = s.d.Cmd("plugin", "rm", authzPluginNameWithTag)
|
| ... | ... |
@@ -82,11 +82,11 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginRejectVolumeRequests(c *check.C) {
|
| 82 | 82 |
c.Assert(err, checker.IsNil) |
| 83 | 83 |
|
| 84 | 84 |
// restart the daemon with the plugin |
| 85 |
- c.Assert(s.d.Restart("--authorization-plugin="+authzPluginNameWithTag), check.IsNil)
|
|
| 85 |
+ s.d.Restart(c, "--authorization-plugin="+authzPluginNameWithTag) |
|
| 86 | 86 |
|
| 87 | 87 |
// defer disabling the plugin |
| 88 | 88 |
defer func() {
|
| 89 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 89 |
+ s.d.Restart(c) |
|
| 90 | 90 |
_, err = s.d.Cmd("plugin", "disable", authzPluginNameWithTag)
|
| 91 | 91 |
c.Assert(err, checker.IsNil) |
| 92 | 92 |
_, err = s.d.Cmd("plugin", "rm", authzPluginNameWithTag)
|
| ... | ... |
@@ -121,16 +121,16 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginBadManifestFailsDaemonStart(c *check |
| 121 | 121 |
c.Assert(err, checker.IsNil) |
| 122 | 122 |
|
| 123 | 123 |
// start the daemon with the plugin, it will error |
| 124 |
- c.Assert(s.d.Restart("--authorization-plugin="+authzPluginBadManifestName), check.NotNil)
|
|
| 124 |
+ c.Assert(s.d.RestartWithError("--authorization-plugin="+authzPluginBadManifestName), check.NotNil)
|
|
| 125 | 125 |
|
| 126 | 126 |
// restarting the daemon without requiring the plugin will succeed |
| 127 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 127 |
+ s.d.Restart(c) |
|
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 | 130 |
func (s *DockerAuthzV2Suite) TestNonexistentAuthZPluginFailsDaemonStart(c *check.C) {
|
| 131 | 131 |
// start the daemon with a non-existent authz plugin, it will error |
| 132 |
- c.Assert(s.d.Restart("--authorization-plugin="+nonexistentAuthzPluginName), check.NotNil)
|
|
| 132 |
+ c.Assert(s.d.RestartWithError("--authorization-plugin="+nonexistentAuthzPluginName), check.NotNil)
|
|
| 133 | 133 |
|
| 134 | 134 |
// restarting the daemon without requiring the plugin will succeed |
| 135 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 135 |
+ s.d.Start(c) |
|
| 136 | 136 |
} |
| ... | ... |
@@ -72,7 +72,7 @@ func (s *DockerAuthzSuite) SetUpTest(c *check.C) {
|
| 72 | 72 |
|
| 73 | 73 |
func (s *DockerAuthzSuite) TearDownTest(c *check.C) {
|
| 74 | 74 |
if s.d != nil {
|
| 75 |
- s.d.Stop() |
|
| 75 |
+ s.d.Stop(c) |
|
| 76 | 76 |
s.ds.TearDownTest(c) |
| 77 | 77 |
s.ctrl = nil |
| 78 | 78 |
} |
| ... | ... |
@@ -206,7 +206,7 @@ func (s *DockerAuthzSuite) TearDownSuite(c *check.C) {
|
| 206 | 206 |
func (s *DockerAuthzSuite) TestAuthZPluginAllowRequest(c *check.C) {
|
| 207 | 207 |
// start the daemon and load busybox, --net=none build fails otherwise |
| 208 | 208 |
// cause it needs to pull busybox |
| 209 |
- c.Assert(s.d.Start("--authorization-plugin="+testAuthZPlugin), check.IsNil)
|
|
| 209 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 210 | 210 |
s.ctrl.reqRes.Allow = true |
| 211 | 211 |
s.ctrl.resRes.Allow = true |
| 212 | 212 |
c.Assert(s.d.LoadBusybox(), check.IsNil) |
| ... | ... |
@@ -231,7 +231,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginTls(c *check.C) {
|
| 231 | 231 |
const testDaemonHTTPSAddr = "tcp://localhost:4271" |
| 232 | 232 |
// start the daemon and load busybox, --net=none build fails otherwise |
| 233 | 233 |
// cause it needs to pull busybox |
| 234 |
- if err := s.d.Start( |
|
| 234 |
+ s.d.Start(c, |
|
| 235 | 235 |
"--authorization-plugin="+testAuthZPlugin, |
| 236 | 236 |
"--tlsverify", |
| 237 | 237 |
"--tlscacert", |
| ... | ... |
@@ -240,9 +240,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginTls(c *check.C) {
|
| 240 | 240 |
"fixtures/https/server-cert.pem", |
| 241 | 241 |
"--tlskey", |
| 242 | 242 |
"fixtures/https/server-key.pem", |
| 243 |
- "-H", testDaemonHTTPSAddr); err != nil {
|
|
| 244 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 245 |
- } |
|
| 243 |
+ "-H", testDaemonHTTPSAddr) |
|
| 246 | 244 |
|
| 247 | 245 |
s.ctrl.reqRes.Allow = true |
| 248 | 246 |
s.ctrl.resRes.Allow = true |
| ... | ... |
@@ -266,8 +264,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginTls(c *check.C) {
|
| 266 | 266 |
} |
| 267 | 267 |
|
| 268 | 268 |
func (s *DockerAuthzSuite) TestAuthZPluginDenyRequest(c *check.C) {
|
| 269 |
- err := s.d.Start("--authorization-plugin=" + testAuthZPlugin)
|
|
| 270 |
- c.Assert(err, check.IsNil) |
|
| 269 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 271 | 270 |
s.ctrl.reqRes.Allow = false |
| 272 | 271 |
s.ctrl.reqRes.Msg = unauthorizedMessage |
| 273 | 272 |
|
| ... | ... |
@@ -283,8 +280,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginDenyRequest(c *check.C) {
|
| 283 | 283 |
|
| 284 | 284 |
// TestAuthZPluginAPIDenyResponse validates that when authorization plugin deny the request, the status code is forbidden |
| 285 | 285 |
func (s *DockerAuthzSuite) TestAuthZPluginAPIDenyResponse(c *check.C) {
|
| 286 |
- err := s.d.Start("--authorization-plugin=" + testAuthZPlugin)
|
|
| 287 |
- c.Assert(err, check.IsNil) |
|
| 286 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 288 | 287 |
s.ctrl.reqRes.Allow = false |
| 289 | 288 |
s.ctrl.resRes.Msg = unauthorizedMessage |
| 290 | 289 |
|
| ... | ... |
@@ -303,8 +299,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAPIDenyResponse(c *check.C) {
|
| 303 | 303 |
} |
| 304 | 304 |
|
| 305 | 305 |
func (s *DockerAuthzSuite) TestAuthZPluginDenyResponse(c *check.C) {
|
| 306 |
- err := s.d.Start("--authorization-plugin=" + testAuthZPlugin)
|
|
| 307 |
- c.Assert(err, check.IsNil) |
|
| 306 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 308 | 307 |
s.ctrl.reqRes.Allow = true |
| 309 | 308 |
s.ctrl.resRes.Allow = false |
| 310 | 309 |
s.ctrl.resRes.Msg = unauthorizedMessage |
| ... | ... |
@@ -324,7 +319,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowEventStream(c *check.C) {
|
| 324 | 324 |
testRequires(c, DaemonIsLinux) |
| 325 | 325 |
|
| 326 | 326 |
// start the daemon and load busybox to avoid pulling busybox from Docker Hub |
| 327 |
- c.Assert(s.d.Start("--authorization-plugin="+testAuthZPlugin), check.IsNil)
|
|
| 327 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 328 | 328 |
s.ctrl.reqRes.Allow = true |
| 329 | 329 |
s.ctrl.resRes.Allow = true |
| 330 | 330 |
c.Assert(s.d.LoadBusybox(), check.IsNil) |
| ... | ... |
@@ -383,8 +378,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowEventStream(c *check.C) {
|
| 383 | 383 |
} |
| 384 | 384 |
|
| 385 | 385 |
func (s *DockerAuthzSuite) TestAuthZPluginErrorResponse(c *check.C) {
|
| 386 |
- err := s.d.Start("--authorization-plugin=" + testAuthZPlugin)
|
|
| 387 |
- c.Assert(err, check.IsNil) |
|
| 386 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 388 | 387 |
s.ctrl.reqRes.Allow = true |
| 389 | 388 |
s.ctrl.resRes.Err = errorMessage |
| 390 | 389 |
|
| ... | ... |
@@ -396,8 +390,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginErrorResponse(c *check.C) {
|
| 396 | 396 |
} |
| 397 | 397 |
|
| 398 | 398 |
func (s *DockerAuthzSuite) TestAuthZPluginErrorRequest(c *check.C) {
|
| 399 |
- err := s.d.Start("--authorization-plugin=" + testAuthZPlugin)
|
|
| 400 |
- c.Assert(err, check.IsNil) |
|
| 399 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin) |
|
| 401 | 400 |
s.ctrl.reqRes.Err = errorMessage |
| 402 | 401 |
|
| 403 | 402 |
// Ensure command is blocked |
| ... | ... |
@@ -408,7 +401,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginErrorRequest(c *check.C) {
|
| 408 | 408 |
} |
| 409 | 409 |
|
| 410 | 410 |
func (s *DockerAuthzSuite) TestAuthZPluginEnsureNoDuplicatePluginRegistration(c *check.C) {
|
| 411 |
- c.Assert(s.d.Start("--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin), check.IsNil)
|
|
| 411 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin) |
|
| 412 | 412 |
|
| 413 | 413 |
s.ctrl.reqRes.Allow = true |
| 414 | 414 |
s.ctrl.resRes.Allow = true |
| ... | ... |
@@ -422,7 +415,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginEnsureNoDuplicatePluginRegistration(c |
| 422 | 422 |
} |
| 423 | 423 |
|
| 424 | 424 |
func (s *DockerAuthzSuite) TestAuthZPluginEnsureLoadImportWorking(c *check.C) {
|
| 425 |
- c.Assert(s.d.Start("--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin), check.IsNil)
|
|
| 425 |
+ s.d.Start(c, "--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin) |
|
| 426 | 426 |
s.ctrl.reqRes.Allow = true |
| 427 | 427 |
s.ctrl.resRes.Allow = true |
| 428 | 428 |
c.Assert(s.d.LoadBusybox(), check.IsNil) |
| ... | ... |
@@ -449,7 +442,7 @@ func (s *DockerAuthzSuite) TestAuthZPluginEnsureLoadImportWorking(c *check.C) {
|
| 449 | 449 |
} |
| 450 | 450 |
|
| 451 | 451 |
func (s *DockerAuthzSuite) TestAuthZPluginHeader(c *check.C) {
|
| 452 |
- c.Assert(s.d.Start("--debug", "--authorization-plugin="+testAuthZPlugin), check.IsNil)
|
|
| 452 |
+ s.d.Start(c, "--debug", "--authorization-plugin="+testAuthZPlugin) |
|
| 453 | 453 |
s.ctrl.reqRes.Allow = true |
| 454 | 454 |
s.ctrl.resRes.Allow = true |
| 455 | 455 |
c.Assert(s.d.LoadBusybox(), check.IsNil) |
| ... | ... |
@@ -18,9 +18,7 @@ import ( |
| 18 | 18 |
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
|
| 19 | 19 |
testRequires(c, Network) |
| 20 | 20 |
|
| 21 |
- if err := s.d.Start(); err != nil {
|
|
| 22 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 23 |
- } |
|
| 21 |
+ s.d.Start(c) |
|
| 24 | 22 |
|
| 25 | 23 |
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName); err != nil {
|
| 26 | 24 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| ... | ... |
@@ -35,9 +33,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
|
| 35 | 35 |
} |
| 36 | 36 |
}() |
| 37 | 37 |
|
| 38 |
- if err := s.d.Restart(); err != nil {
|
|
| 39 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 40 |
- } |
|
| 38 |
+ s.d.Restart(c) |
|
| 41 | 39 |
|
| 42 | 40 |
out, err := s.d.Cmd("plugin", "ls")
|
| 43 | 41 |
if err != nil {
|
| ... | ... |
@@ -51,9 +47,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
|
| 51 | 51 |
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
|
| 52 | 52 |
testRequires(c, Network) |
| 53 | 53 |
|
| 54 |
- if err := s.d.Start(); err != nil {
|
|
| 55 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 56 |
- } |
|
| 54 |
+ s.d.Start(c) |
|
| 57 | 55 |
|
| 58 | 56 |
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName, "--disable"); err != nil {
|
| 59 | 57 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| ... | ... |
@@ -65,9 +59,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
|
| 65 | 65 |
} |
| 66 | 66 |
}() |
| 67 | 67 |
|
| 68 |
- if err := s.d.Restart(); err != nil {
|
|
| 69 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 70 |
- } |
|
| 68 |
+ s.d.Restart(c) |
|
| 71 | 69 |
|
| 72 | 70 |
out, err := s.d.Cmd("plugin", "ls")
|
| 73 | 71 |
if err != nil {
|
| ... | ... |
@@ -82,16 +74,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
|
| 82 | 82 |
func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) {
|
| 83 | 83 |
testRequires(c, Network, IsAmd64) |
| 84 | 84 |
|
| 85 |
- if err := s.d.Start("--live-restore"); err != nil {
|
|
| 86 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 87 |
- } |
|
| 85 |
+ s.d.Start(c, "--live-restore") |
|
| 88 | 86 |
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName); err != nil {
|
| 89 | 87 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| 90 | 88 |
} |
| 91 | 89 |
defer func() {
|
| 92 |
- if err := s.d.Restart("--live-restore"); err != nil {
|
|
| 93 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 94 |
- } |
|
| 90 |
+ s.d.Restart(c, "--live-restore") |
|
| 95 | 91 |
if out, err := s.d.Cmd("plugin", "disable", pName); err != nil {
|
| 96 | 92 |
c.Fatalf("Could not disable plugin: %v %s", err, out)
|
| 97 | 93 |
} |
| ... | ... |
@@ -115,16 +103,12 @@ func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) {
|
| 115 | 115 |
func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) {
|
| 116 | 116 |
testRequires(c, Network, IsAmd64) |
| 117 | 117 |
|
| 118 |
- if err := s.d.Start("--live-restore"); err != nil {
|
|
| 119 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 120 |
- } |
|
| 118 |
+ s.d.Start(c, "--live-restore") |
|
| 121 | 119 |
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName); err != nil {
|
| 122 | 120 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| 123 | 121 |
} |
| 124 | 122 |
defer func() {
|
| 125 |
- if err := s.d.Restart("--live-restore"); err != nil {
|
|
| 126 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 127 |
- } |
|
| 123 |
+ s.d.Restart(c, "--live-restore") |
|
| 128 | 124 |
if out, err := s.d.Cmd("plugin", "disable", pName); err != nil {
|
| 129 | 125 |
c.Fatalf("Could not disable plugin: %v %s", err, out)
|
| 130 | 126 |
} |
| ... | ... |
@@ -147,17 +131,13 @@ func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) |
| 147 | 147 |
func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) {
|
| 148 | 148 |
testRequires(c, Network) |
| 149 | 149 |
|
| 150 |
- if err := s.d.Start(); err != nil {
|
|
| 151 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 152 |
- } |
|
| 150 |
+ s.d.Start(c) |
|
| 153 | 151 |
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pName); err != nil {
|
| 154 | 152 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| 155 | 153 |
} |
| 156 | 154 |
|
| 157 | 155 |
defer func() {
|
| 158 |
- if err := s.d.Restart(); err != nil {
|
|
| 159 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 160 |
- } |
|
| 156 |
+ s.d.Restart(c) |
|
| 161 | 157 |
if out, err := s.d.Cmd("plugin", "disable", pName); err != nil {
|
| 162 | 158 |
c.Fatalf("Could not disable plugin: %v %s", err, out)
|
| 163 | 159 |
} |
| ... | ... |
@@ -190,9 +170,7 @@ func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
|
| 190 | 190 |
destDir := "/tmp/data/" |
| 191 | 191 |
destFile := "foo" |
| 192 | 192 |
|
| 193 |
- if err := s.d.Start(); err != nil {
|
|
| 194 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 195 |
- } |
|
| 193 |
+ s.d.Start(c) |
|
| 196 | 194 |
out, err := s.d.Cmd("plugin", "install", pName, "--grant-all-permissions")
|
| 197 | 195 |
if err != nil {
|
| 198 | 196 |
c.Fatalf("Could not install plugin: %v %s", err, out)
|
| ... | ... |
@@ -43,9 +43,7 @@ func (s *DockerDaemonSuite) TestLegacyDaemonCommand(c *check.C) {
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check.C) {
|
| 46 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 47 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 48 |
- } |
|
| 46 |
+ s.d.StartWithBusybox(c) |
|
| 49 | 47 |
|
| 50 | 48 |
if out, err := s.d.Cmd("run", "-d", "--name", "top1", "-p", "1234:80", "--restart", "always", "busybox:latest", "top"); err != nil {
|
| 51 | 49 |
c.Fatalf("Could not run top1: err=%v\n%s", err, out)
|
| ... | ... |
@@ -75,24 +73,18 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithRunningContainersPorts(c *check |
| 75 | 75 |
|
| 76 | 76 |
testRun(map[string]bool{"top1": true, "top2": true}, "")
|
| 77 | 77 |
|
| 78 |
- if err := s.d.Restart(); err != nil {
|
|
| 79 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 80 |
- } |
|
| 78 |
+ s.d.Restart(c) |
|
| 81 | 79 |
testRun(map[string]bool{"top1": true, "top2": false}, "After daemon restart: ")
|
| 82 | 80 |
} |
| 83 | 81 |
|
| 84 | 82 |
func (s *DockerDaemonSuite) TestDaemonRestartWithVolumesRefs(c *check.C) {
|
| 85 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 86 |
- c.Fatal(err) |
|
| 87 |
- } |
|
| 83 |
+ s.d.StartWithBusybox(c) |
|
| 88 | 84 |
|
| 89 | 85 |
if out, err := s.d.Cmd("run", "--name", "volrestarttest1", "-v", "/foo", "busybox"); err != nil {
|
| 90 | 86 |
c.Fatal(err, out) |
| 91 | 87 |
} |
| 92 | 88 |
|
| 93 |
- if err := s.d.Restart(); err != nil {
|
|
| 94 |
- c.Fatal(err) |
|
| 95 |
- } |
|
| 89 |
+ s.d.Restart(c) |
|
| 96 | 90 |
|
| 97 | 91 |
if _, err := s.d.Cmd("run", "-d", "--volumes-from", "volrestarttest1", "--name", "volrestarttest2", "busybox", "top"); err != nil {
|
| 98 | 92 |
c.Fatal(err) |
| ... | ... |
@@ -112,8 +104,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithVolumesRefs(c *check.C) {
|
| 112 | 112 |
|
| 113 | 113 |
// #11008 |
| 114 | 114 |
func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
|
| 115 |
- err := s.d.StartWithBusybox() |
|
| 116 |
- c.Assert(err, check.IsNil) |
|
| 115 |
+ s.d.StartWithBusybox(c) |
|
| 117 | 116 |
|
| 118 | 117 |
out, err := s.d.Cmd("run", "-d", "--name", "top1", "--restart", "always", "busybox:latest", "top")
|
| 119 | 118 |
c.Assert(err, check.IsNil, check.Commentf("run top1: %v", out))
|
| ... | ... |
@@ -147,8 +138,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
|
| 147 | 147 |
// both stopped |
| 148 | 148 |
testRun(map[string]bool{"top1": false, "top2": false}, "")
|
| 149 | 149 |
|
| 150 |
- err = s.d.Restart() |
|
| 151 |
- c.Assert(err, check.IsNil) |
|
| 150 |
+ s.d.Restart(c) |
|
| 152 | 151 |
|
| 153 | 152 |
// restart=always running |
| 154 | 153 |
testRun(map[string]bool{"top1": true, "top2": false}, "After daemon restart: ")
|
| ... | ... |
@@ -156,8 +146,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
|
| 156 | 156 |
out, err = s.d.Cmd("start", "top2")
|
| 157 | 157 |
c.Assert(err, check.IsNil, check.Commentf("start top2: %v", out))
|
| 158 | 158 |
|
| 159 |
- err = s.d.Restart() |
|
| 160 |
- c.Assert(err, check.IsNil) |
|
| 159 |
+ s.d.Restart(c) |
|
| 161 | 160 |
|
| 162 | 161 |
// both running |
| 163 | 162 |
testRun(map[string]bool{"top1": true, "top2": true}, "After second daemon restart: ")
|
| ... | ... |
@@ -165,8 +154,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartUnlessStopped(c *check.C) {
|
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) {
|
| 168 |
- err := s.d.StartWithBusybox() |
|
| 169 |
- c.Assert(err, check.IsNil) |
|
| 168 |
+ s.d.StartWithBusybox(c) |
|
| 170 | 169 |
|
| 171 | 170 |
out, err := s.d.Cmd("run", "-d", "--name", "test1", "--restart", "on-failure:3", "busybox:latest", "false")
|
| 172 | 171 |
c.Assert(err, check.IsNil, check.Commentf("run top1: %v", out))
|
| ... | ... |
@@ -181,8 +169,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) {
|
| 181 | 181 |
c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
| 182 | 182 |
lastStartTime := out |
| 183 | 183 |
|
| 184 |
- err = s.d.Restart() |
|
| 185 |
- c.Assert(err, check.IsNil) |
|
| 184 |
+ s.d.Restart(c) |
|
| 186 | 185 |
|
| 187 | 186 |
// test1 shouldn't restart at all |
| 188 | 187 |
err = waitInspectWithArgs("test1", "{{.State.Running}} {{.State.Restarting}}", "false false", 0, hostArgs...)
|
| ... | ... |
@@ -196,30 +183,28 @@ func (s *DockerDaemonSuite) TestDaemonRestartOnFailure(c *check.C) {
|
| 196 | 196 |
} |
| 197 | 197 |
|
| 198 | 198 |
func (s *DockerDaemonSuite) TestDaemonStartIptablesFalse(c *check.C) {
|
| 199 |
- if err := s.d.Start("--iptables=false"); err != nil {
|
|
| 200 |
- c.Fatalf("we should have been able to start the daemon with passing iptables=false: %v", err)
|
|
| 201 |
- } |
|
| 199 |
+ s.d.Start(c, "--iptables=false") |
|
| 202 | 200 |
} |
| 203 | 201 |
|
| 204 | 202 |
// Make sure we cannot shrink base device at daemon restart. |
| 205 | 203 |
func (s *DockerDaemonSuite) TestDaemonRestartWithInvalidBasesize(c *check.C) {
|
| 206 | 204 |
testRequires(c, Devicemapper) |
| 207 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 205 |
+ s.d.Start(c) |
|
| 208 | 206 |
|
| 209 | 207 |
oldBasesizeBytes := s.d.GetBaseDeviceSize(c) |
| 210 | 208 |
var newBasesizeBytes int64 = 1073741824 //1GB in bytes |
| 211 | 209 |
|
| 212 | 210 |
if newBasesizeBytes < oldBasesizeBytes {
|
| 213 |
- err := s.d.Restart("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
|
|
| 211 |
+ err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
|
|
| 214 | 212 |
c.Assert(err, check.IsNil, check.Commentf("daemon should not have started as new base device size is less than existing base device size: %v", err))
|
| 215 | 213 |
} |
| 216 |
- c.Assert(s.d.Stop(), check.IsNil) |
|
| 214 |
+ s.d.Stop(c) |
|
| 217 | 215 |
} |
| 218 | 216 |
|
| 219 | 217 |
// Make sure we can grow base device at daemon restart. |
| 220 | 218 |
func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) {
|
| 221 | 219 |
testRequires(c, Devicemapper) |
| 222 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 220 |
+ s.d.Start(c) |
|
| 223 | 221 |
|
| 224 | 222 |
oldBasesizeBytes := s.d.GetBaseDeviceSize(c) |
| 225 | 223 |
|
| ... | ... |
@@ -229,14 +214,14 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithIncreasedBasesize(c *check.C) {
|
| 229 | 229 |
c.Skip(fmt.Sprintf("New base device size (%v) must be greater than (%s)", units.HumanSize(float64(newBasesizeBytes)), units.HumanSize(float64(oldBasesizeBytes))))
|
| 230 | 230 |
} |
| 231 | 231 |
|
| 232 |
- err := s.d.Restart("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
|
|
| 232 |
+ err := s.d.RestartWithError("--storage-opt", fmt.Sprintf("dm.basesize=%d", newBasesizeBytes))
|
|
| 233 | 233 |
c.Assert(err, check.IsNil, check.Commentf("we should have been able to start the daemon with increased base device size: %v", err))
|
| 234 | 234 |
|
| 235 | 235 |
basesizeAfterRestart := s.d.GetBaseDeviceSize(c) |
| 236 | 236 |
newBasesize, err := convertBasesize(newBasesizeBytes) |
| 237 | 237 |
c.Assert(err, check.IsNil, check.Commentf("Error in converting base device size: %v", err))
|
| 238 | 238 |
c.Assert(newBasesize, check.Equals, basesizeAfterRestart, check.Commentf("Basesize passed is not equal to Basesize set"))
|
| 239 |
- c.Assert(s.d.Stop(), check.IsNil) |
|
| 239 |
+ s.d.Stop(c) |
|
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 | 242 |
// Issue #8444: If docker0 bridge is modified (intentionally or unintentionally) and |
| ... | ... |
@@ -246,12 +231,8 @@ func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *check.C |
| 246 | 246 |
// rather than depending on brctl commands to verify docker0 is created and up |
| 247 | 247 |
// let's start the daemon and stop it, and then make a modification to run the |
| 248 | 248 |
// actual test |
| 249 |
- if err := s.d.Start(); err != nil {
|
|
| 250 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 251 |
- } |
|
| 252 |
- if err := s.d.Stop(); err != nil {
|
|
| 253 |
- c.Fatalf("Could not stop daemon: %v", err)
|
|
| 254 |
- } |
|
| 249 |
+ s.d.Start(c) |
|
| 250 |
+ s.d.Stop(c) |
|
| 255 | 251 |
|
| 256 | 252 |
// now we will remove the ip from docker0 and then try starting the daemon |
| 257 | 253 |
ipCmd := exec.Command("ip", "addr", "flush", "dev", "docker0")
|
| ... | ... |
@@ -260,16 +241,14 @@ func (s *DockerDaemonSuite) TestDaemonStartBridgeWithoutIPAssociation(c *check.C |
| 260 | 260 |
c.Fatalf("failed to remove docker0 IP association: %v, stdout: %q, stderr: %q", err, stdout, stderr)
|
| 261 | 261 |
} |
| 262 | 262 |
|
| 263 |
- if err := s.d.Start(); err != nil {
|
|
| 263 |
+ if err := s.d.StartWithError(); err != nil {
|
|
| 264 | 264 |
warning := "**WARNING: Docker bridge network in bad state--delete docker0 bridge interface to fix" |
| 265 | 265 |
c.Fatalf("Could not start daemon when docker0 has no IP address: %v\n%s", err, warning)
|
| 266 | 266 |
} |
| 267 | 267 |
} |
| 268 | 268 |
|
| 269 | 269 |
func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) {
|
| 270 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 271 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 272 |
- } |
|
| 270 |
+ s.d.StartWithBusybox(c) |
|
| 273 | 271 |
|
| 274 | 272 |
if out, err := s.d.Cmd("run", "-d", "--name", "top", "-p", "80", "busybox:latest", "top"); err != nil {
|
| 275 | 273 |
c.Fatalf("Could not run top: %s, %v", out, err)
|
| ... | ... |
@@ -287,9 +266,7 @@ func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) {
|
| 287 | 287 |
c.Fatalf("iptables output should have contained %q, but was %q", ipTablesSearchString, out)
|
| 288 | 288 |
} |
| 289 | 289 |
|
| 290 |
- if err := s.d.Stop(); err != nil {
|
|
| 291 |
- c.Fatalf("Could not stop daemon: %v", err)
|
|
| 292 |
- } |
|
| 290 |
+ s.d.Stop(c) |
|
| 293 | 291 |
|
| 294 | 292 |
// get output from iptables after restart |
| 295 | 293 |
ipTablesCmd = exec.Command("iptables", "-nvL")
|
| ... | ... |
@@ -304,9 +281,7 @@ func (s *DockerDaemonSuite) TestDaemonIptablesClean(c *check.C) {
|
| 304 | 304 |
} |
| 305 | 305 |
|
| 306 | 306 |
func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *check.C) {
|
| 307 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 308 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 309 |
- } |
|
| 307 |
+ s.d.StartWithBusybox(c) |
|
| 310 | 308 |
|
| 311 | 309 |
if out, err := s.d.Cmd("run", "-d", "--name", "top", "--restart=always", "-p", "80", "busybox:latest", "top"); err != nil {
|
| 312 | 310 |
c.Fatalf("Could not run top: %s, %v", out, err)
|
| ... | ... |
@@ -324,9 +299,7 @@ func (s *DockerDaemonSuite) TestDaemonIptablesCreate(c *check.C) {
|
| 324 | 324 |
c.Fatalf("iptables output should have contained %q, but was %q", ipTablesSearchString, out)
|
| 325 | 325 |
} |
| 326 | 326 |
|
| 327 |
- if err := s.d.Restart(); err != nil {
|
|
| 328 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 329 |
- } |
|
| 327 |
+ s.d.Restart(c) |
|
| 330 | 328 |
|
| 331 | 329 |
// make sure the container is not running |
| 332 | 330 |
runningOut, err := s.d.Cmd("inspect", "--format={{.State.Running}}", "top")
|
| ... | ... |
@@ -357,9 +330,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6Enabled(c *check.C) {
|
| 357 | 357 |
setupV6(c) |
| 358 | 358 |
defer teardownV6(c) |
| 359 | 359 |
|
| 360 |
- if err := s.d.StartWithBusybox("--ipv6"); err != nil {
|
|
| 361 |
- c.Fatal(err) |
|
| 362 |
- } |
|
| 360 |
+ s.d.StartWithBusybox(c, "--ipv6") |
|
| 363 | 361 |
|
| 364 | 362 |
iface, err := net.InterfaceByName("docker0")
|
| 365 | 363 |
if err != nil {
|
| ... | ... |
@@ -420,8 +391,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDR(c *check.C) {
|
| 420 | 420 |
setupV6(c) |
| 421 | 421 |
defer teardownV6(c) |
| 422 | 422 |
|
| 423 |
- err := s.d.StartWithBusybox("--ipv6", "--fixed-cidr-v6=2001:db8:2::/64", "--default-gateway-v6=2001:db8:2::100")
|
|
| 424 |
- c.Assert(err, checker.IsNil, check.Commentf("Could not start daemon with busybox: %v", err))
|
|
| 423 |
+ s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:2::/64", "--default-gateway-v6=2001:db8:2::100") |
|
| 425 | 424 |
|
| 426 | 425 |
out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "busybox:latest")
|
| 427 | 426 |
c.Assert(err, checker.IsNil, check.Commentf("Could not run container: %s, %v", out, err))
|
| ... | ... |
@@ -448,8 +418,7 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
|
| 448 | 448 |
setupV6(c) |
| 449 | 449 |
defer teardownV6(c) |
| 450 | 450 |
|
| 451 |
- err := s.d.StartWithBusybox("--ipv6", "--fixed-cidr-v6=2001:db8:1::/64")
|
|
| 452 |
- c.Assert(err, checker.IsNil) |
|
| 451 |
+ s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:1::/64") |
|
| 453 | 452 |
|
| 454 | 453 |
out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox")
|
| 455 | 454 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -460,13 +429,11 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
|
| 460 | 460 |
} |
| 461 | 461 |
|
| 462 | 462 |
func (s *DockerDaemonSuite) TestDaemonLogLevelWrong(c *check.C) {
|
| 463 |
- c.Assert(s.d.Start("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level"))
|
|
| 463 |
+ c.Assert(s.d.StartWithError("--log-level=bogus"), check.NotNil, check.Commentf("Daemon shouldn't start with wrong log level"))
|
|
| 464 | 464 |
} |
| 465 | 465 |
|
| 466 | 466 |
func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *check.C) {
|
| 467 |
- if err := s.d.Start("--log-level=debug"); err != nil {
|
|
| 468 |
- c.Fatal(err) |
|
| 469 |
- } |
|
| 467 |
+ s.d.Start(c, "--log-level=debug") |
|
| 470 | 468 |
content, err := s.d.ReadLogFile() |
| 471 | 469 |
c.Assert(err, checker.IsNil) |
| 472 | 470 |
if !strings.Contains(string(content), `level=debug`) {
|
| ... | ... |
@@ -476,9 +443,7 @@ func (s *DockerDaemonSuite) TestDaemonLogLevelDebug(c *check.C) {
|
| 476 | 476 |
|
| 477 | 477 |
func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *check.C) {
|
| 478 | 478 |
// we creating new daemons to create new logFile |
| 479 |
- if err := s.d.Start("--log-level=fatal"); err != nil {
|
|
| 480 |
- c.Fatal(err) |
|
| 481 |
- } |
|
| 479 |
+ s.d.Start(c, "--log-level=fatal") |
|
| 482 | 480 |
content, err := s.d.ReadLogFile() |
| 483 | 481 |
c.Assert(err, checker.IsNil) |
| 484 | 482 |
if strings.Contains(string(content), `level=debug`) {
|
| ... | ... |
@@ -487,9 +452,7 @@ func (s *DockerDaemonSuite) TestDaemonLogLevelFatal(c *check.C) {
|
| 487 | 487 |
} |
| 488 | 488 |
|
| 489 | 489 |
func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) {
|
| 490 |
- if err := s.d.Start("-D"); err != nil {
|
|
| 491 |
- c.Fatal(err) |
|
| 492 |
- } |
|
| 490 |
+ s.d.Start(c, "-D") |
|
| 493 | 491 |
content, err := s.d.ReadLogFile() |
| 494 | 492 |
c.Assert(err, checker.IsNil) |
| 495 | 493 |
if !strings.Contains(string(content), `level=debug`) {
|
| ... | ... |
@@ -498,9 +461,7 @@ func (s *DockerDaemonSuite) TestDaemonFlagD(c *check.C) {
|
| 498 | 498 |
} |
| 499 | 499 |
|
| 500 | 500 |
func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) {
|
| 501 |
- if err := s.d.Start("--debug"); err != nil {
|
|
| 502 |
- c.Fatal(err) |
|
| 503 |
- } |
|
| 501 |
+ s.d.Start(c, "--debug") |
|
| 504 | 502 |
content, err := s.d.ReadLogFile() |
| 505 | 503 |
c.Assert(err, checker.IsNil) |
| 506 | 504 |
if !strings.Contains(string(content), `level=debug`) {
|
| ... | ... |
@@ -509,9 +470,7 @@ func (s *DockerDaemonSuite) TestDaemonFlagDebug(c *check.C) {
|
| 509 | 509 |
} |
| 510 | 510 |
|
| 511 | 511 |
func (s *DockerDaemonSuite) TestDaemonFlagDebugLogLevelFatal(c *check.C) {
|
| 512 |
- if err := s.d.Start("--debug", "--log-level=fatal"); err != nil {
|
|
| 513 |
- c.Fatal(err) |
|
| 514 |
- } |
|
| 512 |
+ s.d.Start(c, "--debug", "--log-level=fatal") |
|
| 515 | 513 |
content, err := s.d.ReadLogFile() |
| 516 | 514 |
c.Assert(err, checker.IsNil) |
| 517 | 515 |
if !strings.Contains(string(content), `level=debug`) {
|
| ... | ... |
@@ -531,9 +490,7 @@ func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *check.C) {
|
| 531 | 531 |
cmdArgs = append(cmdArgs, "--host", fmt.Sprintf("tcp://%s:%s", hostDirective[0], hostDirective[2]))
|
| 532 | 532 |
} |
| 533 | 533 |
|
| 534 |
- if err := s.d.StartWithBusybox(cmdArgs...); err != nil {
|
|
| 535 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 536 |
- } |
|
| 534 |
+ s.d.StartWithBusybox(c, cmdArgs...) |
|
| 537 | 535 |
|
| 538 | 536 |
for _, hostDirective := range listeningPorts {
|
| 539 | 537 |
output, err := s.d.Cmd("run", "-p", fmt.Sprintf("%s:%s:80", hostDirective[1], hostDirective[2]), "busybox", "true")
|
| ... | ... |
@@ -548,10 +505,8 @@ func (s *DockerDaemonSuite) TestDaemonAllocatesListeningPort(c *check.C) {
|
| 548 | 548 |
func (s *DockerDaemonSuite) TestDaemonKeyGeneration(c *check.C) {
|
| 549 | 549 |
// TODO: skip or update for Windows daemon |
| 550 | 550 |
os.Remove("/etc/docker/key.json")
|
| 551 |
- if err := s.d.Start(); err != nil {
|
|
| 552 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 553 |
- } |
|
| 554 |
- s.d.Stop() |
|
| 551 |
+ s.d.Start(c) |
|
| 552 |
+ s.d.Stop(c) |
|
| 555 | 553 |
|
| 556 | 554 |
k, err := libtrust.LoadKeyFile("/etc/docker/key.json")
|
| 557 | 555 |
if err != nil {
|
| ... | ... |
@@ -578,10 +533,8 @@ func (s *DockerDaemonSuite) TestDaemonKeyMigration(c *check.C) {
|
| 578 | 578 |
c.Fatalf("Error saving private key: %s", err)
|
| 579 | 579 |
} |
| 580 | 580 |
|
| 581 |
- if err := s.d.Start(); err != nil {
|
|
| 582 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 583 |
- } |
|
| 584 |
- s.d.Stop() |
|
| 581 |
+ s.d.Start(c) |
|
| 582 |
+ s.d.Stop(c) |
|
| 585 | 583 |
|
| 586 | 584 |
k2, err := libtrust.LoadKeyFile("/etc/docker/key.json")
|
| 587 | 585 |
if err != nil {
|
| ... | ... |
@@ -597,7 +550,7 @@ func (s *DockerDaemonSuite) TestDaemonKeyMigration(c *check.C) {
|
| 597 | 597 |
// to get a daemon init failure; no other tests for -b/--bip conflict are therefore required |
| 598 | 598 |
func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *check.C) {
|
| 599 | 599 |
//attempt to start daemon with incorrect flags (we know -b and --bip conflict) |
| 600 |
- if err := s.d.Start("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil {
|
|
| 600 |
+ if err := s.d.StartWithError("--bridge", "nosuchbridge", "--bip", "1.1.1.1"); err != nil {
|
|
| 601 | 601 |
//verify we got the right error |
| 602 | 602 |
if !strings.Contains(err.Error(), "Daemon exited") {
|
| 603 | 603 |
c.Fatalf("Expected daemon not to start, got %v", err)
|
| ... | ... |
@@ -615,9 +568,9 @@ func (s *DockerDaemonSuite) TestDaemonExitOnFailure(c *check.C) {
|
| 615 | 615 |
|
| 616 | 616 |
func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) {
|
| 617 | 617 |
d := s.d |
| 618 |
- err := d.Start("--bridge", "nosuchbridge")
|
|
| 618 |
+ err := d.StartWithError("--bridge", "nosuchbridge")
|
|
| 619 | 619 |
c.Assert(err, check.NotNil, check.Commentf("--bridge option with an invalid bridge should cause the daemon to fail"))
|
| 620 |
- defer d.Restart() |
|
| 620 |
+ defer d.Restart(c) |
|
| 621 | 621 |
|
| 622 | 622 |
bridgeName := "external-bridge" |
| 623 | 623 |
bridgeIP := "192.169.1.1/24" |
| ... | ... |
@@ -627,8 +580,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) {
|
| 627 | 627 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 628 | 628 |
defer deleteInterface(c, bridgeName) |
| 629 | 629 |
|
| 630 |
- err = d.StartWithBusybox("--bridge", bridgeName)
|
|
| 631 |
- c.Assert(err, check.IsNil) |
|
| 630 |
+ d.StartWithBusybox(c, "--bridge", bridgeName) |
|
| 632 | 631 |
|
| 633 | 632 |
ipTablesSearchString := bridgeIPNet.String() |
| 634 | 633 |
ipTablesCmd := exec.Command("iptables", "-t", "nat", "-nvL")
|
| ... | ... |
@@ -653,9 +605,8 @@ func (s *DockerDaemonSuite) TestDaemonBridgeExternal(c *check.C) {
|
| 653 | 653 |
func (s *DockerDaemonSuite) TestDaemonBridgeNone(c *check.C) {
|
| 654 | 654 |
// start with bridge none |
| 655 | 655 |
d := s.d |
| 656 |
- err := d.StartWithBusybox("--bridge", "none")
|
|
| 657 |
- c.Assert(err, check.IsNil) |
|
| 658 |
- defer d.Restart() |
|
| 656 |
+ d.StartWithBusybox(c, "--bridge", "none") |
|
| 657 |
+ defer d.Restart(c) |
|
| 659 | 658 |
|
| 660 | 659 |
// verify docker0 iface is not there |
| 661 | 660 |
out, _, err := runCommandWithOutput(exec.Command("ifconfig", "docker0"))
|
| ... | ... |
@@ -713,9 +664,8 @@ func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *check.C) {
|
| 713 | 713 |
bridgeIP := "192.169.1.1/24" |
| 714 | 714 |
ip, bridgeIPNet, _ := net.ParseCIDR(bridgeIP) |
| 715 | 715 |
|
| 716 |
- err := d.StartWithBusybox("--bip", bridgeIP)
|
|
| 717 |
- c.Assert(err, check.IsNil) |
|
| 718 |
- defer d.Restart() |
|
| 716 |
+ d.StartWithBusybox(c, "--bip", bridgeIP) |
|
| 717 |
+ defer d.Restart(c) |
|
| 719 | 718 |
|
| 720 | 719 |
ifconfigSearchString := ip.String() |
| 721 | 720 |
ifconfigCmd := exec.Command("ifconfig", defaultNetworkBridge)
|
| ... | ... |
@@ -748,13 +698,9 @@ func (s *DockerDaemonSuite) TestDaemonBridgeIP(c *check.C) {
|
| 748 | 748 |
} |
| 749 | 749 |
|
| 750 | 750 |
func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) {
|
| 751 |
- if err := s.d.Start(); err != nil {
|
|
| 752 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 753 |
- } |
|
| 754 |
- defer s.d.Restart() |
|
| 755 |
- if err := s.d.Stop(); err != nil {
|
|
| 756 |
- c.Fatalf("Could not stop daemon: %v", err)
|
|
| 757 |
- } |
|
| 751 |
+ s.d.Start(c) |
|
| 752 |
+ defer s.d.Restart(c) |
|
| 753 |
+ s.d.Stop(c) |
|
| 758 | 754 |
|
| 759 | 755 |
// now we will change the docker0's IP and then try starting the daemon |
| 760 | 756 |
bridgeIP := "192.169.100.1/24" |
| ... | ... |
@@ -766,9 +712,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithBridgeIPChange(c *check.C) {
|
| 766 | 766 |
c.Fatalf("failed to change docker0's IP association: %v, stdout: %q, stderr: %q", err, stdout, stderr)
|
| 767 | 767 |
} |
| 768 | 768 |
|
| 769 |
- if err := s.d.Start("--bip", bridgeIP); err != nil {
|
|
| 770 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 771 |
- } |
|
| 769 |
+ s.d.Start(c, "--bip", bridgeIP) |
|
| 772 | 770 |
|
| 773 | 771 |
//check if the iptables contains new bridgeIP MASQUERADE rule |
| 774 | 772 |
ipTablesSearchString := bridgeIPNet.String() |
| ... | ... |
@@ -793,9 +737,8 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr(c *check.C) {
|
| 793 | 793 |
defer deleteInterface(c, bridgeName) |
| 794 | 794 |
|
| 795 | 795 |
args := []string{"--bridge", bridgeName, "--fixed-cidr", "192.169.1.0/30"}
|
| 796 |
- err = d.StartWithBusybox(args...) |
|
| 797 |
- c.Assert(err, check.IsNil) |
|
| 798 |
- defer d.Restart() |
|
| 796 |
+ d.StartWithBusybox(c, args...) |
|
| 797 |
+ defer d.Restart(c) |
|
| 799 | 798 |
|
| 800 | 799 |
for i := 0; i < 4; i++ {
|
| 801 | 800 |
cName := "Container" + strconv.Itoa(i) |
| ... | ... |
@@ -817,9 +760,8 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *check.C) {
|
| 817 | 817 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 818 | 818 |
defer deleteInterface(c, bridgeName) |
| 819 | 819 |
|
| 820 |
- err = d.StartWithBusybox("--bip", bridgeIP, "--fixed-cidr", "10.2.2.0/24")
|
|
| 821 |
- c.Assert(err, check.IsNil) |
|
| 822 |
- defer s.d.Restart() |
|
| 820 |
+ d.StartWithBusybox(c, "--bip", bridgeIP, "--fixed-cidr", "10.2.2.0/24") |
|
| 821 |
+ defer s.d.Restart(c) |
|
| 823 | 822 |
|
| 824 | 823 |
out, err = d.Cmd("run", "-d", "--name", "bb", "busybox", "top")
|
| 825 | 824 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -843,9 +785,8 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCIDREqualBridgeNetwork(c *check |
| 843 | 843 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 844 | 844 |
defer deleteInterface(c, bridgeName) |
| 845 | 845 |
|
| 846 |
- err = d.StartWithBusybox("--bridge", bridgeName, "--fixed-cidr", bridgeIP)
|
|
| 847 |
- c.Assert(err, check.IsNil) |
|
| 848 |
- defer s.d.Restart() |
|
| 846 |
+ d.StartWithBusybox(c, "--bridge", bridgeName, "--fixed-cidr", bridgeIP) |
|
| 847 |
+ defer s.d.Restart(c) |
|
| 849 | 848 |
|
| 850 | 849 |
out, err = d.Cmd("run", "-d", "busybox", "top")
|
| 851 | 850 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -862,12 +803,12 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Implicit(c *check.C) {
|
| 862 | 862 |
bridgeIP := "192.169.1.1" |
| 863 | 863 |
bridgeIPNet := fmt.Sprintf("%s/24", bridgeIP)
|
| 864 | 864 |
|
| 865 |
- err := d.StartWithBusybox("--bip", bridgeIPNet)
|
|
| 866 |
- c.Assert(err, check.IsNil) |
|
| 867 |
- defer d.Restart() |
|
| 865 |
+ d.StartWithBusybox(c, "--bip", bridgeIPNet) |
|
| 866 |
+ defer d.Restart(c) |
|
| 868 | 867 |
|
| 869 | 868 |
expectedMessage := fmt.Sprintf("default via %s dev", bridgeIP)
|
| 870 | 869 |
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
|
| 870 |
+ c.Assert(err, checker.IsNil) |
|
| 871 | 871 |
c.Assert(strings.Contains(out, expectedMessage), check.Equals, true, |
| 872 | 872 |
check.Commentf("Implicit default gateway should be bridge IP %s, but default route was '%s'",
|
| 873 | 873 |
bridgeIP, strings.TrimSpace(out))) |
| ... | ... |
@@ -884,12 +825,12 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4Explicit(c *check.C) {
|
| 884 | 884 |
bridgeIPNet := fmt.Sprintf("%s/24", bridgeIP)
|
| 885 | 885 |
gatewayIP := "192.169.1.254" |
| 886 | 886 |
|
| 887 |
- err := d.StartWithBusybox("--bip", bridgeIPNet, "--default-gateway", gatewayIP)
|
|
| 888 |
- c.Assert(err, check.IsNil) |
|
| 889 |
- defer d.Restart() |
|
| 887 |
+ d.StartWithBusybox(c, "--bip", bridgeIPNet, "--default-gateway", gatewayIP) |
|
| 888 |
+ defer d.Restart(c) |
|
| 890 | 889 |
|
| 891 | 890 |
expectedMessage := fmt.Sprintf("default via %s dev", gatewayIP)
|
| 892 | 891 |
out, err := d.Cmd("run", "busybox", "ip", "-4", "route", "list", "0/0")
|
| 892 |
+ c.Assert(err, checker.IsNil) |
|
| 893 | 893 |
c.Assert(strings.Contains(out, expectedMessage), check.Equals, true, |
| 894 | 894 |
check.Commentf("Explicit default gateway should be %s, but default route was '%s'",
|
| 895 | 895 |
gatewayIP, strings.TrimSpace(out))) |
| ... | ... |
@@ -901,11 +842,10 @@ func (s *DockerDaemonSuite) TestDaemonDefaultGatewayIPv4ExplicitOutsideContainer |
| 901 | 901 |
deleteInterface(c, defaultNetworkBridge) |
| 902 | 902 |
|
| 903 | 903 |
// Program a custom default gateway outside of the container subnet, daemon should accept it and start |
| 904 |
- err := s.d.StartWithBusybox("--bip", "172.16.0.10/16", "--fixed-cidr", "172.16.1.0/24", "--default-gateway", "172.16.0.254")
|
|
| 905 |
- c.Assert(err, check.IsNil) |
|
| 904 |
+ s.d.StartWithBusybox(c, "--bip", "172.16.0.10/16", "--fixed-cidr", "172.16.1.0/24", "--default-gateway", "172.16.0.254") |
|
| 906 | 905 |
|
| 907 | 906 |
deleteInterface(c, defaultNetworkBridge) |
| 908 |
- s.d.Restart() |
|
| 907 |
+ s.d.Restart(c) |
|
| 909 | 908 |
} |
| 910 | 909 |
|
| 911 | 910 |
func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *check.C) {
|
| ... | ... |
@@ -916,15 +856,13 @@ func (s *DockerDaemonSuite) TestDaemonDefaultNetworkInvalidClusterConfig(c *chec |
| 916 | 916 |
deleteInterface(c, defaultNetworkBridge) |
| 917 | 917 |
|
| 918 | 918 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 919 |
- err := s.d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend))
|
|
| 920 |
- c.Assert(err, checker.IsNil) |
|
| 919 |
+ s.d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend))
|
|
| 921 | 920 |
|
| 922 | 921 |
// Start daemon with docker0 bridge |
| 923 | 922 |
result := icmd.RunCommand("ifconfig", defaultNetworkBridge)
|
| 924 | 923 |
c.Assert(result, icmd.Matches, icmd.Success) |
| 925 | 924 |
|
| 926 |
- err = s.d.Restart(fmt.Sprintf("--cluster-store=%s", discoveryBackend))
|
|
| 927 |
- c.Assert(err, checker.IsNil) |
|
| 925 |
+ s.d.Restart(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend))
|
|
| 928 | 926 |
} |
| 929 | 927 |
|
| 930 | 928 |
func (s *DockerDaemonSuite) TestDaemonIP(c *check.C) {
|
| ... | ... |
@@ -933,9 +871,8 @@ func (s *DockerDaemonSuite) TestDaemonIP(c *check.C) {
|
| 933 | 933 |
ipStr := "192.170.1.1/24" |
| 934 | 934 |
ip, _, _ := net.ParseCIDR(ipStr) |
| 935 | 935 |
args := []string{"--ip", ip.String()}
|
| 936 |
- err := d.StartWithBusybox(args...) |
|
| 937 |
- c.Assert(err, check.IsNil) |
|
| 938 |
- defer d.Restart() |
|
| 936 |
+ d.StartWithBusybox(c, args...) |
|
| 937 |
+ defer d.Restart(c) |
|
| 939 | 938 |
|
| 940 | 939 |
out, err := d.Cmd("run", "-d", "-p", "8000:8000", "busybox", "top")
|
| 941 | 940 |
c.Assert(err, check.NotNil, |
| ... | ... |
@@ -972,9 +909,8 @@ func (s *DockerDaemonSuite) TestDaemonICCPing(c *check.C) {
|
| 972 | 972 |
defer deleteInterface(c, bridgeName) |
| 973 | 973 |
|
| 974 | 974 |
args := []string{"--bridge", bridgeName, "--icc=false"}
|
| 975 |
- err = d.StartWithBusybox(args...) |
|
| 976 |
- c.Assert(err, check.IsNil) |
|
| 977 |
- defer d.Restart() |
|
| 975 |
+ d.StartWithBusybox(c, args...) |
|
| 976 |
+ defer d.Restart(c) |
|
| 978 | 977 |
|
| 979 | 978 |
ipTablesCmd := exec.Command("iptables", "-nvL", "FORWARD")
|
| 980 | 979 |
out, _, err = runCommandWithOutput(ipTablesCmd) |
| ... | ... |
@@ -1012,9 +948,8 @@ func (s *DockerDaemonSuite) TestDaemonICCLinkExpose(c *check.C) {
|
| 1012 | 1012 |
defer deleteInterface(c, bridgeName) |
| 1013 | 1013 |
|
| 1014 | 1014 |
args := []string{"--bridge", bridgeName, "--icc=false"}
|
| 1015 |
- err = d.StartWithBusybox(args...) |
|
| 1016 |
- c.Assert(err, check.IsNil) |
|
| 1017 |
- defer d.Restart() |
|
| 1015 |
+ d.StartWithBusybox(c, args...) |
|
| 1016 |
+ defer d.Restart(c) |
|
| 1018 | 1017 |
|
| 1019 | 1018 |
ipTablesCmd := exec.Command("iptables", "-nvL", "FORWARD")
|
| 1020 | 1019 |
out, _, err = runCommandWithOutput(ipTablesCmd) |
| ... | ... |
@@ -1040,9 +975,8 @@ func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *che |
| 1040 | 1040 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 1041 | 1041 |
defer deleteInterface(c, bridgeName) |
| 1042 | 1042 |
|
| 1043 |
- err = s.d.StartWithBusybox("--bridge", bridgeName, "--icc=false")
|
|
| 1044 |
- c.Assert(err, check.IsNil) |
|
| 1045 |
- defer s.d.Restart() |
|
| 1043 |
+ s.d.StartWithBusybox(c, "--bridge", bridgeName, "--icc=false") |
|
| 1044 |
+ defer s.d.Restart(c) |
|
| 1046 | 1045 |
|
| 1047 | 1046 |
_, err = s.d.Cmd("run", "-d", "--name", "child", "--publish", "8080:80", "busybox", "top")
|
| 1048 | 1047 |
c.Assert(err, check.IsNil) |
| ... | ... |
@@ -1072,9 +1006,7 @@ func (s *DockerDaemonSuite) TestDaemonLinksIpTablesRulesWhenLinkAndUnlink(c *che |
| 1072 | 1072 |
func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *check.C) {
|
| 1073 | 1073 |
testRequires(c, DaemonIsLinux) |
| 1074 | 1074 |
|
| 1075 |
- if err := s.d.StartWithBusybox("--default-ulimit", "nofile=42:42", "--default-ulimit", "nproc=1024:1024"); err != nil {
|
|
| 1076 |
- c.Fatal(err) |
|
| 1077 |
- } |
|
| 1075 |
+ s.d.StartWithBusybox(c, "--default-ulimit", "nofile=42:42", "--default-ulimit", "nproc=1024:1024") |
|
| 1078 | 1076 |
|
| 1079 | 1077 |
out, err := s.d.Cmd("run", "--ulimit", "nproc=2048", "--name=test", "busybox", "/bin/sh", "-c", "echo $(ulimit -n); echo $(ulimit -p)")
|
| 1080 | 1078 |
if err != nil {
|
| ... | ... |
@@ -1096,9 +1028,7 @@ func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *check.C) {
|
| 1096 | 1096 |
} |
| 1097 | 1097 |
|
| 1098 | 1098 |
// Now restart daemon with a new default |
| 1099 |
- if err := s.d.Restart("--default-ulimit", "nofile=43"); err != nil {
|
|
| 1100 |
- c.Fatal(err) |
|
| 1101 |
- } |
|
| 1099 |
+ s.d.Restart(c, "--default-ulimit", "nofile=43") |
|
| 1102 | 1100 |
|
| 1103 | 1101 |
out, err = s.d.Cmd("start", "-a", "test")
|
| 1104 | 1102 |
if err != nil {
|
| ... | ... |
@@ -1122,9 +1052,7 @@ func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *check.C) {
|
| 1122 | 1122 |
|
| 1123 | 1123 |
// #11315 |
| 1124 | 1124 |
func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) {
|
| 1125 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1126 |
- c.Fatal(err) |
|
| 1127 |
- } |
|
| 1125 |
+ s.d.StartWithBusybox(c) |
|
| 1128 | 1126 |
|
| 1129 | 1127 |
if out, err := s.d.Cmd("run", "--name=test", "busybox"); err != nil {
|
| 1130 | 1128 |
c.Fatal(err, out) |
| ... | ... |
@@ -1134,9 +1062,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) {
|
| 1134 | 1134 |
c.Fatal(err, out) |
| 1135 | 1135 |
} |
| 1136 | 1136 |
|
| 1137 |
- if err := s.d.Restart(); err != nil {
|
|
| 1138 |
- c.Fatal(err) |
|
| 1139 |
- } |
|
| 1137 |
+ s.d.Restart(c) |
|
| 1140 | 1138 |
|
| 1141 | 1139 |
if out, err := s.d.Cmd("start", "test2"); err != nil {
|
| 1142 | 1140 |
c.Fatal(err, out) |
| ... | ... |
@@ -1144,9 +1070,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRenameContainer(c *check.C) {
|
| 1144 | 1144 |
} |
| 1145 | 1145 |
|
| 1146 | 1146 |
func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *check.C) {
|
| 1147 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1148 |
- c.Fatal(err) |
|
| 1149 |
- } |
|
| 1147 |
+ s.d.StartWithBusybox(c) |
|
| 1150 | 1148 |
|
| 1151 | 1149 |
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
|
| 1152 | 1150 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -1184,9 +1108,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefault(c *check.C) {
|
| 1184 | 1184 |
} |
| 1185 | 1185 |
|
| 1186 | 1186 |
func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *check.C) {
|
| 1187 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1188 |
- c.Fatal(err) |
|
| 1189 |
- } |
|
| 1187 |
+ s.d.StartWithBusybox(c) |
|
| 1190 | 1188 |
|
| 1191 | 1189 |
out, err := s.d.Cmd("run", "--name=test", "--log-driver=none", "busybox", "echo", "testline")
|
| 1192 | 1190 |
if err != nil {
|
| ... | ... |
@@ -1203,9 +1125,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverDefaultOverride(c *check.C) {
|
| 1203 | 1203 |
} |
| 1204 | 1204 |
|
| 1205 | 1205 |
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *check.C) {
|
| 1206 |
- if err := s.d.StartWithBusybox("--log-driver=none"); err != nil {
|
|
| 1207 |
- c.Fatal(err) |
|
| 1208 |
- } |
|
| 1206 |
+ s.d.StartWithBusybox(c, "--log-driver=none") |
|
| 1209 | 1207 |
|
| 1210 | 1208 |
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
|
| 1211 | 1209 |
if err != nil {
|
| ... | ... |
@@ -1222,9 +1142,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNone(c *check.C) {
|
| 1222 | 1222 |
} |
| 1223 | 1223 |
|
| 1224 | 1224 |
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *check.C) {
|
| 1225 |
- if err := s.d.StartWithBusybox("--log-driver=none"); err != nil {
|
|
| 1226 |
- c.Fatal(err) |
|
| 1227 |
- } |
|
| 1225 |
+ s.d.StartWithBusybox(c, "--log-driver=none") |
|
| 1228 | 1226 |
|
| 1229 | 1227 |
out, err := s.d.Cmd("run", "--name=test", "--log-driver=json-file", "busybox", "echo", "testline")
|
| 1230 | 1228 |
if err != nil {
|
| ... | ... |
@@ -1264,7 +1182,7 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneOverride(c *check.C) {
|
| 1264 | 1264 |
} |
| 1265 | 1265 |
|
| 1266 | 1266 |
func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
|
| 1267 |
- c.Assert(s.d.StartWithBusybox("--log-driver=none"), checker.IsNil)
|
|
| 1267 |
+ s.d.StartWithBusybox(c, "--log-driver=none") |
|
| 1268 | 1268 |
|
| 1269 | 1269 |
out, err := s.d.Cmd("run", "--name=test", "busybox", "echo", "testline")
|
| 1270 | 1270 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -1283,17 +1201,13 @@ func (s *DockerDaemonSuite) TestDaemonUnixSockCleanedUp(c *check.C) {
|
| 1283 | 1283 |
defer os.RemoveAll(dir) |
| 1284 | 1284 |
|
| 1285 | 1285 |
sockPath := filepath.Join(dir, "docker.sock") |
| 1286 |
- if err := s.d.Start("--host", "unix://"+sockPath); err != nil {
|
|
| 1287 |
- c.Fatal(err) |
|
| 1288 |
- } |
|
| 1286 |
+ s.d.Start(c, "--host", "unix://"+sockPath) |
|
| 1289 | 1287 |
|
| 1290 | 1288 |
if _, err := os.Stat(sockPath); err != nil {
|
| 1291 | 1289 |
c.Fatal("socket does not exist")
|
| 1292 | 1290 |
} |
| 1293 | 1291 |
|
| 1294 |
- if err := s.d.Stop(); err != nil {
|
|
| 1295 |
- c.Fatal(err) |
|
| 1296 |
- } |
|
| 1292 |
+ s.d.Stop(c) |
|
| 1297 | 1293 |
|
| 1298 | 1294 |
if _, err := os.Stat(sockPath); err == nil || !os.IsNotExist(err) {
|
| 1299 | 1295 |
c.Fatal("unix socket is not cleaned up")
|
| ... | ... |
@@ -1311,13 +1225,8 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) {
|
| 1311 | 1311 |
} |
| 1312 | 1312 |
|
| 1313 | 1313 |
os.Remove("/etc/docker/key.json")
|
| 1314 |
- if err := s.d.Start(); err != nil {
|
|
| 1315 |
- c.Fatalf("Failed to start daemon: %v", err)
|
|
| 1316 |
- } |
|
| 1317 |
- |
|
| 1318 |
- if err := s.d.Stop(); err != nil {
|
|
| 1319 |
- c.Fatalf("Could not stop daemon: %v", err)
|
|
| 1320 |
- } |
|
| 1314 |
+ s.d.Start(c) |
|
| 1315 |
+ s.d.Stop(c) |
|
| 1321 | 1316 |
|
| 1322 | 1317 |
config := &Config{}
|
| 1323 | 1318 |
bytes, err := ioutil.ReadFile("/etc/docker/key.json")
|
| ... | ... |
@@ -1346,7 +1255,7 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) {
|
| 1346 | 1346 |
|
| 1347 | 1347 |
defer os.Remove("/etc/docker/key.json")
|
| 1348 | 1348 |
|
| 1349 |
- if err := s.d.Start(); err == nil {
|
|
| 1349 |
+ if err := s.d.StartWithError(); err == nil {
|
|
| 1350 | 1350 |
c.Fatalf("It should not be successful to start daemon with wrong key: %v", err)
|
| 1351 | 1351 |
} |
| 1352 | 1352 |
|
| ... | ... |
@@ -1359,9 +1268,7 @@ func (s *DockerDaemonSuite) TestDaemonWithWrongkey(c *check.C) {
|
| 1359 | 1359 |
} |
| 1360 | 1360 |
|
| 1361 | 1361 |
func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *check.C) {
|
| 1362 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1363 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 1364 |
- } |
|
| 1362 |
+ s.d.StartWithBusybox(c) |
|
| 1365 | 1363 |
|
| 1366 | 1364 |
out, err := s.d.Cmd("run", "-id", "busybox", "/bin/cat")
|
| 1367 | 1365 |
if err != nil {
|
| ... | ... |
@@ -1373,9 +1280,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartKillWait(c *check.C) {
|
| 1373 | 1373 |
c.Fatalf("Could not kill %s: err=%v\n%s", containerID, err, out)
|
| 1374 | 1374 |
} |
| 1375 | 1375 |
|
| 1376 |
- if err := s.d.Restart(); err != nil {
|
|
| 1377 |
- c.Fatalf("Could not restart daemon: %v", err)
|
|
| 1378 |
- } |
|
| 1376 |
+ s.d.Restart(c) |
|
| 1379 | 1377 |
|
| 1380 | 1378 |
errchan := make(chan error) |
| 1381 | 1379 |
go func() {
|
| ... | ... |
@@ -1401,14 +1306,17 @@ func (s *DockerDaemonSuite) TestHTTPSInfo(c *check.C) {
|
| 1401 | 1401 |
testDaemonHTTPSAddr = "tcp://localhost:4271" |
| 1402 | 1402 |
) |
| 1403 | 1403 |
|
| 1404 |
- if err := s.d.Start("--tlsverify", "--tlscacert", "fixtures/https/ca.pem", "--tlscert", "fixtures/https/server-cert.pem",
|
|
| 1405 |
- "--tlskey", "fixtures/https/server-key.pem", "-H", testDaemonHTTPSAddr); err != nil {
|
|
| 1406 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 1407 |
- } |
|
| 1404 |
+ s.d.Start(c, |
|
| 1405 |
+ "--tlsverify", |
|
| 1406 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1407 |
+ "--tlscert", "fixtures/https/server-cert.pem", |
|
| 1408 |
+ "--tlskey", "fixtures/https/server-key.pem", |
|
| 1409 |
+ "-H", testDaemonHTTPSAddr) |
|
| 1408 | 1410 |
|
| 1409 | 1411 |
args := []string{
|
| 1410 | 1412 |
"--host", testDaemonHTTPSAddr, |
| 1411 |
- "--tlsverify", "--tlscacert", "fixtures/https/ca.pem", |
|
| 1413 |
+ "--tlsverify", |
|
| 1414 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1412 | 1415 |
"--tlscert", "fixtures/https/client-cert.pem", |
| 1413 | 1416 |
"--tlskey", "fixtures/https/client-key.pem", |
| 1414 | 1417 |
"info", |
| ... | ... |
@@ -1426,10 +1334,8 @@ func (s *DockerDaemonSuite) TestHTTPSRun(c *check.C) {
|
| 1426 | 1426 |
testDaemonHTTPSAddr = "tcp://localhost:4271" |
| 1427 | 1427 |
) |
| 1428 | 1428 |
|
| 1429 |
- if err := s.d.StartWithBusybox("--tlsverify", "--tlscacert", "fixtures/https/ca.pem", "--tlscert", "fixtures/https/server-cert.pem",
|
|
| 1430 |
- "--tlskey", "fixtures/https/server-key.pem", "-H", testDaemonHTTPSAddr); err != nil {
|
|
| 1431 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 1432 |
- } |
|
| 1429 |
+ s.d.StartWithBusybox(c, "--tlsverify", "--tlscacert", "fixtures/https/ca.pem", "--tlscert", "fixtures/https/server-cert.pem", |
|
| 1430 |
+ "--tlskey", "fixtures/https/server-key.pem", "-H", testDaemonHTTPSAddr) |
|
| 1433 | 1431 |
|
| 1434 | 1432 |
args := []string{
|
| 1435 | 1433 |
"--host", testDaemonHTTPSAddr, |
| ... | ... |
@@ -1464,14 +1370,17 @@ func (s *DockerDaemonSuite) TestHTTPSInfoRogueCert(c *check.C) {
|
| 1464 | 1464 |
testDaemonHTTPSAddr = "tcp://localhost:4271" |
| 1465 | 1465 |
) |
| 1466 | 1466 |
|
| 1467 |
- if err := s.d.Start("--tlsverify", "--tlscacert", "fixtures/https/ca.pem", "--tlscert", "fixtures/https/server-cert.pem",
|
|
| 1468 |
- "--tlskey", "fixtures/https/server-key.pem", "-H", testDaemonHTTPSAddr); err != nil {
|
|
| 1469 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 1470 |
- } |
|
| 1467 |
+ s.d.Start(c, |
|
| 1468 |
+ "--tlsverify", |
|
| 1469 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1470 |
+ "--tlscert", "fixtures/https/server-cert.pem", |
|
| 1471 |
+ "--tlskey", "fixtures/https/server-key.pem", |
|
| 1472 |
+ "-H", testDaemonHTTPSAddr) |
|
| 1471 | 1473 |
|
| 1472 | 1474 |
args := []string{
|
| 1473 | 1475 |
"--host", testDaemonHTTPSAddr, |
| 1474 |
- "--tlsverify", "--tlscacert", "fixtures/https/ca.pem", |
|
| 1476 |
+ "--tlsverify", |
|
| 1477 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1475 | 1478 |
"--tlscert", "fixtures/https/client-rogue-cert.pem", |
| 1476 | 1479 |
"--tlskey", "fixtures/https/client-rogue-key.pem", |
| 1477 | 1480 |
"info", |
| ... | ... |
@@ -1489,14 +1398,17 @@ func (s *DockerDaemonSuite) TestHTTPSInfoRogueServerCert(c *check.C) {
|
| 1489 | 1489 |
errCaUnknown = "x509: certificate signed by unknown authority" |
| 1490 | 1490 |
testDaemonRogueHTTPSAddr = "tcp://localhost:4272" |
| 1491 | 1491 |
) |
| 1492 |
- if err := s.d.Start("--tlsverify", "--tlscacert", "fixtures/https/ca.pem", "--tlscert", "fixtures/https/server-rogue-cert.pem",
|
|
| 1493 |
- "--tlskey", "fixtures/https/server-rogue-key.pem", "-H", testDaemonRogueHTTPSAddr); err != nil {
|
|
| 1494 |
- c.Fatalf("Could not start daemon with busybox: %v", err)
|
|
| 1495 |
- } |
|
| 1492 |
+ s.d.Start(c, |
|
| 1493 |
+ "--tlsverify", |
|
| 1494 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1495 |
+ "--tlscert", "fixtures/https/server-rogue-cert.pem", |
|
| 1496 |
+ "--tlskey", "fixtures/https/server-rogue-key.pem", |
|
| 1497 |
+ "-H", testDaemonRogueHTTPSAddr) |
|
| 1496 | 1498 |
|
| 1497 | 1499 |
args := []string{
|
| 1498 | 1500 |
"--host", testDaemonRogueHTTPSAddr, |
| 1499 |
- "--tlsverify", "--tlscacert", "fixtures/https/ca.pem", |
|
| 1501 |
+ "--tlsverify", |
|
| 1502 |
+ "--tlscacert", "fixtures/https/ca.pem", |
|
| 1500 | 1503 |
"--tlscert", "fixtures/https/client-rogue-cert.pem", |
| 1501 | 1504 |
"--tlskey", "fixtures/https/client-rogue-key.pem", |
| 1502 | 1505 |
"info", |
| ... | ... |
@@ -1532,29 +1444,32 @@ func pingContainers(c *check.C, d *daemon.Daemon, expectFailure bool) {
|
| 1532 | 1532 |
} |
| 1533 | 1533 |
|
| 1534 | 1534 |
func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
|
| 1535 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1535 |
+ s.d.StartWithBusybox(c) |
|
| 1536 | 1536 |
|
| 1537 | 1537 |
socket := filepath.Join(s.d.Folder, "docker.sock") |
| 1538 | 1538 |
|
| 1539 | 1539 |
out, err := s.d.Cmd("run", "--restart=always", "-v", socket+":/sock", "busybox")
|
| 1540 | 1540 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| 1541 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 1541 |
+ s.d.Restart(c) |
|
| 1542 | 1542 |
} |
| 1543 | 1543 |
|
| 1544 | 1544 |
// os.Kill should kill daemon ungracefully, leaving behind container mounts. |
| 1545 | 1545 |
// A subsequent daemon restart shoud clean up said mounts. |
| 1546 | 1546 |
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *check.C) {
|
| 1547 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1547 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1548 |
+ Experimental: experimentalDaemon, |
|
| 1549 |
+ }) |
|
| 1550 |
+ d.StartWithBusybox(c) |
|
| 1548 | 1551 |
|
| 1549 |
- out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
|
| 1552 |
+ out, err := d.Cmd("run", "-d", "busybox", "top")
|
|
| 1550 | 1553 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| 1551 | 1554 |
id := strings.TrimSpace(out) |
| 1552 |
- c.Assert(s.d.Signal(os.Kill), check.IsNil) |
|
| 1555 |
+ c.Assert(d.Signal(os.Kill), check.IsNil) |
|
| 1553 | 1556 |
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
| 1554 | 1557 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
| 1555 | 1558 |
|
| 1556 | 1559 |
// container mounts should exist even after daemon has crashed. |
| 1557 |
- comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
| 1560 |
+ comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
| 1558 | 1561 |
c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) |
| 1559 | 1562 |
|
| 1560 | 1563 |
// kill the container |
| ... | ... |
@@ -1564,40 +1479,43 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec |
| 1564 | 1564 |
} |
| 1565 | 1565 |
|
| 1566 | 1566 |
// restart daemon. |
| 1567 |
- if err := s.d.Restart(); err != nil {
|
|
| 1568 |
- c.Fatal(err) |
|
| 1569 |
- } |
|
| 1567 |
+ d.Restart(c) |
|
| 1570 | 1568 |
|
| 1571 | 1569 |
// Now, container mounts should be gone. |
| 1572 | 1570 |
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
| 1573 | 1571 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
| 1574 |
- comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
| 1572 |
+ comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
| 1575 | 1573 |
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) |
| 1574 |
+ |
|
| 1575 |
+ d.Stop(c) |
|
| 1576 | 1576 |
} |
| 1577 | 1577 |
|
| 1578 | 1578 |
// os.Interrupt should perform a graceful daemon shutdown and hence cleanup mounts. |
| 1579 | 1579 |
func (s *DockerDaemonSuite) TestCleanupMountsAfterGracefulShutdown(c *check.C) {
|
| 1580 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1580 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1581 |
+ Experimental: experimentalDaemon, |
|
| 1582 |
+ }) |
|
| 1583 |
+ d.StartWithBusybox(c) |
|
| 1581 | 1584 |
|
| 1582 |
- out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
|
| 1585 |
+ out, err := d.Cmd("run", "-d", "busybox", "top")
|
|
| 1583 | 1586 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| 1584 | 1587 |
id := strings.TrimSpace(out) |
| 1585 | 1588 |
|
| 1586 | 1589 |
// Send SIGINT and daemon should clean up |
| 1587 |
- c.Assert(s.d.Signal(os.Interrupt), check.IsNil) |
|
| 1590 |
+ c.Assert(d.Signal(os.Interrupt), check.IsNil) |
|
| 1588 | 1591 |
// Wait for the daemon to stop. |
| 1589 |
- c.Assert(<-s.d.Wait, checker.IsNil) |
|
| 1592 |
+ c.Assert(<-d.Wait, checker.IsNil) |
|
| 1590 | 1593 |
|
| 1591 | 1594 |
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
| 1592 | 1595 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
| 1593 | 1596 |
|
| 1594 |
- comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
| 1597 |
+ comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
| 1595 | 1598 |
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment) |
| 1596 | 1599 |
} |
| 1597 | 1600 |
|
| 1598 | 1601 |
func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
|
| 1599 | 1602 |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
| 1600 |
- c.Assert(s.d.StartWithBusybox("-b", "none"), check.IsNil)
|
|
| 1603 |
+ s.d.StartWithBusybox(c, "-b", "none") |
|
| 1601 | 1604 |
|
| 1602 | 1605 |
out, err := s.d.Cmd("run", "--rm", "busybox", "ip", "l")
|
| 1603 | 1606 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| ... | ... |
@@ -1624,16 +1542,12 @@ func (s *DockerDaemonSuite) TestRunContainerWithBridgeNone(c *check.C) {
|
| 1624 | 1624 |
} |
| 1625 | 1625 |
|
| 1626 | 1626 |
func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
|
| 1627 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1628 |
- t.Fatal(err) |
|
| 1629 |
- } |
|
| 1627 |
+ s.d.StartWithBusybox(t) |
|
| 1630 | 1628 |
if out, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top"); err != nil {
|
| 1631 | 1629 |
t.Fatal(out, err) |
| 1632 | 1630 |
} |
| 1633 | 1631 |
|
| 1634 |
- if err := s.d.Restart(); err != nil {
|
|
| 1635 |
- t.Fatal(err) |
|
| 1636 |
- } |
|
| 1632 |
+ s.d.Restart(t) |
|
| 1637 | 1633 |
// Container 'test' should be removed without error |
| 1638 | 1634 |
if out, err := s.d.Cmd("rm", "test"); err != nil {
|
| 1639 | 1635 |
t.Fatal(out, err) |
| ... | ... |
@@ -1641,9 +1555,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerRunning(t *check.C) {
|
| 1641 | 1641 |
} |
| 1642 | 1642 |
|
| 1643 | 1643 |
func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) {
|
| 1644 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1645 |
- c.Fatal(err) |
|
| 1646 |
- } |
|
| 1644 |
+ s.d.StartWithBusybox(c) |
|
| 1647 | 1645 |
out, err := s.d.Cmd("run", "--name", "netns", "-d", "busybox", "top")
|
| 1648 | 1646 |
if err != nil {
|
| 1649 | 1647 |
c.Fatal(out, err) |
| ... | ... |
@@ -1671,9 +1583,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) {
|
| 1671 | 1671 |
c.Fatal(out, err) |
| 1672 | 1672 |
} |
| 1673 | 1673 |
|
| 1674 |
- if err := s.d.Restart(); err != nil {
|
|
| 1675 |
- c.Fatal(err) |
|
| 1676 |
- } |
|
| 1674 |
+ s.d.Restart(c) |
|
| 1677 | 1675 |
|
| 1678 | 1676 |
// Test again and see now the netns file does not exist |
| 1679 | 1677 |
out, _, err = runCommandWithOutput(exec.Command("stat", "-c", "%n", fileName))
|
| ... | ... |
@@ -1684,7 +1594,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartCleanupNetns(c *check.C) {
|
| 1684 | 1684 |
// tests regression detailed in #13964 where DOCKER_TLS_VERIFY env is ignored |
| 1685 | 1685 |
func (s *DockerDaemonSuite) TestDaemonTLSVerifyIssue13964(c *check.C) {
|
| 1686 | 1686 |
host := "tcp://localhost:4271" |
| 1687 |
- c.Assert(s.d.Start("-H", host), check.IsNil)
|
|
| 1687 |
+ s.d.Start(c, "-H", host) |
|
| 1688 | 1688 |
cmd := exec.Command(dockerBinary, "-H", host, "info") |
| 1689 | 1689 |
cmd.Env = []string{"DOCKER_TLS_VERIFY=1", "DOCKER_CERT_PATH=fixtures/https"}
|
| 1690 | 1690 |
out, _, err := runCommandWithOutput(cmd) |
| ... | ... |
@@ -1705,7 +1615,7 @@ func teardownV6(c *check.C) {
|
| 1705 | 1705 |
} |
| 1706 | 1706 |
|
| 1707 | 1707 |
func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlways(c *check.C) {
|
| 1708 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1708 |
+ s.d.StartWithBusybox(c) |
|
| 1709 | 1709 |
|
| 1710 | 1710 |
out, err := s.d.Cmd("run", "-d", "--restart", "always", "busybox", "top")
|
| 1711 | 1711 |
c.Assert(err, check.IsNil) |
| ... | ... |
@@ -1720,7 +1630,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlway |
| 1720 | 1720 |
c.Assert(err, check.IsNil) |
| 1721 | 1721 |
c.Assert(out, check.Equals, "") |
| 1722 | 1722 |
|
| 1723 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 1723 |
+ s.d.Restart(c) |
|
| 1724 | 1724 |
|
| 1725 | 1725 |
out, err = s.d.Cmd("ps", "-q")
|
| 1726 | 1726 |
c.Assert(err, check.IsNil) |
| ... | ... |
@@ -1728,9 +1638,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithContainerWithRestartPolicyAlway |
| 1728 | 1728 |
} |
| 1729 | 1729 |
|
| 1730 | 1730 |
func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
|
| 1731 |
- if err := s.d.StartWithBusybox("--log-opt=max-size=1k"); err != nil {
|
|
| 1732 |
- c.Fatal(err) |
|
| 1733 |
- } |
|
| 1731 |
+ s.d.StartWithBusybox(c, "--log-opt=max-size=1k") |
|
| 1734 | 1732 |
name := "logtest" |
| 1735 | 1733 |
out, err := s.d.Cmd("run", "-d", "--log-opt=max-file=5", "--name", name, "busybox", "top")
|
| 1736 | 1734 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s, err: %v", out, err))
|
| ... | ... |
@@ -1746,18 +1654,14 @@ func (s *DockerDaemonSuite) TestDaemonWideLogConfig(c *check.C) {
|
| 1746 | 1746 |
} |
| 1747 | 1747 |
|
| 1748 | 1748 |
func (s *DockerDaemonSuite) TestDaemonRestartWithPausedContainer(c *check.C) {
|
| 1749 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 1750 |
- c.Fatal(err) |
|
| 1751 |
- } |
|
| 1749 |
+ s.d.StartWithBusybox(c) |
|
| 1752 | 1750 |
if out, err := s.d.Cmd("run", "-i", "-d", "--name", "test", "busybox", "top"); err != nil {
|
| 1753 | 1751 |
c.Fatal(err, out) |
| 1754 | 1752 |
} |
| 1755 | 1753 |
if out, err := s.d.Cmd("pause", "test"); err != nil {
|
| 1756 | 1754 |
c.Fatal(err, out) |
| 1757 | 1755 |
} |
| 1758 |
- if err := s.d.Restart(); err != nil {
|
|
| 1759 |
- c.Fatal(err) |
|
| 1760 |
- } |
|
| 1756 |
+ s.d.Restart(c) |
|
| 1761 | 1757 |
|
| 1762 | 1758 |
errchan := make(chan error) |
| 1763 | 1759 |
go func() {
|
| ... | ... |
@@ -1783,12 +1687,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPausedContainer(c *check.C) {
|
| 1783 | 1783 |
} |
| 1784 | 1784 |
|
| 1785 | 1785 |
func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) {
|
| 1786 |
- c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1786 |
+ s.d.StartWithBusybox(c) |
|
| 1787 | 1787 |
|
| 1788 | 1788 |
out, err := s.d.Cmd("create", "-v", "test:/foo", "busybox")
|
| 1789 | 1789 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 1790 | 1790 |
|
| 1791 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 1791 |
+ s.d.Restart(c) |
|
| 1792 | 1792 |
|
| 1793 | 1793 |
out, err = s.d.Cmd("volume", "rm", "test")
|
| 1794 | 1794 |
c.Assert(err, check.NotNil, check.Commentf("should not be able to remove in use volume after daemon restart"))
|
| ... | ... |
@@ -1796,29 +1700,37 @@ func (s *DockerDaemonSuite) TestDaemonRestartRmVolumeInUse(c *check.C) {
|
| 1796 | 1796 |
} |
| 1797 | 1797 |
|
| 1798 | 1798 |
func (s *DockerDaemonSuite) TestDaemonRestartLocalVolumes(c *check.C) {
|
| 1799 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 1799 |
+ s.d.Start(c) |
|
| 1800 | 1800 |
|
| 1801 | 1801 |
_, err := s.d.Cmd("volume", "create", "test")
|
| 1802 | 1802 |
c.Assert(err, check.IsNil) |
| 1803 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 1803 |
+ s.d.Restart(c) |
|
| 1804 | 1804 |
|
| 1805 | 1805 |
_, err = s.d.Cmd("volume", "inspect", "test")
|
| 1806 | 1806 |
c.Assert(err, check.IsNil) |
| 1807 | 1807 |
} |
| 1808 | 1808 |
|
| 1809 |
+// FIXME(vdemeester) should be a unit test |
|
| 1809 | 1810 |
func (s *DockerDaemonSuite) TestDaemonCorruptedLogDriverAddress(c *check.C) {
|
| 1810 |
- c.Assert(s.d.Start("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
|
|
| 1811 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1812 |
+ Experimental: experimentalDaemon, |
|
| 1813 |
+ }) |
|
| 1814 |
+ c.Assert(d.StartWithError("--log-driver=syslog", "--log-opt", "syslog-address=corrupted:42"), check.NotNil)
|
|
| 1811 | 1815 |
expected := "Failed to set log opts: syslog-address should be in form proto://address" |
| 1812 |
- runCmd := exec.Command("grep", expected, s.d.LogFileName())
|
|
| 1816 |
+ runCmd := exec.Command("grep", expected, d.LogFileName())
|
|
| 1813 | 1817 |
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
| 1814 | 1818 |
c.Fatalf("Expected %q message; but doesn't exist in log: %q, err: %v", expected, out, err)
|
| 1815 | 1819 |
} |
| 1816 | 1820 |
} |
| 1817 | 1821 |
|
| 1822 |
+// FIXME(vdemeester) should be a unit test |
|
| 1818 | 1823 |
func (s *DockerDaemonSuite) TestDaemonCorruptedFluentdAddress(c *check.C) {
|
| 1819 |
- c.Assert(s.d.Start("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
|
|
| 1824 |
+ d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
|
| 1825 |
+ Experimental: experimentalDaemon, |
|
| 1826 |
+ }) |
|
| 1827 |
+ c.Assert(d.StartWithError("--log-driver=fluentd", "--log-opt", "fluentd-address=corrupted:c"), check.NotNil)
|
|
| 1820 | 1828 |
expected := "Failed to set log opts: invalid fluentd-address corrupted:c: " |
| 1821 |
- runCmd := exec.Command("grep", expected, s.d.LogFileName())
|
|
| 1829 |
+ runCmd := exec.Command("grep", expected, d.LogFileName())
|
|
| 1822 | 1830 |
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
| 1823 | 1831 |
c.Fatalf("Expected %q message; but doesn't exist in log: %q, err: %v", expected, out, err)
|
| 1824 | 1832 |
} |
| ... | ... |
@@ -1830,7 +1742,7 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutHost(c *check.C) {
|
| 1830 | 1830 |
defer func() {
|
| 1831 | 1831 |
s.d.UseDefaultHost = false |
| 1832 | 1832 |
}() |
| 1833 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 1833 |
+ s.d.Start(c) |
|
| 1834 | 1834 |
} |
| 1835 | 1835 |
|
| 1836 | 1836 |
// FIXME(vdemeester) Use a new daemon instance instead of the Suite one |
| ... | ... |
@@ -1839,13 +1751,11 @@ func (s *DockerDaemonSuite) TestDaemonStartWithDefalutTLSHost(c *check.C) {
|
| 1839 | 1839 |
defer func() {
|
| 1840 | 1840 |
s.d.UseDefaultTLSHost = false |
| 1841 | 1841 |
}() |
| 1842 |
- if err := s.d.Start( |
|
| 1842 |
+ s.d.Start(c, |
|
| 1843 | 1843 |
"--tlsverify", |
| 1844 | 1844 |
"--tlscacert", "fixtures/https/ca.pem", |
| 1845 | 1845 |
"--tlscert", "fixtures/https/server-cert.pem", |
| 1846 |
- "--tlskey", "fixtures/https/server-key.pem"); err != nil {
|
|
| 1847 |
- c.Fatalf("Could not start daemon: %v", err)
|
|
| 1848 |
- } |
|
| 1846 |
+ "--tlskey", "fixtures/https/server-key.pem") |
|
| 1849 | 1847 |
|
| 1850 | 1848 |
// The client with --tlsverify should also use default host localhost:2376 |
| 1851 | 1849 |
tmpHost := os.Getenv("DOCKER_HOST")
|
| ... | ... |
@@ -1875,14 +1785,13 @@ func (s *DockerDaemonSuite) TestBridgeIPIsExcludedFromAllocatorPool(c *check.C) |
| 1875 | 1875 |
bridgeIP := "192.169.1.1" |
| 1876 | 1876 |
bridgeRange := bridgeIP + "/30" |
| 1877 | 1877 |
|
| 1878 |
- err := s.d.StartWithBusybox("--bip", bridgeRange)
|
|
| 1879 |
- c.Assert(err, check.IsNil) |
|
| 1880 |
- defer s.d.Restart() |
|
| 1878 |
+ s.d.StartWithBusybox(c, "--bip", bridgeRange) |
|
| 1879 |
+ defer s.d.Restart(c) |
|
| 1881 | 1880 |
|
| 1882 | 1881 |
var cont int |
| 1883 | 1882 |
for {
|
| 1884 | 1883 |
contName := fmt.Sprintf("container%d", cont)
|
| 1885 |
- _, err = s.d.Cmd("run", "--name", contName, "-d", "busybox", "/bin/sleep", "2")
|
|
| 1884 |
+ _, err := s.d.Cmd("run", "--name", contName, "-d", "busybox", "/bin/sleep", "2")
|
|
| 1886 | 1885 |
if err != nil {
|
| 1887 | 1886 |
// pool exhausted |
| 1888 | 1887 |
break |
| ... | ... |
@@ -1920,9 +1829,8 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
|
| 1920 | 1920 |
dockerCmd(c, "run", "--privileged", "--rm", "-v", testDir+":/test:shared", "busybox", "sh", "-c", fmt.Sprintf("mkdir -p /test/test-mount && mount -t ext4 -no loop,rw %v /test/test-mount", loopname))
|
| 1921 | 1921 |
defer mount.Unmount(filepath.Join(testDir, "test-mount")) |
| 1922 | 1922 |
|
| 1923 |
- err = s.d.Start("--graph", filepath.Join(testDir, "test-mount"))
|
|
| 1924 |
- defer s.d.Stop() |
|
| 1925 |
- c.Assert(err, check.IsNil) |
|
| 1923 |
+ s.d.Start(c, "--graph", filepath.Join(testDir, "test-mount")) |
|
| 1924 |
+ defer s.d.Stop(c) |
|
| 1926 | 1925 |
|
| 1927 | 1926 |
// pull a repository large enough to fill the mount point |
| 1928 | 1927 |
pullOut, err := s.d.Cmd("pull", "registry:2")
|
| ... | ... |
@@ -1932,8 +1840,7 @@ func (s *DockerDaemonSuite) TestDaemonNoSpaceLeftOnDeviceError(c *check.C) {
|
| 1932 | 1932 |
|
| 1933 | 1933 |
// Test daemon restart with container links + auto restart |
| 1934 | 1934 |
func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
|
| 1935 |
- err := s.d.StartWithBusybox() |
|
| 1936 |
- c.Assert(err, checker.IsNil) |
|
| 1935 |
+ s.d.StartWithBusybox(c) |
|
| 1937 | 1936 |
|
| 1938 | 1937 |
parent1Args := []string{}
|
| 1939 | 1938 |
parent2Args := []string{}
|
| ... | ... |
@@ -1952,7 +1859,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
|
| 1952 | 1952 |
} |
| 1953 | 1953 |
|
| 1954 | 1954 |
go func() {
|
| 1955 |
- _, err = s.d.Cmd("run", "-d", "--name", name, "--restart=always", "busybox", "top")
|
|
| 1955 |
+ _, err := s.d.Cmd("run", "-d", "--name", name, "--restart=always", "busybox", "top")
|
|
| 1956 | 1956 |
chErr <- err |
| 1957 | 1957 |
wg.Done() |
| 1958 | 1958 |
}() |
| ... | ... |
@@ -1969,18 +1876,16 @@ func (s *DockerDaemonSuite) TestDaemonRestartContainerLinksRestart(c *check.C) {
|
| 1969 | 1969 |
parent2Args = append([]string{"run", "-d"}, parent2Args...)
|
| 1970 | 1970 |
parent2Args = append(parent2Args, []string{"--name=parent2", "--restart=always", "busybox", "top"}...)
|
| 1971 | 1971 |
|
| 1972 |
- _, err = s.d.Cmd(parent1Args...) |
|
| 1972 |
+ _, err := s.d.Cmd(parent1Args...) |
|
| 1973 | 1973 |
c.Assert(err, check.IsNil) |
| 1974 | 1974 |
_, err = s.d.Cmd(parent2Args...) |
| 1975 | 1975 |
c.Assert(err, check.IsNil) |
| 1976 | 1976 |
|
| 1977 |
- err = s.d.Stop() |
|
| 1978 |
- c.Assert(err, check.IsNil) |
|
| 1977 |
+ s.d.Stop(c) |
|
| 1979 | 1978 |
// clear the log file -- we don't need any of it but may for the next part |
| 1980 | 1979 |
// can ignore the error here, this is just a cleanup |
| 1981 | 1980 |
os.Truncate(s.d.LogFileName(), 0) |
| 1982 |
- err = s.d.Start() |
|
| 1983 |
- c.Assert(err, check.IsNil) |
|
| 1981 |
+ s.d.Start(c) |
|
| 1984 | 1982 |
|
| 1985 | 1983 |
for _, num := range []string{"1", "2"} {
|
| 1986 | 1984 |
out, err := s.d.Cmd("inspect", "-f", "{{ .State.Running }}", "parent"+num)
|
| ... | ... |
@@ -1998,9 +1903,8 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) {
|
| 1998 | 1998 |
cgroupParent := "test" |
| 1999 | 1999 |
name := "cgroup-test" |
| 2000 | 2000 |
|
| 2001 |
- err := s.d.StartWithBusybox("--cgroup-parent", cgroupParent)
|
|
| 2002 |
- c.Assert(err, check.IsNil) |
|
| 2003 |
- defer s.d.Restart() |
|
| 2001 |
+ s.d.StartWithBusybox(c, "--cgroup-parent", cgroupParent) |
|
| 2002 |
+ defer s.d.Restart(c) |
|
| 2004 | 2003 |
|
| 2005 | 2004 |
out, err := s.d.Cmd("run", "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 2006 | 2005 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -2022,8 +1926,7 @@ func (s *DockerDaemonSuite) TestDaemonCgroupParent(c *check.C) {
|
| 2022 | 2022 |
|
| 2023 | 2023 |
func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *check.C) {
|
| 2024 | 2024 |
testRequires(c, DaemonIsLinux) // Windows does not support links |
| 2025 |
- err := s.d.StartWithBusybox() |
|
| 2026 |
- c.Assert(err, check.IsNil) |
|
| 2025 |
+ s.d.StartWithBusybox(c) |
|
| 2027 | 2026 |
|
| 2028 | 2027 |
out, err := s.d.Cmd("run", "-d", "--name=test", "busybox", "top")
|
| 2029 | 2028 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -2031,7 +1934,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *check.C) {
|
| 2031 | 2031 |
out, err = s.d.Cmd("run", "--name=test2", "--link", "test:abc", "busybox", "sh", "-c", "ping -c 1 -w 1 abc")
|
| 2032 | 2032 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2033 | 2033 |
|
| 2034 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 2034 |
+ s.d.Restart(c) |
|
| 2035 | 2035 |
|
| 2036 | 2036 |
// should fail since test is not running yet |
| 2037 | 2037 |
out, err = s.d.Cmd("start", "test2")
|
| ... | ... |
@@ -2046,8 +1949,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithLinks(c *check.C) {
|
| 2046 | 2046 |
|
| 2047 | 2047 |
func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
|
| 2048 | 2048 |
testRequires(c, DaemonIsLinux) // Windows does not support links |
| 2049 |
- err := s.d.StartWithBusybox() |
|
| 2050 |
- c.Assert(err, check.IsNil) |
|
| 2049 |
+ s.d.StartWithBusybox(c) |
|
| 2051 | 2050 |
|
| 2052 | 2051 |
out, err := s.d.Cmd("create", "--name=test", "busybox")
|
| 2053 | 2052 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -2059,7 +1961,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
|
| 2059 | 2059 |
out, err = s.d.Cmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top")
|
| 2060 | 2060 |
test3ID := strings.TrimSpace(out) |
| 2061 | 2061 |
|
| 2062 |
- c.Assert(s.d.Restart(), check.IsNil) |
|
| 2062 |
+ s.d.Restart(c) |
|
| 2063 | 2063 |
|
| 2064 | 2064 |
out, err = s.d.Cmd("create", "--name=test", "busybox")
|
| 2065 | 2065 |
c.Assert(err, check.NotNil, check.Commentf("expected error trying to create container with duplicate name"))
|
| ... | ... |
@@ -2095,12 +1997,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
|
| 2095 | 2095 |
func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check.C) {
|
| 2096 | 2096 |
// TODO(mlaventure): Not sure what would the exit code be on windows |
| 2097 | 2097 |
testRequires(t, DaemonIsLinux) |
| 2098 |
- if err := s.d.StartWithBusybox(); err != nil {
|
|
| 2099 |
- t.Fatal(err) |
|
| 2100 |
- } |
|
| 2098 |
+ s.d.StartWithBusybox(t) |
|
| 2101 | 2099 |
|
| 2102 | 2100 |
cid, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top")
|
| 2103 |
- defer s.d.Stop() |
|
| 2101 |
+ defer s.d.Stop(t) |
|
| 2104 | 2102 |
if err != nil {
|
| 2105 | 2103 |
t.Fatal(cid, err) |
| 2106 | 2104 |
} |
| ... | ... |
@@ -2131,9 +2031,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check |
| 2131 | 2131 |
} |
| 2132 | 2132 |
|
| 2133 | 2133 |
// restart the daemon |
| 2134 |
- if err := s.d.Start(); err != nil {
|
|
| 2135 |
- t.Fatal(err) |
|
| 2136 |
- } |
|
| 2134 |
+ s.d.Start(t) |
|
| 2137 | 2135 |
|
| 2138 | 2136 |
// Check that we've got the correct exit code |
| 2139 | 2137 |
out, err := s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", cid)
|
| ... | ... |
@@ -2151,7 +2049,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithKilledRunningContainer(t *check |
| 2151 | 2151 |
// them now, should remove the mounts. |
| 2152 | 2152 |
func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
|
| 2153 | 2153 |
testRequires(c, DaemonIsLinux) |
| 2154 |
- c.Assert(s.d.StartWithBusybox("--live-restore"), check.IsNil)
|
|
| 2154 |
+ s.d.StartWithBusybox(c, "--live-restore") |
|
| 2155 | 2155 |
|
| 2156 | 2156 |
out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
| 2157 | 2157 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| ... | ... |
@@ -2166,9 +2064,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
|
| 2166 | 2166 |
c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment) |
| 2167 | 2167 |
|
| 2168 | 2168 |
// restart daemon. |
| 2169 |
- if err := s.d.Restart("--live-restore"); err != nil {
|
|
| 2170 |
- c.Fatal(err) |
|
| 2171 |
- } |
|
| 2169 |
+ s.d.Start(c, "--live-restore") |
|
| 2172 | 2170 |
|
| 2173 | 2171 |
// container should be running. |
| 2174 | 2172 |
out, err = s.d.Cmd("inspect", "--format={{.State.Running}}", id)
|
| ... | ... |
@@ -2193,12 +2089,10 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
|
| 2193 | 2193 |
func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *check.C) {
|
| 2194 | 2194 |
// TODO(mlaventure): Not sure what would the exit code be on windows |
| 2195 | 2195 |
testRequires(t, DaemonIsLinux) |
| 2196 |
- if err := s.d.StartWithBusybox("--live-restore"); err != nil {
|
|
| 2197 |
- t.Fatal(err) |
|
| 2198 |
- } |
|
| 2196 |
+ s.d.StartWithBusybox(t, "--live-restore") |
|
| 2199 | 2197 |
|
| 2200 | 2198 |
cid, err := s.d.Cmd("run", "-d", "--name", "test", "busybox", "top")
|
| 2201 |
- defer s.d.Stop() |
|
| 2199 |
+ defer s.d.Stop(t) |
|
| 2202 | 2200 |
if err != nil {
|
| 2203 | 2201 |
t.Fatal(cid, err) |
| 2204 | 2202 |
} |
| ... | ... |
@@ -2232,9 +2126,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che |
| 2232 | 2232 |
}, checker.Equals, 0) |
| 2233 | 2233 |
|
| 2234 | 2234 |
// restart the daemon |
| 2235 |
- if err := s.d.Start("--live-restore"); err != nil {
|
|
| 2236 |
- t.Fatal(err) |
|
| 2237 |
- } |
|
| 2235 |
+ s.d.Start(t, "--live-restore") |
|
| 2238 | 2236 |
|
| 2239 | 2237 |
// Check that we've got the correct status |
| 2240 | 2238 |
out, err := s.d.Cmd("inspect", "-f", "{{.State.Status}}", cid)
|
| ... | ... |
@@ -2253,8 +2145,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *che |
| 2253 | 2253 |
// this ensures that the old, pre gh#16032 functionality continues on |
| 2254 | 2254 |
func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) {
|
| 2255 | 2255 |
testRequires(c, DaemonIsLinux) // Windows does not support links |
| 2256 |
- err := s.d.StartWithBusybox() |
|
| 2257 |
- c.Assert(err, check.IsNil) |
|
| 2256 |
+ s.d.StartWithBusybox(c) |
|
| 2258 | 2257 |
|
| 2259 | 2258 |
out, err := s.d.Cmd("run", "-d", "--name=test", "busybox", "top")
|
| 2260 | 2259 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -2272,8 +2163,7 @@ func (s *DockerDaemonSuite) TestRunLinksChanged(c *check.C) {
|
| 2272 | 2272 |
c.Assert(err, check.NotNil, check.Commentf(out)) |
| 2273 | 2273 |
c.Assert(out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received") |
| 2274 | 2274 |
|
| 2275 |
- err = s.d.Restart() |
|
| 2276 |
- c.Assert(err, check.IsNil) |
|
| 2275 |
+ s.d.Restart(c) |
|
| 2277 | 2276 |
out, err = s.d.Cmd("start", "-a", "test2")
|
| 2278 | 2277 |
c.Assert(err, check.NotNil, check.Commentf(out)) |
| 2279 | 2278 |
c.Assert(out, check.Not(checker.Contains), "1 packets transmitted, 1 packets received") |
| ... | ... |
@@ -2296,14 +2186,14 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) {
|
| 2296 | 2296 |
|
| 2297 | 2297 |
// Enable coloring explicitly |
| 2298 | 2298 |
s.d.StartWithLogFile(tty, "--raw-logs=false") |
| 2299 |
- s.d.Stop() |
|
| 2299 |
+ s.d.Stop(c) |
|
| 2300 | 2300 |
c.Assert(b.String(), checker.Contains, infoLog) |
| 2301 | 2301 |
|
| 2302 | 2302 |
b.Reset() |
| 2303 | 2303 |
|
| 2304 | 2304 |
// Disable coloring explicitly |
| 2305 | 2305 |
s.d.StartWithLogFile(tty, "--raw-logs=true") |
| 2306 |
- s.d.Stop() |
|
| 2306 |
+ s.d.Stop(c) |
|
| 2307 | 2307 |
c.Assert(b.String(), check.Not(checker.Contains), infoLog) |
| 2308 | 2308 |
} |
| 2309 | 2309 |
|
| ... | ... |
@@ -2323,7 +2213,7 @@ func (s *DockerDaemonSuite) TestDaemonDebugLog(c *check.C) {
|
| 2323 | 2323 |
go io.Copy(b, p) |
| 2324 | 2324 |
|
| 2325 | 2325 |
s.d.StartWithLogFile(tty, "--debug") |
| 2326 |
- s.d.Stop() |
|
| 2326 |
+ s.d.Stop(c) |
|
| 2327 | 2327 |
c.Assert(b.String(), checker.Contains, debugLog) |
| 2328 | 2328 |
} |
| 2329 | 2329 |
|
| ... | ... |
@@ -2345,8 +2235,7 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
|
| 2345 | 2345 |
|
| 2346 | 2346 |
// --log-level needs to be set so that d.Start() doesn't add --debug causing |
| 2347 | 2347 |
// a conflict with the config |
| 2348 |
- err = s.d.Start("--config-file", configFilePath, "--log-level=info")
|
|
| 2349 |
- c.Assert(err, checker.IsNil) |
|
| 2348 |
+ s.d.Start(c, "--config-file", configFilePath, "--log-level=info") |
|
| 2350 | 2349 |
|
| 2351 | 2350 |
// daemon config file |
| 2352 | 2351 |
daemonConfig = `{
|
| ... | ... |
@@ -2375,8 +2264,7 @@ func (s *DockerDaemonSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
|
| 2375 | 2375 |
|
| 2376 | 2376 |
// Test for #21956 |
| 2377 | 2377 |
func (s *DockerDaemonSuite) TestDaemonLogOptions(c *check.C) {
|
| 2378 |
- err := s.d.StartWithBusybox("--log-driver=syslog", "--log-opt=syslog-address=udp://127.0.0.1:514")
|
|
| 2379 |
- c.Assert(err, check.IsNil) |
|
| 2378 |
+ s.d.StartWithBusybox(c, "--log-driver=syslog", "--log-opt=syslog-address=udp://127.0.0.1:514") |
|
| 2380 | 2379 |
|
| 2381 | 2380 |
out, err := s.d.Cmd("run", "-d", "--log-driver=json-file", "busybox", "top")
|
| 2382 | 2381 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -2389,7 +2277,7 @@ func (s *DockerDaemonSuite) TestDaemonLogOptions(c *check.C) {
|
| 2389 | 2389 |
|
| 2390 | 2390 |
// Test case for #20936, #22443 |
| 2391 | 2391 |
func (s *DockerDaemonSuite) TestDaemonMaxConcurrency(c *check.C) {
|
| 2392 |
- c.Assert(s.d.Start("--max-concurrent-uploads=6", "--max-concurrent-downloads=8"), check.IsNil)
|
|
| 2392 |
+ s.d.Start(c, "--max-concurrent-uploads=6", "--max-concurrent-downloads=8") |
|
| 2393 | 2393 |
|
| 2394 | 2394 |
expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 6"` |
| 2395 | 2395 |
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"` |
| ... | ... |
@@ -2412,7 +2300,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFile(c *check.C) {
|
| 2412 | 2412 |
daemonConfig := `{ "max-concurrent-downloads" : 8 }`
|
| 2413 | 2413 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
| 2414 | 2414 |
configFile.Close() |
| 2415 |
- c.Assert(s.d.Start(fmt.Sprintf("--config-file=%s", configFilePath)), check.IsNil)
|
|
| 2415 |
+ s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
|
|
| 2416 | 2416 |
|
| 2417 | 2417 |
expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 5"` |
| 2418 | 2418 |
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 8"` |
| ... | ... |
@@ -2453,7 +2341,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec |
| 2453 | 2453 |
daemonConfig := `{ "max-concurrent-uploads" : null }`
|
| 2454 | 2454 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
| 2455 | 2455 |
configFile.Close() |
| 2456 |
- c.Assert(s.d.Start(fmt.Sprintf("--config-file=%s", configFilePath)), check.IsNil)
|
|
| 2456 |
+ s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
|
|
| 2457 | 2457 |
|
| 2458 | 2458 |
expectedMaxConcurrentUploads := `level=debug msg="Max Concurrent Uploads: 5"` |
| 2459 | 2459 |
expectedMaxConcurrentDownloads := `level=debug msg="Max Concurrent Downloads: 3"` |
| ... | ... |
@@ -2499,10 +2387,7 @@ func (s *DockerDaemonSuite) TestDaemonMaxConcurrencyWithConfigFileReload(c *chec |
| 2499 | 2499 |
} |
| 2500 | 2500 |
|
| 2501 | 2501 |
func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) {
|
| 2502 |
- err := s.d.StartWithBusybox("-b=none", "--iptables=false")
|
|
| 2503 |
- c.Assert(err, check.IsNil) |
|
| 2504 |
- // s.d.c.Logf("dockerBinary %s", dockerBinary)
|
|
| 2505 |
- c.Logf("dockerBinary %s", dockerBinary)
|
|
| 2502 |
+ s.d.StartWithBusybox(c, "-b=none", "--iptables=false") |
|
| 2506 | 2503 |
out, code, err := s.d.BuildImageWithOut("busyboxs",
|
| 2507 | 2504 |
`FROM busybox |
| 2508 | 2505 |
RUN cat /etc/hosts`, false) |
| ... | ... |
@@ -2515,8 +2400,7 @@ func (s *DockerDaemonSuite) TestBuildOnDisabledBridgeNetworkDaemon(c *check.C) {
|
| 2515 | 2515 |
func (s *DockerDaemonSuite) TestDaemonDNSInHostMode(c *check.C) {
|
| 2516 | 2516 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 2517 | 2517 |
|
| 2518 |
- err := s.d.StartWithBusybox("--dns", "1.2.3.4")
|
|
| 2519 |
- c.Assert(err, checker.IsNil) |
|
| 2518 |
+ s.d.StartWithBusybox(c, "--dns", "1.2.3.4") |
|
| 2520 | 2519 |
|
| 2521 | 2520 |
expectedOutput := "nameserver 1.2.3.4" |
| 2522 | 2521 |
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf")
|
| ... | ... |
@@ -2527,8 +2411,7 @@ func (s *DockerDaemonSuite) TestDaemonDNSInHostMode(c *check.C) {
|
| 2527 | 2527 |
func (s *DockerDaemonSuite) TestDaemonDNSSearchInHostMode(c *check.C) {
|
| 2528 | 2528 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 2529 | 2529 |
|
| 2530 |
- err := s.d.StartWithBusybox("--dns-search", "example.com")
|
|
| 2531 |
- c.Assert(err, checker.IsNil) |
|
| 2530 |
+ s.d.StartWithBusybox(c, "--dns-search", "example.com") |
|
| 2532 | 2531 |
|
| 2533 | 2532 |
expectedOutput := "search example.com" |
| 2534 | 2533 |
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf")
|
| ... | ... |
@@ -2539,8 +2422,7 @@ func (s *DockerDaemonSuite) TestDaemonDNSSearchInHostMode(c *check.C) {
|
| 2539 | 2539 |
func (s *DockerDaemonSuite) TestDaemonDNSOptionsInHostMode(c *check.C) {
|
| 2540 | 2540 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 2541 | 2541 |
|
| 2542 |
- err := s.d.StartWithBusybox("--dns-opt", "timeout:3")
|
|
| 2543 |
- c.Assert(err, checker.IsNil) |
|
| 2542 |
+ s.d.StartWithBusybox(c, "--dns-opt", "timeout:3") |
|
| 2544 | 2543 |
|
| 2545 | 2544 |
expectedOutput := "options timeout:3" |
| 2546 | 2545 |
out, _ := s.d.Cmd("run", "--net=host", "busybox", "cat", "/etc/resolv.conf")
|
| ... | ... |
@@ -2570,8 +2452,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2570 | 2570 |
} |
| 2571 | 2571 |
` |
| 2572 | 2572 |
ioutil.WriteFile(configName, []byte(config), 0644) |
| 2573 |
- err = s.d.StartWithBusybox("--config-file", configName)
|
|
| 2574 |
- c.Assert(err, check.IsNil) |
|
| 2573 |
+ s.d.StartWithBusybox(c, "--config-file", configName) |
|
| 2575 | 2574 |
|
| 2576 | 2575 |
// Run with default runtime |
| 2577 | 2576 |
out, err := s.d.Cmd("run", "--rm", "busybox", "ls")
|
| ... | ... |
@@ -2667,8 +2548,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2667 | 2667 |
} |
| 2668 | 2668 |
|
| 2669 | 2669 |
func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2670 |
- err := s.d.StartWithBusybox("--add-runtime", "oci=docker-runc", "--add-runtime", "vm=/usr/local/bin/vm-manager")
|
|
| 2671 |
- c.Assert(err, check.IsNil) |
|
| 2670 |
+ s.d.StartWithBusybox(c, "--add-runtime", "oci=docker-runc", "--add-runtime", "vm=/usr/local/bin/vm-manager") |
|
| 2672 | 2671 |
|
| 2673 | 2672 |
// Run with default runtime |
| 2674 | 2673 |
out, err := s.d.Cmd("run", "--rm", "busybox", "ls")
|
| ... | ... |
@@ -2688,9 +2568,8 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2688 | 2688 |
c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory") |
| 2689 | 2689 |
|
| 2690 | 2690 |
// Start a daemon without any extra runtimes |
| 2691 |
- s.d.Stop() |
|
| 2692 |
- err = s.d.StartWithBusybox() |
|
| 2693 |
- c.Assert(err, check.IsNil) |
|
| 2691 |
+ s.d.Stop(c) |
|
| 2692 |
+ s.d.StartWithBusybox(c) |
|
| 2694 | 2693 |
|
| 2695 | 2694 |
// Run with default runtime |
| 2696 | 2695 |
out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
| ... | ... |
@@ -2707,18 +2586,16 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2707 | 2707 |
c.Assert(out, checker.Contains, "Unknown runtime specified oci") |
| 2708 | 2708 |
|
| 2709 | 2709 |
// Check that we can't override the default runtime |
| 2710 |
- s.d.Stop() |
|
| 2711 |
- err = s.d.Start("--add-runtime", "runc=my-runc")
|
|
| 2712 |
- c.Assert(err, check.NotNil) |
|
| 2710 |
+ s.d.Stop(c) |
|
| 2711 |
+ c.Assert(s.d.StartWithError("--add-runtime", "runc=my-runc"), checker.NotNil)
|
|
| 2713 | 2712 |
|
| 2714 | 2713 |
content, err := s.d.ReadLogFile() |
| 2715 | 2714 |
c.Assert(err, checker.IsNil) |
| 2716 | 2715 |
c.Assert(string(content), checker.Contains, `runtime name 'runc' is reserved`) |
| 2717 | 2716 |
|
| 2718 | 2717 |
// Check that we can select a default runtime |
| 2719 |
- s.d.Stop() |
|
| 2720 |
- err = s.d.StartWithBusybox("--default-runtime=vm", "--add-runtime", "oci=docker-runc", "--add-runtime", "vm=/usr/local/bin/vm-manager")
|
|
| 2721 |
- c.Assert(err, check.IsNil) |
|
| 2718 |
+ s.d.Stop(c) |
|
| 2719 |
+ s.d.StartWithBusybox(c, "--default-runtime=vm", "--add-runtime", "oci=docker-runc", "--add-runtime", "vm=/usr/local/bin/vm-manager") |
|
| 2722 | 2720 |
|
| 2723 | 2721 |
out, err = s.d.Cmd("run", "--rm", "busybox", "ls")
|
| 2724 | 2722 |
c.Assert(err, check.NotNil, check.Commentf(out)) |
| ... | ... |
@@ -2730,8 +2607,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2730 | 2730 |
} |
| 2731 | 2731 |
|
| 2732 | 2732 |
func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) {
|
| 2733 |
- err := s.d.StartWithBusybox() |
|
| 2734 |
- c.Assert(err, checker.IsNil) |
|
| 2733 |
+ s.d.StartWithBusybox(c) |
|
| 2735 | 2734 |
|
| 2736 | 2735 |
// top1 will exist after daemon restarts |
| 2737 | 2736 |
out, err := s.d.Cmd("run", "-d", "--name", "top1", "busybox:latest", "top")
|
| ... | ... |
@@ -2745,8 +2621,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) |
| 2745 | 2745 |
c.Assert(out, checker.Contains, "top2", check.Commentf("top2 should be running"))
|
| 2746 | 2746 |
|
| 2747 | 2747 |
// now restart daemon gracefully |
| 2748 |
- err = s.d.Restart() |
|
| 2749 |
- c.Assert(err, checker.IsNil) |
|
| 2748 |
+ s.d.Restart(c) |
|
| 2750 | 2749 |
|
| 2751 | 2750 |
out, err = s.d.Cmd("ps", "-a")
|
| 2752 | 2751 |
c.Assert(err, checker.IsNil, check.Commentf("out: %v", out))
|
| ... | ... |
@@ -2755,8 +2630,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C) |
| 2755 | 2755 |
} |
| 2756 | 2756 |
|
| 2757 | 2757 |
func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
|
| 2758 |
- err := s.d.StartWithBusybox() |
|
| 2759 |
- c.Assert(err, checker.IsNil) |
|
| 2758 |
+ s.d.StartWithBusybox(c) |
|
| 2760 | 2759 |
|
| 2761 | 2760 |
containerName := "error-values" |
| 2762 | 2761 |
// Make a container with both a non 0 exit code and an error message |
| ... | ... |
@@ -2774,8 +2648,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
|
| 2774 | 2774 |
c.Assert(err, checker.IsNil) |
| 2775 | 2775 |
|
| 2776 | 2776 |
// now restart daemon |
| 2777 |
- err = s.d.Restart() |
|
| 2778 |
- c.Assert(err, checker.IsNil) |
|
| 2777 |
+ s.d.Restart(c) |
|
| 2779 | 2778 |
|
| 2780 | 2779 |
// Check that those values are still around |
| 2781 | 2780 |
out, err = s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", containerName)
|
| ... | ... |
@@ -2791,8 +2664,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
|
| 2791 | 2791 |
func (s *DockerDaemonSuite) TestDaemonBackcompatPre17Volumes(c *check.C) {
|
| 2792 | 2792 |
testRequires(c, SameHostDaemon) |
| 2793 | 2793 |
d := s.d |
| 2794 |
- err := d.StartWithBusybox() |
|
| 2795 |
- c.Assert(err, checker.IsNil) |
|
| 2794 |
+ d.StartWithBusybox(c) |
|
| 2796 | 2795 |
|
| 2797 | 2796 |
// hack to be able to side-load a container config |
| 2798 | 2797 |
out, err := d.Cmd("create", "busybox:latest")
|
| ... | ... |
@@ -2801,7 +2673,7 @@ func (s *DockerDaemonSuite) TestDaemonBackcompatPre17Volumes(c *check.C) {
|
| 2801 | 2801 |
|
| 2802 | 2802 |
out, err = d.Cmd("inspect", "--type=image", "--format={{.ID}}", "busybox:latest")
|
| 2803 | 2803 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| 2804 |
- c.Assert(d.Stop(), checker.IsNil) |
|
| 2804 |
+ d.Stop(c) |
|
| 2805 | 2805 |
<-d.Wait |
| 2806 | 2806 |
|
| 2807 | 2807 |
imageID := strings.TrimSpace(out) |
| ... | ... |
@@ -2832,8 +2704,7 @@ func (s *DockerDaemonSuite) TestDaemonBackcompatPre17Volumes(c *check.C) {
|
| 2832 | 2832 |
|
| 2833 | 2833 |
configPath := filepath.Join(d.Root, "containers", id, "config.v2.json") |
| 2834 | 2834 |
err = ioutil.WriteFile(configPath, config, 600) |
| 2835 |
- err = d.Start() |
|
| 2836 |
- c.Assert(err, checker.IsNil) |
|
| 2835 |
+ d.Start(c) |
|
| 2837 | 2836 |
|
| 2838 | 2837 |
out, err = d.Cmd("inspect", "--type=container", "--format={{ json .Mounts }}", id)
|
| 2839 | 2838 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -2881,17 +2752,17 @@ func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) {
|
| 2881 | 2881 |
c.Assert(cmd.Run(), checker.IsNil) |
| 2882 | 2882 |
|
| 2883 | 2883 |
// custom one |
| 2884 |
- c.Assert(s.d.StartWithBusybox("--userland-proxy-path", newProxyPath), checker.IsNil)
|
|
| 2884 |
+ s.d.StartWithBusybox(c, "--userland-proxy-path", newProxyPath) |
|
| 2885 | 2885 |
out, err := s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
|
| 2886 | 2886 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| 2887 | 2887 |
|
| 2888 | 2888 |
// try with the original one |
| 2889 |
- c.Assert(s.d.Restart("--userland-proxy-path", dockerProxyPath), checker.IsNil)
|
|
| 2889 |
+ s.d.Restart(c, "--userland-proxy-path", dockerProxyPath) |
|
| 2890 | 2890 |
out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
|
| 2891 | 2891 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| 2892 | 2892 |
|
| 2893 | 2893 |
// not exist |
| 2894 |
- c.Assert(s.d.Restart("--userland-proxy-path", "/does/not/exist"), checker.IsNil)
|
|
| 2894 |
+ s.d.Restart(c, "--userland-proxy-path", "/does/not/exist") |
|
| 2895 | 2895 |
out, err = s.d.Cmd("run", "-p", "5000:5000", "busybox:latest", "true")
|
| 2896 | 2896 |
c.Assert(err, checker.NotNil, check.Commentf(out)) |
| 2897 | 2897 |
c.Assert(out, checker.Contains, "driver failed programming external connectivity on endpoint") |
| ... | ... |
@@ -2901,8 +2772,7 @@ func (s *DockerDaemonSuite) TestDaemonWithUserlandProxyPath(c *check.C) {
|
| 2901 | 2901 |
// Test case for #22471 |
| 2902 | 2902 |
func (s *DockerDaemonSuite) TestDaemonShutdownTimeout(c *check.C) {
|
| 2903 | 2903 |
testRequires(c, SameHostDaemon) |
| 2904 |
- |
|
| 2905 |
- c.Assert(s.d.StartWithBusybox("--shutdown-timeout=3"), check.IsNil)
|
|
| 2904 |
+ s.d.StartWithBusybox(c, "--shutdown-timeout=3") |
|
| 2906 | 2905 |
|
| 2907 | 2906 |
_, err := s.d.Cmd("run", "-d", "busybox", "top")
|
| 2908 | 2907 |
c.Assert(err, check.IsNil) |
| ... | ... |
@@ -2933,7 +2803,7 @@ func (s *DockerDaemonSuite) TestDaemonShutdownTimeoutWithConfigFile(c *check.C) |
| 2933 | 2933 |
daemonConfig := `{ "shutdown-timeout" : 8 }`
|
| 2934 | 2934 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
| 2935 | 2935 |
configFile.Close() |
| 2936 |
- c.Assert(s.d.Start(fmt.Sprintf("--config-file=%s", configFilePath)), check.IsNil)
|
|
| 2936 |
+ s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
|
|
| 2937 | 2937 |
|
| 2938 | 2938 |
configFile, err = os.Create(configFilePath) |
| 2939 | 2939 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -400,7 +400,7 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) {
|
| 400 | 400 |
daemonConfig := `{"labels":["foo=bar"]}`
|
| 401 | 401 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
| 402 | 402 |
configFile.Close() |
| 403 |
- c.Assert(s.d.Start(fmt.Sprintf("--config-file=%s", configFilePath)), check.IsNil)
|
|
| 403 |
+ s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
|
|
| 404 | 404 |
|
| 405 | 405 |
// Get daemon ID |
| 406 | 406 |
out, err := s.d.Cmd("info")
|
| ... | ... |
@@ -444,7 +444,7 @@ func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {
|
| 444 | 444 |
daemonConfig := `{"labels":["foo=bar"]}`
|
| 445 | 445 |
fmt.Fprintf(configFile, "%s", daemonConfig) |
| 446 | 446 |
configFile.Close() |
| 447 |
- c.Assert(s.d.Start(fmt.Sprintf("--config-file=%s", configFilePath)), check.IsNil)
|
|
| 447 |
+ s.d.Start(c, fmt.Sprintf("--config-file=%s", configFilePath))
|
|
| 448 | 448 |
|
| 449 | 449 |
// Get daemon ID |
| 450 | 450 |
out, err := s.d.Cmd("info")
|
| ... | ... |
@@ -81,17 +81,13 @@ func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
|
| 81 | 81 |
|
| 82 | 82 |
func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
|
| 83 | 83 |
// TODO Windows CI: Requires a little work to get this ported. |
| 84 |
- testRequires(c, DaemonIsLinux) |
|
| 85 |
- testRequires(c, SameHostDaemon) |
|
| 86 |
- |
|
| 87 |
- err := s.d.StartWithBusybox() |
|
| 88 |
- c.Assert(err, checker.IsNil) |
|
| 84 |
+ testRequires(c, DaemonIsLinux, SameHostDaemon) |
|
| 85 |
+ s.d.StartWithBusybox(c) |
|
| 89 | 86 |
|
| 90 | 87 |
out, err := s.d.Cmd("run", "-d", "--name", "top", "-p", "80", "busybox:latest", "top")
|
| 91 | 88 |
c.Assert(err, checker.IsNil, check.Commentf("Could not run top: %s", out))
|
| 92 | 89 |
|
| 93 |
- err = s.d.Restart() |
|
| 94 |
- c.Assert(err, checker.IsNil, check.Commentf("Could not restart daemon"))
|
|
| 90 |
+ s.d.Restart(c) |
|
| 95 | 91 |
|
| 96 | 92 |
out, err = s.d.Cmd("start", "top")
|
| 97 | 93 |
c.Assert(err, checker.IsNil, check.Commentf("Could not start top after daemon restart: %s", out))
|
| ... | ... |
@@ -59,7 +59,7 @@ func (s *DockerExternalGraphdriverSuite) SetUpTest(c *check.C) {
|
| 59 | 59 |
|
| 60 | 60 |
func (s *DockerExternalGraphdriverSuite) TearDownTest(c *check.C) {
|
| 61 | 61 |
if s.d != nil {
|
| 62 |
- s.d.Stop() |
|
| 62 |
+ s.d.Stop(c) |
|
| 63 | 63 |
s.ds.TearDownTest(c) |
| 64 | 64 |
} |
| 65 | 65 |
} |
| ... | ... |
@@ -349,15 +349,12 @@ func (s *DockerExternalGraphdriverSuite) TestExternalGraphDriver(c *check.C) {
|
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 | 351 |
func (s *DockerExternalGraphdriverSuite) testExternalGraphDriver(name string, ext string, c *check.C) {
|
| 352 |
- if err := s.d.StartWithBusybox("-s", name); err != nil {
|
|
| 353 |
- b, _ := ioutil.ReadFile(s.d.LogFileName()) |
|
| 354 |
- c.Assert(err, check.IsNil, check.Commentf("\n%s", string(b)))
|
|
| 355 |
- } |
|
| 352 |
+ s.d.StartWithBusybox(c, "-s", name) |
|
| 356 | 353 |
|
| 357 | 354 |
out, err := s.d.Cmd("run", "--name=graphtest", "busybox", "sh", "-c", "echo hello > /hello")
|
| 358 | 355 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 359 | 356 |
|
| 360 |
- err = s.d.Restart("-s", name)
|
|
| 357 |
+ s.d.Restart(c, "-s", name) |
|
| 361 | 358 |
|
| 362 | 359 |
out, err = s.d.Cmd("inspect", "--format={{.GraphDriver.Name}}", "graphtest")
|
| 363 | 360 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -373,8 +370,7 @@ func (s *DockerExternalGraphdriverSuite) testExternalGraphDriver(name string, ex |
| 373 | 373 |
out, err = s.d.Cmd("info")
|
| 374 | 374 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 375 | 375 |
|
| 376 |
- err = s.d.Stop() |
|
| 377 |
- c.Assert(err, check.IsNil) |
|
| 376 |
+ s.d.Stop(c) |
|
| 378 | 377 |
|
| 379 | 378 |
// Don't check s.ec.exists, because the daemon no longer calls the |
| 380 | 379 |
// Exists function. |
| ... | ... |
@@ -396,7 +392,7 @@ func (s *DockerExternalGraphdriverSuite) testExternalGraphDriver(name string, ex |
| 396 | 396 |
func (s *DockerExternalGraphdriverSuite) TestExternalGraphDriverPull(c *check.C) {
|
| 397 | 397 |
testRequires(c, Network, ExperimentalDaemon) |
| 398 | 398 |
|
| 399 |
- c.Assert(s.d.Start(), check.IsNil) |
|
| 399 |
+ s.d.Start(c) |
|
| 400 | 400 |
|
| 401 | 401 |
out, err := s.d.Cmd("pull", "busybox:latest")
|
| 402 | 402 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -58,7 +58,7 @@ func (s *DockerExternalVolumeSuite) SetUpTest(c *check.C) {
|
| 58 | 58 |
|
| 59 | 59 |
func (s *DockerExternalVolumeSuite) TearDownTest(c *check.C) {
|
| 60 | 60 |
if s.d != nil {
|
| 61 |
- s.d.Stop() |
|
| 61 |
+ s.d.Stop(c) |
|
| 62 | 62 |
s.ds.TearDownTest(c) |
| 63 | 63 |
} |
| 64 | 64 |
} |
| ... | ... |
@@ -285,8 +285,7 @@ func (s *DockerExternalVolumeSuite) TearDownSuite(c *check.C) {
|
| 285 | 285 |
} |
| 286 | 286 |
|
| 287 | 287 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *check.C) {
|
| 288 |
- err := s.d.StartWithBusybox() |
|
| 289 |
- c.Assert(err, checker.IsNil) |
|
| 288 |
+ s.d.StartWithBusybox(c) |
|
| 290 | 289 |
|
| 291 | 290 |
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
|
| 292 | 291 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -308,8 +307,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamed(c *check.C) {
|
| 308 | 308 |
} |
| 309 | 309 |
|
| 310 | 310 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *check.C) {
|
| 311 |
- err := s.d.StartWithBusybox() |
|
| 312 |
- c.Assert(err, checker.IsNil) |
|
| 311 |
+ s.d.StartWithBusybox(c) |
|
| 313 | 312 |
|
| 314 | 313 |
out, err := s.d.Cmd("run", "--rm", "--name", "test-data", "-v", "/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
|
| 315 | 314 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -323,8 +321,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnnamed(c *check.C) |
| 323 | 323 |
} |
| 324 | 324 |
|
| 325 | 325 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *check.C) {
|
| 326 |
- err := s.d.StartWithBusybox() |
|
| 327 |
- c.Assert(err, checker.IsNil) |
|
| 326 |
+ s.d.StartWithBusybox(c) |
|
| 328 | 327 |
|
| 329 | 328 |
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
|
| 330 | 329 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -343,8 +340,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverVolumesFrom(c *check |
| 343 | 343 |
} |
| 344 | 344 |
|
| 345 | 345 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverDeleteContainer(c *check.C) {
|
| 346 |
- err := s.d.StartWithBusybox() |
|
| 347 |
- c.Assert(err, checker.IsNil) |
|
| 346 |
+ s.d.StartWithBusybox(c) |
|
| 348 | 347 |
|
| 349 | 348 |
out, err := s.d.Cmd("run", "--name", "vol-test1", "-v", "/foo", "--volume-driver", volumePluginName, "busybox:latest")
|
| 350 | 349 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -401,8 +397,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c * |
| 401 | 401 |
} |
| 402 | 402 |
|
| 403 | 403 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyExists(c *check.C) {
|
| 404 |
- err := s.d.StartWithBusybox() |
|
| 405 |
- c.Assert(err, checker.IsNil) |
|
| 404 |
+ s.d.StartWithBusybox(c) |
|
| 406 | 405 |
|
| 407 | 406 |
specPath := "/etc/docker/plugins/test-external-volume-driver-retry.spec" |
| 408 | 407 |
os.RemoveAll(specPath) |
| ... | ... |
@@ -429,7 +424,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverRetryNotImmediatelyE |
| 429 | 429 |
c.Fatal("volume creates fail when plugin not immediately available")
|
| 430 | 430 |
} |
| 431 | 431 |
|
| 432 |
- _, err = s.d.Cmd("volume", "rm", "external-volume-test")
|
|
| 432 |
+ _, err := s.d.Cmd("volume", "rm", "external-volume-test")
|
|
| 433 | 433 |
c.Assert(err, checker.IsNil) |
| 434 | 434 |
|
| 435 | 435 |
c.Assert(s.ec.activations, checker.Equals, 1) |
| ... | ... |
@@ -490,8 +485,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGet(c *check.C) {
|
| 490 | 490 |
|
| 491 | 491 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c *check.C) {
|
| 492 | 492 |
dockerCmd(c, "volume", "create", "-d", volumePluginName, "abc1") |
| 493 |
- err := s.d.Restart() |
|
| 494 |
- c.Assert(err, checker.IsNil) |
|
| 493 |
+ s.d.Restart(c) |
|
| 495 | 494 |
|
| 496 | 495 |
dockerCmd(c, "run", "--name=test", "-v", "abc1:/foo", "busybox", "true") |
| 497 | 496 |
var mounts []types.MountPoint |
| ... | ... |
@@ -503,7 +497,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverWithDaemonRestart(c |
| 503 | 503 |
// Ensures that the daemon handles when the plugin responds to a `Get` request with a null volume and a null error. |
| 504 | 504 |
// Prior the daemon would panic in this scenario. |
| 505 | 505 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c *check.C) {
|
| 506 |
- c.Assert(s.d.Start(), checker.IsNil) |
|
| 506 |
+ s.d.Start(c) |
|
| 507 | 507 |
|
| 508 | 508 |
out, err := s.d.Cmd("volume", "create", "-d", volumePluginName, "abc2", "--opt", "ninja=1")
|
| 509 | 509 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -515,7 +509,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverGetEmptyResponse(c * |
| 515 | 515 |
|
| 516 | 516 |
// Ensure only cached paths are used in volume list to prevent N+1 calls to `VolumeDriver.Path` |
| 517 | 517 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C) {
|
| 518 |
- c.Assert(s.d.Start(), checker.IsNil) |
|
| 518 |
+ s.d.Start(c) |
|
| 519 | 519 |
c.Assert(s.ec.paths, checker.Equals, 0) |
| 520 | 520 |
|
| 521 | 521 |
out, err := s.d.Cmd("volume", "create", "test", "--driver=test-external-volume-driver")
|
| ... | ... |
@@ -533,8 +527,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverPathCalls(c *check.C |
| 533 | 533 |
} |
| 534 | 534 |
|
| 535 | 535 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *check.C) {
|
| 536 |
- err := s.d.StartWithBusybox() |
|
| 537 |
- c.Assert(err, checker.IsNil) |
|
| 536 |
+ s.d.StartWithBusybox(c) |
|
| 538 | 537 |
|
| 539 | 538 |
out, err := s.d.Cmd("run", "--rm", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", volumePluginName, "busybox:latest", "cat", "/tmp/external-volume-test/test")
|
| 540 | 539 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -543,7 +536,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverMountID(c *check.C) |
| 543 | 543 |
|
| 544 | 544 |
// Check that VolumeDriver.Capabilities gets called, and only called once |
| 545 | 545 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverCapabilities(c *check.C) {
|
| 546 |
- c.Assert(s.d.Start(), checker.IsNil) |
|
| 546 |
+ s.d.Start(c) |
|
| 547 | 547 |
c.Assert(s.ec.caps, checker.Equals, 0) |
| 548 | 548 |
|
| 549 | 549 |
for i := 0; i < 3; i++ {
|
| ... | ... |
@@ -561,7 +554,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *c |
| 561 | 561 |
p := newVolumePlugin(c, driverName) |
| 562 | 562 |
defer p.Close() |
| 563 | 563 |
|
| 564 |
- c.Assert(s.d.StartWithBusybox(), checker.IsNil) |
|
| 564 |
+ s.d.StartWithBusybox(c) |
|
| 565 | 565 |
|
| 566 | 566 |
out, err := s.d.Cmd("volume", "create", "-d", driverName, "--name", "test")
|
| 567 | 567 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -606,7 +599,7 @@ func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverOutOfBandDelete(c *c |
| 606 | 606 |
} |
| 607 | 607 |
|
| 608 | 608 |
func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverUnmountOnMountFail(c *check.C) {
|
| 609 |
- c.Assert(s.d.StartWithBusybox(), checker.IsNil) |
|
| 609 |
+ s.d.StartWithBusybox(c) |
|
| 610 | 610 |
s.d.Cmd("volume", "create", "-d", "test-external-volume-driver", "--opt=invalidOption=1", "--name=testumount")
|
| 611 | 611 |
|
| 612 | 612 |
out, _ := s.d.Cmd("run", "-v", "testumount:/foo", "busybox", "true")
|
| ... | ... |
@@ -76,9 +76,8 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
|
| 76 | 76 |
}) |
| 77 | 77 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 78 | 78 |
discoveryAdvertise := "1.1.1.1:2375" |
| 79 |
- err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
|
|
| 80 |
- c.Assert(err, checker.IsNil) |
|
| 81 |
- defer d.Stop() |
|
| 79 |
+ d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
|
|
| 80 |
+ defer d.Stop(c) |
|
| 82 | 81 |
|
| 83 | 82 |
out, err := d.Cmd("info")
|
| 84 | 83 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -97,12 +96,12 @@ func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
|
| 97 | 97 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 98 | 98 |
|
| 99 | 99 |
// --cluster-advertise with an invalid string is an error |
| 100 |
- err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
|
|
| 101 |
- c.Assert(err, checker.Not(checker.IsNil)) |
|
| 100 |
+ err := d.StartWithError(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
|
|
| 101 |
+ c.Assert(err, checker.NotNil) |
|
| 102 | 102 |
|
| 103 | 103 |
// --cluster-advertise without --cluster-store is also an error |
| 104 |
- err = d.Start("--cluster-advertise=1.1.1.1:2375")
|
|
| 105 |
- c.Assert(err, checker.Not(checker.IsNil)) |
|
| 104 |
+ err = d.StartWithError("--cluster-advertise=1.1.1.1:2375")
|
|
| 105 |
+ c.Assert(err, checker.NotNil) |
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
// TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise` |
| ... | ... |
@@ -116,9 +115,8 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
|
| 116 | 116 |
discoveryBackend := "consul://consuladdr:consulport/some/path" |
| 117 | 117 |
discoveryAdvertise := "eth0" |
| 118 | 118 |
|
| 119 |
- err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
|
|
| 120 |
- c.Assert(err, checker.IsNil) |
|
| 121 |
- defer d.Stop() |
|
| 119 |
+ d.Start(c, fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
|
|
| 120 |
+ defer d.Stop(c) |
|
| 122 | 121 |
|
| 123 | 122 |
iface, err := net.InterfaceByName(discoveryAdvertise) |
| 124 | 123 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -181,9 +179,8 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
|
| 181 | 181 |
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
| 182 | 182 |
Experimental: experimentalDaemon, |
| 183 | 183 |
}) |
| 184 |
- err := d.Start("--debug")
|
|
| 185 |
- c.Assert(err, checker.IsNil) |
|
| 186 |
- defer d.Stop() |
|
| 184 |
+ d.Start(c, "--debug") |
|
| 185 |
+ defer d.Stop(c) |
|
| 187 | 186 |
|
| 188 | 187 |
out, err := d.Cmd("--debug", "info")
|
| 189 | 188 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -205,9 +202,8 @@ func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
|
| 205 | 205 |
d := daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
| 206 | 206 |
Experimental: experimentalDaemon, |
| 207 | 207 |
}) |
| 208 |
- err := d.Start("--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
|
|
| 209 |
- c.Assert(err, checker.IsNil) |
|
| 210 |
- defer d.Stop() |
|
| 208 |
+ d.Start(c, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost) |
|
| 209 |
+ defer d.Stop(c) |
|
| 211 | 210 |
|
| 212 | 211 |
out, err := d.Cmd("info")
|
| 213 | 212 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -222,8 +218,7 @@ func (s *DockerDaemonSuite) TestRegistryMirrors(c *check.C) {
|
| 222 | 222 |
registryMirror1 := "https://192.168.1.2" |
| 223 | 223 |
registryMirror2 := "http://registry.mirror.com:5000" |
| 224 | 224 |
|
| 225 |
- err := s.d.Start("--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2)
|
|
| 226 |
- c.Assert(err, checker.IsNil) |
|
| 225 |
+ s.d.Start(c, "--registry-mirror="+registryMirror1, "--registry-mirror="+registryMirror2) |
|
| 227 | 226 |
|
| 228 | 227 |
out, err := s.d.Cmd("info")
|
| 229 | 228 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -236,8 +231,7 @@ func (s *DockerDaemonSuite) TestRegistryMirrors(c *check.C) {
|
| 236 | 236 |
func (s *DockerDaemonSuite) TestInfoLabels(c *check.C) {
|
| 237 | 237 |
testRequires(c, SameHostDaemon, DaemonIsLinux) |
| 238 | 238 |
|
| 239 |
- err := s.d.Start("--label", `test.empty=`, "--label", `test.empty=`, "--label", `test.label="1"`, "--label", `test.label="2"`)
|
|
| 240 |
- c.Assert(err, checker.IsNil) |
|
| 239 |
+ s.d.Start(c, "--label", `test.empty=`, "--label", `test.empty=`, "--label", `test.label="1"`, "--label", `test.label="2"`) |
|
| 241 | 240 |
|
| 242 | 241 |
out, err := s.d.Cmd("info")
|
| 243 | 242 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -55,7 +55,7 @@ func (s *DockerNetworkSuite) SetUpTest(c *check.C) {
|
| 55 | 55 |
|
| 56 | 56 |
func (s *DockerNetworkSuite) TearDownTest(c *check.C) {
|
| 57 | 57 |
if s.d != nil {
|
| 58 |
- s.d.Stop() |
|
| 58 |
+ s.d.Stop(c) |
|
| 59 | 59 |
s.ds.TearDownTest(c) |
| 60 | 60 |
} |
| 61 | 61 |
} |
| ... | ... |
@@ -807,9 +807,8 @@ func (s *DockerDaemonSuite) TestDockerNetworkNoDiscoveryDefaultBridgeNetwork(c * |
| 807 | 807 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 808 | 808 |
defer deleteInterface(c, bridgeName) |
| 809 | 809 |
|
| 810 |
- err = s.d.StartWithBusybox("--bridge", bridgeName)
|
|
| 811 |
- c.Assert(err, check.IsNil) |
|
| 812 |
- defer s.d.Restart() |
|
| 810 |
+ s.d.StartWithBusybox(c, "--bridge", bridgeName) |
|
| 811 |
+ defer s.d.Restart(c) |
|
| 813 | 812 |
|
| 814 | 813 |
// run two containers and store first container's etc/hosts content |
| 815 | 814 |
out, err = s.d.Cmd("run", "-d", "busybox", "top")
|
| ... | ... |
@@ -989,7 +988,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C |
| 989 | 989 |
server := httptest.NewServer(mux) |
| 990 | 990 |
setupRemoteNetworkDrivers(c, mux, server.URL, dnd, did) |
| 991 | 991 |
|
| 992 |
- s.d.StartWithBusybox() |
|
| 992 |
+ s.d.StartWithBusybox(c) |
|
| 993 | 993 |
_, err := s.d.Cmd("network", "create", "-d", dnd, "--subnet", "1.1.1.0/24", "net1")
|
| 994 | 994 |
c.Assert(err, checker.IsNil) |
| 995 | 995 |
|
| ... | ... |
@@ -1002,9 +1001,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkDriverUngracefulRestart(c *check.C |
| 1002 | 1002 |
server.Close() |
| 1003 | 1003 |
|
| 1004 | 1004 |
startTime := time.Now().Unix() |
| 1005 |
- if err = s.d.Restart(); err != nil {
|
|
| 1006 |
- c.Fatal(err) |
|
| 1007 |
- } |
|
| 1005 |
+ s.d.Restart(c) |
|
| 1008 | 1006 |
lapse := time.Now().Unix() - startTime |
| 1009 | 1007 |
if lapse > 60 {
|
| 1010 | 1008 |
// In normal scenarios, daemon restart takes ~1 second. |
| ... | ... |
@@ -1092,13 +1089,13 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksGracefulDaemonRest |
| 1092 | 1092 |
cName := "bb" |
| 1093 | 1093 |
nwList := []string{"nw1", "nw2", "nw3"}
|
| 1094 | 1094 |
|
| 1095 |
- s.d.StartWithBusybox() |
|
| 1095 |
+ s.d.StartWithBusybox(c) |
|
| 1096 | 1096 |
|
| 1097 | 1097 |
connectContainerToNetworks(c, s.d, cName, nwList) |
| 1098 | 1098 |
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList) |
| 1099 | 1099 |
|
| 1100 | 1100 |
// Reload daemon |
| 1101 |
- s.d.Restart() |
|
| 1101 |
+ s.d.Restart(c) |
|
| 1102 | 1102 |
|
| 1103 | 1103 |
_, err := s.d.Cmd("start", cName)
|
| 1104 | 1104 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -1110,14 +1107,14 @@ func (s *DockerNetworkSuite) TestDockerNetworkMultipleNetworksUngracefulDaemonRe |
| 1110 | 1110 |
cName := "cc" |
| 1111 | 1111 |
nwList := []string{"nw1", "nw2", "nw3"}
|
| 1112 | 1112 |
|
| 1113 |
- s.d.StartWithBusybox() |
|
| 1113 |
+ s.d.StartWithBusybox(c) |
|
| 1114 | 1114 |
|
| 1115 | 1115 |
connectContainerToNetworks(c, s.d, cName, nwList) |
| 1116 | 1116 |
verifyContainerIsConnectedToNetworks(c, s.d, cName, nwList) |
| 1117 | 1117 |
|
| 1118 | 1118 |
// Kill daemon and restart |
| 1119 | 1119 |
c.Assert(s.d.Kill(), checker.IsNil) |
| 1120 |
- c.Assert(s.d.Restart(), checker.IsNil) |
|
| 1120 |
+ s.d.Restart(c) |
|
| 1121 | 1121 |
|
| 1122 | 1122 |
// Restart container |
| 1123 | 1123 |
_, err := s.d.Cmd("start", cName)
|
| ... | ... |
@@ -1134,7 +1131,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkRunNetByID(c *check.C) {
|
| 1134 | 1134 |
|
| 1135 | 1135 |
func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c *check.C) {
|
| 1136 | 1136 |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
| 1137 |
- s.d.StartWithBusybox() |
|
| 1137 |
+ s.d.StartWithBusybox(c) |
|
| 1138 | 1138 |
|
| 1139 | 1139 |
// Run a few containers on host network |
| 1140 | 1140 |
for i := 0; i < 10; i++ {
|
| ... | ... |
@@ -1149,7 +1146,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkHostModeUngracefulDaemonRestart(c |
| 1149 | 1149 |
|
| 1150 | 1150 |
// Kill daemon ungracefully and restart |
| 1151 | 1151 |
c.Assert(s.d.Kill(), checker.IsNil) |
| 1152 |
- c.Assert(s.d.Restart(), checker.IsNil) |
|
| 1152 |
+ s.d.Restart(c) |
|
| 1153 | 1153 |
|
| 1154 | 1154 |
// make sure all the containers are up and running |
| 1155 | 1155 |
for i := 0; i < 10; i++ {
|
| ... | ... |
@@ -1266,7 +1263,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine |
| 1266 | 1266 |
c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
| 1267 | 1267 |
|
| 1268 | 1268 |
// Restart docker daemon to test the config has persisted to disk |
| 1269 |
- s.d.Restart() |
|
| 1269 |
+ s.d.Restart(c) |
|
| 1270 | 1270 |
networks = inspectField(c, "foo", "NetworkSettings.Networks") |
| 1271 | 1271 |
c.Assert(networks, checker.Contains, "test", check.Commentf("Should contain 'test' network"))
|
| 1272 | 1272 |
|
| ... | ... |
@@ -1285,7 +1282,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectDisconnectToStoppedContaine |
| 1285 | 1285 |
c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
|
| 1286 | 1286 |
|
| 1287 | 1287 |
// Restart docker daemon to test the config has persisted to disk |
| 1288 |
- s.d.Restart() |
|
| 1288 |
+ s.d.Restart(c) |
|
| 1289 | 1289 |
networks = inspectField(c, "foo", "NetworkSettings.Networks") |
| 1290 | 1290 |
c.Assert(networks, checker.Not(checker.Contains), "test", check.Commentf("Should not contain 'test' network"))
|
| 1291 | 1291 |
|
| ... | ... |
@@ -1666,10 +1663,8 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateDeleteSpecialCharacters(c *c |
| 1666 | 1666 |
|
| 1667 | 1667 |
func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
|
| 1668 | 1668 |
testRequires(t, DaemonIsLinux) |
| 1669 |
- if err := s.d.StartWithBusybox("--live-restore"); err != nil {
|
|
| 1670 |
- t.Fatal(err) |
|
| 1671 |
- } |
|
| 1672 |
- defer s.d.Stop() |
|
| 1669 |
+ s.d.StartWithBusybox(t, "--live-restore") |
|
| 1670 |
+ defer s.d.Stop(t) |
|
| 1673 | 1671 |
oldCon := "old" |
| 1674 | 1672 |
|
| 1675 | 1673 |
_, err := s.d.Cmd("run", "-d", "--name", oldCon, "-p", "80:80", "busybox", "top")
|
| ... | ... |
@@ -1686,9 +1681,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartRestoreBridgeNetwork(t *check.C) {
|
| 1686 | 1686 |
} |
| 1687 | 1687 |
|
| 1688 | 1688 |
// restart the daemon |
| 1689 |
- if err := s.d.Start("--live-restore"); err != nil {
|
|
| 1690 |
- t.Fatal(err) |
|
| 1691 |
- } |
|
| 1689 |
+ s.d.Start(t, "--live-restore") |
|
| 1692 | 1690 |
|
| 1693 | 1691 |
// start a new container, the new container's ip should not be the same with |
| 1694 | 1692 |
// old running container. |
| ... | ... |
@@ -40,8 +40,7 @@ func (s *DockerDaemonSuite) TestCLIProxyProxyTCPSock(c *check.C) {
|
| 40 | 40 |
|
| 41 | 41 |
c.Assert(ip, checker.Not(checker.Equals), "") |
| 42 | 42 |
|
| 43 |
- err = s.d.Start("-H", "tcp://"+ip+":2375")
|
|
| 44 |
- c.Assert(err, checker.IsNil) |
|
| 43 |
+ s.d.Start(c, "-H", "tcp://"+ip+":2375") |
|
| 45 | 44 |
cmd := exec.Command(dockerBinary, "info") |
| 46 | 45 |
cmd.Env = []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"}
|
| 47 | 46 |
out, _, err := runCommandWithOutput(cmd) |
| ... | ... |
@@ -62,7 +62,7 @@ func (s *DockerSwarmSuite) TestPruneNetwork(c *check.C) {
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
func (s *DockerDaemonSuite) TestPruneImageDangling(c *check.C) {
|
| 65 |
- c.Assert(s.d.StartWithBusybox(), checker.IsNil) |
|
| 65 |
+ s.d.StartWithBusybox(c) |
|
| 66 | 66 |
|
| 67 | 67 |
out, _, err := s.d.BuildImageWithOut("test",
|
| 68 | 68 |
`FROM busybox |
| ... | ... |
@@ -89,13 +89,12 @@ func (s *DockerRegistrySuite) TestUserAgentPassThrough(c *check.C) {
|
| 89 | 89 |
c.Assert(err, check.IsNil) |
| 90 | 90 |
registerUserAgentHandler(loginReg, &loginUA) |
| 91 | 91 |
|
| 92 |
- err = s.d.Start( |
|
| 92 |
+ s.d.Start(c, |
|
| 93 | 93 |
"--insecure-registry", buildReg.hostport, |
| 94 | 94 |
"--insecure-registry", pullReg.hostport, |
| 95 | 95 |
"--insecure-registry", pushReg.hostport, |
| 96 | 96 |
"--insecure-registry", loginReg.hostport, |
| 97 | 97 |
"--disable-legacy-registry=true") |
| 98 |
- c.Assert(err, check.IsNil) |
|
| 99 | 98 |
|
| 100 | 99 |
dockerfileName, cleanup1, err := makefile(fmt.Sprintf("FROM %s", buildRepoName))
|
| 101 | 100 |
c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
|
| ... | ... |
@@ -4434,7 +4434,7 @@ exec "$@"`, |
| 4434 | 4434 |
} |
| 4435 | 4435 |
|
| 4436 | 4436 |
func (s *DockerDaemonSuite) TestRunWithUlimitAndDaemonDefault(c *check.C) {
|
| 4437 |
- c.Assert(s.d.StartWithBusybox("--debug", "--default-ulimit=nofile=65535"), checker.IsNil)
|
|
| 4437 |
+ s.d.StartWithBusybox(c, "--debug", "--default-ulimit=nofile=65535") |
|
| 4438 | 4438 |
|
| 4439 | 4439 |
name := "test-A" |
| 4440 | 4440 |
_, err := s.d.Cmd("run", "--name", name, "-d", "busybox", "top")
|
| ... | ... |
@@ -1449,8 +1449,7 @@ func (s *DockerSuite) TestRunUserDeviceAllowed(c *check.C) {
|
| 1449 | 1449 |
func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *check.C) {
|
| 1450 | 1450 |
testRequires(c, SameHostDaemon, seccompEnabled) |
| 1451 | 1451 |
|
| 1452 |
- err := s.d.StartWithBusybox() |
|
| 1453 |
- c.Assert(err, check.IsNil) |
|
| 1452 |
+ s.d.StartWithBusybox(c) |
|
| 1454 | 1453 |
|
| 1455 | 1454 |
jsonData := `{
|
| 1456 | 1455 |
"defaultAction": "SCMP_ACT_ALLOW", |
| ... | ... |
@@ -1475,8 +1474,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNewFormat(c *check.C) {
|
| 1475 | 1475 |
func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *check.C) {
|
| 1476 | 1476 |
testRequires(c, SameHostDaemon, seccompEnabled) |
| 1477 | 1477 |
|
| 1478 |
- err := s.d.StartWithBusybox() |
|
| 1479 |
- c.Assert(err, check.IsNil) |
|
| 1478 |
+ s.d.StartWithBusybox(c) |
|
| 1480 | 1479 |
|
| 1481 | 1480 |
jsonData := `{
|
| 1482 | 1481 |
"defaultAction": "SCMP_ACT_ALLOW", |
| ... | ... |
@@ -1502,8 +1500,7 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoNameAndNames(c *check.C) {
|
| 1502 | 1502 |
func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *check.C) {
|
| 1503 | 1503 |
testRequires(c, SameHostDaemon, seccompEnabled) |
| 1504 | 1504 |
|
| 1505 |
- err := s.d.StartWithBusybox() |
|
| 1506 |
- c.Assert(err, check.IsNil) |
|
| 1505 |
+ s.d.StartWithBusybox(c) |
|
| 1507 | 1506 |
|
| 1508 | 1507 |
jsonData := `{
|
| 1509 | 1508 |
"archMap": [ |
| ... | ... |
@@ -1540,11 +1537,10 @@ func (s *DockerDaemonSuite) TestRunSeccompJSONNoArchAndArchMap(c *check.C) {
|
| 1540 | 1540 |
func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *check.C) {
|
| 1541 | 1541 |
testRequires(c, SameHostDaemon, seccompEnabled) |
| 1542 | 1542 |
|
| 1543 |
- err := s.d.StartWithBusybox() |
|
| 1544 |
- c.Assert(err, check.IsNil) |
|
| 1543 |
+ s.d.StartWithBusybox(c) |
|
| 1545 | 1544 |
|
| 1546 | 1545 |
// 1) verify I can run containers with the Docker default shipped profile which allows chmod |
| 1547 |
- _, err = s.d.Cmd("run", "busybox", "chmod", "777", ".")
|
|
| 1546 |
+ _, err := s.d.Cmd("run", "busybox", "chmod", "777", ".")
|
|
| 1548 | 1547 |
c.Assert(err, check.IsNil) |
| 1549 | 1548 |
|
| 1550 | 1549 |
jsonData := `{
|
| ... | ... |
@@ -1563,8 +1559,7 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *check.C) {
|
| 1563 | 1563 |
c.Assert(err, check.IsNil) |
| 1564 | 1564 |
|
| 1565 | 1565 |
// 2) restart the daemon and add a custom seccomp profile in which we deny chmod |
| 1566 |
- err = s.d.Restart("--seccomp-profile=" + tmpFile.Name())
|
|
| 1567 |
- c.Assert(err, check.IsNil) |
|
| 1566 |
+ s.d.Restart(c, "--seccomp-profile="+tmpFile.Name()) |
|
| 1568 | 1567 |
|
| 1569 | 1568 |
out, err := s.d.Cmd("run", "busybox", "chmod", "777", ".")
|
| 1570 | 1569 |
c.Assert(err, check.NotNil) |
| ... | ... |
@@ -100,23 +100,23 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *check.C) {
|
| 100 | 100 |
info, err := d.SwarmInfo() |
| 101 | 101 |
c.Assert(err, checker.IsNil) |
| 102 | 102 |
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateActive) |
| 103 |
- c.Assert(d.Stop(), checker.IsNil) |
|
| 103 |
+ d.Stop(c) |
|
| 104 | 104 |
|
| 105 | 105 |
// start a daemon with --cluster-store and --cluster-advertise |
| 106 |
- err = d.Start("--cluster-store=consul://consuladdr:consulport/some/path", "--cluster-advertise=1.1.1.1:2375")
|
|
| 106 |
+ err = d.StartWithError("--cluster-store=consul://consuladdr:consulport/some/path", "--cluster-advertise=1.1.1.1:2375")
|
|
| 107 | 107 |
c.Assert(err, checker.NotNil) |
| 108 | 108 |
content, err := d.ReadLogFile() |
| 109 | 109 |
c.Assert(err, checker.IsNil) |
| 110 | 110 |
c.Assert(string(content), checker.Contains, "--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode") |
| 111 | 111 |
|
| 112 | 112 |
// start a daemon with --live-restore |
| 113 |
- err = d.Start("--live-restore")
|
|
| 113 |
+ err = d.StartWithError("--live-restore")
|
|
| 114 | 114 |
c.Assert(err, checker.NotNil) |
| 115 | 115 |
content, err = d.ReadLogFile() |
| 116 | 116 |
c.Assert(err, checker.IsNil) |
| 117 | 117 |
c.Assert(string(content), checker.Contains, "--live-restore daemon configuration is incompatible with swarm mode") |
| 118 | 118 |
// restart for teardown |
| 119 |
- c.Assert(d.Start(), checker.IsNil) |
|
| 119 |
+ d.Start(c) |
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 | 122 |
// Test case for #24090 |
| ... | ... |
@@ -291,7 +291,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAutoStart(c *check.C) {
|
| 291 | 291 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| 292 | 292 |
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") |
| 293 | 293 |
|
| 294 |
- d.Restart() |
|
| 294 |
+ d.Restart(c) |
|
| 295 | 295 |
|
| 296 | 296 |
out, err = d.Cmd("ps", "-q")
|
| 297 | 297 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| ... | ... |
@@ -806,7 +806,7 @@ func getNodeStatus(c *check.C, d *daemon.Swarm) swarm.LocalNodeState {
|
| 806 | 806 |
} |
| 807 | 807 |
|
| 808 | 808 |
func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Swarm, unlockKey string) {
|
| 809 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 809 |
+ d.Restart(c) |
|
| 810 | 810 |
status := getNodeStatus(c, d) |
| 811 | 811 |
if status == swarm.LocalNodeStateLocked {
|
| 812 | 812 |
// it must not have updated to be unlocked in time - unlock, wait 3 seconds, and try again |
| ... | ... |
@@ -818,19 +818,19 @@ func checkSwarmLockedToUnlocked(c *check.C, d *daemon.Swarm, unlockKey string) {
|
| 818 | 818 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive) |
| 819 | 819 |
|
| 820 | 820 |
time.Sleep(3 * time.Second) |
| 821 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 821 |
+ d.Restart(c) |
|
| 822 | 822 |
} |
| 823 | 823 |
|
| 824 | 824 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive) |
| 825 | 825 |
} |
| 826 | 826 |
|
| 827 | 827 |
func checkSwarmUnlockedToLocked(c *check.C, d *daemon.Swarm) {
|
| 828 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 828 |
+ d.Restart(c) |
|
| 829 | 829 |
status := getNodeStatus(c, d) |
| 830 | 830 |
if status == swarm.LocalNodeStateActive {
|
| 831 | 831 |
// it must not have updated to be unlocked in time - wait 3 seconds, and try again |
| 832 | 832 |
time.Sleep(3 * time.Second) |
| 833 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 833 |
+ d.Restart(c) |
|
| 834 | 834 |
} |
| 835 | 835 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked) |
| 836 | 836 |
} |
| ... | ... |
@@ -859,7 +859,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) {
|
| 859 | 859 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive) |
| 860 | 860 |
|
| 861 | 861 |
// It starts off locked |
| 862 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 862 |
+ d.Restart(c) |
|
| 863 | 863 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked) |
| 864 | 864 |
|
| 865 | 865 |
cmd := d.Command("swarm", "unlock")
|
| ... | ... |
@@ -898,7 +898,7 @@ func (s *DockerSwarmSuite) TestSwarmLeaveLocked(c *check.C) {
|
| 898 | 898 |
c.Assert(err, checker.IsNil, check.Commentf("out: %v", outs))
|
| 899 | 899 |
|
| 900 | 900 |
// It starts off locked |
| 901 |
- c.Assert(d.Restart("--swarm-default-advertise-addr=lo"), checker.IsNil)
|
|
| 901 |
+ d.Restart(c, "--swarm-default-advertise-addr=lo") |
|
| 902 | 902 |
|
| 903 | 903 |
info, err := d.SwarmInfo() |
| 904 | 904 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -933,11 +933,11 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) {
|
| 933 | 933 |
d3 := s.AddDaemon(c, true, true) |
| 934 | 934 |
|
| 935 | 935 |
// they start off unlocked |
| 936 |
- c.Assert(d2.Restart(), checker.IsNil) |
|
| 936 |
+ d2.Restart(c) |
|
| 937 | 937 |
c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive) |
| 938 | 938 |
|
| 939 | 939 |
// stop this one so it does not get autolock info |
| 940 |
- c.Assert(d2.Stop(), checker.IsNil) |
|
| 940 |
+ d2.Stop(c) |
|
| 941 | 941 |
|
| 942 | 942 |
// enable autolock |
| 943 | 943 |
outs, err := d1.Cmd("swarm", "update", "--autolock")
|
| ... | ... |
@@ -970,7 +970,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) {
|
| 970 | 970 |
} |
| 971 | 971 |
|
| 972 | 972 |
// d2 never got the cluster update, so it is still set to unlocked |
| 973 |
- c.Assert(d2.Start(), checker.IsNil) |
|
| 973 |
+ d2.Start(c) |
|
| 974 | 974 |
c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive) |
| 975 | 975 |
|
| 976 | 976 |
// d2 is now set to lock |
| ... | ... |
@@ -1000,7 +1000,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) {
|
| 1000 | 1000 |
|
| 1001 | 1001 |
// managers who join now are never set to locked in the first place |
| 1002 | 1002 |
d4 := s.AddDaemon(c, true, true) |
| 1003 |
- c.Assert(d4.Restart(), checker.IsNil) |
|
| 1003 |
+ d4.Restart(c) |
|
| 1004 | 1004 |
c.Assert(getNodeStatus(c, d4), checker.Equals, swarm.LocalNodeStateActive) |
| 1005 | 1005 |
} |
| 1006 | 1006 |
|
| ... | ... |
@@ -1028,7 +1028,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
|
| 1028 | 1028 |
|
| 1029 | 1029 |
// joined workers start off unlocked |
| 1030 | 1030 |
d2 := s.AddDaemon(c, true, false) |
| 1031 |
- c.Assert(d2.Restart(), checker.IsNil) |
|
| 1031 |
+ d2.Restart(c) |
|
| 1032 | 1032 |
c.Assert(getNodeStatus(c, d2), checker.Equals, swarm.LocalNodeStateActive) |
| 1033 | 1033 |
|
| 1034 | 1034 |
// promote worker |
| ... | ... |
@@ -1074,7 +1074,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
|
| 1074 | 1074 |
}, checker.Not(checker.Equals), string(d3cert)) |
| 1075 | 1075 |
|
| 1076 | 1076 |
// by now, it should *never* be locked on restart |
| 1077 |
- c.Assert(d3.Restart(), checker.IsNil) |
|
| 1077 |
+ d3.Restart(c) |
|
| 1078 | 1078 |
c.Assert(getNodeStatus(c, d3), checker.Equals, swarm.LocalNodeStateActive) |
| 1079 | 1079 |
} |
| 1080 | 1080 |
|
| ... | ... |
@@ -1108,7 +1108,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
|
| 1108 | 1108 |
c.Assert(newUnlockKey, checker.Not(checker.Equals), "") |
| 1109 | 1109 |
c.Assert(newUnlockKey, checker.Not(checker.Equals), unlockKey) |
| 1110 | 1110 |
|
| 1111 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 1111 |
+ d.Restart(c) |
|
| 1112 | 1112 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked) |
| 1113 | 1113 |
|
| 1114 | 1114 |
outs, _ = d.Cmd("node", "ls")
|
| ... | ... |
@@ -1129,7 +1129,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
|
| 1129 | 1129 |
|
| 1130 | 1130 |
time.Sleep(3 * time.Second) |
| 1131 | 1131 |
|
| 1132 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 1132 |
+ d.Restart(c) |
|
| 1133 | 1133 |
|
| 1134 | 1134 |
cmd = d.Command("swarm", "unlock")
|
| 1135 | 1135 |
cmd.Stdin = bytes.NewBufferString(unlockKey) |
| ... | ... |
@@ -1191,8 +1191,8 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
|
| 1191 | 1191 |
c.Assert(newUnlockKey, checker.Not(checker.Equals), "") |
| 1192 | 1192 |
c.Assert(newUnlockKey, checker.Not(checker.Equals), unlockKey) |
| 1193 | 1193 |
|
| 1194 |
- c.Assert(d2.Restart(), checker.IsNil) |
|
| 1195 |
- c.Assert(d3.Restart(), checker.IsNil) |
|
| 1194 |
+ d2.Restart(c) |
|
| 1195 |
+ d3.Restart(c) |
|
| 1196 | 1196 |
|
| 1197 | 1197 |
for _, d := range []*daemon.Swarm{d2, d3} {
|
| 1198 | 1198 |
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateLocked) |
| ... | ... |
@@ -1215,7 +1215,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
|
| 1215 | 1215 |
|
| 1216 | 1216 |
time.Sleep(3 * time.Second) |
| 1217 | 1217 |
|
| 1218 |
- c.Assert(d.Restart(), checker.IsNil) |
|
| 1218 |
+ d.Restart(c) |
|
| 1219 | 1219 |
|
| 1220 | 1220 |
cmd = d.Command("swarm", "unlock")
|
| 1221 | 1221 |
cmd.Stdin = bytes.NewBufferString(unlockKey) |
| ... | ... |
@@ -24,7 +24,7 @@ import ( |
| 24 | 24 |
func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
|
| 25 | 25 |
testRequires(c, DaemonIsLinux, SameHostDaemon, UserNamespaceInKernel) |
| 26 | 26 |
|
| 27 |
- c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), checker.IsNil)
|
|
| 27 |
+ s.d.StartWithBusybox(c, "--userns-remap", "default") |
|
| 28 | 28 |
|
| 29 | 29 |
tmpDir, err := ioutil.TempDir("", "userns")
|
| 30 | 30 |
c.Assert(err, checker.IsNil) |
| ... | ... |
@@ -49,8 +49,7 @@ func (s *DockerRegistrySuite) TestV2Only(c *check.C) {
|
| 49 | 49 |
|
| 50 | 50 |
repoName := fmt.Sprintf("%s/busybox", reg.hostport)
|
| 51 | 51 |
|
| 52 |
- err = s.d.Start("--insecure-registry", reg.hostport, "--disable-legacy-registry=true")
|
|
| 53 |
- c.Assert(err, check.IsNil) |
|
| 52 |
+ s.d.Start(c, "--insecure-registry", reg.hostport, "--disable-legacy-registry=true") |
|
| 54 | 53 |
|
| 55 | 54 |
dockerfileName, cleanup, err := makefile(fmt.Sprintf("FROM %s/busybox", reg.hostport))
|
| 56 | 55 |
c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
|
| ... | ... |
@@ -98,8 +97,7 @@ func (s *DockerRegistrySuite) TestV1(c *check.C) {
|
| 98 | 98 |
v1Repo++ |
| 99 | 99 |
}) |
| 100 | 100 |
|
| 101 |
- err = s.d.Start("--insecure-registry", reg.hostport, "--disable-legacy-registry=false")
|
|
| 102 |
- c.Assert(err, check.IsNil) |
|
| 101 |
+ s.d.Start(c, "--insecure-registry", reg.hostport, "--disable-legacy-registry=false") |
|
| 103 | 102 |
|
| 104 | 103 |
dockerfileName, cleanup, err := makefile(fmt.Sprintf("FROM %s/busybox", reg.hostport))
|
| 105 | 104 |
c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
|
| ... | ... |
@@ -61,7 +61,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkMacvlanPersistance(c *check.C) {
|
| 61 | 61 |
dockerCmd(c, "network", "create", "--driver=macvlan", "-o", "parent=dm-dummy0.60", "dm-persist") |
| 62 | 62 |
assertNwIsAvailable(c, "dm-persist") |
| 63 | 63 |
// Restart docker daemon to test the config has persisted to disk |
| 64 |
- s.d.Restart() |
|
| 64 |
+ s.d.Restart(c) |
|
| 65 | 65 |
// verify network is recreated from persistence |
| 66 | 66 |
assertNwIsAvailable(c, "dm-persist") |
| 67 | 67 |
// cleanup the master interface that also collects the slave dev |
| ... | ... |
@@ -80,7 +80,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIpvlanPersistance(c *check.C) {
|
| 80 | 80 |
dockerCmd(c, "network", "create", "--driver=ipvlan", "-o", "parent=di-dummy0.70", "di-persist") |
| 81 | 81 |
assertNwIsAvailable(c, "di-persist") |
| 82 | 82 |
// Restart docker daemon to test the config has persisted to disk |
| 83 |
- s.d.Restart() |
|
| 83 |
+ s.d.Restart(c) |
|
| 84 | 84 |
// verify network is recreated from persistence |
| 85 | 85 |
assertNwIsAvailable(c, "di-persist") |
| 86 | 86 |
// cleanup the master interface that also collects the slave dev |
| ... | ... |
@@ -43,15 +43,13 @@ func (s *DockerHubPullSuite) SetUpSuite(c *check.C) {
|
| 43 | 43 |
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
| 44 | 44 |
Experimental: experimentalDaemon, |
| 45 | 45 |
}) |
| 46 |
- err := s.d.Start() |
|
| 47 |
- c.Assert(err, checker.IsNil, check.Commentf("starting push/pull test daemon: %v", err))
|
|
| 46 |
+ s.d.Start(c) |
|
| 48 | 47 |
} |
| 49 | 48 |
|
| 50 | 49 |
// TearDownSuite stops the suite daemon. |
| 51 | 50 |
func (s *DockerHubPullSuite) TearDownSuite(c *check.C) {
|
| 52 | 51 |
if s.d != nil {
|
| 53 |
- err := s.d.Stop() |
|
| 54 |
- c.Assert(err, checker.IsNil, check.Commentf("stopping push/pull test daemon: %v", err))
|
|
| 52 |
+ s.d.Stop(c) |
|
| 55 | 53 |
} |
| 56 | 54 |
} |
| 57 | 55 |
|