From e1448eb2386e226d89bc0e22dace84663ea22112 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Sat, 2 Apr 2016 12:40:21 +0200 Subject: [PATCH] A small update of libkermit Using compose/check package (and less code) Signed-off-by: Vincent Demeester --- glide.lock | 44 +++++++++++++++++------------- glide.yaml | 35 ++++++++++++++---------- integration/basic_test.go | 3 +- integration/consul_catalog_test.go | 17 ++++-------- integration/consul_test.go | 3 +- integration/docker_test.go | 23 +++++++--------- integration/etcd_test.go | 3 +- integration/file_test.go | 5 ++-- integration/https_test.go | 3 +- integration/integration_test.go | 11 +++----- integration/marathon_test.go | 3 +- 11 files changed, 78 insertions(+), 72 deletions(-) diff --git a/glide.lock b/glide.lock index 22a3d782f..546940ee6 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: a8cca3f2e5bde6b96d0c195402b14606877bc8630cd7f2f06e65e0884c6a008b -updated: 2016-03-29T23:24:08.772606184+02:00 +hash: 7ae4c083b2f2754acc858a7e2cd453343966dc62eef01fbd51adf8c718959a0c +updated: 2016-04-02T12:38:43.346296635+02:00 imports: - name: github.com/alecthomas/template version: b867cc6ab45cece8143cfcc6fc9c77cf3f2c23c0 @@ -39,7 +39,9 @@ imports: subpackages: - spew - name: github.com/docker/distribution - version: 9038e48c3b982f8e82281ea486f078a73731ac4e + version: ff6f38ccb69afa96214c7ee955359465d1fc767a + subpackages: + - reference - name: github.com/docker/docker version: f39987afe8d611407887b3094c03d6ba6a766a67 subpackages: @@ -79,14 +81,22 @@ imports: - runconfig - utils - volume +- name: github.com/docker/engine-api + version: 8924d6900370b4c7e7984be5adc61f50a80d7537 + subpackages: + - client + - types + - types/container + - types/filters + - types/strslice +- name: github.com/docker/go-connections + version: f549a9393d05688dff0992ef3efd8bbe6c628aeb + subpackages: + - nat +- name: github.com/docker/go-units + version: 5d2041e26a699eaca682e2ea41c8f891e1060444 - name: github.com/docker/libcompose version: e290a513ba909ca3afefd5cd611f3a3fe56f6a3a - subpackages: - - docker - - logger - - lookup - - project - - utils - name: github.com/docker/libkv version: 3732f7ff1b56057c3158f10bceb1e79133025373 subpackages: @@ -115,16 +125,18 @@ imports: - external/github.com/Sirupsen/logrus - external/github.com/docker/docker/pkg/idtools - external/github.com/docker/docker/pkg/ioutils + - external/github.com/docker/docker/pkg/longpath - external/github.com/docker/docker/pkg/pools - external/github.com/docker/docker/pkg/promise - external/github.com/docker/docker/pkg/system - - external/github.com/docker/docker/pkg/longpath - external/github.com/opencontainers/runc/libcontainer/user - external/golang.org/x/sys/unix - external/golang.org/x/net/context - external/github.com/docker/go-units - name: github.com/gambol99/go-marathon version: ade11d1dc2884ee1f387078fc28509559b6235d1 +- name: github.com/go-check/check + version: 11d3bc7aa68e238947792f30573146a3231fc0f1 - name: github.com/golang/glog version: fca8c8854093a154ff1eb580aae10276ad6b1b5f - name: github.com/google/go-querystring @@ -168,8 +180,6 @@ imports: version: fada45142db3f93097ca917da107aa3fad0ffcb5 - name: github.com/mailgun/multibuf version: 565402cd71fbd9c12aa7e295324ea357e970a61e -- name: github.com/mailgun/predicate - version: cb0bff91a7ab7cf7571e661ff883fc997bc554a3 - name: github.com/mailgun/timetools version: fd192d755b00c968d312d23f521eb0cdc6f66bd0 - name: github.com/miekg/dns @@ -184,8 +194,6 @@ imports: version: d8ed2627bdf02c080bf22230dbb337003b7aba2d subpackages: - difflib -- name: github.com/samalba/dockerclient - version: cfb489c624b635251a93e74e1e90eb0959c5367f - name: github.com/samuel/go-zookeeper version: fa6674abf3f4580b946a01bf7a1ce4ba8766205b subpackages: @@ -195,7 +203,7 @@ imports: - name: github.com/spf13/cast version: ee7b3e0353166ab1f3a605294ac8cd2b77953778 - name: github.com/spf13/cobra - version: c678ff029ee250b65714e518f4f5c5cb934955de + version: 2ccf9e982a3e3eb21eba9c9ad8e546529fd74c71 subpackages: - cobra - name: github.com/spf13/jwalterweatherman @@ -216,9 +224,9 @@ imports: - name: github.com/unrolled/render version: 26b4e3aac686940fe29521545afad9966ddfc80c - name: github.com/vdemeester/libkermit - version: 01a5399bdbd3312916c9fa4848108fbc81fe88d8 + version: 9012902ed333111cf804fd5a28114d8a64002951 - name: github.com/vdemeester/shakers - version: 8fe734f75f3a70b651cbfbf8a55a009da09e8dc5 + version: 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 - name: github.com/vulcand/oxy version: 8aaf36279137ac04ace3792a4f86098631b27d5a subpackages: @@ -255,8 +263,6 @@ imports: - unix - name: gopkg.in/alecthomas/kingpin.v2 version: 639879d6110b1b0409410c7b737ef0bb18325038 -- name: gopkg.in/check.v1 - version: 11d3bc7aa68e238947792f30573146a3231fc0f1 - name: gopkg.in/fsnotify.v1 version: 96c060f6a6b7e0d6f75fddd10efeaca3e5d1bcb0 - name: gopkg.in/mgo.v2 diff --git a/glide.yaml b/glide.yaml index 40d65a62e..2d9dd72c0 100644 --- a/glide.yaml +++ b/glide.yaml @@ -4,8 +4,6 @@ import: ref: cc90c7b091275e606ad0ca7102a23fb2072f3f5e subpackages: - etcd - - package: github.com/docker/distribution - ref: 9038e48c3b982f8e82281ea486f078a73731ac4e - package: github.com/mailgun/log ref: 44874009257d4d47ba9806f1b7f72a32a015e4d8 - package: github.com/containous/oxy @@ -26,7 +24,7 @@ import: - zk - package: github.com/docker/libtrust ref: 9cbd2a1374f46905c68a4eb3694a130610adc62a - - package: gopkg.in/check.v1 + - package: github.com/go-check/check ref: 11d3bc7aa68e238947792f30573146a3231fc0f1 - package: golang.org/x/net ref: d9558e5c97f85372afee28cf2b6059d7d3818919 @@ -39,7 +37,7 @@ import: - package: github.com/alecthomas/template ref: b867cc6ab45cece8143cfcc6fc9c77cf3f2c23c0 - package: github.com/vdemeester/shakers - ref: 8fe734f75f3a70b651cbfbf8a55a009da09e8dc5 + ref: 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 - package: github.com/alecthomas/units ref: 6b4e7dc5e3143b85ea77909c72caf89416fc2915 - package: github.com/gambol99/go-marathon @@ -48,8 +46,6 @@ import: ref: cb0bff91a7ab7cf7571e661ff883fc997bc554a3 - package: github.com/thoas/stats ref: 54ed61c2b47e263ae2f01b86837b0c4bd1da28e8 - - package: github.com/samalba/dockerclient - ref: cfb489c624b635251a93e74e1e90eb0959c5367f - package: github.com/Sirupsen/logrus ref: 418b41d23a1bf978c06faea5313ba194650ac088 - package: github.com/unrolled/render @@ -123,14 +119,6 @@ import: ref: bd2bdf7f18f849530ef7a1c29a4290217cab32a1 - package: gopkg.in/alecthomas/kingpin.v2 ref: 639879d6110b1b0409410c7b737ef0bb18325038 - - package: github.com/docker/libcompose - ref: e290a513ba909ca3afefd5cd611f3a3fe56f6a3a - subpackages: - - docker - - logger - - lookup - - project - - utils - package: github.com/cenkalti/backoff ref: 4dc77674aceaabba2c7e3da25d4c823edfb73f99 - package: gopkg.in/fsnotify.v1 @@ -166,5 +154,22 @@ import: - package: github.com/stretchr/testify/mock - package: github.com/xenolf/lego - package: github.com/vdemeester/libkermit - ref: 01a5399bdbd3312916c9fa4848108fbc81fe88d8 + ref: 9012902ed333111cf804fd5a28114d8a64002951 + - package: github.com/docker/libcompose + version: e290a513ba909ca3afefd5cd611f3a3fe56f6a3a + - package: github.com/docker/distribution + version: ff6f38ccb69afa96214c7ee955359465d1fc767a + subpackages: + - reference + - package: github.com/docker/engine-api + subpackages: + - client + - types + - types/container + - types/filters + - types/strslice + - package: github.com/docker/go-connections + subpackages: + - nat + - package: github.com/docker/go-units - package: github.com/mailgun/multibuf diff --git a/integration/basic_test.go b/integration/basic_test.go index d9a9178a8..be2fc6c20 100644 --- a/integration/basic_test.go +++ b/integration/basic_test.go @@ -6,8 +6,9 @@ import ( "time" "fmt" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // SimpleSuite diff --git a/integration/consul_catalog_test.go b/integration/consul_catalog_test.go index 6af779d65..1a79c4ff0 100644 --- a/integration/consul_catalog_test.go +++ b/integration/consul_catalog_test.go @@ -6,11 +6,11 @@ import ( "os/exec" "time" + "github.com/go-check/check" "github.com/hashicorp/consul/api" - docker "github.com/vdemeester/libkermit/docker" + docker "github.com/vdemeester/libkermit/docker/check" checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // Consul catalog test suites @@ -22,16 +22,12 @@ type ConsulCatalogSuite struct { } func (s *ConsulCatalogSuite) SetUpSuite(c *check.C) { - project, err := docker.NewProjectFromEnv() - c.Assert(err, checker.IsNil, check.Commentf("Error while creating docker project")) - s.project = project + s.project = docker.NewProjectFromEnv(c) s.createComposeProject(c, "consul_catalog") - err = s.composeProject.Start() - c.Assert(err, checker.IsNil, check.Commentf("Error starting project")) + s.composeProject.Start(c) - consul, err := s.project.Inspect("integration-test-consul_catalog_consul_1") - c.Assert(err, checker.IsNil, check.Commentf("Error finding consul container")) + consul := s.project.Inspect(c, "integration-test-consul_catalog_consul_1") s.consulIP = consul.NetworkSettings.IPAddress config := api.DefaultConfig() @@ -98,8 +94,7 @@ func (s *ConsulCatalogSuite) TestSingleService(c *check.C) { c.Assert(err, checker.IsNil) defer cmd.Process.Kill() - nginx, err := s.project.Inspect("integration-test-consul_catalog_nginx_1") - c.Assert(err, checker.IsNil, check.Commentf("Error finding nginx container")) + nginx := s.project.Inspect(c, "integration-test-consul_catalog_nginx_1") err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80) c.Assert(err, checker.IsNil, check.Commentf("Error registering service")) diff --git a/integration/consul_test.go b/integration/consul_test.go index beb619f55..f091fcc06 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -5,8 +5,9 @@ import ( "os/exec" "time" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // Consul test suites (using libcompose) diff --git a/integration/docker_test.go b/integration/docker_test.go index f06406acb..3dc869b79 100644 --- a/integration/docker_test.go +++ b/integration/docker_test.go @@ -11,10 +11,11 @@ import ( "time" "github.com/docker/docker/pkg/namesgenerator" - "github.com/vdemeester/libkermit/docker" + "github.com/go-check/check" + d "github.com/vdemeester/libkermit/docker" + docker "github.com/vdemeester/libkermit/docker/check" checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) var ( @@ -36,46 +37,42 @@ type DockerSuite struct { } func (s *DockerSuite) startContainer(c *check.C, image string, args ...string) string { - return s.startContainerWithConfig(c, image, docker.ContainerConfig{ + return s.startContainerWithConfig(c, image, d.ContainerConfig{ Cmd: args, }) } func (s *DockerSuite) startContainerWithLabels(c *check.C, image string, labels map[string]string, args ...string) string { - return s.startContainerWithConfig(c, image, docker.ContainerConfig{ + return s.startContainerWithConfig(c, image, d.ContainerConfig{ Cmd: args, Labels: labels, }) } -func (s *DockerSuite) startContainerWithConfig(c *check.C, image string, config docker.ContainerConfig) string { +func (s *DockerSuite) startContainerWithConfig(c *check.C, image string, config d.ContainerConfig) string { if config.Name == "" { config.Name = namesgenerator.GetRandomName(10) } - container, err := s.project.StartWithConfig(image, config) - c.Assert(err, checker.IsNil, check.Commentf("Error starting a container using config %v", config)) + container := s.project.StartWithConfig(c, image, config) // FIXME(vdemeester) this is ugly (it's because of the / in front of the name in docker..) return strings.SplitAfter(container.Name, "/")[1] } func (s *DockerSuite) SetUpSuite(c *check.C) { - project, err := docker.NewProjectFromEnv() - c.Assert(err, checker.IsNil, check.Commentf("Error while creating docker project")) + project := docker.NewProjectFromEnv(c) s.project = project // Pull required images for repository, tag := range RequiredImages { image := fmt.Sprintf("%s:%s", repository, tag) - s.project.Pull(image) - c.Assert(err, checker.IsNil, check.Commentf("Error while pulling image %s", image)) + s.project.Pull(c, image) } } func (s *DockerSuite) TearDownTest(c *check.C) { - err := s.project.Clean(os.Getenv("CIRCLECI") != "") - c.Assert(err, checker.IsNil, check.Commentf("Error while cleaning containers")) + s.project.Clean(c, os.Getenv("CIRCLECI") != "") } func (s *DockerSuite) TestSimpleConfiguration(c *check.C) { diff --git a/integration/etcd_test.go b/integration/etcd_test.go index 6307bc233..85095d688 100644 --- a/integration/etcd_test.go +++ b/integration/etcd_test.go @@ -5,8 +5,9 @@ import ( "os/exec" "time" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // Etcd test suites (using libcompose) diff --git a/integration/file_test.go b/integration/file_test.go index 6eb937ac7..25a1dde9e 100644 --- a/integration/file_test.go +++ b/integration/file_test.go @@ -5,8 +5,9 @@ import ( "os/exec" "time" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // File test suites @@ -15,7 +16,7 @@ type FileSuite struct{ BaseSuite } func (s *FileSuite) SetUpSuite(c *check.C) { s.createComposeProject(c, "file") - s.composeProject.Start() + s.composeProject.Start(c) } func (s *FileSuite) TestSimpleConfiguration(c *check.C) { diff --git a/integration/https_test.go b/integration/https_test.go index 41b89e243..964048812 100644 --- a/integration/https_test.go +++ b/integration/https_test.go @@ -8,8 +8,9 @@ import ( "os/exec" "time" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // HTTPSSuite diff --git a/integration/integration_test.go b/integration/integration_test.go index 431c2c69e..7178bb070 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -11,10 +11,10 @@ import ( "text/template" "github.com/containous/traefik/integration/utils" - "github.com/vdemeester/libkermit/compose" + "github.com/go-check/check" + compose "github.com/vdemeester/libkermit/compose/check" checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) func Test(t *testing.T) { @@ -41,17 +41,14 @@ type BaseSuite struct { func (s *BaseSuite) TearDownSuite(c *check.C) { // shutdown and delete compose project if s.composeProject != nil { - err := s.composeProject.Stop() - c.Assert(err, checker.IsNil) + s.composeProject.Stop(c) } } func (s *BaseSuite) createComposeProject(c *check.C, name string) { projectName := fmt.Sprintf("integration-test-%s", name) composeFile := fmt.Sprintf("resources/compose/%s.yml", name) - composeProject, err := compose.CreateProject(projectName, composeFile) - c.Assert(err, checker.IsNil) - s.composeProject = composeProject + s.composeProject = compose.CreateProject(c, projectName, composeFile) } func (s *BaseSuite) traefikCmd(c *check.C, args ...string) (*exec.Cmd, string) { diff --git a/integration/marathon_test.go b/integration/marathon_test.go index 82232696e..0453cbea2 100644 --- a/integration/marathon_test.go +++ b/integration/marathon_test.go @@ -5,8 +5,9 @@ import ( "os/exec" "time" + "github.com/go-check/check" + checker "github.com/vdemeester/shakers" - check "gopkg.in/check.v1" ) // Marathon test suites (using libcompose)