influxdb-client 1.8.0.pre.1133 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org')
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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
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:9999/api/v2/delete?bucket=my-bucket&org=my-org')
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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
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:9999/api/v2/delete?bucket=my-bucket&org=my-org')
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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
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:9999/api/v2/delete?bucket=my-bucket&org=my-org')
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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org', times: 1, body: body)
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:9999/api/v2/delete?bucket=my-bucket&org=my-org')
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:9999', 'my-token',
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:9999/api/v2/delete?bucket=my-bucket&org=my-org',
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:9999', 'my-token',
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:9999', 'my-token',
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:9999/api/v2/query?org=my-org')
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:9999', 'my-token',
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:9999/api/v2/query?org=my-org')
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:9999', 'my-token',
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:9999/api/v2/query?org=my-org')
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:9999', 'my-token',
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:9999/api/v2/query?org=my-org',
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:9999',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=s')
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:9999/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns')
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:9999/api/v2/write?bucket=my-bucket2&org=my-org-a&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=s',
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:9999/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns',
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:9999/api/v2/write?bucket=my-bucket2&org=my-org-a&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org-a&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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
- error = assert_raises InfluxDB2::InfluxError do
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
347
- times: 1, body: request)
343
+ sleep(0.5)
348
344
 
349
- sleep(2)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
352
- times: 2, body: request)
348
+ sleep(2)
353
349
 
354
- sleep(4)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
357
- times: 3, body: request)
353
+ sleep(4)
358
354
 
359
- sleep(5)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
362
- times: 4, body: request)
358
+ sleep(5)
363
359
 
364
- sleep(5)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
367
- times: 4, body: request)
363
+ sleep(5)
368
364
 
369
- sleep(5)
370
- end
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
- assert_equal('429', error.code)
368
+ sleep(5)
373
369
 
374
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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
- error = assert_raises InfluxDB2::InfluxError do
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
429
- times: 1, body: request)
422
+ sleep(0.5)
430
423
 
431
- sleep(3)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
434
- times: 2, body: request)
427
+ sleep(3)
435
428
 
436
- sleep(3)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
439
- times: 3, body: request)
432
+ sleep(3)
440
433
 
441
- sleep(3)
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
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
444
- times: 4, body: request)
437
+ sleep(3)
445
438
 
446
- sleep(3)
447
- end
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
- assert_equal('429', error.code)
442
+ sleep(3)
450
443
 
451
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999' \
457
- '(Connection refused - connect(2) for "localhost" port 9999)'
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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
- error = assert_raises InfluxDB2::InfluxError do
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
- sleep(0.5)
471
+ sleep(0.5)
480
472
 
481
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
482
- times: 1, body: request)
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
- sleep(2)
476
+ sleep(2)
485
477
 
486
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
487
- times: 2, body: request)
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
- sleep(4)
481
+ sleep(4)
490
482
 
491
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
492
- times: 3, body: request)
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
- sleep(5)
486
+ sleep(5)
495
487
 
496
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
497
- times: 4, body: request)
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
- sleep(5)
491
+ sleep(5)
500
492
 
501
- assert_requested(:post, 'http://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
502
- times: 4, body: request)
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
- sleep(5)
505
- end
496
+ sleep(5)
506
497
 
507
- assert_equal('Connection refused - ' + error_message, error.message)
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
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