fix test to deal with better better connect/reconnect logic and changed ident & auth handshake
This commit is contained in:
parent
298d928e27
commit
b64d5f7a1b
|
@ -24,7 +24,6 @@ func TestWrite(t *testing.T) {
|
||||||
ApiToken: "abc123token",
|
ApiToken: "abc123token",
|
||||||
Prefix: "my.prefix",
|
Prefix: "my.prefix",
|
||||||
}
|
}
|
||||||
i.Connect()
|
|
||||||
|
|
||||||
// Default to gauge
|
// Default to gauge
|
||||||
m1, _ := telegraf.NewMetric(
|
m1, _ := telegraf.NewMetric(
|
||||||
|
@ -40,10 +39,8 @@ func TestWrite(t *testing.T) {
|
||||||
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC),
|
time.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Simulate a connection close and reconnect.
|
|
||||||
metrics := []telegraf.Metric{m1, m2}
|
metrics := []telegraf.Metric{m1, m2}
|
||||||
i.Write(metrics)
|
i.Write(metrics)
|
||||||
i.Close()
|
|
||||||
|
|
||||||
// Counter and Histogram are increments
|
// Counter and Histogram are increments
|
||||||
m3, _ := telegraf.NewMetric(
|
m3, _ := telegraf.NewMetric(
|
||||||
|
@ -70,7 +67,6 @@ func TestWrite(t *testing.T) {
|
||||||
i.Write(metrics)
|
i.Write(metrics)
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
i.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TCPServer(t *testing.T, wg *sync.WaitGroup) {
|
func TCPServer(t *testing.T, wg *sync.WaitGroup) {
|
||||||
|
@ -82,11 +78,11 @@ func TCPServer(t *testing.T, wg *sync.WaitGroup) {
|
||||||
tp := textproto.NewReader(reader)
|
tp := textproto.NewReader(reader)
|
||||||
|
|
||||||
hello, _ := tp.ReadLine()
|
hello, _ := tp.ReadLine()
|
||||||
assert.Equal(t, "hello version go/telegraf/1.0", hello)
|
assert.Equal(t, "hello version go/telegraf/1.1", hello)
|
||||||
|
conn.Write([]byte("ok\n"))
|
||||||
auth, _ := tp.ReadLine()
|
auth, _ := tp.ReadLine()
|
||||||
assert.Equal(t, "authenticate abc123token", auth)
|
assert.Equal(t, "authenticate abc123token", auth)
|
||||||
|
conn.Write([]byte("ok\n"))
|
||||||
conn.Write([]byte("ok\nok\n"))
|
|
||||||
|
|
||||||
data1, _ := tp.ReadLine()
|
data1, _ := tp.ReadLine()
|
||||||
assert.Equal(t, "gauge my.prefix.192_168_0_1.mymeasurement.myfield 3.14 1289430000", data1)
|
assert.Equal(t, "gauge my.prefix.192_168_0_1.mymeasurement.myfield 3.14 1289430000", data1)
|
||||||
|
@ -99,11 +95,12 @@ func TCPServer(t *testing.T, wg *sync.WaitGroup) {
|
||||||
tp = textproto.NewReader(reader)
|
tp = textproto.NewReader(reader)
|
||||||
|
|
||||||
hello, _ = tp.ReadLine()
|
hello, _ = tp.ReadLine()
|
||||||
assert.Equal(t, "hello version go/telegraf/1.0", hello)
|
assert.Equal(t, "hello version go/telegraf/1.1", hello)
|
||||||
|
conn.Write([]byte("ok\n"))
|
||||||
|
|
||||||
auth, _ = tp.ReadLine()
|
auth, _ = tp.ReadLine()
|
||||||
assert.Equal(t, "authenticate abc123token", auth)
|
assert.Equal(t, "authenticate abc123token", auth)
|
||||||
|
conn.Write([]byte("ok\n"))
|
||||||
conn.Write([]byte("ok\nok\n"))
|
|
||||||
|
|
||||||
data3, _ := tp.ReadLine()
|
data3, _ := tp.ReadLine()
|
||||||
assert.Equal(t, "increment my.prefix.192_168_0_1.my_histogram 3.14 1289430000", data3)
|
assert.Equal(t, "increment my.prefix.192_168_0_1.my_histogram 3.14 1289430000", data3)
|
||||||
|
|
Loading…
Reference in New Issue