MCPcopy
hub / github.com/dgraph-io/dgraph / Start

Method Start

dgraphtest/local_cluster.go:489–555  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

487}
488
489func (c *LocalCluster) Start() error {
490 log.Printf("[INFO] starting cluster with prefix [%v]", c.conf.prefix)
491 startAll := func() error {
492 var wg sync.WaitGroup
493 errCh := make(chan error, c.conf.numZeros+c.conf.numAlphas)
494
495 for i := range c.conf.numZeros {
496 wg.Add(1)
497 go func(id int) {
498 defer wg.Done()
499 if err := c.StartZero(id); err != nil {
500 errCh <- fmt.Errorf("failed to start zero %d: %w", id, err)
501 }
502 }(i)
503 }
504
505 for i := range c.conf.numAlphas {
506 wg.Add(1)
507 go func(id int) {
508 defer wg.Done()
509 if err := c.StartAlpha(id); err != nil {
510 errCh <- fmt.Errorf("failed to start alpha %d: %w", id, err)
511 }
512 }(i)
513 }
514
515 wg.Wait()
516 close(errCh)
517 for err := range errCh {
518 if err != nil {
519 return err
520 }
521 }
522
523 return c.HealthCheck(false)
524 }
525
526 // sometimes health check doesn't work due to unmapped ports. We dont
527 // know why this happens, but checking it 3 times before failing the test.
528 retry := 0
529 for {
530 retry++
531
532 if err := startAll(); err == nil {
533 return nil
534 } else if retry == 3 {
535 return err
536 } else {
537 log.Printf("[WARNING] saw the err, trying again: %v", err)
538 }
539
540 if err1 := c.Stop(); err1 != nil {
541 log.Printf("[WARNING] error while stopping :%v", err1)
542 }
543 c.Cleanup(true)
544
545 if err := c.cleanupDocker(); err != nil {
546 log.Printf("[ERROR] while cleaning old dockers %v", err)

Callers 15

TestCheckUpgradeFunction · 0.95
TestQueryDuplicateNodesFunction · 0.95
setupTargetClusterFunction · 0.95
TestMCPSSEFunction · 0.95
TestMainFunction · 0.95
TestShortestPathFunction · 0.95
SetupSubTestMethod · 0.95

Calls 12

StartZeroMethod · 0.95
StartAlphaMethod · 0.95
HealthCheckMethod · 0.95
StopMethod · 0.95
CleanupMethod · 0.95
cleanupDockerMethod · 0.95
initMethod · 0.95
WaitMethod · 0.80
Int63Method · 0.80
AddMethod · 0.45
DoneMethod · 0.45
ErrorfMethod · 0.45

Tested by 15

TestCheckUpgradeFunction · 0.76
TestQueryDuplicateNodesFunction · 0.76
setupTargetClusterFunction · 0.76
TestMCPSSEFunction · 0.76
TestMainFunction · 0.76
TestShortestPathFunction · 0.76
SetupSubTestMethod · 0.76