mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
dc0c2340b8
integration-cli/docker_cli_pull_test.go:55:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_exec_test.go:46:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_service_health_test.go:86:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_images_test.go:128:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_node_test.go:79:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:51:57: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_health_test.go:159:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_unix_test.go:60:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_inspect_test.go:30:33: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:429:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_attach_unix_test.go:19:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_build_test.go:470:70: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_history_test.go:29:64: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:93:86: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:33:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_links_test.go:145:78: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:114:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_attach_test.go:226:153: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_by_digest_test.go:239:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_create_test.go:135:49: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:143:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_create_test.go:181:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_inspect_test.go:72:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:98:77: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:144:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:63:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:199:79: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_rmi_test.go:69:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_swarm_service_test.go:300:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_prune_unix_test.go:35:25: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_unix_test.go:393:60: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_events_unix_test.go:441:71: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_ps_test.go:33:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_ps_test.go:559:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_events_test.go:117:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:547:74: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1054:84: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1076:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:1232:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_api_containers_test.go:1801:21: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:58:95: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_network_unix_test.go:750:75: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_network_unix_test.go:765:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_swarm_test.go:617:100: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_swarm_test.go:892:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:119:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_daemon_test.go:981:68: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_daemon_test.go:1951:87: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:83:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_run_test.go:357:72: empty-lines: extra empty line at the start of a block (revive) integration-cli/docker_cli_build_test.go:89:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:114:83: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:183:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:290:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:314:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:331:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:366:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:403:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:648:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:708:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:938:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1018:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1097:2: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1182:62: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1244:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1524:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1546:80: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1716:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:1730:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2162:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2270:71: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:2288:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3206:65: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3392:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3433:72: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3678:76: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3732:67: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3759:69: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3802:61: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:3898:66: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4107:9: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4791:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4821:73: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:4854:70: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5341:74: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_cli_build_test.go:5593:81: empty-lines: extra empty line at the end of a block (revive) integration-cli/docker_api_containers_test.go:2145:11: empty-lines: extra empty line at the start of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
128 lines
4.6 KiB
Go
128 lines
4.6 KiB
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/integration-cli/daemon"
|
|
"gotest.tools/v3/assert"
|
|
"gotest.tools/v3/poll"
|
|
)
|
|
|
|
func (s *DockerSwarmSuite) TestAPISwarmListNodes(c *testing.T) {
|
|
d1 := s.AddDaemon(c, true, true)
|
|
d2 := s.AddDaemon(c, true, false)
|
|
d3 := s.AddDaemon(c, true, false)
|
|
|
|
nodes := d1.ListNodes(c)
|
|
assert.Equal(c, len(nodes), 3, fmt.Sprintf("nodes: %#v", nodes))
|
|
|
|
loop0:
|
|
for _, n := range nodes {
|
|
for _, d := range []*daemon.Daemon{d1, d2, d3} {
|
|
if n.ID == d.NodeID() {
|
|
continue loop0
|
|
}
|
|
}
|
|
c.Errorf("unknown nodeID %v", n.ID)
|
|
}
|
|
}
|
|
|
|
func (s *DockerSwarmSuite) TestAPISwarmNodeUpdate(c *testing.T) {
|
|
d := s.AddDaemon(c, true, true)
|
|
|
|
nodes := d.ListNodes(c)
|
|
|
|
d.UpdateNode(c, nodes[0].ID, func(n *swarm.Node) {
|
|
n.Spec.Availability = swarm.NodeAvailabilityPause
|
|
})
|
|
|
|
n := d.GetNode(c, nodes[0].ID)
|
|
assert.Equal(c, n.Spec.Availability, swarm.NodeAvailabilityPause)
|
|
}
|
|
|
|
func (s *DockerSwarmSuite) TestAPISwarmNodeRemove(c *testing.T) {
|
|
testRequires(c, Network)
|
|
d1 := s.AddDaemon(c, true, true)
|
|
d2 := s.AddDaemon(c, true, false)
|
|
_ = s.AddDaemon(c, true, false)
|
|
|
|
nodes := d1.ListNodes(c)
|
|
assert.Equal(c, len(nodes), 3, fmt.Sprintf("nodes: %#v", nodes))
|
|
|
|
// Getting the info so we can take the NodeID
|
|
d2Info := d2.SwarmInfo(c)
|
|
|
|
// forceful removal of d2 should work
|
|
d1.RemoveNode(c, d2Info.NodeID, true)
|
|
|
|
nodes = d1.ListNodes(c)
|
|
assert.Equal(c, len(nodes), 2, fmt.Sprintf("nodes: %#v", nodes))
|
|
|
|
// Restart the node that was removed
|
|
d2.RestartNode(c)
|
|
|
|
// Give some time for the node to rejoin
|
|
time.Sleep(1 * time.Second)
|
|
|
|
// Make sure the node didn't rejoin
|
|
nodes = d1.ListNodes(c)
|
|
assert.Equal(c, len(nodes), 2, fmt.Sprintf("nodes: %#v", nodes))
|
|
}
|
|
|
|
func (s *DockerSwarmSuite) TestAPISwarmNodeDrainPause(c *testing.T) {
|
|
d1 := s.AddDaemon(c, true, true)
|
|
d2 := s.AddDaemon(c, true, false)
|
|
|
|
time.Sleep(1 * time.Second) // make sure all daemons are ready to accept tasks
|
|
|
|
// start a service, expect balanced distribution
|
|
instances := 2
|
|
id := d1.CreateService(c, simpleTestService, setInstances(instances))
|
|
|
|
poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
|
|
// drain d2, all containers should move to d1
|
|
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
|
|
n.Spec.Availability = swarm.NodeAvailabilityDrain
|
|
})
|
|
poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
|
|
// set d2 back to active
|
|
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
|
|
n.Spec.Availability = swarm.NodeAvailabilityActive
|
|
})
|
|
|
|
instances = 1
|
|
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
|
|
poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout*2))
|
|
|
|
instances = 2
|
|
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
|
|
|
|
// drained node first so we don't get any old containers
|
|
poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.GreaterThan(0)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, reducedCheck(sumAsIntegers, d1.CheckActiveContainerCount, d2.CheckActiveContainerCount), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout*2))
|
|
|
|
d2ContainerCount := len(d2.ActiveContainers(c))
|
|
|
|
// set d2 to paused, scale service up, only d1 gets new tasks
|
|
d1.UpdateNode(c, d2.NodeID(), func(n *swarm.Node) {
|
|
n.Spec.Availability = swarm.NodeAvailabilityPause
|
|
})
|
|
|
|
instances = 4
|
|
d1.UpdateService(c, d1.GetService(c, id), setInstances(instances))
|
|
poll.WaitOn(c, pollCheck(c, d1.CheckActiveContainerCount, checker.Equals(instances-d2ContainerCount)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
poll.WaitOn(c, pollCheck(c, d2.CheckActiveContainerCount, checker.Equals(d2ContainerCount)), poll.WithTimeout(defaultReconciliationTimeout))
|
|
}
|