瀏覽代碼

Connect to toxiproxy in functional tests

Evan Huus 10 年之前
父節點
當前提交
d482af099e
共有 3 個文件被更改,包括 12 次插入1 次删除
  1. 1 0
      .travis.yml
  2. 1 1
      Makefile
  3. 10 0
      functional_test.go

+ 1 - 0
.travis.yml

@@ -7,6 +7,7 @@ go:
 env:
   global:
   - KAFKA_PEERS=localhost:9091,localhost:9092,localhost:9093,localhost:9094,localhost:9095
+  - TOXIPROXY_ADDR=http://localhost:8474
   - KAFKA_INSTALL_ROOT=/home/travis/kafka
   - KAFKA_HOSTNAME=localhost
   matrix:

+ 1 - 1
Makefile

@@ -21,4 +21,4 @@ install_go_vet:
 	go get golang.org/x/tools/cmd/vet
 
 get:
-	go get
+	go get -t

+ 10 - 0
functional_test.go

@@ -8,9 +8,12 @@ import (
 	"strings"
 	"testing"
 	"time"
+
+	toxiproxy "github.com/Shopify/toxiproxy/client"
 )
 
 const (
+	VagrantToxiproxy      = "http://192.168.100.67:8474"
 	VagrantKafkaPeers     = "192.168.100.67:9091,192.168.100.67:9092,192.168.100.67:9093,192.168.100.67:9094,192.168.100.67:9095"
 	VagrantZookeeperPeers = "192.168.100.67:2181,192.168.100.67:2182,192.168.100.67:2183,192.168.100.67:2184,192.168.100.67:2185"
 )
@@ -18,9 +21,16 @@ const (
 var (
 	kafkaIsAvailable, kafkaShouldBeAvailable bool
 	kafkaBrokers                             []string
+	proxy                                    *toxiproxy.Client
 )
 
 func init() {
+	proxyAddr := os.Getenv("TOXIPROXY_ADDR")
+	if proxyAddr == "" {
+		proxyAddr = VagrantToxiproxy
+	}
+	proxy = toxiproxy.NewClient(proxyAddr)
+
 	kafkaPeers := os.Getenv("KAFKA_PEERS")
 	if kafkaPeers == "" {
 		kafkaPeers = VagrantKafkaPeers