2014-10-23 20:30:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-05-23 23:56:26 -04:00
|
|
|
"context"
|
2015-04-13 10:30:07 -07:00
|
|
|
"net/http"
|
2014-10-23 20:30:18 +00:00
|
|
|
"strings"
|
2015-04-18 09:46:47 -07:00
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/client"
|
2016-12-30 18:23:00 +01:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-12-30 10:49:36 +01:00
|
|
|
"github.com/docker/docker/integration-cli/request"
|
2015-04-18 09:46:47 -07:00
|
|
|
"github.com/go-check/check"
|
2014-10-23 20:30:18 +00:00
|
|
|
)
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerSuite) TestResizeAPIResponse(c *check.C) {
|
2017-04-16 23:39:30 +02:00
|
|
|
out := runSleepingContainer(c, "-d")
|
2015-04-06 09:21:18 -04:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2017-05-23 23:56:26 -04:00
|
|
|
cli, err := client.NewEnvClient()
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
defer cli.Close()
|
|
|
|
|
|
|
|
options := types.ResizeOptions{
|
|
|
|
Height: 40,
|
|
|
|
Width: 40,
|
|
|
|
}
|
|
|
|
err = cli.ContainerResize(context.Background(), cleanedContainerID, options)
|
2015-04-20 14:03:56 -07:00
|
|
|
c.Assert(err, check.IsNil)
|
2014-10-23 20:30:18 +00:00
|
|
|
}
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerSuite) TestResizeAPIHeightWidthNoInt(c *check.C) {
|
2017-04-16 23:39:30 +02:00
|
|
|
out := runSleepingContainer(c, "-d")
|
2015-04-13 08:36:04 +02:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
|
|
|
|
|
|
|
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
2017-05-23 23:56:26 -04:00
|
|
|
res, _, err := request.Post(endpoint)
|
|
|
|
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
2015-04-20 14:03:56 -07:00
|
|
|
c.Assert(err, check.IsNil)
|
2015-04-13 08:36:04 +02:00
|
|
|
}
|
|
|
|
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 01:50:12 +00:00
|
|
|
func (s *DockerSuite) TestResizeAPIResponseWhenContainerNotStarted(c *check.C) {
|
2015-07-14 08:35:36 +02:00
|
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
2015-04-06 09:21:18 -04:00
|
|
|
cleanedContainerID := strings.TrimSpace(out)
|
2014-10-23 20:30:18 +00:00
|
|
|
|
2015-04-10 03:09:26 -04:00
|
|
|
// make sure the exited container is not running
|
2015-07-14 08:35:36 +02:00
|
|
|
dockerCmd(c, "wait", cleanedContainerID)
|
2014-10-23 20:30:18 +00:00
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
cli, err := client.NewEnvClient()
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
defer cli.Close()
|
|
|
|
|
|
|
|
options := types.ResizeOptions{
|
|
|
|
Height: 40,
|
|
|
|
Width: 40,
|
|
|
|
}
|
2015-04-20 14:03:56 -07:00
|
|
|
|
2017-05-23 23:56:26 -04:00
|
|
|
err = cli.ContainerResize(context.Background(), cleanedContainerID, options)
|
|
|
|
c.Assert(err.Error(), checker.Contains, "is not running")
|
2014-10-23 20:30:18 +00:00
|
|
|
}
|