Browse code

Remove debug log line from cgroup-parent feature e2e test. Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)

Vishnu Kannan authored on 2015/03/21 07:32:40
Showing 2 changed files
... ...
@@ -109,23 +109,6 @@ func TestRunWithUlimits(t *testing.T) {
109 109
 	logDone("run - ulimits are set")
110 110
 }
111 111
 
112
-func getCgroupPaths(test string) map[string]string {
113
-	cgroupPaths := map[string]string{}
114
-	for _, line := range strings.Split(test, "\n") {
115
-		line = strings.TrimSpace(line)
116
-		if line == "" {
117
-			continue
118
-		}
119
-		parts := strings.Split(line, ":")
120
-		if len(parts) != 3 {
121
-			fmt.Printf("unexpected file format for /proc/self/cgroup - %q\n", line)
122
-			continue
123
-		}
124
-		cgroupPaths[parts[1]] = parts[2]
125
-	}
126
-	return cgroupPaths
127
-}
128
-
129 112
 func TestRunContainerWithCgroupParent(t *testing.T) {
130 113
 	testRequires(t, NativeExecDriver)
131 114
 	defer deleteAllContainers()
... ...
@@ -135,7 +118,7 @@ func TestRunContainerWithCgroupParent(t *testing.T) {
135 135
 	if err != nil {
136 136
 		t.Fatalf("failed to read '/proc/self/cgroup - %v", err)
137 137
 	}
138
-	selfCgroupPaths := getCgroupPaths(string(data))
138
+	selfCgroupPaths := parseCgroupPaths(string(data))
139 139
 	selfCpuCgroup, found := selfCgroupPaths["memory"]
140 140
 	if !found {
141 141
 		t.Fatalf("unable to find self cpu cgroup path. CgroupsPath: %v", selfCgroupPaths)
... ...
@@ -145,7 +128,7 @@ func TestRunContainerWithCgroupParent(t *testing.T) {
145 145
 	if err != nil {
146 146
 		t.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
147 147
 	}
148
-	cgroupPaths := getCgroupPaths(string(out))
148
+	cgroupPaths := parseCgroupPaths(string(out))
149 149
 	if len(cgroupPaths) == 0 {
150 150
 		t.Fatalf("unexpected output - %q", string(out))
151 151
 	}
... ...
@@ -173,7 +156,7 @@ func TestRunContainerWithCgroupParentAbsPath(t *testing.T) {
173 173
 	if err != nil {
174 174
 		t.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", string(out), err)
175 175
 	}
176
-	cgroupPaths := getCgroupPaths(string(out))
176
+	cgroupPaths := parseCgroupPaths(string(out))
177 177
 	if len(cgroupPaths) == 0 {
178 178
 		t.Fatalf("unexpected output - %q", string(out))
179 179
 	}
... ...
@@ -328,3 +328,17 @@ func consumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, s
328 328
 		}
329 329
 	}
330 330
 }
331
+
332
+// Parses 'procCgroupData', which is output of '/proc/<pid>/cgroup', and returns
333
+// a map which cgroup name as key and path as value.
334
+func parseCgroupPaths(procCgroupData string) map[string]string {
335
+	cgroupPaths := map[string]string{}
336
+	for _, line := range strings.Split(procCgroupData, "\n") {
337
+		parts := strings.Split(line, ":")
338
+		if len(parts) != 3 {
339
+			continue
340
+		}
341
+		cgroupPaths[parts[1]] = parts[2]
342
+	}
343
+	return cgroupPaths
344
+}