summaryrefslogtreecommitdiff
path: root/integration-cli/docker_cli_service_scale_test.go
diff options
context:
space:
mode:
authorallencloud <allen.sun@daocloud.io>2016-09-19 16:40:44 +0800
committerallencloud <allen.sun@daocloud.io>2016-09-26 17:18:02 +0800
commit5ba203e73a541935128e29a3babf810aac8ee004 (patch)
tree6629eb3864696dca4a995a9dac5fca8b6420fbe4 /integration-cli/docker_cli_service_scale_test.go
parentc8a19aee09756867d68ae8c70c2134a0193866ac (diff)
downloaddocker-5ba203e73a541935128e29a3babf810aac8ee004.tar.gz
validate service parameter in client side to avoid api call
Signed-off-by: allencloud <allen.sun@daocloud.io>
Diffstat (limited to 'integration-cli/docker_cli_service_scale_test.go')
-rw-r--r--integration-cli/docker_cli_service_scale_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/integration-cli/docker_cli_service_scale_test.go b/integration-cli/docker_cli_service_scale_test.go
new file mode 100644
index 0000000000..29cca2358d
--- /dev/null
+++ b/integration-cli/docker_cli_service_scale_test.go
@@ -0,0 +1,57 @@
+// +build !windows
+
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/docker/docker/pkg/integration/checker"
+ "github.com/go-check/check"
+)
+
+func (s *DockerSwarmSuite) TestServiceScale(c *check.C) {
+ d := s.AddDaemon(c, true, true)
+
+ service1Name := "TestService1"
+ service1Args := append([]string{"service", "create", "--name", service1Name, defaultSleepImage}, sleepCommandForDaemonPlatform()...)
+
+ // global mode
+ service2Name := "TestService2"
+ service2Args := append([]string{"service", "create", "--name", service2Name, "--mode=global", defaultSleepImage}, sleepCommandForDaemonPlatform()...)
+
+ // Create services
+ out, err := d.Cmd(service1Args...)
+ c.Assert(err, checker.IsNil)
+
+ out, err = d.Cmd(service2Args...)
+ c.Assert(err, checker.IsNil)
+
+ out, err = d.Cmd("service", "scale", "TestService1=2")
+ c.Assert(err, checker.IsNil)
+
+ out, err = d.Cmd("service", "scale", "TestService1=foobar")
+ c.Assert(err, checker.NotNil)
+
+ str := fmt.Sprintf("%s: invalid replicas value %s", service1Name, "foobar")
+ if !strings.Contains(out, str) {
+ c.Errorf("got: %s, expected has sub string: %s", out, str)
+ }
+
+ out, err = d.Cmd("service", "scale", "TestService1=-1")
+ c.Assert(err, checker.NotNil)
+
+ str = fmt.Sprintf("%s: invalid replicas value %s", service1Name, "-1")
+ if !strings.Contains(out, str) {
+ c.Errorf("got: %s, expected has sub string: %s", out, str)
+ }
+
+ // TestService2 is a global mode
+ out, err = d.Cmd("service", "scale", "TestService2=2")
+ c.Assert(err, checker.NotNil)
+
+ str = fmt.Sprintf("%s: scale can only be used with replicated mode\n", service2Name)
+ if out != str {
+ c.Errorf("got: %s, expected: %s", out, str)
+ }
+}