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

Function stopCluster

t/t.go:381–445  ·  view source on GitHub ↗
(composeFile, prefix string, wg *sync.WaitGroup, err error)

Source from the content-addressed store, hash-verified

379}
380
381func stopCluster(composeFile, prefix string, wg *sync.WaitGroup, err error) {
382 composeArgs := ComposeFileArgs(composeFile, *baseDir)
383 go func() {
384 if err != nil {
385 outputLogs(prefix)
386 }
387 stopArgs := append([]string{"docker", "compose", "--compatibility"},
388 append(composeArgs, "-p", prefix, "stop")...)
389 cmd := command(stopArgs...)
390 cmd.Stderr = nil
391 if err := cmd.Run(); err != nil {
392 fmt.Printf("Error while bringing down cluster. Prefix: %s. Error: %v\n",
393 prefix, err)
394 } else {
395 fmt.Printf("CLUSTER STOPPED: %s\n", prefix)
396 }
397
398 if *runCoverage {
399 // get all matching containers, copy /usr/local/bin/coverage.out
400 containers := testutil.AllContainers(prefix)
401 for _, c := range containers {
402 tmp := fmt.Sprintf("%s.%s", tmpCoverageFile, c.ID)
403
404 containerInfo, err := testutil.DockerInspect(c.ID)
405 if err != nil {
406 fmt.Printf("error while inspecting container. Prefix: %s. Error: %v\n", prefix, err)
407 }
408
409 workDir := containerInfo.Config.WorkingDir
410
411 err = testutil.DockerCpFromContainer(c.ID, workDir+"/coverage.out", tmp)
412 if err != nil {
413 fmt.Printf("error bringing down cluster. Failed at copying coverage file. Prefix: %s. Error: %v\n",
414 prefix, err)
415 }
416
417 if err = appendTestCoverageFile(tmp, coverageFile); err != nil {
418 fmt.Printf("error bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n",
419 prefix, err,
420 )
421 }
422
423 _ = os.Remove(tmp)
424
425 coverageBulk := strings.Replace(composeFile, "docker-compose.yml", "coverage_bulk.out", -1)
426 if err = appendTestCoverageFile(coverageBulk, coverageFile); err != nil {
427 fmt.Printf("Error bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n",
428 prefix, err)
429 }
430 }
431 }
432
433 downArgs := append([]string{"docker", "compose", "--compatibility"},
434 append(composeArgs, "-p", prefix, "down", "-v")...)
435 cmd = command(downArgs...)
436 if err := cmd.Run(); err != nil {
437 fmt.Printf("Error while bringing down cluster. Prefix: %s. Error: %v\n",
438 prefix, err)

Callers 2

runTestsFunction · 0.85
runCustomClusterTestFunction · 0.85

Calls 9

AllContainersFunction · 0.92
DockerInspectFunction · 0.92
DockerCpFromContainerFunction · 0.92
outputLogsFunction · 0.85
appendTestCoverageFileFunction · 0.85
commandFunction · 0.70
RemoveMethod · 0.65
RunMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected