Codebase list golang-github-go-kit-kit / 2a23fa6
kit/sd integration tests: also skip tests if missing needed environment variables for consul and zookeeper Bas van Beek 5 years ago
2 changed file(s) with 26 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
1616 func TestIntegration(t *testing.T) {
1717 consulAddr := os.Getenv("CONSUL_ADDR")
1818 if consulAddr == "" {
19 t.Fatal("CONSUL_ADDR is not set")
19 t.Skip("CONSUL_ADDR not set; skipping integration test")
2020 }
2121 stdClient, err := stdconsul.NewClient(&stdconsul.Config{
2222 Address: consulAddr,
33
44 import (
55 "bytes"
6 "log"
76 "os"
87 "testing"
98 "time"
1716
1817 func TestMain(m *testing.M) {
1918 zkAddr := os.Getenv("ZK_ADDR")
20 if zkAddr == "" {
21 log.Fatal("ZK_ADDR is not set")
22 }
23 host = []string{zkAddr}
19 if zkAddr != "" {
20 host = []string{zkAddr}
21 }
22 m.Run()
2423 }
2524
2625 func TestCreateParentNodesOnServer(t *testing.T) {
26 if len(host) == 0 {
27 t.Skip("ZK_ADDR not set; skipping integration test")
28 }
2729 payload := [][]byte{[]byte("Payload"), []byte("Test")}
2830 c1, err := NewClient(host, logger, Payload(payload))
2931 if err != nil {
6668 }
6769
6870 func TestCreateBadParentNodesOnServer(t *testing.T) {
71 if len(host) == 0 {
72 t.Skip("ZK_ADDR not set; skipping integration test")
73 }
6974 c, _ := NewClient(host, logger)
7075 defer c.Stop()
7176
7782 }
7883
7984 func TestCredentials1(t *testing.T) {
85 if len(host) == 0 {
86 t.Skip("ZK_ADDR not set; skipping integration test")
87 }
8088 acl := stdzk.DigestACL(stdzk.PermAll, "user", "secret")
8189 c, _ := NewClient(host, logger, ACL(acl), Credentials("user", "secret"))
8290 defer c.Stop()
8997 }
9098
9199 func TestCredentials2(t *testing.T) {
100 if len(host) == 0 {
101 t.Skip("ZK_ADDR not set; skipping integration test")
102 }
92103 acl := stdzk.DigestACL(stdzk.PermAll, "user", "secret")
93104 c, _ := NewClient(host, logger, ACL(acl))
94105 defer c.Stop()
101112 }
102113
103114 func TestConnection(t *testing.T) {
115 if len(host) == 0 {
116 t.Skip("ZK_ADDR not set; skipping integration test")
117 }
104118 c, _ := NewClient(host, logger)
105119 c.Stop()
106120
112126 }
113127
114128 func TestGetEntriesOnServer(t *testing.T) {
129 if len(host) == 0 {
130 t.Skip("ZK_ADDR not set; skipping integration test")
131 }
115132 var instancePayload = "10.0.3.204:8002"
116133
117134 c1, err := NewClient(host, logger)
157174 }
158175
159176 func TestGetEntriesPayloadOnServer(t *testing.T) {
177 if len(host) == 0 {
178 t.Skip("ZK_ADDR not set; skipping integration test")
179 }
160180 c, err := NewClient(host, logger)
161181 if err != nil {
162182 t.Fatalf("Connect returned error: %v", err)