From 882f98dcc0304e228a6c0e9c2a82de92186ee3bd Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Mon, 15 Dec 2014 19:06:23 -0500 Subject: [PATCH 1/7] started on integration tests Signed-off-by: Evan Hazlett --- integration-test/machine_test.go | 147 +++++++++++++++++++++++++++++++ integration-test/test_vars.go | 42 +++++++++ integration-test/utils.go | 45 ++++++++++ script/test | 2 +- script/test-integration | 4 + 5 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 integration-test/machine_test.go create mode 100644 integration-test/test_vars.go create mode 100644 integration-test/utils.go create mode 100755 script/test-integration diff --git a/integration-test/machine_test.go b/integration-test/machine_test.go new file mode 100644 index 0000000000..f51c205519 --- /dev/null +++ b/integration-test/machine_test.go @@ -0,0 +1,147 @@ +package main + +import ( + "fmt" + "os/exec" + "sync" + "testing" +) + +const ( + MACHINE_NAME = "machine-integration-test-%s" +) + +func machineCreate(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing create for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "create", "-d", name, mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error creating machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineStop(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing stop for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "stop", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error stopping machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineStart(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing start for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "start", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error starting machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineKill(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing kill for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "kill", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error killing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineRm(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing rm for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "rm", "-f", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error removing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func TestMachineCreate(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineCreate(d.name, t, &wg) + } + wg.Wait() +} + +func TestMachineStop(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineStop(d.name, t, &wg) + } + wg.Wait() +} + +func TestMachineStart(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineStart(d.name, t, &wg) + } + wg.Wait() +} + +func TestMachineKill(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineKill(d.name, t, &wg) + } + wg.Wait() +} + +func TestMachineRemove(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineRm(d.name, t, &wg) + } + wg.Wait() +} diff --git a/integration-test/test_vars.go b/integration-test/test_vars.go new file mode 100644 index 0000000000..eb38405345 --- /dev/null +++ b/integration-test/test_vars.go @@ -0,0 +1,42 @@ +package main + +import ( + "fmt" + "os" + "os/exec" +) + +type ( + MachineDriver struct { + name string + } +) + +var ( + machineBinary = "machine" + machineTestDrivers []MachineDriver +) + +func init() { + machineTestDrivers = []MachineDriver{ + MachineDriver{ + name: "virtualbox", + }, + MachineDriver{ + name: "digitalocean", + }, + } + if machineBin := os.Getenv("MACHINE_BINARY"); machineBin != "" { + machineBinary = machineBin + } else { + whichCmd := exec.Command("which", "machine") + out, _, err := runCommandWithOutput(whichCmd) + if err == nil { + machineBinary = stripTrailingCharacters(out) + + } else { + fmt.Printf("ERROR: couldn't resolve full path to the Machine binary") + os.Exit(1) + } + } +} diff --git a/integration-test/utils.go b/integration-test/utils.go new file mode 100644 index 0000000000..d4004e9ad3 --- /dev/null +++ b/integration-test/utils.go @@ -0,0 +1,45 @@ +package main + +import ( + "fmt" + "os/exec" + "strings" + "syscall" +) + +func getExitCode(err error) (int, error) { + exitCode := 0 + if exiterr, ok := err.(*exec.ExitError); ok { + if procExit := exiterr.Sys().(syscall.WaitStatus); ok { + return procExit.ExitStatus(), nil + } + } + return exitCode, fmt.Errorf("failed to get exit code") +} + +func processExitCode(err error) (exitCode int) { + if err != nil { + var exiterr error + if exitCode, exiterr = getExitCode(err); exiterr != nil { + // TODO: Fix this so we check the error's text. + // we've failed to retrieve exit code, so we set it to 127 + exitCode = 127 + } + } + return +} + +func runCommandWithOutput(cmd *exec.Cmd) (output string, exitCode int, err error) { + exitCode = 0 + out, err := cmd.CombinedOutput() + exitCode = processExitCode(err) + output = string(out) + return + +} + +func stripTrailingCharacters(target string) string { + target = strings.Trim(target, "\n") + target = strings.Trim(target, " ") + return target +} diff --git a/script/test b/script/test index 8f51da548b..e9479e2945 100755 --- a/script/test +++ b/script/test @@ -1,4 +1,4 @@ #!/bin/sh set -e docker build -t docker-machine . -exec docker run --rm docker-machine go test -v ./... +exec docker run --rm docker-machine go test -v -short ./... diff --git a/script/test-integration b/script/test-integration new file mode 100755 index 0000000000..3c6c2c0690 --- /dev/null +++ b/script/test-integration @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +docker build -t docker-machine . +exec docker run --rm docker-machine go test -v $* ./... From 93716e9d2ba07f48d88f15ebf62a09c8583674c8 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 16 Dec 2014 13:14:49 -0500 Subject: [PATCH 2/7] allow filtering driver integration tests Signed-off-by: Evan Hazlett --- integration-test/test_vars.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/integration-test/test_vars.go b/integration-test/test_vars.go index eb38405345..40f0ce9c52 100644 --- a/integration-test/test_vars.go +++ b/integration-test/test_vars.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "os/exec" + "strings" ) type ( @@ -18,14 +19,27 @@ var ( ) func init() { - machineTestDrivers = []MachineDriver{ - MachineDriver{ - name: "virtualbox", - }, - MachineDriver{ - name: "digitalocean", - }, + // allow filtering driver tests + if machineTests := os.Getenv("MACHINE_TESTS"); machineTests != "" { + tests := strings.Split(machineTests, " ") + for _, test := range tests { + mcn := MachineDriver{ + name: test, + } + machineTestDrivers = append(machineTestDrivers, mcn) + } + } else { + machineTestDrivers = []MachineDriver{ + MachineDriver{ + name: "virtualbox", + }, + MachineDriver{ + name: "digitalocean", + }, + } } + + // find machine binary if machineBin := os.Getenv("MACHINE_BINARY"); machineBin != "" { machineBinary = machineBin } else { From 1b1e678b768646ec29e646e360a631847dc16153 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Fri, 19 Dec 2014 10:11:58 -0500 Subject: [PATCH 3/7] added helper script for running tests in docker Signed-off-by: Evan Hazlett --- Dockerfile | 3 +++ commands.go | 4 ++-- script/run-integration-tests | 7 +++++++ script/test-integration | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100755 script/run-integration-tests diff --git a/Dockerfile b/Dockerfile index afd5f9cbc7..aa4154fb7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ FROM golang:1.3-cross +RUN apt-get update && apt-get install -y --no-install-recommends openssh-client RUN go get github.com/mitchellh/gox RUN go get github.com/aktau/github-release +RUN go get github.com/tools/godep ENV GOPATH /go/src/github.com/docker/machine/Godeps/_workspace:/go +ENV MACHINE_BINARY /go/src/github.com/docker/machine/machine WORKDIR /go/src/github.com/docker/machine ADD . /go/src/github.com/docker/machine diff --git a/commands.go b/commands.go index e03cf0e42e..45611d2ea0 100644 --- a/commands.go +++ b/commands.go @@ -94,7 +94,7 @@ var Commands = []cli.Command{ if name == "" { cli.ShowCommandHelp(c, "create") - os.Exit(1) + log.Fatalf("You must specify a machine name") } keyExists, err := drivers.PublicKeyExists() @@ -256,7 +256,7 @@ var Commands = []cli.Command{ Action: func(c *cli.Context) { if len(c.Args()) == 0 { cli.ShowCommandHelp(c, "rm") - os.Exit(1) + log.Fatal("You must specify a machine name") } force := c.Bool("force") diff --git a/script/run-integration-tests b/script/run-integration-tests new file mode 100755 index 0000000000..c54a492e58 --- /dev/null +++ b/script/run-integration-tests @@ -0,0 +1,7 @@ +#!/bin/sh +# HACK: until identity is merged +curl -sSL -o .docker-identity https://bfirsh.s3.amazonaws.com/docker/linux/docker-1.3.1-dev-identity-auth && chmod +x .docker-identity +./.docker-identity > /dev/null 2>&1 +godep go build +go test -v ./integration-test + diff --git a/script/test-integration b/script/test-integration index 3c6c2c0690..144d29f3d1 100755 --- a/script/test-integration +++ b/script/test-integration @@ -1,4 +1,4 @@ #!/bin/sh set -e docker build -t docker-machine . -exec docker run --rm docker-machine go test -v $* ./... +exec docker run --rm $* docker-machine ./script/run-integration-tests From 24ba3540bf18a2338e6994817e7bfcf62d3eec9e Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Fri, 19 Dec 2014 13:58:23 -0500 Subject: [PATCH 4/7] update travis to skip integration tests Signed-off-by: Evan Hazlett --- .travis.yml | 2 +- .../test_vars.go | 4 +- .../utils.go | 1 - integration-test/machine_test.go | 147 ------------------ 4 files changed, 3 insertions(+), 151 deletions(-) rename {integration-test => _integration-test}/test_vars.go (96%) rename {integration-test => _integration-test}/utils.go (98%) delete mode 100644 integration-test/machine_test.go diff --git a/.travis.yml b/.travis.yml index eb6b64aead..7ce858ba9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ go: script: - script/validate-dco - script/validate-gofmt -- go test -v ./... +- go test -v -short ./... diff --git a/integration-test/test_vars.go b/_integration-test/test_vars.go similarity index 96% rename from integration-test/test_vars.go rename to _integration-test/test_vars.go index 40f0ce9c52..34c7230132 100644 --- a/integration-test/test_vars.go +++ b/_integration-test/test_vars.go @@ -30,10 +30,10 @@ func init() { } } else { machineTestDrivers = []MachineDriver{ - MachineDriver{ + { name: "virtualbox", }, - MachineDriver{ + { name: "digitalocean", }, } diff --git a/integration-test/utils.go b/_integration-test/utils.go similarity index 98% rename from integration-test/utils.go rename to _integration-test/utils.go index d4004e9ad3..b2abb1cb52 100644 --- a/integration-test/utils.go +++ b/_integration-test/utils.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os/exec" - "strings" "syscall" ) diff --git a/integration-test/machine_test.go b/integration-test/machine_test.go deleted file mode 100644 index f51c205519..0000000000 --- a/integration-test/machine_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package main - -import ( - "fmt" - "os/exec" - "sync" - "testing" -) - -const ( - MACHINE_NAME = "machine-integration-test-%s" -) - -func machineCreate(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) - fmt.Printf(" - testing create for %s (%s)\n", name, mName) - runCmd := exec.Command(machineBinary, "create", "-d", name, mName) - out, exitCode, err := runCommandWithOutput(runCmd) - if err != nil { - t.Error(out, err) - } - if exitCode != 0 { - t.Errorf("error creating machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) - } - wg.Done() -} - -func machineStop(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) - fmt.Printf(" - testing stop for %s (%s)\n", name, mName) - runCmd := exec.Command(machineBinary, "stop", mName) - out, exitCode, err := runCommandWithOutput(runCmd) - if err != nil { - t.Error(out, err) - } - if exitCode != 0 { - t.Errorf("error stopping machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) - } - wg.Done() -} - -func machineStart(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) - fmt.Printf(" - testing start for %s (%s)\n", name, mName) - runCmd := exec.Command(machineBinary, "start", mName) - out, exitCode, err := runCommandWithOutput(runCmd) - if err != nil { - t.Error(out, err) - } - if exitCode != 0 { - t.Errorf("error starting machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) - } - wg.Done() -} - -func machineKill(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) - fmt.Printf(" - testing kill for %s (%s)\n", name, mName) - runCmd := exec.Command(machineBinary, "kill", mName) - out, exitCode, err := runCommandWithOutput(runCmd) - if err != nil { - t.Error(out, err) - } - if exitCode != 0 { - t.Errorf("error killing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) - } - wg.Done() -} - -func machineRm(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) - fmt.Printf(" - testing rm for %s (%s)\n", name, mName) - runCmd := exec.Command(machineBinary, "rm", "-f", mName) - out, exitCode, err := runCommandWithOutput(runCmd) - if err != nil { - t.Error(out, err) - } - if exitCode != 0 { - t.Errorf("error removing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) - } - wg.Done() -} - -func TestMachineCreate(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - var wg sync.WaitGroup - for _, d := range machineTestDrivers { - wg.Add(1) - go machineCreate(d.name, t, &wg) - } - wg.Wait() -} - -func TestMachineStop(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - var wg sync.WaitGroup - for _, d := range machineTestDrivers { - wg.Add(1) - go machineStop(d.name, t, &wg) - } - wg.Wait() -} - -func TestMachineStart(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - var wg sync.WaitGroup - for _, d := range machineTestDrivers { - wg.Add(1) - go machineStart(d.name, t, &wg) - } - wg.Wait() -} - -func TestMachineKill(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - var wg sync.WaitGroup - for _, d := range machineTestDrivers { - wg.Add(1) - go machineKill(d.name, t, &wg) - } - wg.Wait() -} - -func TestMachineRemove(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test") - } - - var wg sync.WaitGroup - for _, d := range machineTestDrivers { - wg.Add(1) - go machineRm(d.name, t, &wg) - } - wg.Wait() -} From ecd3a6eebe04a4032cefc6b3c9136b69d2005ba1 Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 23 Dec 2014 17:16:35 -0500 Subject: [PATCH 5/7] fix test script Signed-off-by: Evan Hazlett --- _integration-test/utils.go | 1 + script/run-integration-tests | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/_integration-test/utils.go b/_integration-test/utils.go index b2abb1cb52..d4004e9ad3 100644 --- a/_integration-test/utils.go +++ b/_integration-test/utils.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os/exec" + "strings" "syscall" ) diff --git a/script/run-integration-tests b/script/run-integration-tests index c54a492e58..4c9dc04310 100755 --- a/script/run-integration-tests +++ b/script/run-integration-tests @@ -3,5 +3,5 @@ curl -sSL -o .docker-identity https://bfirsh.s3.amazonaws.com/docker/linux/docker-1.3.1-dev-identity-auth && chmod +x .docker-identity ./.docker-identity > /dev/null 2>&1 godep go build -go test -v ./integration-test +go test -v ./_integration-test From b59d41b36bc9ddd1e58b9a8d099ca22bd737324f Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 23 Dec 2014 18:07:10 -0500 Subject: [PATCH 6/7] added test docs to readme; add doc info to tests Signed-off-by: Evan Hazlett --- README.md | 12 +++ _integration-test/machine_test.go | 152 ++++++++++++++++++++++++++++++ script/run-integration-tests | 4 - script/test-integration | 4 - 4 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 _integration-test/machine_test.go delete mode 100755 script/test-integration diff --git a/README.md b/README.md index ab773f56ee..08d1f18b9d 100644 --- a/README.md +++ b/README.md @@ -142,3 +142,15 @@ run: If you have any questions we're in #docker-machine on Freenode. +======= +## Integration Tests +There is a suite of integration tests that will run for the drivers. In order +to use these you must export the corresponding environment variables for each +driver as these perform the actual actions (start, stop, restart, kill, etc). + +By default, the suite will run tests against all drivers in master. You can +override this by setting the environment variable `MACHINE_TESTS`. For example, +`MACHINE_TESTS="virtualbox" ./script/run-integration-tests` will only run the +virtualbox driver integration tests. + +To run, use the helper script `./script/run-integration-tests`. diff --git a/_integration-test/machine_test.go b/_integration-test/machine_test.go new file mode 100644 index 0000000000..3c4f8c68ff --- /dev/null +++ b/_integration-test/machine_test.go @@ -0,0 +1,152 @@ +package main + +import ( + "fmt" + "os/exec" + "sync" + "testing" +) + +const ( + MACHINE_NAME = "machine-integration-test-%s" +) + +func machineCreate(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing create for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "create", "-d", name, mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error creating machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineStop(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing stop for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "stop", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error stopping machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineStart(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing start for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "start", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error starting machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineKill(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing kill for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "kill", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error killing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +func machineRm(name string, t *testing.T, wg *sync.WaitGroup) { + mName := fmt.Sprintf(MACHINE_NAME, name) + fmt.Printf(" - testing rm for %s (%s)\n", name, mName) + runCmd := exec.Command(machineBinary, "rm", "-f", mName) + out, exitCode, err := runCommandWithOutput(runCmd) + if err != nil { + t.Error(out, err) + } + if exitCode != 0 { + t.Errorf("error removing machine: driver: %s; exit code: %d; output: %s", name, exitCode, out) + } + wg.Done() +} + +// TestMachineCreate will test that the driver creates the machine +func TestMachineCreate(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineCreate(d.name, t, &wg) + } + wg.Wait() +} + +// TestMachineCreate will test that the driver stops the machine +func TestMachineStop(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineStop(d.name, t, &wg) + } + wg.Wait() +} + +// TestMachineCreate will test that the driver starts the machine +func TestMachineStart(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineStart(d.name, t, &wg) + } + wg.Wait() +} + +// TestMachineCreate will test that the driver kills the machine +func TestMachineKill(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineKill(d.name, t, &wg) + } + wg.Wait() +} + +// TestMachineCreate will test that the driver removes the machine +func TestMachineRemove(t *testing.T) { + if testing.Short() { + t.Skip("skipping integration test") + } + + var wg sync.WaitGroup + for _, d := range machineTestDrivers { + wg.Add(1) + go machineRm(d.name, t, &wg) + } + wg.Wait() +} diff --git a/script/run-integration-tests b/script/run-integration-tests index 4c9dc04310..d16f3053ac 100755 --- a/script/run-integration-tests +++ b/script/run-integration-tests @@ -1,7 +1,3 @@ #!/bin/sh -# HACK: until identity is merged -curl -sSL -o .docker-identity https://bfirsh.s3.amazonaws.com/docker/linux/docker-1.3.1-dev-identity-auth && chmod +x .docker-identity -./.docker-identity > /dev/null 2>&1 -godep go build go test -v ./_integration-test diff --git a/script/test-integration b/script/test-integration deleted file mode 100755 index 144d29f3d1..0000000000 --- a/script/test-integration +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -e -docker build -t docker-machine . -exec docker run --rm $* docker-machine ./script/run-integration-tests From d52399a22d6ef23dd60a33c3ef8648320021433e Mon Sep 17 00:00:00 2001 From: Evan Hazlett Date: Tue, 30 Dec 2014 15:11:24 -0500 Subject: [PATCH 7/7] fixes from @nathanleclaire Signed-off-by: Evan Hazlett --- _integration-test/machine_test.go | 12 ++++++------ commands.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_integration-test/machine_test.go b/_integration-test/machine_test.go index 3c4f8c68ff..35feb2cddc 100644 --- a/_integration-test/machine_test.go +++ b/_integration-test/machine_test.go @@ -8,11 +8,11 @@ import ( ) const ( - MACHINE_NAME = "machine-integration-test-%s" + machineName = "machine-integration-test-%s" ) func machineCreate(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) + mName := fmt.Sprintf(machineName, name) fmt.Printf(" - testing create for %s (%s)\n", name, mName) runCmd := exec.Command(machineBinary, "create", "-d", name, mName) out, exitCode, err := runCommandWithOutput(runCmd) @@ -26,7 +26,7 @@ func machineCreate(name string, t *testing.T, wg *sync.WaitGroup) { } func machineStop(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) + mName := fmt.Sprintf(machineName, name) fmt.Printf(" - testing stop for %s (%s)\n", name, mName) runCmd := exec.Command(machineBinary, "stop", mName) out, exitCode, err := runCommandWithOutput(runCmd) @@ -40,7 +40,7 @@ func machineStop(name string, t *testing.T, wg *sync.WaitGroup) { } func machineStart(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) + mName := fmt.Sprintf(machineName, name) fmt.Printf(" - testing start for %s (%s)\n", name, mName) runCmd := exec.Command(machineBinary, "start", mName) out, exitCode, err := runCommandWithOutput(runCmd) @@ -54,7 +54,7 @@ func machineStart(name string, t *testing.T, wg *sync.WaitGroup) { } func machineKill(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) + mName := fmt.Sprintf(machineName, name) fmt.Printf(" - testing kill for %s (%s)\n", name, mName) runCmd := exec.Command(machineBinary, "kill", mName) out, exitCode, err := runCommandWithOutput(runCmd) @@ -68,7 +68,7 @@ func machineKill(name string, t *testing.T, wg *sync.WaitGroup) { } func machineRm(name string, t *testing.T, wg *sync.WaitGroup) { - mName := fmt.Sprintf(MACHINE_NAME, name) + mName := fmt.Sprintf(machineName, name) fmt.Printf(" - testing rm for %s (%s)\n", name, mName) runCmd := exec.Command(machineBinary, "rm", "-f", mName) out, exitCode, err := runCommandWithOutput(runCmd) diff --git a/commands.go b/commands.go index 45611d2ea0..80a9dda55b 100644 --- a/commands.go +++ b/commands.go @@ -94,7 +94,7 @@ var Commands = []cli.Command{ if name == "" { cli.ShowCommandHelp(c, "create") - log.Fatalf("You must specify a machine name") + log.Fatal("You must specify a machine name") } keyExists, err := drivers.PublicKeyExists()