MCPcopy
hub / github.com/moby/moby / TestAPISwarmRaftQuorum

Method TestAPISwarmRaftQuorum

integration-cli/docker_api_swarm_test.go:365–413  ·  view source on GitHub ↗
(c *testing.T)

Source from the content-addressed store, hash-verified

363}
364
365func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
366 ctx := testutil.GetContext(c)
367 if runtime.GOARCH == "s390x" {
368 c.Skip("Disabled on s390x")
369 }
370 if runtime.GOARCH == "ppc64le" {
371 c.Skip("Disabled on ppc64le")
372 }
373
374 d1 := s.AddDaemon(ctx, c, true, true)
375 d2 := s.AddDaemon(ctx, c, true, true)
376 d3 := s.AddDaemon(ctx, c, true, true)
377
378 d1.CreateService(ctx, c, simpleTestService)
379
380 d2.Stop(c)
381
382 // make sure there is a leader
383 poll.WaitOn(c, pollCheck(c, d1.CheckLeader(ctx), checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout))
384
385 d1.CreateService(ctx, c, simpleTestService, func(s *swarm.Service) {
386 s.Spec.Name = "top1"
387 })
388
389 d3.Stop(c)
390
391 var service swarm.Service
392 simpleTestService(&service)
393 service.Spec.Name = "top2"
394 cli := d1.NewClientT(c)
395 defer cli.Close()
396
397 // d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
398 poll.WaitOn(c, pollCheck(c, func(t *testing.T) (any, string) {
399 _, err := cli.ServiceCreate(testutil.GetContext(t), client.ServiceCreateOptions{
400 Spec: service.Spec,
401 })
402 return err.Error(), ""
403 }, checker.Contains("Make sure more than half of the managers are online.")), poll.WithTimeout(defaultReconciliationTimeout*2))
404
405 d2.StartNode(c)
406
407 // make sure there is a leader
408 poll.WaitOn(c, pollCheck(c, d1.CheckLeader(ctx), checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout))
409
410 d1.CreateService(ctx, c, simpleTestService, func(s *swarm.Service) {
411 s.Spec.Name = "top3"
412 })
413}
414
415func (s *DockerSwarmSuite) TestAPISwarmLeaveRemovesContainer(c *testing.T) {
416 ctx := testutil.GetContext(c)

Callers

nothing calls this directly

Calls 15

AddDaemonMethod · 0.95
GetContextFunction · 0.92
IsNilFunction · 0.92
ContainsFunction · 0.92
pollCheckFunction · 0.85
simpleTestServiceFunction · 0.85
CheckLeaderMethod · 0.80
WithTimeoutMethod · 0.80
NewClientTMethod · 0.80
StartNodeMethod · 0.80
SkipMethod · 0.65
CreateServiceMethod · 0.65

Tested by

no test coverage detected