influxdb-client 1.17.0.pre.3057 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +18 -2
- data/lib/influxdb2/client/client.rb +2 -0
- data/lib/influxdb2/client/default_api.rb +19 -7
- data/lib/influxdb2/client/influx_error.rb +3 -0
- data/lib/influxdb2/client/version.rb +1 -1
- data/test/influxdb/redirect_test.rb +145 -0
- data/test/influxdb/write_api_batching_test.rb +24 -5
- data/test/influxdb/write_api_test.rb +23 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc6fd6dd1906594584875d1274c8fb79200e793ced41d6228f7d169e4f5d192a
|
4
|
+
data.tar.gz: 37230349c80c42b2af0999e81fea24ecaced43ff7b8aae583510bacb7cf49538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4fbcef9b4ce901887d12b659b1467f1cc0d1b123238dc5373f02a0bab5b3bfc477b7572ab3994eef0de1a7a200c005058457d0be4827e929291844c6236f5d
|
7
|
+
data.tar.gz: 4ca1d999089888084313eb50667c44662383d3650d78f15c34a6a01eb36c3dabceec5f3fa389ec697333fb1341ee639671b3fe12fb41e84a0d90f3603c6f18c1
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
##
|
1
|
+
## 2.0.0 [2021-09-13]
|
2
|
+
|
3
|
+
### Bug Fixes
|
4
|
+
1. [#90](https://github.com/influxdata/influxdb-client-ruby/pull/90): Fix parse text plain 503 error response
|
5
|
+
|
6
|
+
### Breaking Changes
|
7
|
+
Due to a security reason `Authorization` header is not forwarded when redirect leads to a different domain.
|
8
|
+
To overcome this limitation you have to set the client property `redirect_forward_authorization` to `true`.
|
9
|
+
|
10
|
+
### Features
|
11
|
+
1. [#89](https://github.com/influxdata/influxdb-client-ruby/pull/89): `Authorization` header is not forwarded when redirect leads to a different domain
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
1. [#89](https://github.com/influxdata/influxdb-client-ruby/pull/89): Correct redirect location
|
15
|
+
|
16
|
+
## 1.17.0 [2021-08-20]
|
2
17
|
|
3
18
|
### Bug Fixes
|
4
19
|
1. [#87](https://github.com/influxdata/influxdb-client-ruby/pull/87): Parsing infinite numbers
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ This repository contains the reference Ruby client for the InfluxDB 2.0.
|
|
23
23
|
- [Management API](#management-api)
|
24
24
|
- [Advanced Usage](#advanced-usage)
|
25
25
|
- [Default Tags](#default-tags)
|
26
|
+
- [Proxy configuration](#proxy-configuration)
|
26
27
|
- [Contributing](#contributing)
|
27
28
|
- [License](#license)
|
28
29
|
|
@@ -63,13 +64,13 @@ The client can be installed manually or with bundler.
|
|
63
64
|
To install the client gem manually:
|
64
65
|
|
65
66
|
```
|
66
|
-
gem install influxdb-client -v
|
67
|
+
gem install influxdb-client -v 2.0.0
|
67
68
|
```
|
68
69
|
|
69
70
|
For management API:
|
70
71
|
|
71
72
|
```
|
72
|
-
gem install influxdb-client-apis -v
|
73
|
+
gem install influxdb-client-apis -v 2.0.0
|
73
74
|
```
|
74
75
|
|
75
76
|
## Usage
|
@@ -93,6 +94,7 @@ client = InfluxDB2::Client.new('https://localhost:8086', 'my-token')
|
|
93
94
|
| write_timeout | Number of seconds to wait for one block of data to be written | Integer | 10 |
|
94
95
|
| read_timeout | Number of seconds to wait for one block of data to be read | Integer | 10 |
|
95
96
|
| max_redirect_count | Maximal number of followed HTTP redirects | Integer | 10 |
|
97
|
+
| redirect_forward_authorization | Pass Authorization header to different domain during HTTP redirect. | bool | false |
|
96
98
|
| use_ssl | Turn on/off SSL for HTTP communication | bool | true |
|
97
99
|
| verify_mode | Sets the flags for the certification verification at beginning of SSL/TLS session. | `OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER` | none |
|
98
100
|
|
@@ -400,6 +402,20 @@ client.close!
|
|
400
402
|
|
401
403
|
Server availability can be checked using the `client.health` method. That is equivalent of the [influx ping](https://v2.docs.influxdata.com/v2.0/reference/cli/influx/ping/).
|
402
404
|
|
405
|
+
### Proxy configuration
|
406
|
+
|
407
|
+
You can configure the client to tunnel requests through an HTTP proxy. To configure the proxy use a `http_proxy` environment variable.
|
408
|
+
|
409
|
+
```ruby
|
410
|
+
ENV['HTTP_PROXY'] = 'http://my-user:my-password@my-proxy:8099'
|
411
|
+
```
|
412
|
+
|
413
|
+
Client automatically follows HTTP redirects. The default redirect policy is to follow up to 10 consecutive requests.
|
414
|
+
You can configure redirect counts by the client property: `max_redirect_count`.
|
415
|
+
|
416
|
+
Due to a security reason `Authorization` header is not forwarded when redirect leads to a different domain.
|
417
|
+
To overcome this limitation you have to set the client property `redirect_forward_authorization` to `true`.
|
418
|
+
|
403
419
|
### InfluxDB 1.8 API compatibility
|
404
420
|
|
405
421
|
[InfluxDB 1.8.0 introduced forward compatibility APIs](https://docs.influxdata.com/influxdb/v1.8/tools/api/#influxdb-2-0-api-compatibility-endpoints) for InfluxDB 2.0. This allow you to easily move from InfluxDB 1.x to InfluxDB 2.0 Cloud or open source.
|
@@ -42,6 +42,8 @@ module InfluxDB2
|
|
42
42
|
# @option options [Integer] :write_timeout Number of seconds to wait for one block of data to be written
|
43
43
|
# @option options [Integer] :read_timeout Number of seconds to wait for one block of data to be read
|
44
44
|
# @option options [Integer] :max_redirect_count Maximal number of followed HTTP redirects
|
45
|
+
# @option options [bool] :redirect_forward_authorization Pass Authorization header to different domain
|
46
|
+
# during HTTP redirect.
|
45
47
|
# @option options [bool] :use_ssl Turn on/off SSL for HTTP communication
|
46
48
|
# @option options [Integer] :verify_mode Sets the flags for the certification verification
|
47
49
|
# at beginning of SSL/TLS session. Could be one of `OpenSSL::SSL::VERIFY_NONE` or `OpenSSL::SSL::VERIFY_PEER`.
|
@@ -73,21 +73,24 @@ module InfluxDB2
|
|
73
73
|
_post(payload, uri, headers: headers.merge(HEADER_CONTENT_TYPE => 'text/plain'))
|
74
74
|
end
|
75
75
|
|
76
|
-
def _post(payload, uri, limit: @max_redirect_count, headers: {})
|
77
|
-
_request(payload, uri, limit: limit,
|
76
|
+
def _post(payload, uri, limit: @max_redirect_count, add_authorization: true, headers: {})
|
77
|
+
_request(payload, uri, limit: limit, add_authorization: add_authorization,
|
78
|
+
headers: headers, request: Net::HTTP::Post)
|
78
79
|
end
|
79
80
|
|
80
|
-
def _get(uri, limit: @max_redirect_count, headers: {})
|
81
|
-
_request(nil, uri, limit: limit,
|
81
|
+
def _get(uri, limit: @max_redirect_count, add_authorization: true, headers: {})
|
82
|
+
_request(nil, uri, limit: limit, add_authorization: add_authorization,
|
83
|
+
headers: headers.merge('Accept' => 'application/json'), request: Net::HTTP::Get)
|
82
84
|
end
|
83
85
|
|
84
|
-
def _request(payload, uri, limit: @max_redirect_count, headers: {},
|
86
|
+
def _request(payload, uri, limit: @max_redirect_count, add_authorization: true, headers: {},
|
87
|
+
request: Net::HTTP::Post)
|
85
88
|
raise InfluxError.from_message("Too many HTTP redirects. Exceeded limit: #{@max_redirect_count}") if limit.zero?
|
86
89
|
|
87
90
|
http = _prepare_http_client(uri)
|
88
91
|
|
89
92
|
request = request.new(uri.request_uri)
|
90
|
-
request['Authorization'] = "Token #{@options[:token]}"
|
93
|
+
request['Authorization'] = "Token #{@options[:token]}" if add_authorization
|
91
94
|
request['User-Agent'] = "influxdb-client-ruby/#{InfluxDB2::VERSION}"
|
92
95
|
headers.each { |k, v| request[k] = v }
|
93
96
|
|
@@ -100,7 +103,16 @@ module InfluxDB2
|
|
100
103
|
response
|
101
104
|
when Net::HTTPRedirection then
|
102
105
|
location = response['location']
|
103
|
-
|
106
|
+
redirect_forward_authorization = @options[:redirect_forward_authorization] || false
|
107
|
+
|
108
|
+
uri_redirect = URI.parse(location)
|
109
|
+
uri_redirect.query = uri.query
|
110
|
+
uri_redirect.path = File.join(uri_redirect.path, uri.path)
|
111
|
+
|
112
|
+
redirect_forward_authorization ||= (uri_redirect.host == uri.host) && (uri_redirect.port == uri.port)
|
113
|
+
|
114
|
+
_post(payload, uri_redirect, limit: limit - 1, add_authorization: redirect_forward_authorization,
|
115
|
+
headers: headers)
|
104
116
|
else
|
105
117
|
raise InfluxError.from_response(response)
|
106
118
|
end
|
@@ -35,6 +35,9 @@ module InfluxDB2
|
|
35
35
|
obj = new(message: json['message'] || '', code: response.code, reference: json['code'] || '',
|
36
36
|
retry_after: response['Retry-After'] || '')
|
37
37
|
obj
|
38
|
+
rescue JSON::ParserError
|
39
|
+
new(message: response.body || '', code: response.code, reference: '',
|
40
|
+
retry_after: response['Retry-After'] || '')
|
38
41
|
end
|
39
42
|
|
40
43
|
def self.from_message(message)
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'test_helper'
|
22
|
+
|
23
|
+
class WriteApiTest < MiniTest::Test
|
24
|
+
def setup
|
25
|
+
WebMock.disable_net_connect!
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_redirect_same
|
29
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
30
|
+
.to_return(status: 307, headers:
|
31
|
+
{ 'location' => 'http://localhost:8086' })
|
32
|
+
.then.to_return(status: 204)
|
33
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
34
|
+
.to_return(status: 204)
|
35
|
+
|
36
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
37
|
+
bucket: 'my-bucket',
|
38
|
+
org: 'my-org',
|
39
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
40
|
+
use_ssl: false)
|
41
|
+
|
42
|
+
client.create_write_api.write(data: 'h2o,location=west value=33i 15')
|
43
|
+
|
44
|
+
headers = {
|
45
|
+
'Authorization' => 'Token my-token',
|
46
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
47
|
+
'Content-Type' => 'text/plain'
|
48
|
+
}
|
49
|
+
|
50
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
51
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_redirect_301
|
55
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
56
|
+
.to_return(status: 301, headers:
|
57
|
+
{ 'location' => 'http://localhost:9090/' })
|
58
|
+
.then.to_return(status: 204)
|
59
|
+
stub_request(:any, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
60
|
+
.to_return(status: 204)
|
61
|
+
|
62
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
63
|
+
bucket: 'my-bucket',
|
64
|
+
org: 'my-org',
|
65
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
66
|
+
use_ssl: false)
|
67
|
+
|
68
|
+
client.create_write_api.write(data: 'h2o,location=west value=33i 15')
|
69
|
+
|
70
|
+
headers = {
|
71
|
+
'Authorization' => 'Token my-token',
|
72
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
73
|
+
'Content-Type' => 'text/plain'
|
74
|
+
}
|
75
|
+
|
76
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
77
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
78
|
+
|
79
|
+
assert_not_requested(:post, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
80
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
81
|
+
|
82
|
+
assert_requested(:post, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
83
|
+
times: 1, body: 'h2o,location=west value=33i 15')
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_redirect_301_allow
|
87
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
88
|
+
.to_return(status: 301, headers:
|
89
|
+
{ 'location' => 'http://localhost:9090/' })
|
90
|
+
.then.to_return(status: 204)
|
91
|
+
stub_request(:any, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
92
|
+
.to_return(status: 204)
|
93
|
+
|
94
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
95
|
+
bucket: 'my-bucket',
|
96
|
+
org: 'my-org',
|
97
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
98
|
+
use_ssl: false,
|
99
|
+
redirect_forward_authorization: true)
|
100
|
+
|
101
|
+
client.create_write_api.write(data: 'h2o,location=west value=33i 15')
|
102
|
+
|
103
|
+
headers = {
|
104
|
+
'Authorization' => 'Token my-token',
|
105
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
106
|
+
'Content-Type' => 'text/plain'
|
107
|
+
}
|
108
|
+
|
109
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
110
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
111
|
+
|
112
|
+
assert_requested(:post, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
113
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_redirect_different_path
|
117
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
118
|
+
.to_return(status: 301, headers:
|
119
|
+
{ 'location' => 'http://localhost:8086/influxdb/' })
|
120
|
+
.then.to_return(status: 204)
|
121
|
+
stub_request(:any, 'http://localhost:8086/influxdb/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
122
|
+
.to_return(status: 204)
|
123
|
+
|
124
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
125
|
+
bucket: 'my-bucket',
|
126
|
+
org: 'my-org',
|
127
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
128
|
+
use_ssl: false,
|
129
|
+
redirect_forward_authorization: true)
|
130
|
+
|
131
|
+
client.create_write_api.write(data: 'h2o,location=west value=33i 15')
|
132
|
+
|
133
|
+
headers = {
|
134
|
+
'Authorization' => 'Token my-token',
|
135
|
+
'User-Agent' => "influxdb-client-ruby/#{InfluxDB2::VERSION}",
|
136
|
+
'Content-Type' => 'text/plain'
|
137
|
+
}
|
138
|
+
|
139
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
140
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
141
|
+
|
142
|
+
assert_requested(:post, 'http://localhost:8086/influxdb/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
143
|
+
times: 1, body: 'h2o,location=west value=33i 15', headers: headers)
|
144
|
+
end
|
145
|
+
end
|
@@ -210,11 +210,6 @@ class WriteApiBatchingTest < MiniTest::Test
|
|
210
210
|
@write_client.write(data: ['h2o_feet,location=coyote_creek water_level=1.0 1',
|
211
211
|
'h2o_feet,location=coyote_creek water_level=2.0 2'])
|
212
212
|
|
213
|
-
sleep(0.05)
|
214
|
-
|
215
|
-
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
216
|
-
times: 0, body: request)
|
217
|
-
|
218
213
|
sleep(2)
|
219
214
|
|
220
215
|
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
@@ -617,4 +612,28 @@ class WriteApiRetryStrategyTest < MiniTest::Test
|
|
617
612
|
assert_gte backoff, 1_600
|
618
613
|
assert_lte backoff, 2_000
|
619
614
|
end
|
615
|
+
|
616
|
+
def test_write_error_plain_retry
|
617
|
+
error_body = 'Service Unavailable'
|
618
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
619
|
+
.to_return(status: 503, headers: { 'content-type' => 'text/plain', 'Retry-After' => '2' }, body: error_body)
|
620
|
+
.to_return(status: 503, headers: { 'content-type' => 'text/plain' }, body: error_body).to_return(status: 204)
|
621
|
+
|
622
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
623
|
+
bucket: 'my-bucket',
|
624
|
+
org: 'my-org',
|
625
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
626
|
+
use_ssl: false)
|
627
|
+
|
628
|
+
@write_options = InfluxDB2::WriteOptions.new(write_type: InfluxDB2::WriteType::BATCHING,
|
629
|
+
batch_size: 1, flush_interval: 1_000, retry_interval: 1_000)
|
630
|
+
|
631
|
+
write_api = client.create_write_api(write_options: @write_options)
|
632
|
+
request = 'h2o,location=west value=33i 15'
|
633
|
+
write_api.write(data: request)
|
634
|
+
|
635
|
+
sleep(10)
|
636
|
+
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
637
|
+
times: 3, body: request)
|
638
|
+
end
|
620
639
|
end
|
@@ -201,7 +201,7 @@ class WriteApiTest < MiniTest::Test
|
|
201
201
|
def test_follow_redirect
|
202
202
|
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
203
203
|
.to_return(status: 307, headers:
|
204
|
-
{ 'location' => 'http://localhost:9090/
|
204
|
+
{ 'location' => 'http://localhost:9090/' })
|
205
205
|
.then.to_return(status: 204)
|
206
206
|
stub_request(:any, 'http://localhost:9090/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
207
207
|
.to_return(status: 204)
|
@@ -223,7 +223,7 @@ class WriteApiTest < MiniTest::Test
|
|
223
223
|
def test_follow_redirect_max
|
224
224
|
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
225
225
|
.to_return(status: 307, headers:
|
226
|
-
{ 'location' => 'http://localhost:8086/
|
226
|
+
{ 'location' => 'http://localhost:8086/' })
|
227
227
|
|
228
228
|
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
229
229
|
bucket: 'my-bucket',
|
@@ -384,4 +384,25 @@ class WriteApiDefaultTagsTest < MiniTest::Test
|
|
384
384
|
assert_requested(:post, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
385
385
|
times: 1, body: expected)
|
386
386
|
end
|
387
|
+
|
388
|
+
def test_write_error_plain
|
389
|
+
error_body = 'Service Unavailable'
|
390
|
+
stub_request(:any, 'http://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
391
|
+
.to_return(status: 503, headers: { 'content-type' => 'text/plain' },
|
392
|
+
body: error_body)
|
393
|
+
|
394
|
+
client = InfluxDB2::Client.new('http://localhost:8086', 'my-token',
|
395
|
+
bucket: 'my-bucket',
|
396
|
+
org: 'my-org',
|
397
|
+
precision: InfluxDB2::WritePrecision::NANOSECOND,
|
398
|
+
use_ssl: false)
|
399
|
+
|
400
|
+
error = assert_raises InfluxDB2::InfluxError do
|
401
|
+
write_api = client.create_write_api
|
402
|
+
write_api.write(data: 'h2o,location=west value=33i 15')
|
403
|
+
end
|
404
|
+
|
405
|
+
assert_equal '503', error.code
|
406
|
+
assert_equal 'Service Unavailable', error.message
|
407
|
+
end
|
387
408
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- test/influxdb/query_api_integration_test.rb
|
162
162
|
- test/influxdb/query_api_stream_test.rb
|
163
163
|
- test/influxdb/query_api_test.rb
|
164
|
+
- test/influxdb/redirect_test.rb
|
164
165
|
- test/influxdb/write_api_batching_test.rb
|
165
166
|
- test/influxdb/write_api_integration_test.rb
|
166
167
|
- test/influxdb/write_api_test.rb
|
@@ -183,9 +184,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: 2.2.0
|
184
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
186
|
requirements:
|
186
|
-
- - "
|
187
|
+
- - ">="
|
187
188
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
189
|
+
version: '0'
|
189
190
|
requirements: []
|
190
191
|
rubygems_version: 3.0.3.1
|
191
192
|
signing_key:
|
@@ -201,6 +202,7 @@ test_files:
|
|
201
202
|
- test/influxdb/query_api_integration_test.rb
|
202
203
|
- test/influxdb/query_api_stream_test.rb
|
203
204
|
- test/influxdb/query_api_test.rb
|
205
|
+
- test/influxdb/redirect_test.rb
|
204
206
|
- test/influxdb/write_api_batching_test.rb
|
205
207
|
- test/influxdb/write_api_integration_test.rb
|
206
208
|
- test/influxdb/write_api_test.rb
|