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

Function runTests

t/t.go:619–807  ·  view source on GitHub ↗
(taskCh chan task, closer *z.Closer)

Source from the content-addressed store, hash-verified

617var _threadId int32
618
619func runTests(taskCh chan task, closer *z.Closer) error {
620 var err error
621 threadId := atomic.AddInt32(&_threadId, 1)
622
623 {
624 ts := time.Now()
625 defer func() {
626 oc.Took(threadId, "DONE", time.Since(ts))
627 }()
628 }
629
630 wg := new(sync.WaitGroup)
631 defer func() {
632 wg.Wait()
633 closer.Done()
634 }()
635
636 defaultCompose := filepath.Join(*baseDir, "dgraph/docker-compose.yml")
637 prefix := getClusterPrefix()
638
639 var started, stopped bool
640 start := func() error {
641 if isUnitOnly() || len(*useExisting) > 0 || started {
642 return nil
643 }
644 err := startCluster(defaultCompose, prefix)
645 if err != nil {
646 closer.Signal()
647 return err
648 }
649 started = true
650 return nil
651 }
652
653 stop := func() {
654 if isUnitOnly() || *keepCluster || stopped {
655 return
656 }
657 wg.Add(1)
658 stopCluster(defaultCompose, prefix, wg, err)
659 stopped = true
660 }
661 defer stop()
662
663 ctx := closer.Ctx()
664 ctx = context.WithValue(ctx, _threadIdKey{}, threadId)
665
666 tmpDir, err := os.MkdirTemp("", "dgraph-test-xml")
667 if err != nil {
668 return fmt.Errorf("failed to create temp directory: %v", err)
669 }
670 defer func() {
671 if err := os.RemoveAll(tmpDir); err != nil {
672 log.Printf("Failed to remove temporary directory %s: %v", tmpDir, err)
673 }
674 }()
675
676 var xmlFiles []string

Callers 1

runFunction · 0.70

Calls 15

GetContainerInstanceFunction · 0.92
getClusterPrefixFunction · 0.85
isUnitOnlyFunction · 0.85
startClusterFunction · 0.85
stopClusterFunction · 0.85
combineJUnitXMLFunction · 0.85
hasTestFilesFunction · 0.85
sanitizeFilenameFunction · 0.85
runTestsForFunction · 0.85
runCustomClusterTestFunction · 0.85
TookMethod · 0.80
WaitMethod · 0.80

Tested by

no test coverage detected