riak-client 2.3.0 → 2.3.1
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/.document +5 -5
- data/Gemfile +17 -17
- data/Guardfile +20 -20
- data/LICENSE.md +16 -16
- data/README.markdown +1 -1
- data/RELEASE_NOTES.md +9 -0
- data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -18
- data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -64
- data/lib/riak/client/beefcake/footer +4 -4
- data/lib/riak/client/beefcake/header +6 -6
- data/lib/riak/client/beefcake/messages.rb +0 -16
- data/lib/riak/client/decaying.rb +36 -36
- data/lib/riak/client/feature_detection.rb +120 -120
- data/lib/riak/client/instrumentation.rb +19 -19
- data/lib/riak/client/node.rb +49 -49
- data/lib/riak/client/search.rb +27 -27
- data/lib/riak/conflict.rb +13 -13
- data/lib/riak/core_ext.rb +7 -7
- data/lib/riak/core_ext/blank.rb +53 -53
- data/lib/riak/core_ext/extract_options.rb +7 -7
- data/lib/riak/core_ext/json.rb +15 -15
- data/lib/riak/core_ext/slice.rb +18 -18
- data/lib/riak/core_ext/stringify_keys.rb +10 -10
- data/lib/riak/core_ext/symbolize_keys.rb +10 -10
- data/lib/riak/core_ext/to_param.rb +31 -31
- data/lib/riak/crdt.rb +21 -21
- data/lib/riak/crdt/operation.rb +19 -19
- data/lib/riak/encoding.rb +6 -6
- data/lib/riak/errors/backend_creation.rb +9 -9
- data/lib/riak/errors/connection_error.rb +50 -50
- data/lib/riak/errors/protobuffs_error.rb +11 -11
- data/lib/riak/i18n.rb +7 -7
- data/lib/riak/instrumentation.rb +6 -6
- data/lib/riak/json.rb +52 -52
- data/lib/riak/list_buckets.rb +28 -28
- data/lib/riak/locale/fr.yml +51 -51
- data/lib/riak/map_reduce/results.rb +49 -49
- data/lib/riak/map_reduce_error.rb +7 -7
- data/lib/riak/multiget.rb +122 -122
- data/lib/riak/stamp.rb +77 -77
- data/lib/riak/util/tcp_socket_extensions.rb +58 -58
- data/lib/riak/version.rb +1 -1
- data/spec/failover/failover.rb +59 -59
- data/spec/fixtures/bitcask.txt +25 -25
- data/spec/fixtures/multipart-basic-conflict.txt +15 -15
- data/spec/fixtures/multipart-blank.txt +7 -7
- data/spec/fixtures/multipart-mapreduce.txt +10 -10
- data/spec/fixtures/multipart-with-body.txt +16 -16
- data/spec/fixtures/multipart-with-marked-tombstones.txt +17 -17
- data/spec/fixtures/multipart-with-unmarked-tombstone.txt +16 -16
- data/spec/fixtures/server.cert.crt +15 -15
- data/spec/fixtures/server.cert.key +15 -15
- data/spec/fixtures/test.pem +1 -1
- data/spec/integration/riak/threading_spec.rb +150 -150
- data/spec/integration/yokozuna/index_spec.rb +61 -61
- data/spec/integration/yokozuna/schema_spec.rb +49 -49
- data/spec/riak/core_ext/to_param_spec.rb +15 -15
- data/spec/riak/crdt/inner_counter_spec.rb +21 -21
- data/spec/riak/crdt/inner_set_spec.rb +33 -33
- data/spec/riak/crdt/set_spec.rb +61 -61
- data/spec/riak/escape_spec.rb +72 -72
- data/spec/riak/feature_detection_spec.rb +77 -77
- data/spec/riak/index_collection_spec.rb +53 -53
- data/spec/riak/instrumentation_spec.rb +124 -124
- data/spec/riak/link_spec.rb +85 -85
- data/spec/riak/list_buckets_spec.rb +41 -41
- data/spec/riak/node_spec.rb +26 -26
- data/spec/riak/stamp_spec.rb +54 -54
- data/spec/support/certs/README.md +12 -12
- data/spec/support/certs/ca.crt +21 -21
- data/spec/support/certs/client.crl +13 -13
- data/spec/support/certs/client.crt +94 -94
- data/spec/support/certs/client.csr +18 -18
- data/spec/support/certs/client.key +27 -27
- data/spec/support/certs/empty_ca.crt +21 -21
- data/spec/support/certs/server.crl +13 -13
- data/spec/support/certs/server.crt +94 -94
- data/spec/support/certs/server.key +27 -27
- data/spec/support/integration_setup.rb +10 -10
- data/spec/support/test_client.yml.example +9 -9
- metadata +3 -3
    
        data/spec/riak/link_spec.rb
    CHANGED
    
    | @@ -1,85 +1,85 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Riak::Link do
         | 
| 4 | 
            -
              describe "parsing a link header" do
         | 
| 5 | 
            -
                it "creates Link objects from the data" do
         | 
| 6 | 
            -
                  result = Riak::Link.parse('</riak/foo/bar>; rel="tag", </riak/foo>; rel="up"')
         | 
| 7 | 
            -
                  expect(result).to be_kind_of(Array)
         | 
| 8 | 
            -
                  expect(result).to be_all {|i| Riak::Link === i }
         | 
| 9 | 
            -
                end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                it "sets the bucket, key, url and rel parameters properly" do
         | 
| 12 | 
            -
                  result = Riak::Link.parse('</riak/foo/bar>; riaktag="tag", </riak/foo>; rel="up"')
         | 
| 13 | 
            -
                  expect(result[0].url).to eq("/riak/foo/bar")
         | 
| 14 | 
            -
                  expect(result[0].bucket).to eq("foo")
         | 
| 15 | 
            -
                  expect(result[0].key).to eq("bar")
         | 
| 16 | 
            -
                  expect(result[0].rel).to eq("tag")
         | 
| 17 | 
            -
                  expect(result[1].url).to eq("/riak/foo")
         | 
| 18 | 
            -
                  expect(result[1].bucket).to eq("foo")
         | 
| 19 | 
            -
                  expect(result[1].key).to eq(nil)
         | 
| 20 | 
            -
                  expect(result[1].rel).to eq("up")
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                it "keeps the url intact if it does not point to a bucket or bucket/key" do
         | 
| 24 | 
            -
                  result = Riak::Link.parse('</mapred>; rel="riak_kv_wm_mapred"')
         | 
| 25 | 
            -
                  expect(result[0].url).to eq("/mapred")
         | 
| 26 | 
            -
                  expect(result[0].bucket).to be_nil
         | 
| 27 | 
            -
                  expect(result[0].key).to be_nil
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                it "parses the Riak 1.0 URL scheme" do
         | 
| 31 | 
            -
                  result = Riak::Link.parse('</buckets/b/keys/k>; riaktag="tag"').first
         | 
| 32 | 
            -
                  expect(result.bucket).to eq('b')
         | 
| 33 | 
            -
                  expect(result.key).to eq('k')
         | 
| 34 | 
            -
                  expect(result.tag).to eq('tag')
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
              end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
              context "converting to a string" do
         | 
| 39 | 
            -
                it "to a string appropriate for use in the Link header" do
         | 
| 40 | 
            -
                  expect(Riak::Link.new("/riak/foo", "up").to_s).to eq('</riak/foo>; riaktag="up"')
         | 
| 41 | 
            -
                  expect(Riak::Link.new("/riak/foo/bar", "next").to_s).to eq('</riak/foo/bar>; riaktag="next"')
         | 
| 42 | 
            -
                  expect(Riak::Link.new("/riak", "riak_kv_wm_raw").to_s).to eq('</riak>; riaktag="riak_kv_wm_raw"')
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                it "converts to a string using the new URL scheme" do
         | 
| 46 | 
            -
                  expect(Riak::Link.new("bucket", "key", "tag").to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
         | 
| 47 | 
            -
                  expect(Riak::Link.parse('</riak/bucket/key>; riaktag="tag"').first.to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
              it "converts to a walk spec when pointing to an object" do
         | 
| 52 | 
            -
                expect(Riak::Link.new("/riak/foo/bar", "next").to_walk_spec.to_s).to eq("foo,next,_")
         | 
| 53 | 
            -
                expect { Riak::Link.new("/riak/foo", "up").to_walk_spec }.to raise_error
         | 
| 54 | 
            -
              end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
              it "is equivalent to a link with the same url and rel" do
         | 
| 57 | 
            -
                one = Riak::Link.new("/riak/foo/bar", "next")
         | 
| 58 | 
            -
                two = Riak::Link.new("/riak/foo/bar", "next")
         | 
| 59 | 
            -
                expect(one).to eq(two)
         | 
| 60 | 
            -
                expect([one]).to include(two)
         | 
| 61 | 
            -
                expect([two]).to include(one)
         | 
| 62 | 
            -
              end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
              it "unescapes the bucket name" do
         | 
| 65 | 
            -
                expect(Riak::Link.new("/riak/bucket%20spaces/key", "foo").bucket).to eq("bucket spaces")
         | 
| 66 | 
            -
              end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
              it "unescapes the key name" do
         | 
| 69 | 
            -
                expect(Riak::Link.new("/riak/bucket/key%2Fname", "foo").key).to eq("key/name")
         | 
| 70 | 
            -
              end
         | 
| 71 | 
            -
             | 
| 72 | 
            -
              it "doesn't rely on the prefix to equal /riak/ when extracting the bucket and key" do
         | 
| 73 | 
            -
                link = Riak::Link.new("/raw/bucket/key", "foo")
         | 
| 74 | 
            -
                expect(link.bucket).to eq("bucket")
         | 
| 75 | 
            -
                expect(link.key).to eq("key")
         | 
| 76 | 
            -
              end
         | 
| 77 | 
            -
             | 
| 78 | 
            -
              it "constructs from bucket, key and tag" do
         | 
| 79 | 
            -
                link = Riak::Link.new("bucket", "key", "tag")
         | 
| 80 | 
            -
                expect(link.bucket).to eq("bucket")
         | 
| 81 | 
            -
                expect(link.key).to eq("key")
         | 
| 82 | 
            -
                expect(link.tag).to eq("tag")
         | 
| 83 | 
            -
                expect(link.url).to eq("/riak/bucket/key")
         | 
| 84 | 
            -
              end
         | 
| 85 | 
            -
            end
         | 
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Riak::Link do
         | 
| 4 | 
            +
              describe "parsing a link header" do
         | 
| 5 | 
            +
                it "creates Link objects from the data" do
         | 
| 6 | 
            +
                  result = Riak::Link.parse('</riak/foo/bar>; rel="tag", </riak/foo>; rel="up"')
         | 
| 7 | 
            +
                  expect(result).to be_kind_of(Array)
         | 
| 8 | 
            +
                  expect(result).to be_all {|i| Riak::Link === i }
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it "sets the bucket, key, url and rel parameters properly" do
         | 
| 12 | 
            +
                  result = Riak::Link.parse('</riak/foo/bar>; riaktag="tag", </riak/foo>; rel="up"')
         | 
| 13 | 
            +
                  expect(result[0].url).to eq("/riak/foo/bar")
         | 
| 14 | 
            +
                  expect(result[0].bucket).to eq("foo")
         | 
| 15 | 
            +
                  expect(result[0].key).to eq("bar")
         | 
| 16 | 
            +
                  expect(result[0].rel).to eq("tag")
         | 
| 17 | 
            +
                  expect(result[1].url).to eq("/riak/foo")
         | 
| 18 | 
            +
                  expect(result[1].bucket).to eq("foo")
         | 
| 19 | 
            +
                  expect(result[1].key).to eq(nil)
         | 
| 20 | 
            +
                  expect(result[1].rel).to eq("up")
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it "keeps the url intact if it does not point to a bucket or bucket/key" do
         | 
| 24 | 
            +
                  result = Riak::Link.parse('</mapred>; rel="riak_kv_wm_mapred"')
         | 
| 25 | 
            +
                  expect(result[0].url).to eq("/mapred")
         | 
| 26 | 
            +
                  expect(result[0].bucket).to be_nil
         | 
| 27 | 
            +
                  expect(result[0].key).to be_nil
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                it "parses the Riak 1.0 URL scheme" do
         | 
| 31 | 
            +
                  result = Riak::Link.parse('</buckets/b/keys/k>; riaktag="tag"').first
         | 
| 32 | 
            +
                  expect(result.bucket).to eq('b')
         | 
| 33 | 
            +
                  expect(result.key).to eq('k')
         | 
| 34 | 
            +
                  expect(result.tag).to eq('tag')
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
              context "converting to a string" do
         | 
| 39 | 
            +
                it "to a string appropriate for use in the Link header" do
         | 
| 40 | 
            +
                  expect(Riak::Link.new("/riak/foo", "up").to_s).to eq('</riak/foo>; riaktag="up"')
         | 
| 41 | 
            +
                  expect(Riak::Link.new("/riak/foo/bar", "next").to_s).to eq('</riak/foo/bar>; riaktag="next"')
         | 
| 42 | 
            +
                  expect(Riak::Link.new("/riak", "riak_kv_wm_raw").to_s).to eq('</riak>; riaktag="riak_kv_wm_raw"')
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                it "converts to a string using the new URL scheme" do
         | 
| 46 | 
            +
                  expect(Riak::Link.new("bucket", "key", "tag").to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
         | 
| 47 | 
            +
                  expect(Riak::Link.parse('</riak/bucket/key>; riaktag="tag"').first.to_s(true)).to eq('</buckets/bucket/keys/key>; riaktag="tag"')
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              it "converts to a walk spec when pointing to an object" do
         | 
| 52 | 
            +
                expect(Riak::Link.new("/riak/foo/bar", "next").to_walk_spec.to_s).to eq("foo,next,_")
         | 
| 53 | 
            +
                expect { Riak::Link.new("/riak/foo", "up").to_walk_spec }.to raise_error
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              it "is equivalent to a link with the same url and rel" do
         | 
| 57 | 
            +
                one = Riak::Link.new("/riak/foo/bar", "next")
         | 
| 58 | 
            +
                two = Riak::Link.new("/riak/foo/bar", "next")
         | 
| 59 | 
            +
                expect(one).to eq(two)
         | 
| 60 | 
            +
                expect([one]).to include(two)
         | 
| 61 | 
            +
                expect([two]).to include(one)
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              it "unescapes the bucket name" do
         | 
| 65 | 
            +
                expect(Riak::Link.new("/riak/bucket%20spaces/key", "foo").bucket).to eq("bucket spaces")
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              it "unescapes the key name" do
         | 
| 69 | 
            +
                expect(Riak::Link.new("/riak/bucket/key%2Fname", "foo").key).to eq("key/name")
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              it "doesn't rely on the prefix to equal /riak/ when extracting the bucket and key" do
         | 
| 73 | 
            +
                link = Riak::Link.new("/raw/bucket/key", "foo")
         | 
| 74 | 
            +
                expect(link.bucket).to eq("bucket")
         | 
| 75 | 
            +
                expect(link.key).to eq("key")
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              it "constructs from bucket, key and tag" do
         | 
| 79 | 
            +
                link = Riak::Link.new("bucket", "key", "tag")
         | 
| 80 | 
            +
                expect(link.bucket).to eq("bucket")
         | 
| 81 | 
            +
                expect(link.key).to eq("key")
         | 
| 82 | 
            +
                expect(link.tag).to eq("tag")
         | 
| 83 | 
            +
                expect(link.url).to eq("/riak/bucket/key")
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
            end
         | 
| @@ -1,41 +1,41 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Riak::ListBuckets do
         | 
| 4 | 
            -
              before :each do
         | 
| 5 | 
            -
                @client = Riak::Client.new
         | 
| 6 | 
            -
                @backend = double 'backend'
         | 
| 7 | 
            -
                @fake_pool = double 'connection pool'
         | 
| 8 | 
            -
                allow(@fake_pool).to receive(:take).and_yield(@backend)
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                @expect_list = expect(@backend).to receive(:list_buckets)
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                @client.instance_variable_set :@protobuffs_pool, @fake_pool
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              describe "non-streaming" do
         | 
| 16 | 
            -
                it 'calls the backend without a block' do
         | 
| 17 | 
            -
                  @expect_list.with({}).and_return(%w{a b c d})
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  @client.list_buckets
         | 
| 20 | 
            -
                end
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              describe "streaming" do
         | 
| 24 | 
            -
                it 'calls the backend with a block' do
         | 
| 25 | 
            -
                  @expect_list.
         | 
| 26 | 
            -
                    and_yield(%w{abc abd abe}).
         | 
| 27 | 
            -
                    and_yield(%w{bbb ccc ddd})
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                  @yielded = []
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                  @client.list_buckets do |bucket|
         | 
| 32 | 
            -
                    @yielded << bucket
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                  @yielded.each do |b|
         | 
| 36 | 
            -
                    expect(b).to be_a Riak::Bucket
         | 
| 37 | 
            -
                  end
         | 
| 38 | 
            -
                  expect(@yielded.map(&:name)).to eq(%w{abc abd abe bbb ccc ddd})
         | 
| 39 | 
            -
                end
         | 
| 40 | 
            -
              end
         | 
| 41 | 
            -
            end
         | 
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Riak::ListBuckets do
         | 
| 4 | 
            +
              before :each do
         | 
| 5 | 
            +
                @client = Riak::Client.new
         | 
| 6 | 
            +
                @backend = double 'backend'
         | 
| 7 | 
            +
                @fake_pool = double 'connection pool'
         | 
| 8 | 
            +
                allow(@fake_pool).to receive(:take).and_yield(@backend)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                @expect_list = expect(@backend).to receive(:list_buckets)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                @client.instance_variable_set :@protobuffs_pool, @fake_pool
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              describe "non-streaming" do
         | 
| 16 | 
            +
                it 'calls the backend without a block' do
         | 
| 17 | 
            +
                  @expect_list.with({}).and_return(%w{a b c d})
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  @client.list_buckets
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              describe "streaming" do
         | 
| 24 | 
            +
                it 'calls the backend with a block' do
         | 
| 25 | 
            +
                  @expect_list.
         | 
| 26 | 
            +
                    and_yield(%w{abc abd abe}).
         | 
| 27 | 
            +
                    and_yield(%w{bbb ccc ddd})
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  @yielded = []
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  @client.list_buckets do |bucket|
         | 
| 32 | 
            +
                    @yielded << bucket
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  @yielded.each do |b|
         | 
| 36 | 
            +
                    expect(b).to be_a Riak::Bucket
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                  expect(@yielded.map(&:name)).to eq(%w{abc abd abe bbb ccc ddd})
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
    
        data/spec/riak/node_spec.rb
    CHANGED
    
    | @@ -1,26 +1,26 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Riak::Client::Node do
         | 
| 4 | 
            -
              before :each do
         | 
| 5 | 
            -
                @client = Riak::Client.new
         | 
| 6 | 
            -
                @node = Riak::Client::Node.new @client
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              describe 'when initializing' do
         | 
| 10 | 
            -
                it 'defaults to the local interface on port 8087' do
         | 
| 11 | 
            -
                  node = Riak::Client::Node.new @client
         | 
| 12 | 
            -
                  expect(node.host).to eq('127.0.0.1')
         | 
| 13 | 
            -
                  expect(node.pb_port).to eq(8087)
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                it 'accepts a host' do
         | 
| 17 | 
            -
                  node = Riak::Client::Node.new(@client, :host => 'riak.basho.com')
         | 
| 18 | 
            -
                  expect(node.host).to eq("riak.basho.com")
         | 
| 19 | 
            -
                end
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                it 'accepts a Protobuffs port' do
         | 
| 22 | 
            -
                  node = Riak::Client::Node.new @client, :pb_port => 9000
         | 
| 23 | 
            -
                  expect(node.pb_port).to eq(9000)
         | 
| 24 | 
            -
                end
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
            end
         | 
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Riak::Client::Node do
         | 
| 4 | 
            +
              before :each do
         | 
| 5 | 
            +
                @client = Riak::Client.new
         | 
| 6 | 
            +
                @node = Riak::Client::Node.new @client
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              describe 'when initializing' do
         | 
| 10 | 
            +
                it 'defaults to the local interface on port 8087' do
         | 
| 11 | 
            +
                  node = Riak::Client::Node.new @client
         | 
| 12 | 
            +
                  expect(node.host).to eq('127.0.0.1')
         | 
| 13 | 
            +
                  expect(node.pb_port).to eq(8087)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                it 'accepts a host' do
         | 
| 17 | 
            +
                  node = Riak::Client::Node.new(@client, :host => 'riak.basho.com')
         | 
| 18 | 
            +
                  expect(node.host).to eq("riak.basho.com")
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'accepts a Protobuffs port' do
         | 
| 22 | 
            +
                  node = Riak::Client::Node.new @client, :pb_port => 9000
         | 
| 23 | 
            +
                  expect(node.pb_port).to eq(9000)
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
    
        data/spec/riak/stamp_spec.rb
    CHANGED
    
    | @@ -1,54 +1,54 @@ | |
| 1 | 
            -
            require 'spec_helper'
         | 
| 2 | 
            -
            require 'riak/stamp'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            describe Riak::Stamp, test_client: true do
         | 
| 5 | 
            -
              subject { described_class.new test_client }
         | 
| 6 | 
            -
              it "generates always increasing integer identifiers" do
         | 
| 7 | 
            -
                1000.times do
         | 
| 8 | 
            -
                  one = subject.next
         | 
| 9 | 
            -
                  two = subject.next
         | 
| 10 | 
            -
                  expect([one, two]).to be_all {|i| Integer === i }
         | 
| 11 | 
            -
                  expect(two).to be > one
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              it "delays until the next millisecond when the sequence overflows" do
         | 
| 16 | 
            -
                old = subject.instance_variable_get(:@timestamp) + 0
         | 
| 17 | 
            -
                subject.instance_variable_set(:@sequence, described_class::SEQUENCE_MASK)
         | 
| 18 | 
            -
                count = 0
         | 
| 19 | 
            -
                # Simulate the time_gen method returning the same thing multiple times
         | 
| 20 | 
            -
                allow(subject).to receive(:time_gen) do
         | 
| 21 | 
            -
                  count += 1
         | 
| 22 | 
            -
                  if count < 10
         | 
| 23 | 
            -
                    old
         | 
| 24 | 
            -
                  else
         | 
| 25 | 
            -
                    old + 1
         | 
| 26 | 
            -
                  end
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
                expect((subject.next >> described_class::TIMESTAMP_SHIFT) & described_class::TIMESTAMP_MASK).to eq(old + 1)
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              it "raises an exception when the system clock moves backwards" do
         | 
| 32 | 
            -
                old = subject.instance_variable_get(:@timestamp)
         | 
| 33 | 
            -
                expect(subject).to receive(:time_gen).and_return(old - 10)
         | 
| 34 | 
            -
                expect {
         | 
| 35 | 
            -
                  subject.next
         | 
| 36 | 
            -
                }.to raise_error(Riak::BackwardsClockError)
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              # The client/worker ID should be used for disambiguation, not for
         | 
| 40 | 
            -
              # primary ordering.  This breaks from the Snowflake model where the
         | 
| 41 | 
            -
              # worker ID is in more significant bits.
         | 
| 42 | 
            -
              it "uses the client ID as the bottom component of the identifier" do
         | 
| 43 | 
            -
                expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
              context "using a non-integer client ID" do
         | 
| 47 | 
            -
                subject { described_class.new(Riak::Client.new(:client_id => "ripple")) }
         | 
| 48 | 
            -
                let(:hash) { "ripple".hash }
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                it "uses the hash of the client ID as the bottom component of the identifier" do
         | 
| 51 | 
            -
                  expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
         | 
| 52 | 
            -
                end
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
            end
         | 
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'riak/stamp'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe Riak::Stamp, test_client: true do
         | 
| 5 | 
            +
              subject { described_class.new test_client }
         | 
| 6 | 
            +
              it "generates always increasing integer identifiers" do
         | 
| 7 | 
            +
                1000.times do
         | 
| 8 | 
            +
                  one = subject.next
         | 
| 9 | 
            +
                  two = subject.next
         | 
| 10 | 
            +
                  expect([one, two]).to be_all {|i| Integer === i }
         | 
| 11 | 
            +
                  expect(two).to be > one
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              it "delays until the next millisecond when the sequence overflows" do
         | 
| 16 | 
            +
                old = subject.instance_variable_get(:@timestamp) + 0
         | 
| 17 | 
            +
                subject.instance_variable_set(:@sequence, described_class::SEQUENCE_MASK)
         | 
| 18 | 
            +
                count = 0
         | 
| 19 | 
            +
                # Simulate the time_gen method returning the same thing multiple times
         | 
| 20 | 
            +
                allow(subject).to receive(:time_gen) do
         | 
| 21 | 
            +
                  count += 1
         | 
| 22 | 
            +
                  if count < 10
         | 
| 23 | 
            +
                    old
         | 
| 24 | 
            +
                  else
         | 
| 25 | 
            +
                    old + 1
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                expect((subject.next >> described_class::TIMESTAMP_SHIFT) & described_class::TIMESTAMP_MASK).to eq(old + 1)
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it "raises an exception when the system clock moves backwards" do
         | 
| 32 | 
            +
                old = subject.instance_variable_get(:@timestamp)
         | 
| 33 | 
            +
                expect(subject).to receive(:time_gen).and_return(old - 10)
         | 
| 34 | 
            +
                expect {
         | 
| 35 | 
            +
                  subject.next
         | 
| 36 | 
            +
                }.to raise_error(Riak::BackwardsClockError)
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              # The client/worker ID should be used for disambiguation, not for
         | 
| 40 | 
            +
              # primary ordering.  This breaks from the Snowflake model where the
         | 
| 41 | 
            +
              # worker ID is in more significant bits.
         | 
| 42 | 
            +
              it "uses the client ID as the bottom component of the identifier" do
         | 
| 43 | 
            +
                expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              context "using a non-integer client ID" do
         | 
| 47 | 
            +
                subject { described_class.new(Riak::Client.new(:client_id => "ripple")) }
         | 
| 48 | 
            +
                let(:hash) { "ripple".hash }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                it "uses the hash of the client ID as the bottom component of the identifier" do
         | 
| 51 | 
            +
                  expect(subject.next & described_class::CLIENT_ID_MASK).to eq(subject.client.client_id.hash & described_class::CLIENT_ID_MASK)
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
| @@ -1,13 +1,13 @@ | |
| 1 | 
            -
            **DO NOT USE THESE IN PRODUCTION**
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            This directory has certificates and a key for testing Riak authentication.
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            * server.key - a private key for a Riak server
         | 
| 6 | 
            -
            * server.crt - the certificate for server.key
         | 
| 7 | 
            -
            * ca.crt - a certificate for the CA that issued server.crt
         | 
| 8 | 
            -
            * empty_ca.crt - a certificate for a CA that has and cannot ever issue a 
         | 
| 9 | 
            -
              certificate (I deleted its private key)
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            **DO NOT USE THESE IN PRODUCTION**
         | 
| 12 | 
            -
             | 
| 1 | 
            +
            **DO NOT USE THESE IN PRODUCTION**
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            This directory has certificates and a key for testing Riak authentication.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * server.key - a private key for a Riak server
         | 
| 6 | 
            +
            * server.crt - the certificate for server.key
         | 
| 7 | 
            +
            * ca.crt - a certificate for the CA that issued server.crt
         | 
| 8 | 
            +
            * empty_ca.crt - a certificate for a CA that has and cannot ever issue a 
         | 
| 9 | 
            +
              certificate (I deleted its private key)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            **DO NOT USE THESE IN PRODUCTION**
         | 
| 12 | 
            +
             | 
| 13 13 | 
             
            These were generated using https://github.com/basho-labs/riak-ruby-ca .
         | 
    
        data/spec/support/certs/ca.crt
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 1 | 
            -
            -----BEGIN CERTIFICATE-----
         | 
| 2 | 
            -
            MIIDjDCCAnQCCQDCaCbuH5N1HjANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC
         | 
| 3 | 
            -
            VVMxEDAOBgNVBAgMB0Zsb3JpZGExDjAMBgNVBAcMBU1pYW1pMQ4wDAYDVQQKDAVC
         | 
| 4 | 
            -
            YXNobzEZMBcGA1UECwwQUmlhayBSdWJ5IENsaWVudDELMAkGA1UEAwwCQ0ExHjAc
         | 
| 5 | 
            -
            BgkqhkiG9w0BCQEWD2JyeWNlQGJhc2hvLmNvbTAeFw0xNDA5MTgyMjU4MDJaFw0y
         | 
| 6 | 
            -
            NDA5MTUyMjU4MDJaMIGHMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHRmxvcmlkYTEO
         | 
| 7 | 
            -
            MAwGA1UEBwwFTWlhbWkxDjAMBgNVBAoMBUJhc2hvMRkwFwYDVQQLDBBSaWFrIFJ1
         | 
| 8 | 
            -
            YnkgQ2xpZW50MQswCQYDVQQDDAJDQTEeMBwGCSqGSIb3DQEJARYPYnJ5Y2VAYmFz
         | 
| 9 | 
            -
            aG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLREjyW0bsMQ
         | 
| 10 | 
            -
            2xZuZfXrTqndZdtmJrUaUdwLcTYXo/BLJq8mw/UoKBajzDJS1OsVutOT3l1mQZNk
         | 
| 11 | 
            -
            pE15lJbPo301RtkGOeYlTx6ptawutrvlMlACnWtYyuL9U8qqnMJAsdBEjTU3Xxao
         | 
| 12 | 
            -
            /vJTECBVaKtL9D5vEu2fOn4ZWvSuYG14ZXhltBPgon95SrJX+erXgHs0IH6l1ftW
         | 
| 13 | 
            -
            xZL9Uw/Tj/s8XEMK8n6FB+CYuj33fZMjswvdXABzhEAW8bCupJT42V/S9Zj4B0Z8
         | 
| 14 | 
            -
            iv6wgurc1yuU6yl0VDGZ6Ee++7ter3GZZrV4YC5A8UjW0+8sADUYKiZNYWTO6S+N
         | 
| 15 | 
            -
            Pu/sLRdykwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBzcs/VIHHeyUWlS+Rx/s/m
         | 
| 16 | 
            -
            m54RK332r2+8Mywtwdz57kA6rsbYBrrlKVmEzjtgCIcpF/3hhEChYcSA4w0Aa+zd
         | 
| 17 | 
            -
            Zd6eNtUyicPFfm/8GycaLM3Ptj3duq4jHha2IzhomfACm8pkBj8IU8Y5q/YBV+3L
         | 
| 18 | 
            -
            hJxderphbz6lqrH6USkt/aaFzu+1onYlxzGZDyiFPOxUbRPXN12y3XCeFSfuHBej
         | 
| 19 | 
            -
            ifFRSHGR8HU++g4VYnOi/1YXSDFh7yRvA2qBlz+kYprBS2GggXIrfCgT+FnMALlg
         | 
| 20 | 
            -
            6TrfsWQiI3pyGKUsNjdaQckdLMWr8jvutb7vPZ1WdMdgKxbE0Swo1HBbkCAe5JjG
         | 
| 21 | 
            -
            -----END CERTIFICATE-----
         | 
| 1 | 
            +
            -----BEGIN CERTIFICATE-----
         | 
| 2 | 
            +
            MIIDjDCCAnQCCQDCaCbuH5N1HjANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC
         | 
| 3 | 
            +
            VVMxEDAOBgNVBAgMB0Zsb3JpZGExDjAMBgNVBAcMBU1pYW1pMQ4wDAYDVQQKDAVC
         | 
| 4 | 
            +
            YXNobzEZMBcGA1UECwwQUmlhayBSdWJ5IENsaWVudDELMAkGA1UEAwwCQ0ExHjAc
         | 
| 5 | 
            +
            BgkqhkiG9w0BCQEWD2JyeWNlQGJhc2hvLmNvbTAeFw0xNDA5MTgyMjU4MDJaFw0y
         | 
| 6 | 
            +
            NDA5MTUyMjU4MDJaMIGHMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHRmxvcmlkYTEO
         | 
| 7 | 
            +
            MAwGA1UEBwwFTWlhbWkxDjAMBgNVBAoMBUJhc2hvMRkwFwYDVQQLDBBSaWFrIFJ1
         | 
| 8 | 
            +
            YnkgQ2xpZW50MQswCQYDVQQDDAJDQTEeMBwGCSqGSIb3DQEJARYPYnJ5Y2VAYmFz
         | 
| 9 | 
            +
            aG8uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLREjyW0bsMQ
         | 
| 10 | 
            +
            2xZuZfXrTqndZdtmJrUaUdwLcTYXo/BLJq8mw/UoKBajzDJS1OsVutOT3l1mQZNk
         | 
| 11 | 
            +
            pE15lJbPo301RtkGOeYlTx6ptawutrvlMlACnWtYyuL9U8qqnMJAsdBEjTU3Xxao
         | 
| 12 | 
            +
            /vJTECBVaKtL9D5vEu2fOn4ZWvSuYG14ZXhltBPgon95SrJX+erXgHs0IH6l1ftW
         | 
| 13 | 
            +
            xZL9Uw/Tj/s8XEMK8n6FB+CYuj33fZMjswvdXABzhEAW8bCupJT42V/S9Zj4B0Z8
         | 
| 14 | 
            +
            iv6wgurc1yuU6yl0VDGZ6Ee++7ter3GZZrV4YC5A8UjW0+8sADUYKiZNYWTO6S+N
         | 
| 15 | 
            +
            Pu/sLRdykwIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQBzcs/VIHHeyUWlS+Rx/s/m
         | 
| 16 | 
            +
            m54RK332r2+8Mywtwdz57kA6rsbYBrrlKVmEzjtgCIcpF/3hhEChYcSA4w0Aa+zd
         | 
| 17 | 
            +
            Zd6eNtUyicPFfm/8GycaLM3Ptj3duq4jHha2IzhomfACm8pkBj8IU8Y5q/YBV+3L
         | 
| 18 | 
            +
            hJxderphbz6lqrH6USkt/aaFzu+1onYlxzGZDyiFPOxUbRPXN12y3XCeFSfuHBej
         | 
| 19 | 
            +
            ifFRSHGR8HU++g4VYnOi/1YXSDFh7yRvA2qBlz+kYprBS2GggXIrfCgT+FnMALlg
         | 
| 20 | 
            +
            6TrfsWQiI3pyGKUsNjdaQckdLMWr8jvutb7vPZ1WdMdgKxbE0Swo1HBbkCAe5JjG
         | 
| 21 | 
            +
            -----END CERTIFICATE-----
         |