mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
attaching services api and UI chain to docker parent
Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
parent
df73d5e0cd
commit
742db1737c
4 changed files with 210 additions and 0 deletions
77
integration-cli/docker_cli_service_test.go
Normal file
77
integration-cli/docker_cli_service_test.go
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
// +build experimental
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/go-check/check"
|
||||
)
|
||||
|
||||
func isSrvAvailable(c *check.C, sname string, name string) bool {
|
||||
runCmd := exec.Command(dockerBinary, "service", "ls")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
lines := strings.Split(out, "\n")
|
||||
for i := 1; i < len(lines)-1; i++ {
|
||||
if strings.Contains(lines[i], sname) && strings.Contains(lines[i], name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
func isNwAvailable(c *check.C, name string) bool {
|
||||
runCmd := exec.Command(dockerBinary, "network", "ls")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
lines := strings.Split(out, "\n")
|
||||
for i := 1; i < len(lines)-1; i++ {
|
||||
if strings.Contains(lines[i], name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestDockerServiceCreateDelete(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "network", "create", "test")
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if !isNwAvailable(c, "test") {
|
||||
c.Fatalf("Network test not found")
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "service", "publish", "s1.test")
|
||||
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if !isSrvAvailable(c, "s1", "test") {
|
||||
c.Fatalf("service s1.test not found")
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "service", "unpublish", "s1.test")
|
||||
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if isSrvAvailable(c, "s1", "test") {
|
||||
c.Fatalf("service s1.test not removed")
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "network", "rm", "test")
|
||||
out, _, _, err = runCommandWithStdoutStderr(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
if isNetworkPresent(c, "test") {
|
||||
c.Fatalf("Network test is not removed")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue