1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add more complicated demotion testcases

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2016-07-08 12:01:58 -07:00
parent 8a50315f3c
commit a3f1577365

View file

@ -3,6 +3,7 @@
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
@ -298,7 +299,36 @@ func (s *DockerSwarmSuite) TestApiSwarmPromoteDemote(c *check.C) {
time.Sleep(100 * time.Millisecond)
}
// todo: test raft qourum stability
// Demoting last node should fail
node := d1.getNode(c, d1.NodeID)
node.Spec.Role = swarm.NodeRoleWorker
url := fmt.Sprintf("/nodes/%s/update?version=%d", node.ID, node.Version.Index)
status, out, err := d1.SockRequest("POST", url, node.Spec)
c.Assert(err, checker.IsNil)
c.Assert(status, checker.Equals, http.StatusInternalServerError, check.Commentf("output: %q", string(out)))
c.Assert(string(out), checker.Contains, "last manager of the swarm")
info, err = d1.info()
c.Assert(err, checker.IsNil)
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
c.Assert(info.ControlAvailable, checker.Equals, true)
// Promote already demoted node
d1.updateNode(c, d2.NodeID, func(n *swarm.Node) {
n.Spec.Role = swarm.NodeRoleManager
})
for i := 0; ; i++ {
info, err := d2.info()
c.Assert(err, checker.IsNil)
c.Assert(info.LocalNodeState, checker.Equals, swarm.LocalNodeStateActive)
if info.ControlAvailable {
break
}
if i > 100 {
c.Errorf("node did not turn into manager")
}
time.Sleep(100 * time.Millisecond)
}
}
func (s *DockerSwarmSuite) TestApiSwarmServicesCreate(c *check.C) {