influxdb 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,10 @@ require "json"
4
4
  describe InfluxDB::Client do
5
5
  let(:subject) do
6
6
  described_class.new "database", {
7
- host: "influxdb.test",
8
- port: 9999,
9
- username: "username",
10
- password: "password",
7
+ host: "influxdb.test",
8
+ port: 9999,
9
+ username: "username",
10
+ password: "password",
11
11
  time_precision: "s"
12
12
  }.merge(args)
13
13
  end
@@ -27,9 +27,9 @@ describe InfluxDB::Client do
27
27
  context "with single series with multiple points" do
28
28
  let(:response) do
29
29
  { "results" => [{ "statement_id" => 0,
30
- "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
31
- "columns" => %w[time temp value],
32
- "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
30
+ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
31
+ "columns" => %w[time temp value],
32
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
33
33
  end
34
34
  let(:expected_result) do
35
35
  [{ "name" => "cpu", "tags" => { "region" => "us" },
@@ -46,13 +46,21 @@ describe InfluxDB::Client do
46
46
  context "with series with different tags" do
47
47
  let(:response) do
48
48
  { "results" => [{ "statement_id" => 0,
49
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
50
- { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w[time temp value], "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
49
+ "series" => [{ "name" => "cpu",
50
+ "tags" => { "region" => "pl" },
51
+ "columns" => %w[time temp value],
52
+ "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
53
+ { "name" => "cpu",
54
+ "tags" => { "region" => "us" },
55
+ "columns" => %w[time temp value],
56
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
51
57
  end
52
58
  let(:expected_result) do
53
- [{ "name" => "cpu", "tags" => { "region" => "pl" },
59
+ [{ "name" => "cpu",
60
+ "tags" => { "region" => "pl" },
54
61
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
55
- { "name" => "cpu", "tags" => { "region" => "us" },
62
+ { "name" => "cpu",
63
+ "tags" => { "region" => "us" },
56
64
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
57
65
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
58
66
  end
@@ -66,16 +74,36 @@ describe InfluxDB::Client do
66
74
  context "with multiple series with different tags" do
67
75
  let(:response) do
68
76
  { "results" => [{ "statement_id" => 0,
69
- "series" => [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w[time value], "values" => [["2015-07-08T07:15:22Z", 327]] },
70
- { "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 873]] },
71
- { "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "columns" => %w[time value], "values" => [["2015-07-08T07:15:22Z", 943]] },
72
- { "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
77
+ "series" => [{ "name" => "access_times.service_1",
78
+ "tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
79
+ "columns" => %w[time value],
80
+ "values" => [["2015-07-08T07:15:22Z", 327]] },
81
+ { "name" => "access_times.service_1",
82
+ "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
83
+ "columns" => %w[time value],
84
+ "values" => [["2015-07-08T06:15:22Z", 873]] },
85
+ { "name" => "access_times.service_2",
86
+ "tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
87
+ "columns" => %w[time value],
88
+ "values" => [["2015-07-08T07:15:22Z", 943]] },
89
+ { "name" => "access_times.service_2",
90
+ "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
91
+ "columns" => %w[time value],
92
+ "values" => [["2015-07-08T06:15:22Z", 606]] }] }] }
73
93
  end
74
94
  let(:expected_result) do
75
- [{ "name" => "access_times.service_1", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
76
- { "name" => "access_times.service_1", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }] },
77
- { "name" => "access_times.service_2", "tags" => { "code" => "200", "result" => "failure", "status" => "OK" }, "values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 943 }] },
78
- { "name" => "access_times.service_2", "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" }, "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }] }]
95
+ [{ "name" => "access_times.service_1",
96
+ "tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
97
+ "values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
98
+ { "name" => "access_times.service_1",
99
+ "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
100
+ "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }] },
101
+ { "name" => "access_times.service_2",
102
+ "tags" => { "code" => "200", "result" => "failure", "status" => "OK" },
103
+ "values" => [{ "time" => "2015-07-08T07:15:22Z", "value" => 943 }] },
104
+ { "name" => "access_times.service_2",
105
+ "tags" => { "code" => "500", "result" => "failure", "status" => "Internal Server Error" },
106
+ "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }] }]
79
107
  end
80
108
  let(:query) { "SELECT * FROM /access_times.*/" }
81
109
 
@@ -87,12 +115,20 @@ describe InfluxDB::Client do
87
115
  context "with multiple series for explicit value only" do
88
116
  let(:response) do
89
117
  { "results" => [{ "statement_id" => 0,
90
- "series" => [{ "name" => "access_times.service_1", "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
91
- { "name" => "access_times.service_2", "columns" => %w[time value], "values" => [["2015-07-08T06:15:22Z", 606], ["2015-07-08T07:15:22Z", 943]] }] }] }
118
+ "series" => [{ "name" => "access_times.service_1",
119
+ "columns" => %w[time value],
120
+ "values" => [["2015-07-08T06:15:22Z", 873], ["2015-07-08T07:15:22Z", 327]] },
121
+ { "name" => "access_times.service_2",
122
+ "columns" => %w[time value],
123
+ "values" => [["2015-07-08T06:15:22Z", 606], ["2015-07-08T07:15:22Z", 943]] }] }] }
92
124
  end
93
125
  let(:expected_result) do
94
- [{ "name" => "access_times.service_1", "tags" => nil, "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }, { "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
95
- { "name" => "access_times.service_2", "tags" => nil, "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }, { "time" => "2015-07-08T07:15:22Z", "value" => 943 }] }]
126
+ [{ "name" => "access_times.service_1",
127
+ "tags" => nil,
128
+ "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 873 }, { "time" => "2015-07-08T07:15:22Z", "value" => 327 }] },
129
+ { "name" => "access_times.service_2",
130
+ "tags" => nil,
131
+ "values" => [{ "time" => "2015-07-08T06:15:22Z", "value" => 606 }, { "time" => "2015-07-08T07:15:22Z", "value" => 943 }] }]
96
132
  end
97
133
  let(:query) { "SELECT value FROM /access_times.*/" }
98
134
 
@@ -104,14 +140,22 @@ describe InfluxDB::Client do
104
140
  context "with a block" do
105
141
  let(:response) do
106
142
  { "results" => [{ "statement_id" => 0,
107
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
108
- { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w[time temp value], "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
143
+ "series" => [{ "name" => "cpu",
144
+ "tags" => { "region" => "pl" },
145
+ "columns" => %w[time temp value],
146
+ "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
147
+ { "name" => "cpu",
148
+ "tags" => { "region" => "us" },
149
+ "columns" => %w[time temp value],
150
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
109
151
  end
110
152
 
111
153
  let(:expected_result) do
112
- [{ "name" => "cpu", "tags" => { "region" => "pl" },
154
+ [{ "name" => "cpu",
155
+ "tags" => { "region" => "pl" },
113
156
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
114
- { "name" => "cpu", "tags" => { "region" => "us" },
157
+ { "name" => "cpu",
158
+ "tags" => { "region" => "us" },
115
159
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
116
160
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
117
161
  end
@@ -132,13 +176,21 @@ describe InfluxDB::Client do
132
176
 
133
177
  let(:response) do
134
178
  { "results" => [{ "statement_id" => 0,
135
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [[1_438_580_576, 34, 0.343443]] },
136
- { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w[time temp value], "values" => [[1_438_612_976, 92, 0.3445], [1_438_612_989, 68, 0.8787]] }] }] }
179
+ "series" => [{ "name" => "cpu",
180
+ "tags" => { "region" => "pl" },
181
+ "columns" => %w[time temp value],
182
+ "values" => [[1_438_580_576, 34, 0.343443]] },
183
+ { "name" => "cpu",
184
+ "tags" => { "region" => "us" },
185
+ "columns" => %w[time temp value],
186
+ "values" => [[1_438_612_976, 92, 0.3445], [1_438_612_989, 68, 0.8787]] }] }] }
137
187
  end
138
188
  let(:expected_result) do
139
- [{ "name" => "cpu", "tags" => { "region" => "pl" },
189
+ [{ "name" => "cpu",
190
+ "tags" => { "region" => "pl" },
140
191
  "values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] },
141
- { "name" => "cpu", "tags" => { "region" => "us" },
192
+ { "name" => "cpu",
193
+ "tags" => { "region" => "us" },
142
194
  "values" => [{ "time" => 1_438_612_976, "temp" => 92, "value" => 0.3445 },
143
195
  { "time" => 1_438_612_989, "temp" => 68, "value" => 0.8787 }] }]
144
196
  end
@@ -155,10 +207,15 @@ describe InfluxDB::Client do
155
207
 
156
208
  let(:response) do
157
209
  { "results" => [{ "statement_id" => 0,
158
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [[1_438_580_576, 34, 0.343443]] }] }] }
210
+ "series" => [{ "name" => "cpu",
211
+ "tags" => { "region" => "pl" },
212
+ "columns" => %w[time temp value],
213
+ "values" => [[1_438_580_576, 34, 0.343443]] }] }] }
159
214
  end
160
215
  let(:expected_result) do
161
- [{ "name" => "cpu", "tags" => { "region" => "pl" }, "values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] }]
216
+ [{ "name" => "cpu",
217
+ "tags" => { "region" => "pl" },
218
+ "values" => [{ "time" => 1_438_580_576, "temp" => 34, "value" => 0.343443 }] }]
162
219
  end
163
220
  let(:query) { 'SELECT * FROM cpu' }
164
221
 
@@ -170,12 +227,14 @@ describe InfluxDB::Client do
170
227
  context "with database" do
171
228
  let(:extra_params) { { db: 'overriden_db' } }
172
229
  let(:response) do
173
- { "results" => [{ "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
230
+ { "results" => [{ "series" => [{ "name" => "cpu",
231
+ "tags" => { "region" => "us" },
174
232
  "columns" => %w[time temp value],
175
- "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
233
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] }] }
176
234
  end
177
235
  let(:expected_result) do
178
- [{ "name" => "cpu", "tags" => { "region" => "us" },
236
+ [{ "name" => "cpu",
237
+ "tags" => { "region" => "us" },
179
238
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
180
239
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] }]
181
240
  end
@@ -191,19 +250,23 @@ describe InfluxDB::Client do
191
250
  context "with single series with multiple points" do
192
251
  let(:response) do
193
252
  { "results" => [{ "statement_id" => 0,
194
- "series" => [{ "name" => "cpu", "tags" => { "region" => "us" },
195
- "columns" => %w[time temp value],
196
- "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
253
+ "series" => [{ "name" => "cpu",
254
+ "tags" => { "region" => "us" },
255
+ "columns" => %w[time temp value],
256
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
197
257
  { "statement_id" => 1,
198
- "series" => [{ "name" => "memory", "tags" => { "region" => "us" },
199
- "columns" => %w[time free total],
200
- "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
258
+ "series" => [{ "name" => "memory",
259
+ "tags" => { "region" => "us" },
260
+ "columns" => %w[time free total],
261
+ "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
201
262
  end
202
263
  let(:expected_result) do
203
- [{ "name" => "cpu", "tags" => { "region" => "us" },
264
+ [{ "name" => "cpu",
265
+ "tags" => { "region" => "us" },
204
266
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
205
267
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
206
- { "name" => "memory", "tags" => { "region" => "us" },
268
+ { "name" => "memory",
269
+ "tags" => { "region" => "us" },
207
270
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
208
271
  { "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
209
272
  end
@@ -217,21 +280,37 @@ describe InfluxDB::Client do
217
280
  context "with series with different tags" do
218
281
  let(:response) do
219
282
  { "results" => [{ "statement_id" => 0,
220
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
221
- { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w[time temp value], "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
283
+ "series" => [{ "name" => "cpu",
284
+ "tags" => { "region" => "pl" },
285
+ "columns" => %w[time temp value],
286
+ "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
287
+ { "name" => "cpu",
288
+ "tags" => { "region" => "us" },
289
+ "columns" => %w[time temp value],
290
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
222
291
  { "statement_id" => 1,
223
- "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w[time free total], "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
224
- { "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w[time free total], "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
292
+ "series" => [{ "name" => "memory",
293
+ "tags" => { "region" => "pl" },
294
+ "columns" => %w[time free total],
295
+ "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
296
+ { "name" => "memory",
297
+ "tags" => { "region" => "us" },
298
+ "columns" => %w[time free total],
299
+ "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
225
300
  end
226
301
  let(:expected_result) do
227
- [{ "name" => "cpu", "tags" => { "region" => "pl" },
302
+ [{ "name" => "cpu",
303
+ "tags" => { "region" => "pl" },
228
304
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
229
- { "name" => "cpu", "tags" => { "region" => "us" },
305
+ { "name" => "cpu",
306
+ "tags" => { "region" => "us" },
230
307
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
231
308
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
232
- { "name" => "memory", "tags" => { "region" => "pl" },
309
+ { "name" => "memory",
310
+ "tags" => { "region" => "pl" },
233
311
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "free" => 34 * 2**20, "total" => 128 * 2**20 }] },
234
- { "name" => "memory", "tags" => { "region" => "us" },
312
+ { "name" => "memory",
313
+ "tags" => { "region" => "us" },
235
314
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
236
315
  { "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
237
316
  end
@@ -245,22 +324,38 @@ describe InfluxDB::Client do
245
324
  context "with a block" do
246
325
  let(:response) do
247
326
  { "results" => [{ "statement_id" => 0,
248
- "series" => [{ "name" => "cpu", "tags" => { "region" => "pl" }, "columns" => %w[time temp value], "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
249
- { "name" => "cpu", "tags" => { "region" => "us" }, "columns" => %w[time temp value], "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
327
+ "series" => [{ "name" => "cpu",
328
+ "tags" => { "region" => "pl" },
329
+ "columns" => %w[time temp value],
330
+ "values" => [["2015-07-07T15:13:04Z", 34, 0.343443]] },
331
+ { "name" => "cpu",
332
+ "tags" => { "region" => "us" },
333
+ "columns" => %w[time temp value],
334
+ "values" => [["2015-07-07T14:58:37Z", 92, 0.3445], ["2015-07-07T14:59:09Z", 68, 0.8787]] }] },
250
335
  { "statement_id" => 1,
251
- "series" => [{ "name" => "memory", "tags" => { "region" => "pl" }, "columns" => %w[time free total], "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
252
- { "name" => "memory", "tags" => { "region" => "us" }, "columns" => %w[time free total], "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
336
+ "series" => [{ "name" => "memory",
337
+ "tags" => { "region" => "pl" },
338
+ "columns" => %w[time free total],
339
+ "values" => [["2015-07-07T15:13:04Z", 35_651_584, 134_217_728]] },
340
+ { "name" => "memory",
341
+ "tags" => { "region" => "us" },
342
+ "columns" => %w[time free total],
343
+ "values" => [["2015-07-07T14:58:37Z", 96_468_992, 134_217_728], ["2015-07-07T14:59:09Z", 71_303_168, 134_217_728]] }] }] }
253
344
  end
254
345
 
255
346
  let(:expected_result) do
256
- [{ "name" => "cpu", "tags" => { "region" => "pl" },
347
+ [{ "name" => "cpu",
348
+ "tags" => { "region" => "pl" },
257
349
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "temp" => 34, "value" => 0.343443 }] },
258
- { "name" => "cpu", "tags" => { "region" => "us" },
350
+ { "name" => "cpu",
351
+ "tags" => { "region" => "us" },
259
352
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "temp" => 92, "value" => 0.3445 },
260
353
  { "time" => "2015-07-07T14:59:09Z", "temp" => 68, "value" => 0.8787 }] },
261
- { "name" => "memory", "tags" => { "region" => "pl" },
354
+ { "name" => "memory",
355
+ "tags" => { "region" => "pl" },
262
356
  "values" => [{ "time" => "2015-07-07T15:13:04Z", "free" => 34 * 2**20, "total" => 128 * 2**20 }] },
263
- { "name" => "memory", "tags" => { "region" => "us" },
357
+ { "name" => "memory",
358
+ "tags" => { "region" => "us" },
264
359
  "values" => [{ "time" => "2015-07-07T14:58:37Z", "free" => 92 * 2**20, "total" => 128 * 2**20 },
265
360
  { "time" => "2015-07-07T14:59:09Z", "free" => 68 * 2**20, "total" => 128 * 2**20 }] }]
266
361
  end
@@ -6,10 +6,10 @@ describe InfluxDB::Client do
6
6
  described_class.new(
7
7
  "database",
8
8
  {
9
- host: "influxdb.test",
10
- port: 9999,
11
- username: "username",
12
- password: "password",
9
+ host: "influxdb.test",
10
+ port: 9999,
11
+ username: "username",
12
+ password: "password",
13
13
  time_precision: "s"
14
14
  }.merge(args)
15
15
  )
@@ -22,7 +22,7 @@ describe InfluxDB::Client do
22
22
  describe "retrying requests" do
23
23
  let(:series) { "cpu" }
24
24
  let(:data) do
25
- { tags: { region: 'us', host: 'server_1' },
25
+ { tags: { region: 'us', host: 'server_1' },
26
26
  values: { temp: 88, value: 54 } }
27
27
  end
28
28
  let(:body) do
@@ -34,9 +34,9 @@ describe InfluxDB::Client do
34
34
  before do
35
35
  allow(client).to receive(:log)
36
36
  stub_request(:post, "http://influxdb.test:9999/write").with(
37
- query: { u: "username", p: "password", precision: 's', db: database },
37
+ query: { u: "username", p: "password", precision: 's', db: database },
38
38
  headers: { "Content-Type" => "application/octet-stream" },
39
- body: body
39
+ body: body
40
40
  ).to_raise(Timeout::Error)
41
41
  end
42
42
 
@@ -74,9 +74,9 @@ describe InfluxDB::Client do
74
74
  before do
75
75
  stub_request(:post, "http://influxdb.test:9999/write")
76
76
  .with(
77
- query: { u: "username", p: "password", precision: 's', db: database },
77
+ query: { u: "username", p: "password", precision: 's', db: database },
78
78
  headers: { "Content-Type" => "application/octet-stream" },
79
- body: body
79
+ body: body
80
80
  )
81
81
  .to_raise(Timeout::Error).then
82
82
  .to_raise(Timeout::Error).then
@@ -93,9 +93,9 @@ describe InfluxDB::Client do
93
93
 
94
94
  it "raise an exception if the server didn't return 200" do
95
95
  stub_request(:post, "http://influxdb.test:9999/write").with(
96
- query: { u: "username", p: "password", precision: 's', db: database },
96
+ query: { u: "username", p: "password", precision: 's', db: database },
97
97
  headers: { "Content-Type" => "application/octet-stream" },
98
- body: body
98
+ body: body
99
99
  ).to_return(status: 401)
100
100
 
101
101
  expect { client.write_point(series, data) }.to raise_error(InfluxDB::AuthenticationError)
@@ -43,13 +43,13 @@ describe InfluxDB::Client do
43
43
  let(:expected_result) do
44
44
  {
45
45
  "measurement_a" => {
46
- "a_string_field" => ["string"],
47
- "a_boolean_field" => ["boolean"],
48
- "a_float_field" => ["float"],
49
- "an_integer_field" => ["integer"],
46
+ "a_string_field" => ["string"],
47
+ "a_boolean_field" => ["boolean"],
48
+ "a_float_field" => ["float"],
49
+ "an_integer_field" => ["integer"],
50
50
  },
51
51
  "measurement_b" => {
52
- "another_string" => ["string"],
52
+ "another_string" => ["string"],
53
53
  }
54
54
  }
55
55
  end
@@ -24,7 +24,7 @@ describe InfluxDB::Client do
24
24
  describe "#write with discard_write_errors" do
25
25
  let(:client) do
26
26
  described_class.new(
27
- udp: { host: "localhost", port: 44_444 },
27
+ udp: { host: "localhost", port: 44_444 },
28
28
  discard_write_errors: true
29
29
  )
30
30
  end
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
17
17
  describe "#write_point" do
18
18
  let(:series) { "cpu" }
19
19
  let(:data) do
20
- { tags: { region: 'us', host: 'server_1' },
20
+ { tags: { region: 'us', host: 'server_1' },
21
21
  values: { temp: 88, value: 54 } }
22
22
  end
23
23
  let(:body) do
@@ -26,9 +26,9 @@ describe InfluxDB::Client do
26
26
 
27
27
  before do
28
28
  stub_request(:post, "http://influxdb.test:9999/write").with(
29
- query: { u: "username", p: "password", precision: 's', db: database },
29
+ query: { u: "username", p: "password", precision: 's', db: database },
30
30
  headers: { "Content-Type" => "application/octet-stream" },
31
- body: body
31
+ body: body
32
32
  ).to_return(status: 204)
33
33
  end
34
34
 
@@ -48,10 +48,10 @@ describe InfluxDB::Client do
48
48
  context "with multiple series" do
49
49
  let(:data) do
50
50
  [{ series: 'cpu',
51
- tags: { region: 'us', host: 'server_1' },
51
+ tags: { region: 'us', host: 'server_1' },
52
52
  values: { temp: 88, value: 54 } },
53
53
  { series: 'gpu',
54
- tags: { region: 'uk', host: 'server_5' },
54
+ tags: { region: 'uk', host: 'server_5' },
55
55
  values: { value: 0.5435345 } }]
56
56
  end
57
57
  let(:body) do
@@ -62,9 +62,9 @@ describe InfluxDB::Client do
62
62
 
63
63
  before do
64
64
  stub_request(:post, "http://influxdb.test:9999/write").with(
65
- query: { u: "username", p: "password", precision: 's', db: database },
65
+ query: { u: "username", p: "password", precision: 's', db: database },
66
66
  headers: { "Content-Type" => "application/octet-stream" },
67
- body: body
67
+ body: body
68
68
  ).to_return(status: 204)
69
69
  end
70
70
 
@@ -88,9 +88,9 @@ describe InfluxDB::Client do
88
88
 
89
89
  before do
90
90
  stub_request(:post, "http://influxdb.test:9999/write").with(
91
- query: { u: "username", p: "password", precision: 's', db: database },
91
+ query: { u: "username", p: "password", precision: 's', db: database },
92
92
  headers: { "Content-Type" => "application/octet-stream" },
93
- body: body
93
+ body: body
94
94
  ).to_return(status: 204)
95
95
  end
96
96
 
@@ -101,11 +101,11 @@ describe InfluxDB::Client do
101
101
 
102
102
  context "with time precision set to milisceconds" do
103
103
  let(:data) do
104
- [{ series: 'cpu',
105
- values: { temp: 88, value: 54 },
104
+ [{ series: 'cpu',
105
+ values: { temp: 88, value: 54 },
106
106
  timestamp: (Time.now.to_f * 1000).to_i },
107
- { series: 'gpu',
108
- values: { value: 0.5435345 },
107
+ { series: 'gpu',
108
+ values: { value: 0.5435345 },
109
109
  timestamp: (Time.now.to_f * 1000).to_i }]
110
110
  end
111
111
 
@@ -117,9 +117,9 @@ describe InfluxDB::Client do
117
117
 
118
118
  before do
119
119
  stub_request(:post, "http://influxdb.test:9999/write").with(
120
- query: { u: "username", p: "password", precision: 'ms', db: database },
120
+ query: { u: "username", p: "password", precision: 'ms', db: database },
121
121
  headers: { "Content-Type" => "application/octet-stream" },
122
- body: body
122
+ body: body
123
123
  ).to_return(status: 204)
124
124
  end
125
125
  it "should POST multiple points" do
@@ -143,9 +143,9 @@ describe InfluxDB::Client do
143
143
 
144
144
  before do
145
145
  stub_request(:post, "http://influxdb.test:9999/write").with(
146
- query: { u: "username", p: "password", precision: 's', db: database, rp: 'rp_1_hour' },
146
+ query: { u: "username", p: "password", precision: 's', db: database, rp: 'rp_1_hour' },
147
147
  headers: { "Content-Type" => "application/octet-stream" },
148
- body: body
148
+ body: body
149
149
  ).to_return(status: 204)
150
150
  end
151
151
  it "should POST multiple points" do
@@ -169,9 +169,9 @@ describe InfluxDB::Client do
169
169
 
170
170
  before do
171
171
  stub_request(:post, "http://influxdb.test:9999/write").with(
172
- query: { u: "username", p: "password", precision: 's', db: 'overriden_db' },
172
+ query: { u: "username", p: "password", precision: 's', db: 'overriden_db' },
173
173
  headers: { "Content-Type" => "application/octet-stream" },
174
- body: body
174
+ body: body
175
175
  ).to_return(status: 204)
176
176
  end
177
177
  it "should POST multiple points" do