99
1010 "github.com/influxdb/telegraf/testutil"
1111
12- "github.com/stretchr/testify/assert"
1312 "github.com/stretchr/testify/require"
1413)
1514
@@ -35,49 +34,121 @@ func TestNSQStats(t *testing.T) {
3534 // actually validate the tests
3635 tests := []struct {
3736 m string
38- v int64
37+ f map [ string ] interface {}
3938 g map [string ]string
4039 }{
41- {`nsq_server_count` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` }},
42- {`nsq_server_topic_count` , int64 (2 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` }},
43- {`nsq_topic_depth` , int64 (12 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` }},
44- {`nsq_topic_backend_depth` , int64 (13 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` }},
45- {`nsq_topic_message_count` , int64 (14 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` }},
46- {`nsq_topic_channel_count` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` }},
47- {`nsq_channel_depth` , int64 (0 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
48- {`nsq_channel_backend_depth` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
49- {`nsq_channel_inflight_count` , int64 (2 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
50- {`nsq_channel_deferred_count` , int64 (3 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
51- {`nsq_channel_message_count` , int64 (4 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
52- {`nsq_channel_requeue_count` , int64 (5 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
53- {`nsq_channel_timeout_count` , int64 (6 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
54- {`nsq_channel_client_count` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` }},
55- {`nsq_client_ready_count` , int64 (200 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` , `client_name` : `373a715cd990` , `client_id` : `373a715cd990` , `client_hostname` : `373a715cd990` , `client_version` : `V2` , `client_address` : `172.17.0.11:35560` , `client_tls` : `false` , `client_snappy` : `false` , `client_deflate` : `false` , `client_user_agent` : `nsq_to_nsq/0.3.6 go-nsq/1.0.5` }},
56- {`nsq_client_inflight_count` , int64 (7 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` , `client_name` : `373a715cd990` , `client_id` : `373a715cd990` , `client_hostname` : `373a715cd990` , `client_version` : `V2` , `client_address` : `172.17.0.11:35560` , `client_tls` : `false` , `client_snappy` : `false` , `client_deflate` : `false` , `client_user_agent` : `nsq_to_nsq/0.3.6 go-nsq/1.0.5` }},
57- {`nsq_client_message_count` , int64 (8 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` , `client_name` : `373a715cd990` , `client_id` : `373a715cd990` , `client_hostname` : `373a715cd990` , `client_version` : `V2` , `client_address` : `172.17.0.11:35560` , `client_tls` : `false` , `client_snappy` : `false` , `client_deflate` : `false` , `client_user_agent` : `nsq_to_nsq/0.3.6 go-nsq/1.0.5` }},
58- {`nsq_client_finish_count` , int64 (9 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` , `client_name` : `373a715cd990` , `client_id` : `373a715cd990` , `client_hostname` : `373a715cd990` , `client_version` : `V2` , `client_address` : `172.17.0.11:35560` , `client_tls` : `false` , `client_snappy` : `false` , `client_deflate` : `false` , `client_user_agent` : `nsq_to_nsq/0.3.6 go-nsq/1.0.5` }},
59- {`nsq_client_requeue_count` , int64 (10 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t1` , `channel` : `c1` , `client_name` : `373a715cd990` , `client_id` : `373a715cd990` , `client_hostname` : `373a715cd990` , `client_version` : `V2` , `client_address` : `172.17.0.11:35560` , `client_tls` : `false` , `client_snappy` : `false` , `client_deflate` : `false` , `client_user_agent` : `nsq_to_nsq/0.3.6 go-nsq/1.0.5` }},
60- {`nsq_topic_depth` , int64 (28 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` }},
61- {`nsq_topic_backend_depth` , int64 (29 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` }},
62- {`nsq_topic_message_count` , int64 (30 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` }},
63- {`nsq_topic_channel_count` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` }},
64- {`nsq_channel_depth` , int64 (15 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
65- {`nsq_channel_backend_depth` , int64 (16 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
66- {`nsq_channel_inflight_count` , int64 (17 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
67- {`nsq_channel_deferred_count` , int64 (18 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
68- {`nsq_channel_message_count` , int64 (19 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
69- {`nsq_channel_requeue_count` , int64 (20 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
70- {`nsq_channel_timeout_count` , int64 (21 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
71- {`nsq_channel_client_count` , int64 (1 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` }},
72- {`nsq_client_ready_count` , int64 (22 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` , `client_name` : `377569bd462b` , `client_id` : `377569bd462b` , `client_hostname` : `377569bd462b` , `client_version` : `V2` , `client_address` : `172.17.0.8:48145` , `client_user_agent` : `go-nsq/1.0.5` , `client_tls` : `true` , `client_snappy` : `true` , `client_deflate` : `true` }},
73- {`nsq_client_inflight_count` , int64 (23 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` , `client_name` : `377569bd462b` , `client_id` : `377569bd462b` , `client_hostname` : `377569bd462b` , `client_version` : `V2` , `client_address` : `172.17.0.8:48145` , `client_user_agent` : `go-nsq/1.0.5` , `client_tls` : `true` , `client_snappy` : `true` , `client_deflate` : `true` }},
74- {`nsq_client_message_count` , int64 (24 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` , `client_name` : `377569bd462b` , `client_id` : `377569bd462b` , `client_hostname` : `377569bd462b` , `client_version` : `V2` , `client_address` : `172.17.0.8:48145` , `client_user_agent` : `go-nsq/1.0.5` , `client_tls` : `true` , `client_snappy` : `true` , `client_deflate` : `true` }},
75- {`nsq_client_finish_count` , int64 (25 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` , `client_name` : `377569bd462b` , `client_id` : `377569bd462b` , `client_hostname` : `377569bd462b` , `client_version` : `V2` , `client_address` : `172.17.0.8:48145` , `client_user_agent` : `go-nsq/1.0.5` , `client_tls` : `true` , `client_snappy` : `true` , `client_deflate` : `true` }},
76- {`nsq_client_requeue_count` , int64 (26 ), map [string ]string {`server_host` : host , `server_version` : `0.3.6` , `topic` : `t2` , `channel` : `c2` , `client_name` : `377569bd462b` , `client_id` : `377569bd462b` , `client_hostname` : `377569bd462b` , `client_version` : `V2` , `client_address` : `172.17.0.8:48145` , `client_user_agent` : `go-nsq/1.0.5` , `client_tls` : `true` , `client_snappy` : `true` , `client_deflate` : `true` }},
40+ {
41+ "nsq_server" ,
42+ map [string ]interface {}{
43+ "server_count" : int64 (1 ),
44+ "topic_count" : int64 (2 ),
45+ },
46+ map [string ]string {
47+ "server_host" : host ,
48+ "server_version" : "0.3.6" ,
49+ },
50+ },
51+ {
52+ "nsq_topic" ,
53+ map [string ]interface {}{
54+ "depth" : int64 (12 ),
55+ "backend_depth" : int64 (13 ),
56+ "message_count" : int64 (14 ),
57+ "channel_count" : int64 (1 ),
58+ },
59+ map [string ]string {
60+ "server_host" : host ,
61+ "server_version" : "0.3.6" ,
62+ "topic" : "t1" },
63+ },
64+ {
65+ "nsq_channel" ,
66+ map [string ]interface {}{
67+ "depth" : int64 (0 ),
68+ "backend_depth" : int64 (1 ),
69+ "inflight_count" : int64 (2 ),
70+ "deferred_count" : int64 (3 ),
71+ "message_count" : int64 (4 ),
72+ "requeue_count" : int64 (5 ),
73+ "timeout_count" : int64 (6 ),
74+ "client_count" : int64 (1 ),
75+ },
76+ map [string ]string {
77+ "server_host" : host ,
78+ "server_version" : "0.3.6" ,
79+ "topic" : "t1" ,
80+ "channel" : "c1" ,
81+ },
82+ },
83+ {
84+ "nsq_client" ,
85+ map [string ]interface {}{
86+ "ready_count" : int64 (200 ),
87+ "inflight_count" : int64 (7 ),
88+ "message_count" : int64 (8 ),
89+ "finish_count" : int64 (9 ),
90+ "requeue_count" : int64 (10 ),
91+ },
92+ map [string ]string {"server_host" : host , "server_version" : "0.3.6" ,
93+ "topic" : "t1" , "channel" : "c1" , "client_name" : "373a715cd990" ,
94+ "client_id" : "373a715cd990" , "client_hostname" : "373a715cd990" ,
95+ "client_version" : "V2" , "client_address" : "172.17.0.11:35560" ,
96+ "client_tls" : "false" , "client_snappy" : "false" ,
97+ "client_deflate" : "false" ,
98+ "client_user_agent" : "nsq_to_nsq/0.3.6 go-nsq/1.0.5" },
99+ },
100+ {
101+ "nsq_topic" ,
102+ map [string ]interface {}{
103+ "depth" : int64 (28 ),
104+ "backend_depth" : int64 (29 ),
105+ "message_count" : int64 (30 ),
106+ "channel_count" : int64 (1 ),
107+ },
108+ map [string ]string {
109+ "server_host" : host ,
110+ "server_version" : "0.3.6" ,
111+ "topic" : "t2" },
112+ },
113+ {
114+ "nsq_channel" ,
115+ map [string ]interface {}{
116+ "depth" : int64 (15 ),
117+ "backend_depth" : int64 (16 ),
118+ "inflight_count" : int64 (17 ),
119+ "deferred_count" : int64 (18 ),
120+ "message_count" : int64 (19 ),
121+ "requeue_count" : int64 (20 ),
122+ "timeout_count" : int64 (21 ),
123+ "client_count" : int64 (1 ),
124+ },
125+ map [string ]string {
126+ "server_host" : host ,
127+ "server_version" : "0.3.6" ,
128+ "topic" : "t2" ,
129+ "channel" : "c2" ,
130+ },
131+ },
132+ {
133+ "nsq_client" ,
134+ map [string ]interface {}{
135+ "ready_count" : int64 (22 ),
136+ "inflight_count" : int64 (23 ),
137+ "message_count" : int64 (24 ),
138+ "finish_count" : int64 (25 ),
139+ "requeue_count" : int64 (26 ),
140+ },
141+ map [string ]string {"server_host" : host , "server_version" : "0.3.6" ,
142+ "topic" : "t2" , "channel" : "c2" , "client_name" : "377569bd462b" ,
143+ "client_id" : "377569bd462b" , "client_hostname" : "377569bd462b" ,
144+ "client_version" : "V2" , "client_address" : "172.17.0.8:48145" ,
145+ "client_user_agent" : "go-nsq/1.0.5" , "client_tls" : "true" ,
146+ "client_snappy" : "true" , "client_deflate" : "true" },
147+ },
77148 }
78149
79150 for _ , test := range tests {
80- assert . True (t , acc . CheckTaggedValue ( test .m , test .v , test .g ), "Failed expectation: ( \" %v \" , \" %v \" , \" %v \" )" , test . m , test . v , fmt . Sprint ( test . g ) )
151+ acc . AssertContainsTaggedFields (t , test .m , test .f , test .g )
81152 }
82153}
83154
0 commit comments