Browse code

TestCase for CpuShares and Cpuset Signed-off-by: Rajdeep Dua <dua_rajdeep@yahoo.com>

Rajdeep Dua authored on 2015/05/16 06:00:54
Showing 1 changed files
... ...
@@ -771,6 +771,39 @@ func UtilCreateNetworkMode(c *check.C, networkMode string) {
771 771
 	}
772 772
 }
773 773
 
774
+func (s *DockerSuite) TestContainerApiCreateWithCpuSharesCpuset(c *check.C) {
775
+	config := map[string]interface{}{
776
+		"Image":      "busybox",
777
+		"CpuShares":  512,
778
+		"CpusetCpus": "0,1",
779
+	}
780
+
781
+	status, body, err := sockRequest("POST", "/containers/create", config)
782
+	c.Assert(err, check.IsNil)
783
+	c.Assert(status, check.Equals, http.StatusCreated)
784
+
785
+	var container types.ContainerCreateResponse
786
+	if err := json.Unmarshal(body, &container); err != nil {
787
+		c.Fatal(err)
788
+	}
789
+
790
+	status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
791
+	c.Assert(err, check.IsNil)
792
+	c.Assert(status, check.Equals, http.StatusOK)
793
+
794
+	var containerJson types.ContainerJSON
795
+
796
+	c.Assert(json.Unmarshal(body, &containerJson), check.IsNil)
797
+
798
+	out, err := inspectField(containerJson.Id, "HostConfig.CpuShares")
799
+	c.Assert(err, check.IsNil)
800
+	c.Assert(out, check.Equals, "512")
801
+
802
+	outCpuset, errCpuset := inspectField(containerJson.Id, "HostConfig.CpusetCpus")
803
+	c.Assert(errCpuset, check.IsNil, check.Commentf("Output: %s", outCpuset))
804
+	c.Assert(outCpuset, check.Equals, "0,1")
805
+}
806
+
774 807
 func (s *DockerSuite) TestContainerApiVerifyHeader(c *check.C) {
775 808
 	config := map[string]interface{}{
776 809
 		"Image": "busybox",