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

Function removeAllTestContainers

t/t.go:1056–1102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1054}
1055
1056func removeAllTestContainers() {
1057 containers := testutil.AllContainers(getGlobalPrefix())
1058
1059 cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
1060 x.Check(err)
1061 dur := 10
1062
1063 var wg sync.WaitGroup
1064 for _, c := range containers {
1065 wg.Add(1)
1066 go func(c container.Summary) {
1067 defer wg.Done()
1068 o := container.StopOptions{Timeout: &dur}
1069 err := cli.ContainerStop(ctxb, c.ID, o)
1070 fmt.Printf("Stopped container %s with error: %v\n", c.Names[0], err)
1071
1072 err = cli.ContainerRemove(ctxb, c.ID, container.RemoveOptions{})
1073 fmt.Printf("Removed container %s with error: %v\n", c.Names[0], err)
1074 }(c)
1075 }
1076 wg.Wait()
1077
1078 networks, err := cli.NetworkList(ctxb, network.ListOptions{})
1079 x.Check(err)
1080 for _, n := range networks {
1081 if strings.HasPrefix(n.Name, getGlobalPrefix()) {
1082 if err := cli.NetworkRemove(ctxb, n.ID); err != nil {
1083 fmt.Printf("Error: %v while removing network: %+v\n", err, n)
1084 } else {
1085 fmt.Printf("Removed network: %s\n", n.Name)
1086 }
1087 }
1088 }
1089
1090 o := volume.ListOptions{Filters: filters.Args{}}
1091 volumes, err := cli.VolumeList(ctxb, o)
1092 x.Check(err)
1093 for _, v := range volumes.Volumes {
1094 if strings.HasPrefix(v.Name, getGlobalPrefix()) {
1095 if err := cli.VolumeRemove(ctxb, v.Name, true); err != nil {
1096 fmt.Printf("Error: %v while removing volume: %+v\n", err, v)
1097 } else {
1098 fmt.Printf("Removed volume: %s\n", v.Name)
1099 }
1100 }
1101 }
1102}
1103
1104var loadPackages = []string{
1105 "/systest/21million/bulk",

Callers 1

runFunction · 0.85

Calls 6

AllContainersFunction · 0.92
CheckFunction · 0.92
getGlobalPrefixFunction · 0.85
WaitMethod · 0.80
AddMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected