influxdb 0.3.11 → 0.3.12
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/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/lib/influxdb/client/http.rb +5 -6
- data/lib/influxdb/point_value.rb +2 -2
- data/lib/influxdb/version.rb +1 -1
- data/spec/influxdb/cases/query_continuous_query_spec.rb +2 -4
- data/spec/influxdb/cases/query_database_spec.rb +13 -26
- data/spec/influxdb/cases/query_retention_policy_spec.rb +14 -55
- data/spec/influxdb/cases/query_user_spec.rb +9 -42
- data/spec/influxdb/point_value_spec.rb +13 -5
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b721d82a22974293685ba5fc0275d58e14d91c95
         | 
| 4 | 
            +
              data.tar.gz: 8b45e5a10d9d8018c3919bdc8b62651819cf18d5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ed273daa7368a7529acfd072273345056eb4001402d4869e5021776fe3a9e89ce967e519a1224aaa74e01d8205982a3109e2a250e35c997d96aed01e699d8409
         | 
| 7 | 
            +
              data.tar.gz: 02f5b7f0c6e4050be231d33b5dd56068faa6ec7607a20ef48d885b6c38e04f628c88673d449cc34a15c8c488951e02c987be6797421da5a2c3394371a69c3243
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -39,6 +39,8 @@ matrix: | |
| 39 39 | 
             
                  env: TEST_TASK=smoke influx_version=0.13.0 pkghash=4f0aa76fee22cf4c18e2a0779ba4f462
         | 
| 40 40 | 
             
                - rvm: 2.3.1
         | 
| 41 41 | 
             
                  env: TEST_TASK=smoke influx_version=1.0.2 pkghash=3e4c349cb57507913d9abda1459bdbed
         | 
| 42 | 
            +
                - rvm: 2.3.1
         | 
| 43 | 
            +
                  env: TEST_TASK=smoke influx_version=1.1.0 pkghash=682904c350ecfc2a60ec9c6c08453ef2
         | 
| 42 44 | 
             
                - rvm: 2.3.1
         | 
| 43 45 | 
             
                  env: TEST_TASK=smoke influx_version=nightly channel=nightlies
         | 
| 44 46 | 
             
              fail_fast: true
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -6,6 +6,11 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-ruby/ | |
| 6 6 |  | 
| 7 7 | 
             
            - None.
         | 
| 8 8 |  | 
| 9 | 
            +
            ## v0.3.12, released 2016-11-15
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            - Bugfix for broken Unicode support (regression introduced in #169).
         | 
| 12 | 
            +
              Please note, this is only properly tested on Ruby 2.1+ (#171).
         | 
| 13 | 
            +
             | 
| 9 14 | 
             
            ## v0.3.11, released 2016-10-12
         | 
| 10 15 |  | 
| 11 16 | 
             
            - Bugfix/Enhancement in `PointValue#escape`. Input strings are now scrubbed
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/lib/influxdb/client/http.rb
    CHANGED
    
    | @@ -56,14 +56,13 @@ module InfluxDB | |
| 56 56 | 
             
                    raise InfluxDB::ConnectionError, InfluxDB::NON_RECOVERABLE_MESSAGE
         | 
| 57 57 | 
             
                  rescue Timeout::Error, *InfluxDB::RECOVERABLE_EXCEPTIONS => e
         | 
| 58 58 | 
             
                    retry_count += 1
         | 
| 59 | 
            -
                     | 
| 60 | 
            -
                      log :error, "Failed to contact host #{host}: #{e.inspect} - retrying in #{delay}s."
         | 
| 61 | 
            -
                      sleep delay
         | 
| 62 | 
            -
                      delay = [config.max_delay, delay * 2].min
         | 
| 63 | 
            -
                      retry
         | 
| 64 | 
            -
                    else
         | 
| 59 | 
            +
                    unless (config.retry == -1 || retry_count <= config.retry) && !stopped?
         | 
| 65 60 | 
             
                      raise InfluxDB::ConnectionError, "Tried #{retry_count - 1} times to reconnect but failed."
         | 
| 66 61 | 
             
                    end
         | 
| 62 | 
            +
                    log :error, "Failed to contact host #{host}: #{e.inspect} - retrying in #{delay}s."
         | 
| 63 | 
            +
                    sleep delay
         | 
| 64 | 
            +
                    delay = [config.max_delay, delay * 2].min
         | 
| 65 | 
            +
                    retry
         | 
| 67 66 | 
             
                  ensure
         | 
| 68 67 | 
             
                    http.finish if http.started?
         | 
| 69 68 | 
             
                  end
         | 
    
        data/lib/influxdb/point_value.rb
    CHANGED
    
    | @@ -31,13 +31,13 @@ module InfluxDB | |
| 31 31 |  | 
| 32 32 | 
             
                def escape(s, type)
         | 
| 33 33 | 
             
                  # rubocop:disable Style/AlignParameters
         | 
| 34 | 
            -
                  s = s.encode "UTF-8".freeze, " | 
| 34 | 
            +
                  s = s.encode "UTF-8".freeze, "UTF-8".freeze,
         | 
| 35 35 | 
             
                    invalid: :replace,
         | 
| 36 36 | 
             
                    undef: :replace,
         | 
| 37 37 | 
             
                    replace: "".freeze
         | 
| 38 38 |  | 
| 39 39 | 
             
                  ESCAPES[type].each do |ch|
         | 
| 40 | 
            -
                    s = s. | 
| 40 | 
            +
                    s = s.gsub(ch) { "\\#{ch}" }
         | 
| 41 41 | 
             
                  end
         | 
| 42 42 | 
             
                  s
         | 
| 43 43 | 
             
                end
         | 
    
        data/lib/influxdb/version.rb
    CHANGED
    
    
| @@ -22,11 +22,9 @@ describe InfluxDB::Client do | |
| 22 22 | 
             
                let(:database) { "testdb" }
         | 
| 23 23 | 
             
                let(:response) do
         | 
| 24 24 | 
             
                  { "results" => [{ "series" => [{ "name" => "otherdb", "columns" => %w(name query),
         | 
| 25 | 
            -
                                                   "values" =>
         | 
| 26 | 
            -
                                                      [["clicks_per_hour", "CREATE CONTINUOUS QUERY clicks_per_hour ON otherdb BEGIN SELECT count(name) INTO \"otherdb\".\"default\".clicksCount_1h FROM \"otherdb\".\"default\".clicks GROUP BY time(1h) END"]] },
         | 
| 25 | 
            +
                                                   "values" => [["clicks_per_hour", "CREATE CONTINUOUS QUERY clicks_per_hour ON otherdb BEGIN SELECT count(name) INTO \"otherdb\".\"default\".clicksCount_1h FROM \"otherdb\".\"default\".clicks GROUP BY time(1h) END"]] },
         | 
| 27 26 | 
             
                                                 { "name" => "testdb", "columns" => %w(name query),
         | 
| 28 | 
            -
                                                   "values" =>
         | 
| 29 | 
            -
                                                      [["event_counts", "CREATE CONTINUOUS QUERY event_counts ON testdb BEGIN SELECT count(type) INTO \"testdb\".\"default\".typeCount_10m_byType FROM \"testdb\".\"default\".events GROUP BY time(10m), type END"]] }] }] }
         | 
| 27 | 
            +
                                                   "values" => [["event_counts", "CREATE CONTINUOUS QUERY event_counts ON testdb BEGIN SELECT count(type) INTO \"testdb\".\"default\".typeCount_10m_byType FROM \"testdb\".\"default\".events GROUP BY time(10m), type END"]] }] }] }
         | 
| 30 28 | 
             
                end
         | 
| 31 29 |  | 
| 32 30 | 
             
                let(:expected_result) do
         | 
| @@ -16,14 +16,18 @@ describe InfluxDB::Client do | |
| 16 16 | 
             
              end
         | 
| 17 17 |  | 
| 18 18 | 
             
              let(:args) { {} }
         | 
| 19 | 
            +
              let(:query) { nil }
         | 
| 20 | 
            +
              let(:response) { { "results" => [] } }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              before do
         | 
| 23 | 
            +
                stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 24 | 
            +
                  query: { u: "username", p: "password", q: query }
         | 
| 25 | 
            +
                ).to_return(body: JSON.generate(response))
         | 
| 26 | 
            +
              end
         | 
| 19 27 |  | 
| 20 28 | 
             
              describe "#create_database" do
         | 
| 21 29 | 
             
                describe "from param" do
         | 
| 22 | 
            -
                   | 
| 23 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 24 | 
            -
                      query: { u: "username", p: "password", q: "CREATE DATABASE foo" }
         | 
| 25 | 
            -
                    )
         | 
| 26 | 
            -
                  end
         | 
| 30 | 
            +
                  let(:query) { "CREATE DATABASE foo" }
         | 
| 27 31 |  | 
| 28 32 | 
             
                  it "should GET to create a new database" do
         | 
| 29 33 | 
             
                    expect(subject.create_database("foo")).to be_a(Net::HTTPOK)
         | 
| @@ -31,11 +35,7 @@ describe InfluxDB::Client do | |
| 31 35 | 
             
                end
         | 
| 32 36 |  | 
| 33 37 | 
             
                describe "from config" do
         | 
| 34 | 
            -
                   | 
| 35 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 36 | 
            -
                      query: { u: "username", p: "password", q: "CREATE DATABASE database" }
         | 
| 37 | 
            -
                    )
         | 
| 38 | 
            -
                  end
         | 
| 38 | 
            +
                  let(:query) { "CREATE DATABASE database" }
         | 
| 39 39 |  | 
| 40 40 | 
             
                  it "should GET to create a new database using database name from config" do
         | 
| 41 41 | 
             
                    expect(subject.create_database).to be_a(Net::HTTPOK)
         | 
| @@ -45,11 +45,7 @@ describe InfluxDB::Client do | |
| 45 45 |  | 
| 46 46 | 
             
              describe "#delete_database" do
         | 
| 47 47 | 
             
                describe "from param" do
         | 
| 48 | 
            -
                   | 
| 49 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 50 | 
            -
                      query: { u: "username", p: "password", q: "DROP DATABASE foo" }
         | 
| 51 | 
            -
                    )
         | 
| 52 | 
            -
                  end
         | 
| 48 | 
            +
                  let(:query) { "DROP DATABASE foo" }
         | 
| 53 49 |  | 
| 54 50 | 
             
                  it "should GET to remove a database" do
         | 
| 55 51 | 
             
                    expect(subject.delete_database("foo")).to be_a(Net::HTTPOK)
         | 
| @@ -57,11 +53,7 @@ describe InfluxDB::Client do | |
| 57 53 | 
             
                end
         | 
| 58 54 |  | 
| 59 55 | 
             
                describe "from config" do
         | 
| 60 | 
            -
                   | 
| 61 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 62 | 
            -
                      query: { u: "username", p: "password", q: "DROP DATABASE database" }
         | 
| 63 | 
            -
                    )
         | 
| 64 | 
            -
                  end
         | 
| 56 | 
            +
                  let(:query) { "DROP DATABASE database" }
         | 
| 65 57 |  | 
| 66 58 | 
             
                  it "should GET to remove a database using database name from config" do
         | 
| 67 59 | 
             
                    expect(subject.delete_database).to be_a(Net::HTTPOK)
         | 
| @@ -70,15 +62,10 @@ describe InfluxDB::Client do | |
| 70 62 | 
             
              end
         | 
| 71 63 |  | 
| 72 64 | 
             
              describe "#list_databases" do
         | 
| 65 | 
            +
                let(:query) { "SHOW DATABASES" }
         | 
| 73 66 | 
             
                let(:response) { { "results" => [{ "series" => [{ "name" => "databases", "columns" => ["name"], "values" => [["foobar"]] }] }] } }
         | 
| 74 67 | 
             
                let(:expected_result) { [{ "name" => "foobar" }] }
         | 
| 75 68 |  | 
| 76 | 
            -
                before do
         | 
| 77 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 78 | 
            -
                    query: { u: "username", p: "password", q: "SHOW DATABASES" }
         | 
| 79 | 
            -
                  ).to_return(body: JSON.generate(response), status: 200)
         | 
| 80 | 
            -
                end
         | 
| 81 | 
            -
             | 
| 82 69 | 
             
                it "should GET a list of databases" do
         | 
| 83 70 | 
             
                  expect(subject.list_databases).to eq(expected_result)
         | 
| 84 71 | 
             
                end
         | 
| @@ -16,17 +16,20 @@ describe InfluxDB::Client do | |
| 16 16 | 
             
              end
         | 
| 17 17 |  | 
| 18 18 | 
             
              let(:args) { {} }
         | 
| 19 | 
            +
              let(:query) { nil }
         | 
| 20 | 
            +
              let(:response) { { "results" => [] } }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              before do
         | 
| 23 | 
            +
                stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 24 | 
            +
                  query: { u: "username", p: "password", q: query }
         | 
| 25 | 
            +
                ).to_return(body: JSON.generate(response))
         | 
| 26 | 
            +
              end
         | 
| 19 27 |  | 
| 20 28 | 
             
              describe "#list_retention_policies" do
         | 
| 21 29 | 
             
                let(:response) { { "results" => [{ "series" => [{ "columns" => %w(name duration replicaN default), "values" => [["default", "0", 1, true], ["another", "1", 2, false]] }] }] } }
         | 
| 30 | 
            +
                let(:query) { "SHOW RETENTION POLICIES ON \"database\"" }
         | 
| 22 31 | 
             
                let(:expected_result) { [{ "name" => "default", "duration" => "0", "replicaN" => 1, "default" => true }, { "name" => "another", "duration" => "1", "replicaN" => 2, "default" => false }] }
         | 
| 23 32 |  | 
| 24 | 
            -
                before do
         | 
| 25 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 26 | 
            -
                    query: { u: "username", p: "password", q: "SHOW RETENTION POLICIES ON \"database\"" }
         | 
| 27 | 
            -
                  ).to_return(body: JSON.generate(response), status: 200)
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 33 | 
             
                it "should GET a list of retention policies" do
         | 
| 31 34 | 
             
                  expect(subject.list_retention_policies('database')).to eq(expected_result)
         | 
| 32 35 | 
             
                end
         | 
| @@ -34,17 +37,7 @@ describe InfluxDB::Client do | |
| 34 37 |  | 
| 35 38 | 
             
              describe "#create_retention_policy" do
         | 
| 36 39 | 
             
                context "default" do
         | 
| 37 | 
            -
                   | 
| 38 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query")
         | 
| 39 | 
            -
                      .with(
         | 
| 40 | 
            -
                        query:
         | 
| 41 | 
            -
                          {
         | 
| 42 | 
            -
                            u: "username",
         | 
| 43 | 
            -
                            p: "password",
         | 
| 44 | 
            -
                            q: "CREATE RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2 DEFAULT"
         | 
| 45 | 
            -
                          }
         | 
| 46 | 
            -
                      )
         | 
| 47 | 
            -
                  end
         | 
| 40 | 
            +
                  let(:query) { "CREATE RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2 DEFAULT" }
         | 
| 48 41 |  | 
| 49 42 | 
             
                  it "should GET to create a new database" do
         | 
| 50 43 | 
             
                    expect(subject.create_retention_policy('1h.cpu', 'foo', '1h', 2, true)).to be_a(Net::HTTPOK)
         | 
| @@ -52,17 +45,7 @@ describe InfluxDB::Client do | |
| 52 45 | 
             
                end
         | 
| 53 46 |  | 
| 54 47 | 
             
                context "non-default" do
         | 
| 55 | 
            -
                   | 
| 56 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query")
         | 
| 57 | 
            -
                      .with(
         | 
| 58 | 
            -
                        query:
         | 
| 59 | 
            -
                          {
         | 
| 60 | 
            -
                            u: "username",
         | 
| 61 | 
            -
                            p: "password",
         | 
| 62 | 
            -
                            q: "CREATE RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2"
         | 
| 63 | 
            -
                          }
         | 
| 64 | 
            -
                      )
         | 
| 65 | 
            -
                  end
         | 
| 48 | 
            +
                  let(:query) { "CREATE RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2" }
         | 
| 66 49 |  | 
| 67 50 | 
             
                  it "should GET to create a new database" do
         | 
| 68 51 | 
             
                    expect(subject.create_retention_policy('1h.cpu', 'foo', '1h', 2)).to be_a(Net::HTTPOK)
         | 
| @@ -71,11 +54,7 @@ describe InfluxDB::Client do | |
| 71 54 | 
             
              end
         | 
| 72 55 |  | 
| 73 56 | 
             
              describe "#delete_retention_policy" do
         | 
| 74 | 
            -
                 | 
| 75 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 76 | 
            -
                    query: { u: "username", p: "password", q: "DROP RETENTION POLICY \"1h.cpu\" ON foo" }
         | 
| 77 | 
            -
                  )
         | 
| 78 | 
            -
                end
         | 
| 57 | 
            +
                let(:query) { "DROP RETENTION POLICY \"1h.cpu\" ON foo" }
         | 
| 79 58 |  | 
| 80 59 | 
             
                it "should GET to remove a database" do
         | 
| 81 60 | 
             
                  expect(subject.delete_retention_policy('1h.cpu', 'foo')).to be_a(Net::HTTPOK)
         | 
| @@ -84,17 +63,7 @@ describe InfluxDB::Client do | |
| 84 63 |  | 
| 85 64 | 
             
              describe "#alter_retention_policy" do
         | 
| 86 65 | 
             
                context "default" do
         | 
| 87 | 
            -
                   | 
| 88 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query")
         | 
| 89 | 
            -
                      .with(
         | 
| 90 | 
            -
                        query:
         | 
| 91 | 
            -
                          {
         | 
| 92 | 
            -
                            u: "username",
         | 
| 93 | 
            -
                            p: "password",
         | 
| 94 | 
            -
                            q: "ALTER RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2 DEFAULT"
         | 
| 95 | 
            -
                          }
         | 
| 96 | 
            -
                      )
         | 
| 97 | 
            -
                  end
         | 
| 66 | 
            +
                  let(:query) { "ALTER RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2 DEFAULT" }
         | 
| 98 67 |  | 
| 99 68 | 
             
                  it "should GET to alter a new database" do
         | 
| 100 69 | 
             
                    expect(subject.alter_retention_policy('1h.cpu', 'foo', '1h', 2, true)).to be_a(Net::HTTPOK)
         | 
| @@ -102,17 +71,7 @@ describe InfluxDB::Client do | |
| 102 71 | 
             
                end
         | 
| 103 72 |  | 
| 104 73 | 
             
                context "non-default" do
         | 
| 105 | 
            -
                   | 
| 106 | 
            -
                    stub_request(:get, "http://influxdb.test:9999/query")
         | 
| 107 | 
            -
                      .with(
         | 
| 108 | 
            -
                        query:
         | 
| 109 | 
            -
                          {
         | 
| 110 | 
            -
                            u: "username",
         | 
| 111 | 
            -
                            p: "password",
         | 
| 112 | 
            -
                            q: "ALTER RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2"
         | 
| 113 | 
            -
                          }
         | 
| 114 | 
            -
                      )
         | 
| 115 | 
            -
                  end
         | 
| 74 | 
            +
                  let(:query) { "ALTER RETENTION POLICY \"1h.cpu\" ON foo DURATION 1h REPLICATION 2" }
         | 
| 116 75 |  | 
| 117 76 | 
             
                  it "should GET to alter a new database" do
         | 
| 118 77 | 
             
                    expect(subject.alter_retention_policy('1h.cpu', 'foo', '1h', 2)).to be_a(Net::HTTPOK)
         | 
| @@ -16,18 +16,20 @@ describe InfluxDB::Client do | |
| 16 16 | 
             
              end
         | 
| 17 17 |  | 
| 18 18 | 
             
              let(:args) { {} }
         | 
| 19 | 
            +
              let(:query) { nil }
         | 
| 20 | 
            +
              let(:response) { { "results" => [] } }
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              before do
         | 
| 23 | 
            +
                stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 24 | 
            +
                  query: { u: "username", p: "password", q: query }
         | 
| 25 | 
            +
                ).to_return(body: JSON.generate(response))
         | 
| 26 | 
            +
              end
         | 
| 19 27 |  | 
| 20 28 | 
             
              describe "#update user password" do
         | 
| 21 29 | 
             
                let(:user) { 'useruser' }
         | 
| 22 30 | 
             
                let(:pass) { 'passpass' }
         | 
| 23 31 | 
             
                let(:query) { "SET PASSWORD FOR #{user} = '#{pass}'" }
         | 
| 24 32 |  | 
| 25 | 
            -
                before do
         | 
| 26 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 27 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 28 | 
            -
                  )
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 33 | 
             
                it "should GET to update user password" do
         | 
| 32 34 | 
             
                  expect(subject.update_user_password(user, pass)).to be_a(Net::HTTPOK)
         | 
| 33 35 | 
             
                end
         | 
| @@ -39,12 +41,6 @@ describe InfluxDB::Client do | |
| 39 41 | 
             
                let(:db) { 'foo' }
         | 
| 40 42 | 
             
                let(:query) { "GRANT #{perm.to_s.upcase} ON #{db} TO #{user}" }
         | 
| 41 43 |  | 
| 42 | 
            -
                before do
         | 
| 43 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 44 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 45 | 
            -
                  )
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
             | 
| 48 44 | 
             
                it "should GET to grant privileges for a user on a database" do
         | 
| 49 45 | 
             
                  expect(subject.grant_user_privileges(user, db, perm)).to be_a(Net::HTTPOK)
         | 
| 50 46 | 
             
                end
         | 
| @@ -54,12 +50,6 @@ describe InfluxDB::Client do | |
| 54 50 | 
             
                let(:user) { 'useruser' }
         | 
| 55 51 | 
             
                let(:query) { "GRANT ALL PRIVILEGES TO #{user}" }
         | 
| 56 52 |  | 
| 57 | 
            -
                before do
         | 
| 58 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 59 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 60 | 
            -
                  )
         | 
| 61 | 
            -
                end
         | 
| 62 | 
            -
             | 
| 63 53 | 
             
                it "should GET to grant privileges for a user on a database" do
         | 
| 64 54 | 
             
                  expect(subject.grant_user_admin_privileges(user)).to be_a(Net::HTTPOK)
         | 
| 65 55 | 
             
                end
         | 
| @@ -71,12 +61,6 @@ describe InfluxDB::Client do | |
| 71 61 | 
             
                let(:db) { 'foo' }
         | 
| 72 62 | 
             
                let(:query) { "REVOKE #{perm.to_s.upcase} ON #{db} FROM #{user}" }
         | 
| 73 63 |  | 
| 74 | 
            -
                before do
         | 
| 75 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 76 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 77 | 
            -
                  )
         | 
| 78 | 
            -
                end
         | 
| 79 | 
            -
             | 
| 80 64 | 
             
                it "should GET to revoke privileges from a user on a database" do
         | 
| 81 65 | 
             
                  expect(subject.revoke_user_privileges(user, db, perm)).to be_a(Net::HTTPOK)
         | 
| 82 66 | 
             
                end
         | 
| @@ -88,12 +72,6 @@ describe InfluxDB::Client do | |
| 88 72 | 
             
                let(:db) { 'foo' }
         | 
| 89 73 | 
             
                let(:query) { "CREATE user #{user} WITH PASSWORD '#{pass}'; GRANT ALL ON #{db} TO #{user}" }
         | 
| 90 74 |  | 
| 91 | 
            -
                before do
         | 
| 92 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 93 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 94 | 
            -
                  )
         | 
| 95 | 
            -
                end
         | 
| 96 | 
            -
             | 
| 97 75 | 
             
                context "without specifying permissions" do
         | 
| 98 76 | 
             
                  it "should GET to create a new database user with all permissions" do
         | 
| 99 77 | 
             
                    expect(subject.create_database_user(db, user, pass)).to be_a(Net::HTTPOK)
         | 
| @@ -114,12 +92,6 @@ describe InfluxDB::Client do | |
| 114 92 | 
             
                let(:user) { 'useruser' }
         | 
| 115 93 | 
             
                let(:query) { "DROP USER #{user}" }
         | 
| 116 94 |  | 
| 117 | 
            -
                before do
         | 
| 118 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 119 | 
            -
                    query: { u: "username", p: "password", q: query }
         | 
| 120 | 
            -
                  )
         | 
| 121 | 
            -
                end
         | 
| 122 | 
            -
             | 
| 123 95 | 
             
                it "should GET to delete a user" do
         | 
| 124 96 | 
             
                  expect(subject.delete_user(user)).to be_a(Net::HTTPOK)
         | 
| 125 97 | 
             
                end
         | 
| @@ -127,14 +99,9 @@ describe InfluxDB::Client do | |
| 127 99 |  | 
| 128 100 | 
             
              describe "#list_users" do
         | 
| 129 101 | 
             
                let(:response) { { "results" => [{ "series" => [{ "columns" => %w(user admin), "values" => [["dbadmin", true], ["foobar", false]] }] }] } }
         | 
| 102 | 
            +
                let(:query) { "SHOW USERS" }
         | 
| 130 103 | 
             
                let(:expected_result) { [{ "username" => "dbadmin", "admin" => true }, { "username" => "foobar", "admin" => false }] }
         | 
| 131 104 |  | 
| 132 | 
            -
                before do
         | 
| 133 | 
            -
                  stub_request(:get, "http://influxdb.test:9999/query").with(
         | 
| 134 | 
            -
                    query: { u: "username", p: "password", q: "SHOW USERS" }
         | 
| 135 | 
            -
                  ).to_return(body: JSON.generate(response, status: 200))
         | 
| 136 | 
            -
                end
         | 
| 137 | 
            -
             | 
| 138 105 | 
             
                it "should GET a list of database users" do
         | 
| 139 106 | 
             
                  expect(subject.list_users).to eq(expected_result)
         | 
| 140 107 | 
             
                end
         | 
| @@ -1,26 +1,34 @@ | |
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require "spec_helper"
         | 
| 2 4 |  | 
| 3 5 | 
             
            describe InfluxDB::PointValue do
         | 
| 4 6 | 
             
              describe "escaping" do
         | 
| 5 7 | 
             
                let(:data) do
         | 
| 6 | 
            -
                  {
         | 
| 8 | 
            +
                  point = {
         | 
| 7 9 | 
             
                    series: '1= ,"\\1',
         | 
| 8 10 | 
             
                    tags: {
         | 
| 9 11 | 
             
                      '2= ,"\\2' => '3= ,"\\3'
         | 
| 10 12 | 
             
                    },
         | 
| 11 13 | 
             
                    values: {
         | 
| 12 14 | 
             
                      '4= ,"\\4' => '5= ,"\\5',
         | 
| 13 | 
            -
                      intval: | 
| 14 | 
            -
                      floatval: | 
| 15 | 
            -
                       | 
| 15 | 
            +
                      intval:           5,
         | 
| 16 | 
            +
                      floatval:         7.0,
         | 
| 17 | 
            +
                      invalid_encoding: "a b",
         | 
| 18 | 
            +
                      non_latin:        "Улан-Удэ"
         | 
| 16 19 | 
             
                    }
         | 
| 17 20 | 
             
                  }
         | 
| 21 | 
            +
                  if RUBY_VERSION > "2.0.0"
         | 
| 22 | 
            +
                    # see github.com/influxdata/influxdb-ruby/issues/171 for details
         | 
| 23 | 
            +
                    point[:values][:invalid_encoding] = "a\255 b"
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                  point
         | 
| 18 26 | 
             
                end
         | 
| 19 27 |  | 
| 20 28 | 
             
                it 'should escape correctly' do
         | 
| 21 29 | 
             
                  point = InfluxDB::PointValue.new(data)
         | 
| 22 30 | 
             
                  expected = %(1=\\ \\,"\\1,2\\=\\ \\,"\\2=3\\=\\ \\,"\\3 ) +
         | 
| 23 | 
            -
                             %(4\\=\\ \\,\\"\\4="5= ,\\"\\5",intval=5i,floatval=7.0, | 
| 31 | 
            +
                             %(4\\=\\ \\,\\"\\4="5= ,\\"\\5",intval=5i,floatval=7.0,invalid_encoding="a b",non_latin="Улан-Удэ")
         | 
| 24 32 | 
             
                  expect(point.dump).to eq(expected)
         | 
| 25 33 | 
             
                end
         | 
| 26 34 | 
             
              end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ RSpec.configure do |config| | |
| 22 22 | 
             
                logfile = File.open("tmp/spec.log", File::WRONLY | File::TRUNC | File::CREAT)
         | 
| 23 23 |  | 
| 24 24 | 
             
                InfluxDB::Logging.logger = Logger.new(logfile).tap do |logger|
         | 
| 25 | 
            -
                  logger.formatter = proc {|severity, _datetime, progname, message|
         | 
| 25 | 
            +
                  logger.formatter = proc { |severity, _datetime, progname, message|
         | 
| 26 26 | 
             
                    "%-5s - %s: %s\n".format severity, progname, message
         | 
| 27 27 | 
             
                  }
         | 
| 28 28 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: influxdb
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.12
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Todd Persen
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-11-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: json
         |