diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..8d4e1c2 --- /dev/null +++ b/circle.yml @@ -0,0 +1,18 @@ +machine: + pre: + - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0 + services: + - docker + +dependencies: + pre: + - sudo pip install docker-compose + - docker-compose -f docker-compose-integration.yml up -d --force-recreate + +test: + override: + - go test -v -race -tags integration ./...: + environment: + ETCD_ADDR: http://localhost:2379 + CONSUL_ADDR: localhost:8500 + ZK_ADDR: localhost:2181 diff --git a/docker-compose-integration.yml b/docker-compose-integration.yml new file mode 100644 index 0000000..f316a13 --- /dev/null +++ b/docker-compose-integration.yml @@ -0,0 +1,16 @@ +version: '2' +services: + etcd: + image: quay.io/coreos/etcd + ports: + - "2379:2379" + command: /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 -listen-client-urls "http://0.0.0.0:2379,http://0.0.0.0:4001" + consul: + image: progrium/consul + ports: + - "8500:8500" + command: -server -bootstrap + zk: + image: zookeeper + ports: + - "2181:2181" diff --git a/sd/consul/integration_test.go b/sd/consul/integration_test.go index 3355537..471af4e 100644 --- a/sd/consul/integration_test.go +++ b/sd/consul/integration_test.go @@ -14,11 +14,9 @@ ) func TestIntegration(t *testing.T) { - // Connect to Consul. - // docker run -p 8500:8500 progrium/consul -server -bootstrap - consulAddr := os.Getenv("CONSUL_ADDRESS") + consulAddr := os.Getenv("CONSUL_ADDR") if consulAddr == "" { - t.Fatal("CONSUL_ADDRESS is not set") + t.Fatal("CONSUL_ADDR is not set") } stdClient, err := stdconsul.NewClient(&stdconsul.Config{ Address: consulAddr, diff --git a/sd/zk/integration_test.go b/sd/zk/integration_test.go index 6084415..6c60443 100644 --- a/sd/zk/integration_test.go +++ b/sd/zk/integration_test.go @@ -4,8 +4,7 @@ import ( "bytes" - "flag" - "fmt" + "log" "os" "testing" "time" @@ -18,21 +17,11 @@ ) func TestMain(m *testing.M) { - flag.Parse() - - fmt.Println("Starting ZooKeeper server...") - - ts, err := stdzk.StartTestCluster(1, nil, nil) - if err != nil { - fmt.Printf("ZooKeeper server error: %v\n", err) - os.Exit(1) - } - - host = []string{fmt.Sprintf("localhost:%d", ts.Servers[0].Port)} - code := m.Run() - - ts.Stop() - os.Exit(code) + zkAddr := os.Getenv("ZK_ADDR") + if zkAddr == "" { + log.Fatal("ZK_ADDR is not set") + } + host = []string{zkAddr} } func TestCreateParentNodesOnServer(t *testing.T) {