spec/riak/client_spec.rb in riak-client-2.3.2 vs spec/riak/client_spec.rb in riak-client-2.4.0.pre1
- old
+ new
@@ -15,19 +15,20 @@
end
it "accepts a Protobuffs port" do
client = Riak::Client.new :pb_port => 9000
expect(client.nodes.size).to eq(1)
+ expect(client.nodes.first.host).to eq('127.0.0.1')
expect(client.nodes.first.pb_port).to eq(9000)
end
it "accepts a client ID" do
client = Riak::Client.new :client_id => "AAAAAA=="
expect(client.client_id).to eq("AAAAAA==")
end
- it "creates a client ID if not specified" do
+ it "creates a client ID if not specified", :integration => true do
expect(Riak::Client.new(pb_port: test_client.nodes.first.pb_port).
client_id).to_not be_nil
end
it "accepts multiple nodes" do
@@ -37,10 +38,56 @@
{host: 'riak3.basho.com', pb_port: 5678}
]
expect(client.nodes.size).to eq(3)
expect(client.nodes.first.host).to eq("riak1.basho.com")
end
+
+ it "maps port to unset nodes, and does not create localhost node" do
+ client = Riak::Client.new nodes: [
+ {host: 'riak1.basho.com'},
+ {host: 'riak2.basho.com', pb_port: 1234},
+ {host: 'riak3.basho.com', pb_port: 5678}
+ ], pb_port: 4321
+ expect(client.nodes.size).to eq(3)
+ expect(client.nodes[0].host).to eq("riak1.basho.com")
+ expect(client.nodes[0].pb_port).to eq(4321)
+ expect(client.nodes[1].host).to eq("riak2.basho.com")
+ expect(client.nodes[1].pb_port).to eq(1234)
+ end
+
+ it "defaults to max_retries = 2" do
+ client = Riak::Client.new
+ expect(client.max_retries).to eq(2)
+ end
+
+ it "accepts max_retries option" do
+ client = Riak::Client.new :max_retries => 42
+ expect(client.max_retries).to eq(42)
+ end
+
+ it "accepts timeouts" do
+ client = Riak::Client.new(
+ :connect_timeout => 1,
+ :read_timeout => 2,
+ :write_timeout => 3
+ )
+ expect(client.connect_timeout).to eq(1)
+ expect(client.read_timeout).to eq(2)
+ expect(client.write_timeout).to eq(3)
+ end
+
+ it "accepts convert_timestamp" do
+ client = Riak::Client.new(
+ :convert_timestamp => true
+ )
+ expect(client.convert_timestamp).to be
+ end
+
+ it "has default convert_timestamp of false" do
+ client = Riak::Client.new
+ expect(client.convert_timestamp).to_not be
+ end
end
it "exposes a Stamp object" do
expect(subject).to respond_to(:stamp)
expect(subject.stamp).to be_kind_of(Riak::Stamp)
@@ -224,10 +271,10 @@
raise Riak::ProtobuffsFailedHeader
end
rescue RuntimeError
end
- expect(call_count).to eq(3)
+ expect(call_count).to eq(@client.max_retries + 1)
end
it "throws a RuntimeError if it runs out of retries" do
error = nil
begin