influxdb 0.6.2 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +92 -0
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +34 -0
- data/README.md +80 -34
- data/Rakefile +1 -1
- data/bin/provision.sh +3 -3
- data/influxdb.gemspec +2 -2
- data/lib/influxdb/client.rb +15 -9
- data/lib/influxdb/client/http.rb +11 -1
- data/lib/influxdb/config.rb +7 -5
- data/lib/influxdb/errors.rb +1 -0
- data/lib/influxdb/point_value.rb +4 -1
- data/lib/influxdb/query/batch.rb +9 -3
- data/lib/influxdb/query/cluster.rb +2 -2
- data/lib/influxdb/query/continuous_query.rb +1 -1
- data/lib/influxdb/query/core.rb +11 -7
- data/lib/influxdb/query/database.rb +2 -2
- data/lib/influxdb/query/series.rb +6 -2
- data/lib/influxdb/query/user.rb +8 -8
- data/lib/influxdb/timestamp_conversion.rb +52 -12
- data/lib/influxdb/version.rb +1 -1
- data/lib/influxdb/writer/async.rb +38 -11
- data/lib/influxdb/writer/udp.rb +3 -0
- data/spec/influxdb/cases/async_client_spec.rb +59 -35
- data/spec/influxdb/cases/query_cluster_spec.rb +3 -3
- data/spec/influxdb/cases/query_continuous_query_spec.rb +1 -1
- data/spec/influxdb/cases/query_database_spec.rb +4 -4
- data/spec/influxdb/cases/query_series_spec.rb +24 -8
- data/spec/influxdb/cases/query_user_spec.rb +8 -8
- data/spec/influxdb/cases/querying_issue_7000_spec.rb +1 -1
- data/spec/influxdb/cases/querying_spec.rb +1 -1
- data/spec/influxdb/cases/retry_requests_spec.rb +1 -1
- data/spec/influxdb/cases/udp_client_spec.rb +8 -14
- data/spec/influxdb/client_spec.rb +2 -2
- data/spec/influxdb/config_spec.rb +44 -14
- data/spec/influxdb/logging_spec.rb +3 -0
- data/spec/influxdb/point_value_spec.rb +11 -1
- data/spec/influxdb/time_conversion_spec.rb +19 -0
- data/spec/smoke/smoke_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -4
- metadata +13 -14
- data/.travis.yml +0 -55
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
require "timeout"
|
3
3
|
|
4
4
|
describe InfluxDB::Client do
|
5
|
-
let(:async_options) {
|
5
|
+
let(:async_options) { { sleep_interval: 0.1 } }
|
6
6
|
let(:client) { described_class.new(async: async_options) }
|
7
7
|
let(:subject) { client }
|
8
8
|
let(:stub_url) { "http://localhost:8086/write?db=&p=root&precision=s&u=root" }
|
@@ -14,18 +14,13 @@ describe InfluxDB::Client do
|
|
14
14
|
it "sends writes to client" do
|
15
15
|
post_request = stub_request(:post, stub_url).to_return(status: 204)
|
16
16
|
|
17
|
-
(worker.max_post_points + 100).times do
|
18
|
-
subject.write_point('a', {})
|
17
|
+
(worker.max_post_points + 100).times do |i|
|
18
|
+
subject.write_point('a', values: { i: i })
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
# (and scheduler decisions). On the CI, the system is less
|
23
|
-
# responsive and needs a bit more time.
|
24
|
-
timeout_stretch = ENV["TRAVIS"] == "true" ? 10 : 3
|
21
|
+
sleep 1 until worker.threads.none? { |t| t[:influxdb].nil? }
|
25
22
|
|
26
|
-
|
27
|
-
subject.stop!
|
28
|
-
end
|
23
|
+
subject.stop!
|
29
24
|
|
30
25
|
worker.threads.each do |t|
|
31
26
|
expect(t.stop?).to be true
|
@@ -41,6 +36,7 @@ describe InfluxDB::Client do
|
|
41
36
|
let(:precision) { 'test_precision' }
|
42
37
|
let(:retention_policy) { 'test_period' }
|
43
38
|
let(:database) { 'test_database' }
|
39
|
+
let(:async_options) { { num_worker_threads: 1, sleep_interval: 0.1 } }
|
44
40
|
|
45
41
|
it "writes aggregate payload to the client" do
|
46
42
|
queue = Queue.new
|
@@ -51,9 +47,11 @@ describe InfluxDB::Client do
|
|
51
47
|
subject.write_point(series, { values: { t: 60 } }, precision, retention_policy, database)
|
52
48
|
subject.write_point(series, { values: { t: 61 } }, precision, retention_policy, database)
|
53
49
|
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
sleep 1 until worker.threads.none? { |t| t[:influxdb].nil? }
|
51
|
+
|
52
|
+
subject.stop!
|
53
|
+
|
54
|
+
expect(queue.pop).to eq ["#{series} t=60i\n#{series} t=61i", precision, retention_policy, database]
|
57
55
|
end
|
58
56
|
|
59
57
|
context 'when different precision, retention_policy and database are given' do
|
@@ -72,36 +70,62 @@ describe InfluxDB::Client do
|
|
72
70
|
subject.write_point(series, { values: { t: 62 } }, precision, retention_policy2, database)
|
73
71
|
subject.write_point(series, { values: { t: 63 } }, precision, retention_policy, database2)
|
74
72
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
73
|
+
sleep 1 until worker.threads.none? { |t| t[:influxdb].nil? }
|
74
|
+
|
75
|
+
subject.stop!
|
76
|
+
|
77
|
+
expect(queue.pop).to eq ["#{series} t=60i", precision, retention_policy, database]
|
78
|
+
expect(queue.pop).to eq ["#{series} t=61i", precision2, retention_policy, database]
|
79
|
+
expect(queue.pop).to eq ["#{series} t=62i", precision, retention_policy2, database]
|
80
|
+
expect(queue.pop).to eq ["#{series} t=63i", precision, retention_policy, database2]
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "async options" do
|
87
|
-
let(:async_options) do
|
88
|
-
{
|
89
|
-
max_post_points: 10,
|
90
|
-
max_queue_size: 100,
|
91
|
-
num_worker_threads: 1,
|
92
|
-
sleep_interval: 0.5,
|
93
|
-
block_on_full_queue: false
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
87
|
subject { worker }
|
98
88
|
before { worker.stop! }
|
99
89
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
90
|
+
context 'when all options are given' do
|
91
|
+
let(:async_options) do
|
92
|
+
{
|
93
|
+
max_post_points: 10,
|
94
|
+
max_queue_size: 100,
|
95
|
+
num_worker_threads: 1,
|
96
|
+
sleep_interval: 0.5,
|
97
|
+
block_on_full_queue: false,
|
98
|
+
shutdown_timeout: 0.6,
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
it "uses the specified values" do
|
103
|
+
expect(subject.max_post_points).to be 10
|
104
|
+
expect(subject.max_queue_size).to be 100
|
105
|
+
expect(subject.num_worker_threads).to be 1
|
106
|
+
expect(subject.sleep_interval).to be_within(0.0001).of(0.5)
|
107
|
+
expect(subject.block_on_full_queue).to be false
|
108
|
+
expect(subject.queue).to be_kind_of(InfluxDB::MaxQueue)
|
109
|
+
expect(subject.shutdown_timeout).to be_within(0.0001).of(0.6)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when only sleep_interval is given' do
|
114
|
+
let(:async_options) { { sleep_interval: 0.2 } }
|
115
|
+
|
116
|
+
it "uses a value for shutdown_timeout that is 2x sleep_interval" do
|
117
|
+
expect(subject.sleep_interval).to be_within(0.0001).of(0.2)
|
118
|
+
expect(subject.shutdown_timeout).to be_within(0.0001).of(0.4)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when only shutdown_timeout is given' do
|
123
|
+
let(:async_options) { { shutdown_timeout: 0.3 } }
|
124
|
+
|
125
|
+
it "uses that value" do
|
126
|
+
expect(subject.sleep_interval).to be_within(0.0001).of(5)
|
127
|
+
expect(subject.shutdown_timeout).to be_within(0.0001).of(0.3)
|
128
|
+
end
|
129
|
+
end
|
106
130
|
end
|
107
131
|
end
|
@@ -3,7 +3,7 @@ require "json"
|
|
3
3
|
|
4
4
|
describe InfluxDB::Client do
|
5
5
|
let(:subject) do
|
6
|
-
described_class.new "database", {
|
6
|
+
described_class.new "database", **{
|
7
7
|
host: "influxdb.test",
|
8
8
|
port: 9999,
|
9
9
|
username: "username",
|
@@ -17,7 +17,7 @@ describe InfluxDB::Client do
|
|
17
17
|
describe "#create_cluster_admin" do
|
18
18
|
let(:user) { 'adminadmin' }
|
19
19
|
let(:pass) { 'passpass' }
|
20
|
-
let(:query) { "CREATE USER #{user} WITH PASSWORD '#{pass}' WITH ALL PRIVILEGES" }
|
20
|
+
let(:query) { "CREATE USER \"#{user}\" WITH PASSWORD '#{pass}' WITH ALL PRIVILEGES" }
|
21
21
|
|
22
22
|
context 'with existing admin user' do
|
23
23
|
before do
|
@@ -67,7 +67,7 @@ describe InfluxDB::Client do
|
|
67
67
|
|
68
68
|
describe "#revoke_cluster_admin_privileges" do
|
69
69
|
let(:user) { 'useruser' }
|
70
|
-
let(:query) { "REVOKE ALL PRIVILEGES FROM #{user}" }
|
70
|
+
let(:query) { "REVOKE ALL PRIVILEGES FROM \"#{user}\"" }
|
71
71
|
|
72
72
|
before do
|
73
73
|
stub_request(:get, "http://influxdb.test:9999/query").with(
|
@@ -104,7 +104,7 @@ describe InfluxDB::Client do
|
|
104
104
|
describe "#delete_continuous_query" do
|
105
105
|
let(:name) { "event_counts_per_10m_by_type" }
|
106
106
|
let(:database) { "testdb" }
|
107
|
-
let(:query) { "DROP CONTINUOUS QUERY #{name} ON #{database}" }
|
107
|
+
let(:query) { "DROP CONTINUOUS QUERY \"#{name}\" ON \"#{database}\"" }
|
108
108
|
|
109
109
|
before do
|
110
110
|
stub_request(:get, "http://influxdb.test:9999/query")
|
@@ -23,7 +23,7 @@ describe InfluxDB::Client do
|
|
23
23
|
|
24
24
|
describe "#create_database" do
|
25
25
|
describe "from param" do
|
26
|
-
let(:query) { "CREATE DATABASE foo" }
|
26
|
+
let(:query) { "CREATE DATABASE \"foo\"" }
|
27
27
|
|
28
28
|
it "should GET to create a new database" do
|
29
29
|
expect(subject.create_database("foo")).to be_a(Net::HTTPOK)
|
@@ -31,7 +31,7 @@ describe InfluxDB::Client do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "from config" do
|
34
|
-
let(:query) { "CREATE DATABASE database" }
|
34
|
+
let(:query) { "CREATE DATABASE \"database\"" }
|
35
35
|
|
36
36
|
it "should GET to create a new database using database name from config" do
|
37
37
|
expect(subject.create_database).to be_a(Net::HTTPOK)
|
@@ -41,7 +41,7 @@ describe InfluxDB::Client do
|
|
41
41
|
|
42
42
|
describe "#delete_database" do
|
43
43
|
describe "from param" do
|
44
|
-
let(:query) { "DROP DATABASE foo" }
|
44
|
+
let(:query) { "DROP DATABASE \"foo\"" }
|
45
45
|
|
46
46
|
it "should GET to remove a database" do
|
47
47
|
expect(subject.delete_database("foo")).to be_a(Net::HTTPOK)
|
@@ -49,7 +49,7 @@ describe InfluxDB::Client do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "from config" do
|
52
|
-
let(:query) { "DROP DATABASE database" }
|
52
|
+
let(:query) { "DROP DATABASE \"database\"" }
|
53
53
|
|
54
54
|
it "should GET to remove a database using database name from config" do
|
55
55
|
expect(subject.delete_database).to be_a(Net::HTTPOK)
|
@@ -5,7 +5,7 @@ describe InfluxDB::Client do
|
|
5
5
|
let(:subject) do
|
6
6
|
described_class.new(
|
7
7
|
"database",
|
8
|
-
{
|
8
|
+
**{
|
9
9
|
host: "influxdb.test",
|
10
10
|
port: 9999,
|
11
11
|
username: "username",
|
@@ -49,16 +49,32 @@ describe InfluxDB::Client do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#delete_series" do
|
52
|
-
|
53
|
-
|
52
|
+
describe "without a where clause" do
|
53
|
+
let(:name) { "events" }
|
54
|
+
let(:query) { "DROP SERIES FROM \"#{name}\"" }
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
before do
|
57
|
+
stub_request(:get, "http://influxdb.test:9999/query")
|
58
|
+
.with(query: { u: "username", p: "password", q: query, db: "database" })
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should GET to remove a database" do
|
62
|
+
expect(subject.delete_series(name)).to be_a(Net::HTTPOK)
|
63
|
+
end
|
58
64
|
end
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
describe "with a where clause" do
|
67
|
+
let(:name) { "events" }
|
68
|
+
let(:query) { "DROP SERIES FROM \"#{name}\" WHERE \"tag\"='value'" }
|
69
|
+
|
70
|
+
before do
|
71
|
+
stub_request(:get, "http://influxdb.test:9999/query")
|
72
|
+
.with(query: { u: "username", p: "password", q: query, db: "database" })
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should GET to remove a database" do
|
76
|
+
expect(subject.delete_series(name, where: "\"tag\"='value'")).to be_a(Net::HTTPOK)
|
77
|
+
end
|
62
78
|
end
|
63
79
|
end
|
64
80
|
end
|
@@ -24,7 +24,7 @@ describe InfluxDB::Client do
|
|
24
24
|
describe "#update user password" do
|
25
25
|
let(:user) { 'useruser' }
|
26
26
|
let(:pass) { 'passpass' }
|
27
|
-
let(:query) { "SET PASSWORD FOR #{user} = '#{pass}'" }
|
27
|
+
let(:query) { "SET PASSWORD FOR \"#{user}\" = '#{pass}'" }
|
28
28
|
|
29
29
|
it "should GET to update user password" do
|
30
30
|
expect(subject.update_user_password(user, pass)).to be_a(Net::HTTPOK)
|
@@ -35,7 +35,7 @@ describe InfluxDB::Client do
|
|
35
35
|
let(:user) { 'useruser' }
|
36
36
|
let(:perm) { :write }
|
37
37
|
let(:db) { 'foo' }
|
38
|
-
let(:query) { "GRANT #{perm.to_s.upcase} ON #{db} TO #{user}" }
|
38
|
+
let(:query) { "GRANT #{perm.to_s.upcase} ON \"#{db}\" TO \"#{user}\"" }
|
39
39
|
|
40
40
|
it "should GET to grant privileges for a user on a database" do
|
41
41
|
expect(subject.grant_user_privileges(user, db, perm)).to be_a(Net::HTTPOK)
|
@@ -44,7 +44,7 @@ describe InfluxDB::Client do
|
|
44
44
|
|
45
45
|
describe "#grant_user_admin_privileges" do
|
46
46
|
let(:user) { 'useruser' }
|
47
|
-
let(:query) { "GRANT ALL PRIVILEGES TO #{user}" }
|
47
|
+
let(:query) { "GRANT ALL PRIVILEGES TO \"#{user}\"" }
|
48
48
|
|
49
49
|
it "should GET to grant privileges for a user on a database" do
|
50
50
|
expect(subject.grant_user_admin_privileges(user)).to be_a(Net::HTTPOK)
|
@@ -55,7 +55,7 @@ describe InfluxDB::Client do
|
|
55
55
|
let(:user) { 'useruser' }
|
56
56
|
let(:perm) { :write }
|
57
57
|
let(:db) { 'foo' }
|
58
|
-
let(:query) { "REVOKE #{perm.to_s.upcase} ON #{db} FROM #{user}" }
|
58
|
+
let(:query) { "REVOKE #{perm.to_s.upcase} ON \"#{db}\" FROM \"#{user}\"" }
|
59
59
|
|
60
60
|
it "should GET to revoke privileges from a user on a database" do
|
61
61
|
expect(subject.revoke_user_privileges(user, db, perm)).to be_a(Net::HTTPOK)
|
@@ -66,7 +66,7 @@ describe InfluxDB::Client do
|
|
66
66
|
let(:user) { 'useruser' }
|
67
67
|
let(:pass) { 'passpass' }
|
68
68
|
let(:db) { 'foo' }
|
69
|
-
let(:query) { "CREATE user #{user} WITH PASSWORD '#{pass}'; GRANT ALL ON #{db} TO #{user}" }
|
69
|
+
let(:query) { "CREATE user \"#{user}\" WITH PASSWORD '#{pass}'; GRANT ALL ON \"#{db}\" TO \"#{user}\"" }
|
70
70
|
|
71
71
|
context "without specifying permissions" do
|
72
72
|
it "should GET to create a new database user with all permissions" do
|
@@ -76,7 +76,7 @@ describe InfluxDB::Client do
|
|
76
76
|
|
77
77
|
context "with passing permission as argument" do
|
78
78
|
let(:permission) { :read }
|
79
|
-
let(:query) { "CREATE user #{user} WITH PASSWORD '#{pass}'; GRANT #{permission.to_s.upcase} ON #{db} TO #{user}" }
|
79
|
+
let(:query) { "CREATE user \"#{user}\" WITH PASSWORD '#{pass}'; GRANT #{permission.to_s.upcase} ON \"#{db}\" TO \"#{user}\"" }
|
80
80
|
|
81
81
|
it "should GET to create a new database user with permission set" do
|
82
82
|
expect(subject.create_database_user(db, user, pass, permissions: permission)).to be_a(Net::HTTPOK)
|
@@ -86,7 +86,7 @@ describe InfluxDB::Client do
|
|
86
86
|
|
87
87
|
describe "#delete_user" do
|
88
88
|
let(:user) { 'useruser' }
|
89
|
-
let(:query) { "DROP USER #{user}" }
|
89
|
+
let(:query) { "DROP USER \"#{user}\"" }
|
90
90
|
|
91
91
|
it "should GET to delete a user" do
|
92
92
|
expect(subject.delete_user(user)).to be_a(Net::HTTPOK)
|
@@ -105,7 +105,7 @@ describe InfluxDB::Client do
|
|
105
105
|
|
106
106
|
describe "#list_user_grants" do
|
107
107
|
let(:user) { 'useruser' }
|
108
|
-
let(:list_query) { "SHOW GRANTS FOR #{user}" }
|
108
|
+
let(:list_query) { "SHOW GRANTS FOR \"#{user}\"" }
|
109
109
|
|
110
110
|
before do
|
111
111
|
stub_request(:get, "http://influxdb.test:9999/query")
|
@@ -1,7 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe InfluxDB::Client do
|
4
|
-
let(:
|
4
|
+
let(:socket) { UDPSocket.new.tap { |s| s.bind "localhost", 0 } }
|
5
|
+
after { socket.close rescue nil }
|
6
|
+
|
7
|
+
let(:client) { described_class.new(udp: { host: "localhost", port: socket.addr[1] }) }
|
5
8
|
|
6
9
|
specify { expect(client.writer).to be_a(InfluxDB::Writer::UDP) }
|
7
10
|
|
@@ -9,32 +12,23 @@ describe InfluxDB::Client do
|
|
9
12
|
let(:message) { 'responses,region=eu value=5i' }
|
10
13
|
|
11
14
|
it "sends a UDP packet" do
|
12
|
-
s = UDPSocket.new
|
13
|
-
s.bind("localhost", 44_444)
|
14
|
-
|
15
15
|
client.write_point("responses", values: { value: 5 }, tags: { region: 'eu' })
|
16
16
|
|
17
|
-
rec_message =
|
17
|
+
rec_message = socket.recvfrom(30).first
|
18
18
|
expect(rec_message).to eq message
|
19
|
-
|
20
|
-
s.close
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
22
|
describe "#write with discard_write_errors" do
|
25
23
|
let(:client) do
|
26
|
-
described_class.new
|
27
|
-
udp: { host: "localhost", port:
|
24
|
+
described_class.new \
|
25
|
+
udp: { host: "localhost", port: socket.addr[1] },
|
28
26
|
discard_write_errors: true
|
29
|
-
)
|
30
27
|
end
|
31
28
|
|
32
29
|
it "doesn't raise" do
|
33
|
-
s = UDPSocket.new
|
34
|
-
s.bind("localhost", 44_444)
|
35
|
-
|
36
30
|
client.write_point("responses", values: { value: 5 }, tags: { region: 'eu' })
|
37
|
-
|
31
|
+
socket.close
|
38
32
|
|
39
33
|
client.write_point("responses", values: { value: 7 }, tags: { region: 'eu' })
|
40
34
|
|
@@ -5,7 +5,7 @@ describe InfluxDB::Client do
|
|
5
5
|
let(:subject) do
|
6
6
|
described_class.new(
|
7
7
|
"database",
|
8
|
-
{
|
8
|
+
**{
|
9
9
|
host: "influxdb.test",
|
10
10
|
port: 9999,
|
11
11
|
username: "username",
|
@@ -47,7 +47,7 @@ describe InfluxDB::Client do
|
|
47
47
|
it "escapes params" do
|
48
48
|
url = subject.send(:full_url, "/unknown", value: ' !@#$%^&*()/\\_+-=?|`~')
|
49
49
|
encoded_fragment = "value=+%21%40%23%24%25%5E%26%2A%28%29%2F%5C_%2B-%3D%3F%7C%60"
|
50
|
-
encoded_fragment << (
|
50
|
+
encoded_fragment << (RUBY_VERSION >= "2.5.0" ? "~" : "%7E")
|
51
51
|
expect(url).to include(encoded_fragment)
|
52
52
|
end
|
53
53
|
|
@@ -1,11 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe InfluxDB::Config do
|
4
|
-
|
5
|
-
|
4
|
+
after { client.stop! }
|
5
|
+
|
6
|
+
let(:client) do
|
7
|
+
kwargs = args.last.is_a?(Hash) ? args.pop : {}
|
8
|
+
InfluxDB::Client.new(*args, **kwargs)
|
6
9
|
end
|
10
|
+
let(:conf) { client.config }
|
7
11
|
|
8
|
-
let(:args) {
|
12
|
+
let(:args) { [] }
|
9
13
|
|
10
14
|
context "with no parameters specified" do
|
11
15
|
specify { expect(conf.database).to be_nil }
|
@@ -20,17 +24,19 @@ describe InfluxDB::Config do
|
|
20
24
|
specify { expect(conf).not_to be_udp }
|
21
25
|
specify { expect(conf).not_to be_async }
|
22
26
|
specify { expect(conf.epoch).to be_falsey }
|
27
|
+
specify { expect(conf.proxy_addr).to be_nil }
|
28
|
+
specify { expect(conf.proxy_port).to be_nil }
|
23
29
|
end
|
24
30
|
|
25
31
|
context "with no database specified" do
|
26
32
|
let(:args) do
|
27
|
-
[
|
33
|
+
[
|
28
34
|
host: "host",
|
29
35
|
port: "port",
|
30
36
|
username: "username",
|
31
37
|
password: "password",
|
32
38
|
time_precision: "m"
|
33
|
-
|
39
|
+
]
|
34
40
|
end
|
35
41
|
|
36
42
|
specify { expect(conf.database).to be_nil }
|
@@ -64,7 +70,7 @@ describe InfluxDB::Config do
|
|
64
70
|
end
|
65
71
|
|
66
72
|
context "with ssl option specified" do
|
67
|
-
let(:args) { [
|
73
|
+
let(:args) { [use_ssl: true] }
|
68
74
|
|
69
75
|
specify { expect(conf.database).to be_nil }
|
70
76
|
specify { expect(conf.hosts).to eq ["localhost"] }
|
@@ -75,7 +81,7 @@ describe InfluxDB::Config do
|
|
75
81
|
end
|
76
82
|
|
77
83
|
context "with multiple hosts specified" do
|
78
|
-
let(:args) { [
|
84
|
+
let(:args) { [hosts: ["1.1.1.1", "2.2.2.2"]] }
|
79
85
|
|
80
86
|
specify { expect(conf.database).to be_nil }
|
81
87
|
specify { expect(conf.port).to eq 8086 }
|
@@ -85,7 +91,7 @@ describe InfluxDB::Config do
|
|
85
91
|
end
|
86
92
|
|
87
93
|
context "with auth_method basic auth specified" do
|
88
|
-
let(:args) { [
|
94
|
+
let(:args) { [auth_method: 'basic_auth'] }
|
89
95
|
|
90
96
|
specify { expect(conf.database).to be_nil }
|
91
97
|
specify { expect(conf.hosts).to eq ["localhost"] }
|
@@ -96,38 +102,38 @@ describe InfluxDB::Config do
|
|
96
102
|
end
|
97
103
|
|
98
104
|
context "with udp specified with params" do
|
99
|
-
let(:args) { [
|
105
|
+
let(:args) { [udp: { host: 'localhost', port: 4444 }] }
|
100
106
|
|
101
107
|
specify { expect(conf).to be_udp }
|
102
108
|
end
|
103
109
|
|
104
110
|
context "with udp specified as true" do
|
105
|
-
let(:args) { [
|
111
|
+
let(:args) { [udp: true] }
|
106
112
|
|
107
113
|
specify { expect(conf).to be_udp }
|
108
114
|
end
|
109
115
|
|
110
116
|
context "with async specified with params" do
|
111
|
-
let(:args) { [
|
117
|
+
let(:args) { [async: { max_queue: 20_000 }] }
|
112
118
|
|
113
119
|
specify { expect(conf).to be_async }
|
114
120
|
end
|
115
121
|
|
116
122
|
context "with async specified as true" do
|
117
|
-
let(:args) { [
|
123
|
+
let(:args) { [async: true] }
|
118
124
|
|
119
125
|
specify { expect(conf).to be_async }
|
120
126
|
end
|
121
127
|
|
122
128
|
context "with epoch specified as seconds" do
|
123
|
-
let(:args) { [
|
129
|
+
let(:args) { [epoch: 's'] }
|
124
130
|
|
125
131
|
specify { expect(conf.epoch).to eq 's' }
|
126
132
|
end
|
127
133
|
|
128
134
|
context "given a config URL" do
|
129
135
|
let(:url) { "https://foo:bar@influx.example.com:8765/testdb?open_timeout=42&unknown=false&denormalize=false" }
|
130
|
-
let(:args) { [
|
136
|
+
let(:args) { [url: url] }
|
131
137
|
|
132
138
|
it "applies values found in URL" do
|
133
139
|
expect(conf.database).to eq "testdb"
|
@@ -156,6 +162,15 @@ describe InfluxDB::Config do
|
|
156
162
|
expect(conf).not_to be_async
|
157
163
|
end
|
158
164
|
|
165
|
+
context "with encoded values" do
|
166
|
+
let(:url) { "https://weird%24user:weird%25pass@influx.example.com:8765/testdb" }
|
167
|
+
|
168
|
+
it "decode encoded values" do
|
169
|
+
expect(conf.username).to eq "weird$user"
|
170
|
+
expect(conf.password).to eq "weird%pass"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
159
174
|
context "UDP" do
|
160
175
|
let(:url) { "udp://test.localhost:2345?discard_write_errors=1" }
|
161
176
|
specify { expect(conf).to be_udp }
|
@@ -205,4 +220,19 @@ describe InfluxDB::Config do
|
|
205
220
|
expect(conf).not_to be_async
|
206
221
|
end
|
207
222
|
end
|
223
|
+
|
224
|
+
context "given explicit proxy information" do
|
225
|
+
let(:args) do
|
226
|
+
[host: "host",
|
227
|
+
port: "port",
|
228
|
+
username: "username",
|
229
|
+
password: "password",
|
230
|
+
time_precision: "m",
|
231
|
+
proxy_addr: "my.proxy.addr",
|
232
|
+
proxy_port: 8080]
|
233
|
+
end
|
234
|
+
|
235
|
+
specify { expect(conf.proxy_addr).to eq("my.proxy.addr") }
|
236
|
+
specify { expect(conf.proxy_port).to eq(8080) }
|
237
|
+
end
|
208
238
|
end
|