influxdb-client 1.7.0 → 1.8.0.pre.1289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -6
- data/CHANGELOG.md +12 -0
- data/README.md +44 -13
- data/bin/influxdb-onboarding.sh +2 -2
- data/bin/influxdb-restart.sh +3 -2
- data/lib/influxdb2/client/client.rb +5 -4
- data/lib/influxdb2/client/point.rb +1 -1
- data/lib/influxdb2/client/version.rb +1 -1
- data/lib/influxdb2/client/worker.rb +2 -2
- data/lib/influxdb2/client/write_api.rb +56 -3
- data/test/influxdb/client_test.rb +10 -10
- data/test/influxdb/delete_api_integration_test.rb +9 -1
- data/test/influxdb/delete_api_test.rb +15 -15
- data/test/influxdb/query_api_integration_test.rb +1 -1
- data/test/influxdb/query_api_stream_test.rb +1 -1
- data/test/influxdb/query_api_test.rb +7 -7
- data/test/influxdb/write_api_batching_test.rb +157 -108
- data/test/influxdb/write_api_integration_test.rb +2 -2
- data/test/influxdb/write_api_test.rb +135 -38
- metadata +4 -4
@@ -24,7 +24,7 @@ class DeleteApiIntegrationTest < MiniTest::Test
|
|
24
24
|
def setup
|
25
25
|
WebMock.allow_net_connect!
|
26
26
|
|
27
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
27
|
+
@client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
28
28
|
bucket: 'my-bucket',
|
29
29
|
org: 'my-org',
|
30
30
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -56,6 +56,8 @@ class DeleteApiIntegrationTest < MiniTest::Test
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_delete
|
59
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
60
|
+
skip
|
59
61
|
@client.create_delete_api.delete(Time.utc(2015, 10, 16, 8, 20, 15), Time.utc(2020, 10, 16, 8, 20, 15),
|
60
62
|
predicate: 'location="europe"')
|
61
63
|
|
@@ -63,18 +65,24 @@ class DeleteApiIntegrationTest < MiniTest::Test
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def test_delete_without_predicate
|
68
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
69
|
+
skip
|
66
70
|
@client.create_delete_api.delete(Time.utc(2016, 10, 15, 7, 20, 15), Time.utc(2018, 10, 14, 8, 20, 15))
|
67
71
|
|
68
72
|
assert_equal 2, _query_count
|
69
73
|
end
|
70
74
|
|
71
75
|
def test_delete_all
|
76
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
77
|
+
skip
|
72
78
|
@client.create_delete_api.delete(Time.utc(2010, 10, 15, 7, 20, 15), Time.utc(2020, 10, 14, 8, 20, 15))
|
73
79
|
|
74
80
|
assert_equal 0, _query_count
|
75
81
|
end
|
76
82
|
|
77
83
|
def test_delete_without_interval
|
84
|
+
# TODO: https://github.com/influxdata/influxdb/issues/19545
|
85
|
+
skip
|
78
86
|
error = assert_raises InfluxDB2::InfluxError do
|
79
87
|
@client.create_delete_api.delete(nil, nil)
|
80
88
|
end
|
@@ -26,9 +26,9 @@ class DeleteApiTest < MiniTest::Test
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_delete
|
29
|
-
stub_request(:any, 'http://localhost:
|
29
|
+
stub_request(:any, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org')
|
30
30
|
.to_return(status: 204)
|
31
|
-
client = InfluxDB2::Client.new('http://localhost:
|
31
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
32
32
|
bucket: 'my-bucket',
|
33
33
|
org: 'my-org',
|
34
34
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -40,13 +40,13 @@ class DeleteApiTest < MiniTest::Test
|
|
40
40
|
body = '{"start":"2019-10-15T08:20:15+00:00","stop":"2019-11-15T08:20:15+00:00","predicate":"key1=\"value1\" ' \
|
41
41
|
'AND key2=\"value\""}'
|
42
42
|
|
43
|
-
assert_requested(:post, 'http://localhost:
|
43
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_delete_time_as_date_time
|
47
|
-
stub_request(:any, 'http://localhost:
|
47
|
+
stub_request(:any, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org')
|
48
48
|
.to_return(status: 204)
|
49
|
-
client = InfluxDB2::Client.new('http://localhost:
|
49
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
50
50
|
bucket: 'my-bucket',
|
51
51
|
org: 'my-org',
|
52
52
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -59,13 +59,13 @@ class DeleteApiTest < MiniTest::Test
|
|
59
59
|
body = '{"start":"2019-02-03T04:05:06+07:00","stop":"2019-03-03T04:05:06+07:00","predicate":"key1=\"value1\" ' \
|
60
60
|
'AND key2=\"value\""}'
|
61
61
|
|
62
|
-
assert_requested(:post, 'http://localhost:
|
62
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_delete_time_as_string
|
66
|
-
stub_request(:any, 'http://localhost:
|
66
|
+
stub_request(:any, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org')
|
67
67
|
.to_return(status: 204)
|
68
|
-
client = InfluxDB2::Client.new('http://localhost:
|
68
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
69
69
|
bucket: 'my-bucket',
|
70
70
|
org: 'my-org',
|
71
71
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -77,13 +77,13 @@ class DeleteApiTest < MiniTest::Test
|
|
77
77
|
body = '{"start":"2019-02-03T04:05:06+07:00","stop":"2019-04-03T04:05:06+07:00","predicate":"key1=\"value1\" ' \
|
78
78
|
'AND key2=\"value\""}'
|
79
79
|
|
80
|
-
assert_requested(:post, 'http://localhost:
|
80
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_without_predicate
|
84
|
-
stub_request(:any, 'http://localhost:
|
84
|
+
stub_request(:any, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org')
|
85
85
|
.to_return(status: 204)
|
86
|
-
client = InfluxDB2::Client.new('http://localhost:
|
86
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
87
87
|
bucket: 'my-bucket',
|
88
88
|
org: 'my-org',
|
89
89
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -94,13 +94,13 @@ class DeleteApiTest < MiniTest::Test
|
|
94
94
|
|
95
95
|
body = '{"start":"2019-02-03T04:05:06+07:00","stop":"2019-04-03T04:05:06+07:00"}'
|
96
96
|
|
97
|
-
assert_requested(:post, 'http://localhost:
|
97
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_user_agent_header
|
101
|
-
stub_request(:any, 'http://localhost:
|
101
|
+
stub_request(:any, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org')
|
102
102
|
.to_return(status: 204)
|
103
|
-
client = InfluxDB2::Client.new('http://localhost:
|
103
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
104
104
|
bucket: 'my-bucket',
|
105
105
|
org: 'my-org',
|
106
106
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -115,7 +115,7 @@ class DeleteApiTest < MiniTest::Test
|
|
115
115
|
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
116
116
|
'Content-Type' => 'application/json'
|
117
117
|
}
|
118
|
-
assert_requested(:post, 'http://localhost:
|
118
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/delete?bucket=my-bucket&org=my-org',
|
119
119
|
times: 1, body: body, headers: headers)
|
120
120
|
end
|
121
121
|
end
|
@@ -24,7 +24,7 @@ class QueryApiIntegrationTest < MiniTest::Test
|
|
24
24
|
def setup
|
25
25
|
WebMock.allow_net_connect!
|
26
26
|
|
27
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
27
|
+
@client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
28
28
|
bucket: 'my-bucket',
|
29
29
|
org: 'my-org',
|
30
30
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -24,7 +24,7 @@ class QueryApiStreamTest < MiniTest::Test
|
|
24
24
|
def setup
|
25
25
|
WebMock.allow_net_connect!
|
26
26
|
|
27
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
27
|
+
@client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
28
28
|
bucket: 'my-bucket',
|
29
29
|
org: 'my-org',
|
30
30
|
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
@@ -35,9 +35,9 @@ class QueryApiTest < MiniTest::Test
|
|
35
35
|
',,0,1970-01-01T00:00:20Z,1970-01-01T00:00:30Z,1970-01-01T00:00:20Z,22,free,mem,B,west'
|
36
36
|
|
37
37
|
def test_query_raw
|
38
|
-
stub_request(:post, 'http://localhost:
|
38
|
+
stub_request(:post, 'http://localhost:8086/api/v2/query?org=my-org')
|
39
39
|
.to_return(body: SUCCESS_DATA)
|
40
|
-
client = InfluxDB2::Client.new('http://localhost:
|
40
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
41
41
|
bucket: 'my-bucket',
|
42
42
|
org: 'my-org',
|
43
43
|
use_ssl: false)
|
@@ -50,10 +50,10 @@ class QueryApiTest < MiniTest::Test
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_query
|
53
|
-
stub_request(:post, 'http://localhost:
|
53
|
+
stub_request(:post, 'http://localhost:8086/api/v2/query?org=my-org')
|
54
54
|
.to_return(body: SUCCESS_DATA)
|
55
55
|
|
56
|
-
client = InfluxDB2::Client.new('http://localhost:
|
56
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
57
57
|
bucket: 'my-bucket',
|
58
58
|
org: 'my-org',
|
59
59
|
use_ssl: false)
|
@@ -74,10 +74,10 @@ class QueryApiTest < MiniTest::Test
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_headers
|
77
|
-
stub_request(:post, 'http://localhost:
|
77
|
+
stub_request(:post, 'http://localhost:8086/api/v2/query?org=my-org')
|
78
78
|
.to_return(body: SUCCESS_DATA)
|
79
79
|
|
80
|
-
client = InfluxDB2::Client.new('http://localhost:
|
80
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
81
81
|
bucket: 'my-bucket',
|
82
82
|
org: 'my-org',
|
83
83
|
use_ssl: false)
|
@@ -90,7 +90,7 @@ class QueryApiTest < MiniTest::Test
|
|
90
90
|
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
91
91
|
'Content-Type' => 'application/json'
|
92
92
|
}
|
93
|
-
assert_requested(:post, 'http://localhost:
|
93
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/query?org=my-org',
|
94
94
|
times: 1, headers: headers)
|
95
95
|
end
|
96
96
|
end
|
@@ -26,7 +26,7 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
26
26
|
|
27
27
|
@write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
28
28
|
batch_size: 2, flush_interval: 5_000, retry_interval: 2_000)
|
29
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
29
|
+
@client = InfluxDB2::Client.new('http://localhost:8086',
|
30
30
|
'my-token',
|
31
31
|
bucket: 'my-bucket',
|
32
32
|
org: 'my-org',
|
@@ -68,7 +68,7 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_batch_size
|
71
|
-
stub_request(:post, 'http://localhost:
|
71
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
72
72
|
.to_return(status: 204)
|
73
73
|
|
74
74
|
@write_client.write(data: 'h2o_feet,location=coyote_creek level\\ water_level=1.0 1')
|
@@ -83,20 +83,20 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
83
83
|
request2 = "h2o_feet,location=coyote_creek level\\ water_level=3.0 3\n" \
|
84
84
|
'h2o_feet,location=coyote_creek level\\ water_level=4.0 4'
|
85
85
|
|
86
|
-
assert_requested(:post, 'http://localhost:
|
86
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
87
87
|
times: 1, body: request1)
|
88
|
-
assert_requested(:post, 'http://localhost:
|
88
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
89
89
|
times: 1, body: request2)
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_batch_size_group_by
|
93
|
-
stub_request(:post, 'http://localhost:
|
93
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
94
94
|
.to_return(status: 204)
|
95
|
-
stub_request(:post, 'http://localhost:
|
95
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=s')
|
96
96
|
.to_return(status: 204)
|
97
|
-
stub_request(:post, 'http://localhost:
|
97
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns')
|
98
98
|
.to_return(status: 204)
|
99
|
-
stub_request(:post, 'http://localhost:
|
99
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket2&org=my-org-a&precision=ns')
|
100
100
|
.to_return(status: 204)
|
101
101
|
|
102
102
|
bucket = 'my-bucket'
|
@@ -113,21 +113,21 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
113
113
|
|
114
114
|
sleep(1)
|
115
115
|
|
116
|
-
assert_requested(:post, 'http://localhost:
|
116
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
117
117
|
times: 1, body: 'h2o_feet,location=coyote_creek level\\ water_level=1.0 1')
|
118
|
-
assert_requested(:post, 'http://localhost:
|
118
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=s',
|
119
119
|
times: 1, body: 'h2o_feet,location=coyote_creek level\\ water_level=2.0 2')
|
120
|
-
assert_requested(:post, 'http://localhost:
|
120
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns',
|
121
121
|
times: 1, body: "h2o_feet,location=coyote_creek level\\ water_level=3.0 3\n" \
|
122
122
|
'h2o_feet,location=coyote_creek level\\ water_level=4.0 4')
|
123
|
-
assert_requested(:post, 'http://localhost:
|
123
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket2&org=my-org-a&precision=ns',
|
124
124
|
times: 1, body: 'h2o_feet,location=coyote_creek level\\ water_level=5.0 5')
|
125
|
-
assert_requested(:post, 'http://localhost:
|
125
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns',
|
126
126
|
times: 1, body: 'h2o_feet,location=coyote_creek level\\ water_level=6.0 6')
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_flush_interval
|
130
|
-
stub_request(:post, 'http://localhost:
|
130
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
131
131
|
.to_return(status: 204)
|
132
132
|
|
133
133
|
request1 = "h2o_feet,location=coyote_creek level\\ water_level=1.0 1\n" \
|
@@ -139,31 +139,31 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
139
139
|
|
140
140
|
sleep(1)
|
141
141
|
|
142
|
-
assert_requested(:post, 'http://localhost:
|
142
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
143
143
|
times: 1, body: request1)
|
144
144
|
|
145
145
|
@write_client.write(data: 'h2o_feet,location=coyote_creek level\\ water_level=3.0 3')
|
146
146
|
|
147
147
|
sleep(2)
|
148
148
|
|
149
|
-
assert_requested(:post, 'http://localhost:
|
149
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
150
150
|
times: 0, body: request2)
|
151
151
|
|
152
152
|
sleep(3)
|
153
153
|
|
154
|
-
assert_requested(:post, 'http://localhost:
|
154
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
155
155
|
times: 1, body: request2)
|
156
156
|
end
|
157
157
|
|
158
158
|
def test_flush_all_by_close_client
|
159
|
-
stub_request(:post, 'http://localhost:
|
159
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
160
160
|
.to_return(status: 204)
|
161
161
|
|
162
162
|
@client.close!
|
163
163
|
|
164
164
|
@write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
165
165
|
batch_size: 10, flush_interval: 5_000)
|
166
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
166
|
+
@client = InfluxDB2::Client.new('http://localhost:8086',
|
167
167
|
'my-token',
|
168
168
|
bucket: 'my-bucket',
|
169
169
|
org: 'my-org',
|
@@ -176,12 +176,12 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
176
176
|
@write_client.write(data: 'h2o_feet,location=coyote_creek level\\ water_level=2.0 2')
|
177
177
|
@write_client.write(data: 'h2o_feet,location=coyote_creek level\\ water_level=3.0 3')
|
178
178
|
|
179
|
-
assert_requested(:post, 'http://localhost:
|
179
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
180
180
|
times: 0, body: 'h2o_feet,location=coyote_creek level\\ water_level=3.0 3')
|
181
181
|
|
182
182
|
@client.close!
|
183
183
|
|
184
|
-
assert_requested(:post, 'http://localhost:
|
184
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
185
185
|
times: 1, body: "h2o_feet,location=coyote_creek level\\ water_level=1.0 1\n" \
|
186
186
|
"h2o_feet,location=coyote_creek level\\ water_level=2.0 2\n" \
|
187
187
|
'h2o_feet,location=coyote_creek level\\ water_level=3.0 3')
|
@@ -190,7 +190,7 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
190
190
|
def test_jitter_interval
|
191
191
|
@client.close!
|
192
192
|
|
193
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
193
|
+
@client = InfluxDB2::Client.new('http://localhost:8086',
|
194
194
|
'my-token',
|
195
195
|
bucket: 'my-bucket',
|
196
196
|
org: 'my-org',
|
@@ -201,7 +201,7 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
201
201
|
batch_size: 2, flush_interval: 5_000, jitter_interval: 2_000)
|
202
202
|
@write_client = @client.create_write_api(write_options: @write_options)
|
203
203
|
|
204
|
-
stub_request(:post, 'http://localhost:
|
204
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
205
205
|
.to_return(status: 204)
|
206
206
|
|
207
207
|
request = "h2o_feet,location=coyote_creek water_level=1.0 1\n" \
|
@@ -212,12 +212,12 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
212
212
|
|
213
213
|
sleep(0.05)
|
214
214
|
|
215
|
-
assert_requested(:post, 'http://localhost:
|
215
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
216
216
|
times: 0, body: request)
|
217
217
|
|
218
218
|
sleep(2)
|
219
219
|
|
220
|
-
assert_requested(:post, 'http://localhost:
|
220
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
221
221
|
times: 1, body: request)
|
222
222
|
end
|
223
223
|
end
|
@@ -228,7 +228,7 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
228
228
|
|
229
229
|
@write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
230
230
|
batch_size: 2, flush_interval: 5_000, retry_interval: 2_000)
|
231
|
-
@client = InfluxDB2::Client.new('http://localhost:
|
231
|
+
@client = InfluxDB2::Client.new('http://localhost:8086',
|
232
232
|
'my-token',
|
233
233
|
bucket: 'my-bucket',
|
234
234
|
org: 'my-org',
|
@@ -250,7 +250,7 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
250
250
|
error_body = '{"code":"temporarily unavailable","message":"Token is temporarily over quota. '\
|
251
251
|
'The Retry-After header describes when to try the write again."}'
|
252
252
|
|
253
|
-
stub_request(:post, 'http://localhost:
|
253
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
254
254
|
.to_return(status: 429, headers: { 'X-Platform-Error-Code' => 'temporarily unavailable' }, body: error_body).then
|
255
255
|
.to_return(status: 204)
|
256
256
|
|
@@ -262,17 +262,17 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
262
262
|
|
263
263
|
sleep(0.5)
|
264
264
|
|
265
|
-
assert_requested(:post, 'http://localhost:
|
265
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
266
266
|
times: 1, body: request)
|
267
267
|
|
268
268
|
sleep(1)
|
269
269
|
|
270
|
-
assert_requested(:post, 'http://localhost:
|
270
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
271
271
|
times: 1, body: request)
|
272
272
|
|
273
273
|
sleep(5)
|
274
274
|
|
275
|
-
assert_requested(:post, 'http://localhost:
|
275
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
276
276
|
times: 2, body: request)
|
277
277
|
end
|
278
278
|
|
@@ -280,7 +280,7 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
280
280
|
error_body = '{"code":"temporarily unavailable","message":"Server is temporarily unavailable to accept writes. '\
|
281
281
|
'The Retry-After header describes when to try the write again."}'
|
282
282
|
|
283
|
-
stub_request(:post, 'http://localhost:
|
283
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
284
284
|
.to_return(status: 503, headers: { 'X-Platform-Error-Code' => 'temporarily unavailable', 'Retry-After' => '3' },
|
285
285
|
body: error_body).then
|
286
286
|
.to_return(status: 204)
|
@@ -296,22 +296,22 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
296
296
|
|
297
297
|
sleep(0.5)
|
298
298
|
|
299
|
-
assert_requested(:post, 'http://localhost:
|
299
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
300
300
|
times: 1, body: request)
|
301
301
|
|
302
302
|
sleep(1)
|
303
303
|
|
304
|
-
assert_requested(:post, 'http://localhost:
|
304
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
305
305
|
times: 1, body: request)
|
306
306
|
|
307
307
|
sleep(1)
|
308
308
|
|
309
|
-
assert_requested(:post, 'http://localhost:
|
309
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
310
310
|
times: 1, body: request)
|
311
311
|
|
312
312
|
sleep(1)
|
313
313
|
|
314
|
-
assert_requested(:post, 'http://localhost:
|
314
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
315
315
|
times: 2, body: request)
|
316
316
|
end
|
317
317
|
|
@@ -321,7 +321,7 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
321
321
|
|
322
322
|
headers = { 'X-Platform-Error-Code' => 'temporarily unavailable' }
|
323
323
|
|
324
|
-
stub_request(:post, 'http://localhost:
|
324
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
325
325
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
326
326
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
327
327
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
@@ -338,40 +338,36 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
338
338
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
339
339
|
max_retry_delay: 5_000, exponential_base: 2)
|
340
340
|
|
341
|
-
|
342
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
343
|
-
|
344
|
-
sleep(0.5)
|
341
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
345
342
|
|
346
|
-
|
347
|
-
times: 1, body: request)
|
343
|
+
sleep(0.5)
|
348
344
|
|
349
|
-
|
345
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
346
|
+
times: 1, body: request)
|
350
347
|
|
351
|
-
|
352
|
-
times: 2, body: request)
|
348
|
+
sleep(2)
|
353
349
|
|
354
|
-
|
350
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
351
|
+
times: 2, body: request)
|
355
352
|
|
356
|
-
|
357
|
-
times: 3, body: request)
|
353
|
+
sleep(4)
|
358
354
|
|
359
|
-
|
355
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
356
|
+
times: 3, body: request)
|
360
357
|
|
361
|
-
|
362
|
-
times: 4, body: request)
|
358
|
+
sleep(5)
|
363
359
|
|
364
|
-
|
360
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
361
|
+
times: 4, body: request)
|
365
362
|
|
366
|
-
|
367
|
-
times: 4, body: request)
|
363
|
+
sleep(5)
|
368
364
|
|
369
|
-
|
370
|
-
|
365
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
366
|
+
times: 4, body: request)
|
371
367
|
|
372
|
-
|
368
|
+
sleep(5)
|
373
369
|
|
374
|
-
assert_requested(:post, 'http://localhost:
|
370
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
375
371
|
times: 4, body: request)
|
376
372
|
end
|
377
373
|
|
@@ -379,12 +375,13 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
379
375
|
error_body = '{"code":"invalid","message":"unable to parse '\
|
380
376
|
'\'h2o_feet, location=coyote_creek water_level=1.0 1\': missing tag key"}'
|
381
377
|
|
382
|
-
stub_request(:any, 'http://localhost:
|
378
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
383
379
|
.to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
|
384
380
|
|
385
381
|
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
386
382
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
387
|
-
max_retry_delay: 5_000, exponential_base: 2
|
383
|
+
max_retry_delay: 5_000, exponential_base: 2,
|
384
|
+
batch_abort_on_exception: true)
|
388
385
|
|
389
386
|
error = assert_raises InfluxDB2::InfluxError do
|
390
387
|
@client.create_write_api(write_options: write_options).write(data: 'h2o,location=west value=33i 15')
|
@@ -403,7 +400,7 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
403
400
|
|
404
401
|
headers = { 'X-Platform-Error-Code' => 'temporarily unavailable', 'Retry-After' => '3' }
|
405
402
|
|
406
|
-
stub_request(:post, 'http://localhost:
|
403
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
407
404
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
408
405
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
409
406
|
.to_return(status: 429, headers: headers, body: error_body).then # retry
|
@@ -420,43 +417,39 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
420
417
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
421
418
|
max_retry_delay: 5_000, exponential_base: 2)
|
422
419
|
|
423
|
-
|
424
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
425
|
-
|
426
|
-
sleep(0.5)
|
420
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
427
421
|
|
428
|
-
|
429
|
-
times: 1, body: request)
|
422
|
+
sleep(0.5)
|
430
423
|
|
431
|
-
|
424
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
425
|
+
times: 1, body: request)
|
432
426
|
|
433
|
-
|
434
|
-
times: 2, body: request)
|
427
|
+
sleep(3)
|
435
428
|
|
436
|
-
|
429
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
430
|
+
times: 2, body: request)
|
437
431
|
|
438
|
-
|
439
|
-
times: 3, body: request)
|
432
|
+
sleep(3)
|
440
433
|
|
441
|
-
|
434
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
435
|
+
times: 3, body: request)
|
442
436
|
|
443
|
-
|
444
|
-
times: 4, body: request)
|
437
|
+
sleep(3)
|
445
438
|
|
446
|
-
|
447
|
-
|
439
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
440
|
+
times: 4, body: request)
|
448
441
|
|
449
|
-
|
442
|
+
sleep(3)
|
450
443
|
|
451
|
-
assert_requested(:post, 'http://localhost:
|
444
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
452
445
|
times: 4, body: request)
|
453
446
|
end
|
454
447
|
|
455
448
|
def test_connection_error
|
456
|
-
error_message = 'Failed to open TCP connection to localhost:
|
457
|
-
'(Connection refused - connect(2) for "localhost" port
|
449
|
+
error_message = 'Failed to open TCP connection to localhost:8086' \
|
450
|
+
'(Connection refused - connect(2) for "localhost" port 8086)'
|
458
451
|
|
459
|
-
stub_request(:post, 'http://localhost:
|
452
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
460
453
|
.to_raise(Errno::ECONNREFUSED.new(error_message))
|
461
454
|
.to_raise(Errno::ECONNREFUSED.new(error_message))
|
462
455
|
.to_raise(Errno::ECONNREFUSED.new(error_message))
|
@@ -473,42 +466,41 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
473
466
|
batch_size: 1, retry_interval: 2_000, max_retries: 3,
|
474
467
|
max_retry_delay: 5_000, exponential_base: 2)
|
475
468
|
|
476
|
-
|
477
|
-
@client.create_write_api(write_options: write_options).write(data: point)
|
469
|
+
@client.create_write_api(write_options: write_options).write(data: point)
|
478
470
|
|
479
|
-
|
471
|
+
sleep(0.5)
|
480
472
|
|
481
|
-
|
482
|
-
|
473
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
474
|
+
times: 1, body: request)
|
483
475
|
|
484
|
-
|
476
|
+
sleep(2)
|
485
477
|
|
486
|
-
|
487
|
-
|
478
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
479
|
+
times: 2, body: request)
|
488
480
|
|
489
|
-
|
481
|
+
sleep(4)
|
490
482
|
|
491
|
-
|
492
|
-
|
483
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
484
|
+
times: 3, body: request)
|
493
485
|
|
494
|
-
|
486
|
+
sleep(5)
|
495
487
|
|
496
|
-
|
497
|
-
|
488
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
489
|
+
times: 4, body: request)
|
498
490
|
|
499
|
-
|
491
|
+
sleep(5)
|
500
492
|
|
501
|
-
|
502
|
-
|
493
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
494
|
+
times: 4, body: request)
|
503
495
|
|
504
|
-
|
505
|
-
end
|
496
|
+
sleep(5)
|
506
497
|
|
507
|
-
|
498
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
499
|
+
times: 4, body: request)
|
508
500
|
end
|
509
501
|
|
510
502
|
def test_write_connection_error
|
511
|
-
stub_request(:post, 'http://localhost:
|
503
|
+
stub_request(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
512
504
|
.to_raise(Errno::ECONNREFUSED.new(''))
|
513
505
|
.to_raise(Errno::ECONNREFUSED.new(''))
|
514
506
|
.to_return(status: 204)
|
@@ -527,22 +519,79 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
527
519
|
|
528
520
|
sleep(0.5)
|
529
521
|
|
530
|
-
assert_requested(:post, 'http://localhost:
|
522
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
531
523
|
times: 1, body: request)
|
532
524
|
|
533
525
|
sleep(2)
|
534
526
|
|
535
|
-
assert_requested(:post, 'http://localhost:
|
527
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
536
528
|
times: 2, body: request)
|
537
529
|
|
538
530
|
sleep(4)
|
539
531
|
|
540
|
-
assert_requested(:post, 'http://localhost:
|
532
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
541
533
|
times: 3, body: request)
|
542
534
|
|
543
535
|
sleep(5)
|
544
536
|
|
545
|
-
assert_requested(:post, 'http://localhost:
|
537
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
546
538
|
times: 3, body: request)
|
547
539
|
end
|
540
|
+
|
541
|
+
def test_abort_on_exception
|
542
|
+
error_body = '{"code":"invalid","message":"unable to parse '\
|
543
|
+
'\'h2o,location=europe 1\'"}'
|
544
|
+
|
545
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
546
|
+
.to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
|
547
|
+
.to_return(status: 204)
|
548
|
+
|
549
|
+
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
550
|
+
batch_size: 1, retry_interval: 500, max_retries: 1,
|
551
|
+
max_retry_delay: 5_000, exponential_base: 1,
|
552
|
+
batch_abort_on_exception: true)
|
553
|
+
|
554
|
+
write_api = @client.create_write_api(write_options: write_options)
|
555
|
+
|
556
|
+
error = assert_raises InfluxDB2::InfluxError do
|
557
|
+
write_api.write(data: 'h2o,location=europe 1')
|
558
|
+
write_api.write(data: 'h2o,location=europe level=2.0 1')
|
559
|
+
|
560
|
+
sleep(2)
|
561
|
+
end
|
562
|
+
|
563
|
+
assert_equal("unable to parse 'h2o,location=europe 1'", error.message)
|
564
|
+
|
565
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
566
|
+
times: 1, body: 'h2o,location=europe 1')
|
567
|
+
|
568
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
569
|
+
times: 0, body: 'h2o,location=europe level=2.0 1')
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_abort_on_exception_next_batch
|
573
|
+
error_body = '{"code":"invalid","message":"unable to parse '\
|
574
|
+
'\'h2o,location=europe 1\'"}'
|
575
|
+
|
576
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
577
|
+
.to_return(status: 400, headers: { 'X-Platform-Error-Code' => 'invalid' }, body: error_body)
|
578
|
+
.to_return(status: 204)
|
579
|
+
|
580
|
+
write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
581
|
+
batch_size: 1, retry_interval: 500, max_retries: 1,
|
582
|
+
max_retry_delay: 5_000, exponential_base: 1)
|
583
|
+
|
584
|
+
write_api = @client.create_write_api(write_options: write_options)
|
585
|
+
|
586
|
+
write_api.write(data: 'h2o,location=europe 1')
|
587
|
+
write_api.write(data: 'h2o,location=europe level=2.0 1')
|
588
|
+
|
589
|
+
sleep(2)
|
590
|
+
|
591
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
592
|
+
times: 1, body: 'h2o,location=europe 1')
|
593
|
+
|
594
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
595
|
+
times: 1, body: 'h2o,location=europe level=2.0 1')
|
596
|
+
end
|
548
597
|
end
|