@@ -168,94 +168,6 @@ func (s *DockerSuite) TestContainerApiGetChanges(c *check.C) {
168168 c .Assert (success , checker .True , check .Commentf ("/etc/passwd has been removed but is not present in the diff" ))
169169}
170170
171- func (s * DockerSuite ) TestContainerApiStartVolumeBinds (c * check.C ) {
172- // TODO Windows CI: Investigate further why this fails on Windows to Windows CI.
173- testRequires (c , DaemonIsLinux )
174- path := "/foo"
175- if daemonPlatform == "windows" {
176- path = `c:\foo`
177- }
178- name := "testing"
179- config := map [string ]interface {}{
180- "Image" : "busybox" ,
181- "Volumes" : map [string ]struct {}{path : {}},
182- }
183-
184- status , _ , err := sockRequest ("POST" , "/containers/create?name=" + name , config )
185- c .Assert (err , checker .IsNil )
186- c .Assert (status , checker .Equals , http .StatusCreated )
187-
188- bindPath := randomTmpDirPath ("test" , daemonPlatform )
189- config = map [string ]interface {}{
190- "Binds" : []string {bindPath + ":" + path },
191- }
192- status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , config )
193- c .Assert (err , checker .IsNil )
194- c .Assert (status , checker .Equals , http .StatusNoContent )
195-
196- pth , err := inspectMountSourceField (name , path )
197- c .Assert (err , checker .IsNil )
198- c .Assert (pth , checker .Equals , bindPath , check .Commentf ("expected volume host path to be %s, got %s" , bindPath , pth ))
199- }
200-
201- // Test for GH#10618
202- func (s * DockerSuite ) TestContainerApiStartDupVolumeBinds (c * check.C ) {
203- // TODO Windows to Windows CI - Port this
204- testRequires (c , DaemonIsLinux )
205- name := "testdups"
206- config := map [string ]interface {}{
207- "Image" : "busybox" ,
208- "Volumes" : map [string ]struct {}{"/tmp" : {}},
209- }
210-
211- status , _ , err := sockRequest ("POST" , "/containers/create?name=" + name , config )
212- c .Assert (err , checker .IsNil )
213- c .Assert (status , checker .Equals , http .StatusCreated )
214-
215- bindPath1 := randomTmpDirPath ("test1" , daemonPlatform )
216- bindPath2 := randomTmpDirPath ("test2" , daemonPlatform )
217-
218- config = map [string ]interface {}{
219- "Binds" : []string {bindPath1 + ":/tmp" , bindPath2 + ":/tmp" },
220- }
221- status , body , err := sockRequest ("POST" , "/containers/" + name + "/start" , config )
222- c .Assert (err , checker .IsNil )
223- c .Assert (status , checker .Equals , http .StatusInternalServerError )
224- c .Assert (string (body ), checker .Contains , "Duplicate mount point" , check .Commentf ("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v" , string (body ), err ))
225- }
226-
227- func (s * DockerSuite ) TestContainerApiStartVolumesFrom (c * check.C ) {
228- // TODO Windows to Windows CI - Port this
229- testRequires (c , DaemonIsLinux )
230- volName := "voltst"
231- volPath := "/tmp"
232-
233- dockerCmd (c , "run" , "--name" , volName , "-v" , volPath , "busybox" )
234-
235- name := "TestContainerApiStartVolumesFrom"
236- config := map [string ]interface {}{
237- "Image" : "busybox" ,
238- "Volumes" : map [string ]struct {}{volPath : {}},
239- }
240-
241- status , _ , err := sockRequest ("POST" , "/containers/create?name=" + name , config )
242- c .Assert (err , checker .IsNil )
243- c .Assert (status , checker .Equals , http .StatusCreated )
244-
245- config = map [string ]interface {}{
246- "VolumesFrom" : []string {volName },
247- }
248- status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , config )
249- c .Assert (err , checker .IsNil )
250- c .Assert (status , checker .Equals , http .StatusNoContent )
251-
252- pth , err := inspectMountSourceField (name , volPath )
253- c .Assert (err , checker .IsNil )
254- pth2 , err := inspectMountSourceField (volName , volPath )
255- c .Assert (err , checker .IsNil )
256- c .Assert (pth , checker .Equals , pth2 , check .Commentf ("expected volume host path to be %s, got %s" , pth , pth2 ))
257- }
258-
259171func (s * DockerSuite ) TestGetContainerStats (c * check.C ) {
260172 // Problematic on Windows as Windows does not support stats
261173 testRequires (c , DaemonIsLinux )
@@ -442,27 +354,6 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
442354 }
443355}
444356
445- // #9981 - Allow a docker created volume (ie, one in /var/lib/docker/volumes) to be used to overwrite (via passing in Binds on api start) an existing volume
446- func (s * DockerSuite ) TestPostContainerBindNormalVolume (c * check.C ) {
447- // TODO Windows to Windows CI - Port this
448- testRequires (c , DaemonIsLinux )
449- dockerCmd (c , "create" , "-v" , "/foo" , "--name=one" , "busybox" )
450-
451- fooDir , err := inspectMountSourceField ("one" , "/foo" )
452- c .Assert (err , checker .IsNil )
453-
454- dockerCmd (c , "create" , "-v" , "/foo" , "--name=two" , "busybox" )
455-
456- bindSpec := map [string ][]string {"Binds" : {fooDir + ":/foo" }}
457- status , _ , err := sockRequest ("POST" , "/containers/two/start" , bindSpec )
458- c .Assert (err , checker .IsNil )
459- c .Assert (status , checker .Equals , http .StatusNoContent )
460-
461- fooDir2 , err := inspectMountSourceField ("two" , "/foo" )
462- c .Assert (err , checker .IsNil )
463- c .Assert (fooDir2 , checker .Equals , fooDir , check .Commentf ("expected volume path to be %s, got: %s" , fooDir , fooDir2 ))
464- }
465-
466357func (s * DockerSuite ) TestContainerApiPause (c * check.C ) {
467358 // Problematic on Windows as Windows does not support pause
468359 testRequires (c , DaemonIsLinux )
@@ -887,26 +778,6 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
887778 c .Assert (string (b ), checker .Contains , "Minimum memory limit allowed is 4MB" )
888779}
889780
890- func (s * DockerSuite ) TestStartWithTooLowMemoryLimit (c * check.C ) {
891- // TODO Windows: Port once memory is supported
892- testRequires (c , DaemonIsLinux )
893- out , _ := dockerCmd (c , "create" , "busybox" )
894-
895- containerID := strings .TrimSpace (out )
896-
897- config := `{
898- "CpuShares": 100,
899- "Memory": 524287
900- }`
901-
902- res , body , err := sockRequestRaw ("POST" , "/containers/" + containerID + "/start" , strings .NewReader (config ), "application/json" )
903- c .Assert (err , checker .IsNil )
904- b , err2 := readBody (body )
905- c .Assert (err2 , checker .IsNil )
906- c .Assert (res .StatusCode , checker .Equals , http .StatusInternalServerError )
907- c .Assert (string (b ), checker .Contains , "Minimum memory limit allowed is 4MB" )
908- }
909-
910781func (s * DockerSuite ) TestContainerApiRename (c * check.C ) {
911782 // TODO Windows: Debug why this sometimes fails on TP5. For now, leave disabled
912783 testRequires (c , DaemonIsLinux )
@@ -973,13 +844,12 @@ func (s *DockerSuite) TestContainerApiStart(c *check.C) {
973844 c .Assert (err , checker .IsNil )
974845 c .Assert (status , checker .Equals , http .StatusCreated )
975846
976- conf := make (map [string ]interface {})
977- status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , conf )
847+ status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , nil )
978848 c .Assert (err , checker .IsNil )
979849 c .Assert (status , checker .Equals , http .StatusNoContent )
980850
981851 // second call to start should give 304
982- status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , conf )
852+ status , _ , err = sockRequest ("POST" , "/containers/" + name + "/start" , nil )
983853 c .Assert (err , checker .IsNil )
984854
985855 // TODO(tibor): figure out why this doesn't work on windows
@@ -1189,16 +1059,21 @@ func (s *DockerSuite) TestContainerApiDeleteRemoveVolume(c *check.C) {
11891059func (s * DockerSuite ) TestContainerApiChunkedEncoding (c * check.C ) {
11901060 // TODO Windows CI: This can be ported
11911061 testRequires (c , DaemonIsLinux )
1192- out , _ := dockerCmd (c , "create" , "-v" , "/foo" , "busybox" , "true" )
1193- id := strings .TrimSpace (out )
11941062
11951063 conn , err := sockConn (time .Duration (10 * time .Second ))
11961064 c .Assert (err , checker .IsNil )
11971065 client := httputil .NewClientConn (conn , nil )
11981066 defer client .Close ()
11991067
1200- bindCfg := strings .NewReader (`{"Binds": ["/tmp:/foo"]}` )
1201- req , err := http .NewRequest ("POST" , "/containers/" + id + "/start" , bindCfg )
1068+ config := map [string ]interface {}{
1069+ "Image" : "busybox" ,
1070+ "Cmd" : append ([]string {"/bin/sh" , "-c" }, defaultSleepCommand ... ),
1071+ "OpenStdin" : true ,
1072+ }
1073+ b , err := json .Marshal (config )
1074+ c .Assert (err , checker .IsNil )
1075+
1076+ req , err := http .NewRequest ("POST" , "/containers/create" , bytes .NewBuffer (b ))
12021077 c .Assert (err , checker .IsNil )
12031078 req .Header .Set ("Content-Type" , "application/json" )
12041079 // This is a cheat to make the http request do chunked encoding
@@ -1207,18 +1082,9 @@ func (s *DockerSuite) TestContainerApiChunkedEncoding(c *check.C) {
12071082 req .ContentLength = - 1
12081083
12091084 resp , err := client .Do (req )
1210- c .Assert (err , checker .IsNil , check .Commentf ("error starting container with chunked encoding" ))
1085+ c .Assert (err , checker .IsNil , check .Commentf ("error creating container with chunked encoding" ))
12111086 resp .Body .Close ()
1212- c .Assert (resp .StatusCode , checker .Equals , 204 )
1213-
1214- out = inspectFieldJSON (c , id , "HostConfig.Binds" )
1215-
1216- var binds []string
1217- c .Assert (json .NewDecoder (strings .NewReader (out )).Decode (& binds ), checker .IsNil )
1218- c .Assert (binds , checker .HasLen , 1 , check .Commentf ("Got unexpected binds: %v" , binds ))
1219-
1220- expected := "/tmp:/foo"
1221- c .Assert (binds [0 ], checker .Equals , expected , check .Commentf ("got incorrect bind spec" ))
1087+ c .Assert (resp .StatusCode , checker .Equals , http .StatusCreated )
12221088}
12231089
12241090func (s * DockerSuite ) TestContainerApiPostContainerStop (c * check.C ) {
@@ -1302,59 +1168,6 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
13021168 c .Assert (status , checker .Equals , http .StatusCreated )
13031169}
13041170
1305- // #14640
1306- func (s * DockerSuite ) TestPostContainersStartWithoutLinksInHostConfig (c * check.C ) {
1307- // TODO Windows: Windows doesn't support supplying a hostconfig on start.
1308- // An alternate test could be written to validate the negative testing aspect of this
1309- testRequires (c , DaemonIsLinux )
1310- name := "test-host-config-links"
1311- dockerCmd (c , append ([]string {"create" , "--name" , name , "busybox" }, defaultSleepCommand ... )... )
1312-
1313- hc := inspectFieldJSON (c , name , "HostConfig" )
1314- config := `{"HostConfig":` + hc + `}`
1315-
1316- res , b , err := sockRequestRaw ("POST" , "/containers/" + name + "/start" , strings .NewReader (config ), "application/json" )
1317- c .Assert (err , checker .IsNil )
1318- c .Assert (res .StatusCode , checker .Equals , http .StatusNoContent )
1319- b .Close ()
1320- }
1321-
1322- // #14640
1323- func (s * DockerSuite ) TestPostContainersStartWithLinksInHostConfig (c * check.C ) {
1324- // TODO Windows: Windows doesn't support supplying a hostconfig on start.
1325- // An alternate test could be written to validate the negative testing aspect of this
1326- testRequires (c , DaemonIsLinux )
1327- name := "test-host-config-links"
1328- dockerCmd (c , "run" , "--name" , "foo" , "-d" , "busybox" , "top" )
1329- dockerCmd (c , "create" , "--name" , name , "--link" , "foo:bar" , "busybox" , "top" )
1330-
1331- hc := inspectFieldJSON (c , name , "HostConfig" )
1332- config := `{"HostConfig":` + hc + `}`
1333-
1334- res , b , err := sockRequestRaw ("POST" , "/containers/" + name + "/start" , strings .NewReader (config ), "application/json" )
1335- c .Assert (err , checker .IsNil )
1336- c .Assert (res .StatusCode , checker .Equals , http .StatusNoContent )
1337- b .Close ()
1338- }
1339-
1340- // #14640
1341- func (s * DockerSuite ) TestPostContainersStartWithLinksInHostConfigIdLinked (c * check.C ) {
1342- // Windows does not support links
1343- testRequires (c , DaemonIsLinux )
1344- name := "test-host-config-links"
1345- out , _ := dockerCmd (c , "run" , "--name" , "link0" , "-d" , "busybox" , "top" )
1346- id := strings .TrimSpace (out )
1347- dockerCmd (c , "create" , "--name" , name , "--link" , id , "busybox" , "top" )
1348-
1349- hc := inspectFieldJSON (c , name , "HostConfig" )
1350- config := `{"HostConfig":` + hc + `}`
1351-
1352- res , b , err := sockRequestRaw ("POST" , "/containers/" + name + "/start" , strings .NewReader (config ), "application/json" )
1353- c .Assert (err , checker .IsNil )
1354- c .Assert (res .StatusCode , checker .Equals , http .StatusNoContent )
1355- b .Close ()
1356- }
1357-
13581171// #14915
13591172func (s * DockerSuite ) TestContainerApiCreateNoHostConfig118 (c * check.C ) {
13601173 config := struct {
@@ -1434,23 +1247,6 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
14341247 c .Assert (string (body ), checker .Equals , expected )
14351248}
14361249
1437- func (s * DockerSuite ) TestStartWithNilDNS (c * check.C ) {
1438- // TODO Windows: Add once DNS is supported
1439- testRequires (c , DaemonIsLinux )
1440- out , _ := dockerCmd (c , "create" , "busybox" )
1441- containerID := strings .TrimSpace (out )
1442-
1443- config := `{"HostConfig": {"Dns": null}}`
1444-
1445- res , b , err := sockRequestRaw ("POST" , "/containers/" + containerID + "/start" , strings .NewReader (config ), "application/json" )
1446- c .Assert (err , checker .IsNil )
1447- c .Assert (res .StatusCode , checker .Equals , http .StatusNoContent )
1448- b .Close ()
1449-
1450- dns := inspectFieldJSON (c , containerID , "HostConfig.Dns" )
1451- c .Assert (dns , checker .Equals , "[]" )
1452- }
1453-
14541250func (s * DockerSuite ) TestPostContainersCreateShmSizeNegative (c * check.C ) {
14551251 // ShmSize is not supported on Windows
14561252 testRequires (c , DaemonIsLinux )
0 commit comments