Browse code

add TestRunInValidCPUShares

Signed-off-by: Yuan Sun <sunyuan3@huawei.com>

Yuan Sun authored on 2015/10/08 11:04:51
Showing 1 changed files
... ...
@@ -415,3 +415,21 @@ func (s *DockerSuite) TestRunInvalidCpusetMemsFlagValue(c *check.C) {
415 415
 	expected := fmt.Sprintf("Error response from daemon: Requested memory nodes are not available - requested %s, available: %s.\n", strconv.Itoa(invalid), sysInfo.Mems)
416 416
 	c.Assert(out, check.Equals, expected, check.Commentf("Expected output to contain %q, got %q", expected, out))
417 417
 }
418
+
419
+func (s *DockerSuite) TestRunInvalidCPUShares(c *check.C) {
420
+	testRequires(c, cpuShare)
421
+	out, _, err := dockerCmdWithError("run", "--cpu-shares", "1", "busybox", "echo", "test")
422
+	c.Assert(err, check.NotNil, check.Commentf(out))
423
+	expected := "The minimum allowed cpu-shares is 2"
424
+	c.Assert(out, checker.Contains, expected)
425
+
426
+	out, _, err = dockerCmdWithError("run", "--cpu-shares", "-1", "busybox", "echo", "test")
427
+	c.Assert(err, check.NotNil, check.Commentf(out))
428
+	expected = "shares: invalid argument"
429
+	c.Assert(out, checker.Contains, expected)
430
+
431
+	out, _, err = dockerCmdWithError("run", "--cpu-shares", "99999999", "busybox", "echo", "test")
432
+	c.Assert(err, check.NotNil, check.Commentf(out))
433
+	expected = "The maximum allowed cpu-shares is"
434
+	c.Assert(out, checker.Contains, expected)
435
+}