mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	rm-gocheck: check.CommentInterface -> string
sed -E -i 's#(\*testing\.T\b.*)check\.CommentInterface\b#\1string#g' \ -- "integration-cli/daemon/daemon.go" "integration-cli/daemon/daemon_swarm.go" "integration-cli/docker_api_exec_test.go" "integration-cli/docker_api_swarm_service_test.go" "integration-cli/docker_api_swarm_test.go" "integration-cli/docker_cli_daemon_test.go" "integration-cli/docker_cli_prune_unix_test.go" "integration-cli/docker_cli_restart_test.go" "integration-cli/docker_cli_service_create_test.go" "integration-cli/docker_cli_service_health_test.go" "integration-cli/docker_cli_service_logs_test.go" "integration-cli/docker_cli_swarm_test.go" "integration-cli/docker_utils_test.go" Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
		
							parent
							
								
									6e5cf532af
								
							
						
					
					
						commit
						3a24472c8e
					
				
					 13 changed files with 64 additions and 64 deletions
				
			
		| 
						 | 
				
			
			@ -89,7 +89,7 @@ func (d *Daemon) inspectFieldWithError(name, field string) (string, error) {
 | 
			
		|||
 | 
			
		||||
// CheckActiveContainerCount returns the number of active containers
 | 
			
		||||
// FIXME(vdemeester) should re-use ActivateContainers in some way
 | 
			
		||||
func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, string) {
 | 
			
		||||
	out, err := d.Cmd("ps", "-q")
 | 
			
		||||
	assert.NilError(c, err)
 | 
			
		||||
	if len(strings.TrimSpace(out)) == 0 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,8 +16,8 @@ import (
 | 
			
		|||
 | 
			
		||||
// CheckServiceTasksInState returns the number of tasks with a matching state,
 | 
			
		||||
// and optional message substring.
 | 
			
		||||
func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks := d.GetServiceTasks(c, service)
 | 
			
		||||
		var count int
 | 
			
		||||
		for _, task := range tasks {
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +33,8 @@ func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState,
 | 
			
		|||
 | 
			
		||||
// CheckServiceTasksInStateWithError returns the number of tasks with a matching state,
 | 
			
		||||
// and optional message substring.
 | 
			
		||||
func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.TaskState, errorMessage string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks := d.GetServiceTasks(c, service)
 | 
			
		||||
		var count int
 | 
			
		||||
		for _, task := range tasks {
 | 
			
		||||
| 
						 | 
				
			
			@ -49,13 +49,13 @@ func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.T
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckServiceRunningTasks returns the number of running tasks for the specified service
 | 
			
		||||
func (d *Daemon) CheckServiceRunningTasks(service string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckServiceRunningTasks(service string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return d.CheckServiceTasksInState(service, swarm.TaskStateRunning, "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckServiceUpdateState returns the current update state for the specified service
 | 
			
		||||
func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		service := d.GetService(c, service)
 | 
			
		||||
		if service.UpdateStatus == nil {
 | 
			
		||||
			return "", nil
 | 
			
		||||
| 
						 | 
				
			
			@ -65,8 +65,8 @@ func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (inter
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckPluginRunning returns the runtime state of the plugin
 | 
			
		||||
func (d *Daemon) CheckPluginRunning(plugin string) func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckPluginRunning(plugin string) func(c *testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		apiclient := d.NewClientT(c)
 | 
			
		||||
		resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
 | 
			
		||||
		if client.IsErrNotFound(err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -78,8 +78,8 @@ func (d *Daemon) CheckPluginRunning(plugin string) func(c *testing.T) (interface
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckPluginImage returns the runtime state of the plugin
 | 
			
		||||
func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		apiclient := d.NewClientT(c)
 | 
			
		||||
		resp, _, err := apiclient.PluginInspectWithRaw(context.Background(), plugin)
 | 
			
		||||
		if client.IsErrNotFound(err) {
 | 
			
		||||
| 
						 | 
				
			
			@ -91,15 +91,15 @@ func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckServiceTasks returns the number of tasks for the specified service
 | 
			
		||||
func (d *Daemon) CheckServiceTasks(service string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckServiceTasks(service string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks := d.GetServiceTasks(c, service)
 | 
			
		||||
		return len(tasks), nil
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckRunningTaskNetworks returns the number of times each network is referenced from a task.
 | 
			
		||||
func (d *Daemon) CheckRunningTaskNetworks(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckRunningTaskNetworks(c *testing.T) (interface{}, string) {
 | 
			
		||||
	cli := d.NewClientT(c)
 | 
			
		||||
	defer cli.Close()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +123,7 @@ func (d *Daemon) CheckRunningTaskNetworks(c *testing.T) (interface{}, check.Comm
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckRunningTaskImages returns the times each image is running as a task.
 | 
			
		||||
func (d *Daemon) CheckRunningTaskImages(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckRunningTaskImages(c *testing.T) (interface{}, string) {
 | 
			
		||||
	cli := d.NewClientT(c)
 | 
			
		||||
	defer cli.Close()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ func (d *Daemon) CheckRunningTaskImages(c *testing.T) (interface{}, check.Commen
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckNodeReadyCount returns the number of ready node on the swarm
 | 
			
		||||
func (d *Daemon) CheckNodeReadyCount(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckNodeReadyCount(c *testing.T) (interface{}, string) {
 | 
			
		||||
	nodes := d.ListNodes(c)
 | 
			
		||||
	var readyCount int
 | 
			
		||||
	for _, node := range nodes {
 | 
			
		||||
| 
						 | 
				
			
			@ -159,20 +159,20 @@ func (d *Daemon) CheckNodeReadyCount(c *testing.T) (interface{}, check.CommentIn
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// CheckLocalNodeState returns the current swarm node state
 | 
			
		||||
func (d *Daemon) CheckLocalNodeState(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckLocalNodeState(c *testing.T) (interface{}, string) {
 | 
			
		||||
	info := d.SwarmInfo(c)
 | 
			
		||||
	return info.LocalNodeState, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckControlAvailable returns the current swarm control available
 | 
			
		||||
func (d *Daemon) CheckControlAvailable(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckControlAvailable(c *testing.T) (interface{}, string) {
 | 
			
		||||
	info := d.SwarmInfo(c)
 | 
			
		||||
	assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
 | 
			
		||||
	return info.ControlAvailable, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckLeader returns whether there is a leader on the swarm or not
 | 
			
		||||
func (d *Daemon) CheckLeader(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func (d *Daemon) CheckLeader(c *testing.T) (interface{}, string) {
 | 
			
		||||
	cli := d.NewClientT(c)
 | 
			
		||||
	defer cli.Close()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -216,7 +216,7 @@ func (s *DockerSuite) TestExecStateCleanup(c *testing.T) {
 | 
			
		|||
 | 
			
		||||
	stateDir := "/var/run/docker/containerd/" + cid
 | 
			
		||||
 | 
			
		||||
	checkReadDir := func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	checkReadDir := func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		fi, err := ioutil.ReadDir(stateDir)
 | 
			
		||||
		assert.NilError(c, err)
 | 
			
		||||
		return len(fi), nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -224,7 +224,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *testing.T) {
 | 
			
		|||
 | 
			
		||||
	checkStartingTasks := func(expected int) []swarm.Task {
 | 
			
		||||
		var startingTasks []swarm.Task
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
			tasks := d.GetServiceTasks(c, id)
 | 
			
		||||
			startingTasks = nil
 | 
			
		||||
			for _, t := range tasks {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -223,7 +223,7 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *testing.T) {
 | 
			
		|||
	// back to manager quickly might cause the node to pause for awhile
 | 
			
		||||
	// while waiting for the role to change to worker, and the test can
 | 
			
		||||
	// time out during this interval.
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		certBytes, err := ioutil.ReadFile(filepath.Join(d2.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", fmt.Sprintf("error: %v", err)
 | 
			
		||||
| 
						 | 
				
			
			@ -317,7 +317,7 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *testing.T) {
 | 
			
		|||
	)
 | 
			
		||||
	var lastErr error
 | 
			
		||||
	checkLeader := func(nodes ...*daemon.Daemon) checkF {
 | 
			
		||||
		return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
		return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
			// clear these out before each run
 | 
			
		||||
			leader = nil
 | 
			
		||||
			followers = nil
 | 
			
		||||
| 
						 | 
				
			
			@ -404,7 +404,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
 | 
			
		|||
	defer cli.Close()
 | 
			
		||||
 | 
			
		||||
	// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout*2, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout*2, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		_, err := cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
 | 
			
		||||
		return err.Error(), nil
 | 
			
		||||
	}, checker.Contains, "Make sure more than half of the managers are online.")
 | 
			
		||||
| 
						 | 
				
			
			@ -738,7 +738,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
 | 
			
		|||
		)
 | 
			
		||||
 | 
			
		||||
		// check info in a waitAndAssert, because if the cluster doesn't have a leader, `info` will return an error
 | 
			
		||||
		checkInfo := func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
		checkInfo := func(c *testing.T) (interface{}, string) {
 | 
			
		||||
			client := d.NewClientT(c)
 | 
			
		||||
			daemonInfo, err := client.Info(context.Background())
 | 
			
		||||
			info = daemonInfo.Swarm
 | 
			
		||||
| 
						 | 
				
			
			@ -755,7 +755,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
 | 
			
		|||
		var mCount, wCount int
 | 
			
		||||
 | 
			
		||||
		for _, n := range d.ListNodes(c) {
 | 
			
		||||
			waitReady := func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
			waitReady := func(c *testing.T) (interface{}, string) {
 | 
			
		||||
				if n.Status.State == swarm.NodeStateReady {
 | 
			
		||||
					return true, nil
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -765,7 +765,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
 | 
			
		|||
			}
 | 
			
		||||
			waitAndAssert(c, defaultReconciliationTimeout, waitReady, checker.True)
 | 
			
		||||
 | 
			
		||||
			waitActive := func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
			waitActive := func(c *testing.T) (interface{}, string) {
 | 
			
		||||
				if n.Spec.Availability == swarm.NodeAvailabilityActive {
 | 
			
		||||
					return true, nil
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2072,7 +2072,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *tes
 | 
			
		|||
 | 
			
		||||
	// Give time to containerd to process the command if we don't
 | 
			
		||||
	// the resume event might be received after we do the inspect
 | 
			
		||||
	waitAndAssert(t, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(t, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
 | 
			
		||||
		result := icmd.RunCommand("kill", "-0", strings.TrimSpace(pid))
 | 
			
		||||
		return result.ExitCode, nil
 | 
			
		||||
	}, checker.Equals, 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string
 | 
			
		|||
	assert.NilError(c, err)
 | 
			
		||||
 | 
			
		||||
	for _, s := range kept {
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
 | 
			
		||||
			out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
 | 
			
		||||
			assert.NilError(c, err)
 | 
			
		||||
			return out, nil
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for _, s := range pruned {
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
		waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
 | 
			
		||||
			out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
 | 
			
		||||
			assert.NilError(c, err)
 | 
			
		||||
			return out, nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ func (s *DockerSuite) TestRestartRunningContainer(c *testing.T) {
 | 
			
		|||
 | 
			
		||||
	assert.NilError(c, waitRun(cleanedContainerID))
 | 
			
		||||
 | 
			
		||||
	getLogs := func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	getLogs := func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		out, _ := dockerCmd(c, "logs", cleanedContainerID)
 | 
			
		||||
		return out, nil
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,13 +24,13 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, id)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -138,13 +138,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testi
 | 
			
		|||
	assert.Equal(c, len(refs), len(testPaths))
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, serviceName)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -188,13 +188,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing
 | 
			
		|||
	assert.Equal(c, len(refs), 2)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, serviceName)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -285,13 +285,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi
 | 
			
		|||
	assert.Equal(c, len(refs), len(testPaths))
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, serviceName)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -335,13 +335,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing
 | 
			
		|||
	assert.Equal(c, len(refs), 2)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, serviceName)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -367,13 +367,13 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, id)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -423,13 +423,13 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, id)
 | 
			
		||||
		return len(tasks) > 0, nil
 | 
			
		||||
	}, checker.Equals, true)
 | 
			
		||||
 | 
			
		||||
	task := tasks[0]
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		if task.NodeID == "" || task.Status.ContainerStatus == nil {
 | 
			
		||||
			task = d.GetTask(c, task.ID)
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, id)
 | 
			
		||||
		return tasks, nil
 | 
			
		||||
	}, checker.HasLen, 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -48,14 +48,14 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
 | 
			
		|||
	task := tasks[0]
 | 
			
		||||
 | 
			
		||||
	// wait for task to start
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		task = d.GetTask(c, task.ID)
 | 
			
		||||
		return task.Status.State, nil
 | 
			
		||||
	}, checker.Equals, swarm.TaskStateRunning)
 | 
			
		||||
	containerID := task.Status.ContainerStatus.ContainerID
 | 
			
		||||
 | 
			
		||||
	// wait for container to be healthy
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
 | 
			
		||||
		return strings.TrimSpace(out), nil
 | 
			
		||||
	}, checker.Equals, "healthy")
 | 
			
		||||
| 
						 | 
				
			
			@ -63,13 +63,13 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
 | 
			
		|||
	// make it fail
 | 
			
		||||
	d.Cmd("exec", containerID, "rm", "/status")
 | 
			
		||||
	// wait for container to be unhealthy
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
 | 
			
		||||
		return strings.TrimSpace(out), nil
 | 
			
		||||
	}, checker.Equals, "unhealthy")
 | 
			
		||||
 | 
			
		||||
	// Task should be terminated
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		task = d.GetTask(c, task.ID)
 | 
			
		||||
		return task.Status.State, nil
 | 
			
		||||
	}, checker.Equals, swarm.TaskStateFailed)
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
 | 
			
		|||
	id := strings.TrimSpace(out)
 | 
			
		||||
 | 
			
		||||
	var tasks []swarm.Task
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		tasks = d.GetServiceTasks(c, id)
 | 
			
		||||
		return tasks, nil
 | 
			
		||||
	}, checker.HasLen, 1)
 | 
			
		||||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
 | 
			
		|||
	task := tasks[0]
 | 
			
		||||
 | 
			
		||||
	// wait for task to start
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		task = d.GetTask(c, task.ID)
 | 
			
		||||
		return task.Status.State, nil
 | 
			
		||||
	}, checker.Equals, swarm.TaskStateStarting)
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
 | 
			
		|||
	containerID := task.Status.ContainerStatus.ContainerID
 | 
			
		||||
 | 
			
		||||
	// wait for health check to work
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID)
 | 
			
		||||
		failingStreak, _ := strconv.Atoi(strings.TrimSpace(out))
 | 
			
		||||
		return failingStreak, nil
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
 | 
			
		|||
	d.Cmd("exec", containerID, "touch", "/status")
 | 
			
		||||
 | 
			
		||||
	// Task should be at running status
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		task = d.GetTask(c, task.ID)
 | 
			
		||||
		return task.Status.State, nil
 | 
			
		||||
	}, checker.Equals, swarm.TaskStateRunning)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,8 +55,8 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *testing.T) {
 | 
			
		|||
// countLogLines returns a closure that can be used with waitAndAssert to
 | 
			
		||||
// verify that a minimum number of expected container log messages have been
 | 
			
		||||
// output.
 | 
			
		||||
func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		result := icmd.RunCmd(d.Command("service", "logs", "-t", "--raw", name))
 | 
			
		||||
		result.Assert(c, icmd.Expected{})
 | 
			
		||||
		// if this returns an emptystring, trying to split it later will return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -383,7 +383,7 @@ func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *testing.T) {
 | 
			
		|||
	out, err = d.Cmd("network", "rm", "testnet")
 | 
			
		||||
	assert.NilError(c, err, out)
 | 
			
		||||
 | 
			
		||||
	checkNetwork := func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	checkNetwork := func(*testing.T) (interface{}, string) {
 | 
			
		||||
		out, err := d.Cmd("network", "ls")
 | 
			
		||||
		assert.NilError(c, err)
 | 
			
		||||
		return out, nil
 | 
			
		||||
| 
						 | 
				
			
			@ -544,7 +544,7 @@ func (s *DockerSwarmSuite) TestSwarmTaskListFilter(c *testing.T) {
 | 
			
		|||
 | 
			
		||||
	filter := "name=redis-cluster"
 | 
			
		||||
 | 
			
		||||
	checkNumTasks := func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	checkNumTasks := func(*testing.T) (interface{}, string) {
 | 
			
		||||
		out, err := d.Cmd("service", "ps", "--filter", filter, name)
 | 
			
		||||
		assert.NilError(c, err, out)
 | 
			
		||||
		return len(strings.Split(out, "\n")) - 2, nil // includes header and nl in last line
 | 
			
		||||
| 
						 | 
				
			
			@ -985,8 +985,8 @@ func getNodeStatus(c *testing.T, d *daemon.Daemon) swarm.LocalNodeState {
 | 
			
		|||
	return info.LocalNodeState
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, string) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		keyBytes, err := ioutil.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key"))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return fmt.Errorf("error reading key: %v", err), nil
 | 
			
		||||
| 
						 | 
				
			
			@ -1214,7 +1214,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
 | 
			
		|||
	// (because we never want a manager TLS key to be on disk unencrypted if the cluster
 | 
			
		||||
	// is set to autolock)
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, d3.CheckControlAvailable, checker.False)
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		certBytes, err := ioutil.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt"))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", fmt.Sprintf("error: %v", err)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -441,11 +441,11 @@ func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, compariso
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type checkF func(*testing.T) (interface{}, check.CommentInterface)
 | 
			
		||||
type checkF func(*testing.T) (interface{}, string)
 | 
			
		||||
type reducer func(...interface{}) interface{}
 | 
			
		||||
 | 
			
		||||
func reducedCheck(r reducer, funcs ...checkF) checkF {
 | 
			
		||||
	return func(c *testing.T) (interface{}, check.CommentInterface) {
 | 
			
		||||
	return func(c *testing.T) (interface{}, string) {
 | 
			
		||||
		var values []interface{}
 | 
			
		||||
		var comments []string
 | 
			
		||||
		for _, f := range funcs {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue