poseidon 0.0.5.pre1 → 0.0.5

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/CHANGES.md +11 -3
  4. data/README.md +4 -1
  5. data/Rakefile +1 -1
  6. data/lib/poseidon.rb +1 -0
  7. data/lib/poseidon/broker_pool.rb +15 -5
  8. data/lib/poseidon/compression/gzip_codec.rb +3 -3
  9. data/lib/poseidon/compression/snappy_codec.rb +14 -2
  10. data/lib/poseidon/connection.rb +9 -0
  11. data/lib/poseidon/partition_consumer.rb +5 -5
  12. data/lib/poseidon/producer.rb +9 -6
  13. data/lib/poseidon/producer_compression_config.rb +5 -4
  14. data/lib/poseidon/protocol/request_buffer.rb +5 -14
  15. data/lib/poseidon/protocol/response_buffer.rb +7 -7
  16. data/lib/poseidon/sync_producer.rb +5 -3
  17. data/lib/poseidon/version.rb +1 -1
  18. data/poseidon.gemspec +2 -1
  19. data/spec/integration/multiple_brokers/consumer_spec.rb +1 -1
  20. data/spec/integration/multiple_brokers/metadata_failures_spec.rb +1 -1
  21. data/spec/integration/multiple_brokers/rebalance_spec.rb +1 -1
  22. data/spec/integration/multiple_brokers/round_robin_spec.rb +1 -1
  23. data/spec/integration/simple/compression_spec.rb +2 -2
  24. data/spec/integration/simple/connection_spec.rb +4 -4
  25. data/spec/integration/simple/multiple_brokers_spec.rb +1 -1
  26. data/spec/integration/simple/simple_producer_and_consumer_spec.rb +7 -7
  27. data/spec/integration/simple/truncated_messages_spec.rb +4 -4
  28. data/spec/integration/simple/unavailable_broker_spec.rb +1 -1
  29. data/spec/spec_helper.rb +1 -7
  30. data/spec/unit/broker_pool_spec.rb +14 -14
  31. data/spec/unit/cluster_metadata_spec.rb +1 -1
  32. data/spec/unit/compression/gzip_codec_spec.rb +34 -0
  33. data/spec/unit/compression/snappy_codec_spec.rb +49 -0
  34. data/spec/unit/compression_spec.rb +1 -1
  35. data/spec/unit/connection_spec.rb +1 -1
  36. data/spec/unit/fetched_message_spec.rb +1 -1
  37. data/spec/unit/message_conductor_spec.rb +1 -1
  38. data/spec/unit/message_set_spec.rb +1 -1
  39. data/spec/unit/message_spec.rb +2 -2
  40. data/spec/unit/message_to_send_spec.rb +1 -1
  41. data/spec/unit/messages_for_broker_spec.rb +3 -3
  42. data/spec/unit/messages_to_send_batch_spec.rb +4 -4
  43. data/spec/unit/messages_to_send_spec.rb +8 -8
  44. data/spec/unit/partition_consumer_spec.rb +13 -13
  45. data/spec/unit/producer_compression_config_spec.rb +8 -1
  46. data/spec/unit/producer_spec.rb +10 -4
  47. data/spec/unit/protocol/request_buffer_spec.rb +16 -0
  48. data/spec/unit/protocol_spec.rb +5 -5
  49. data/spec/unit/sync_producer_spec.rb +22 -22
  50. data/spec/unit/topic_metadata_spec.rb +1 -1
  51. metadata +28 -9
@@ -1,6 +1,6 @@
1
1
  require 'integration/multiple_brokers/spec_helper'
2
2
 
3
- describe "round robin sending" do
3
+ RSpec.describe "round robin sending", :type => :request do
4
4
  describe "with small message batches" do
5
5
  it "evenly distributes messages across brokers" do
6
6
  c = Connection.new("localhost", 9092, "metadata_fetcher", 10_000)
@@ -1,6 +1,6 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
- describe "compression" do
3
+ RSpec.describe "compression", :type => :request do
4
4
  it "roundtrips" do
5
5
  i = rand(1000)
6
6
 
@@ -12,7 +12,7 @@ describe "compression" do
12
12
  :type => :sync,
13
13
  :compression_codec => :gzip)
14
14
  messages = [MessageToSend.new("test12", "Hello World: #{i}")]
15
-
15
+
16
16
  expect(@producer.send_messages(messages)).to eq(true)
17
17
  sleep 1
18
18
  messages = @consumer.fetch
@@ -1,7 +1,7 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
3
  include Protocol
4
- describe Connection do
4
+ RSpec.describe Connection, :type => :request do
5
5
  before(:each) do
6
6
  @connection = Connection.new("localhost", 9092, "test", 10_000)
7
7
  end
@@ -11,10 +11,10 @@ describe Connection do
11
11
  end
12
12
 
13
13
  it 'sends and parsers produce requests' do
14
- message = MessageStruct.new(0, 0, nil, "hello")
14
+ message = MessageStruct.new(0, 0, nil, "hello")
15
15
  message_with_offset = MessageWithOffsetStruct.new(0, message)
16
16
  message_set = MessageSetStruct.new([message_with_offset])
17
- messages_for_partitions = [MessagesForPartition.new(0,message_set)]
17
+ messages_for_partitions = [MessagesForPartition.new(0,message_set)]
18
18
  messages_for_topics = [MessagesForTopic.new("test2",messages_for_partitions)]
19
19
  @connection.produce(1, 10_000, messages_for_topics)
20
20
  end
@@ -24,7 +24,7 @@ describe Connection do
24
24
  topic_fetches = [TopicFetch.new("test2", partition_fetches)]
25
25
  @connection.fetch(1000, 0, topic_fetches)
26
26
  end
27
-
27
+
28
28
  it 'sends and parsers offset requests' do
29
29
  partition_offset_requests = [PartitionOffsetRequest.new(0,-1,1000)]
30
30
  offset_topic_requests = [TopicOffsetRequest.new("test2", partition_offset_requests)]
@@ -1,6 +1,6 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
- describe "three brokers in cluster" do
3
+ RSpec.describe "three brokers in cluster", :type => :request do
4
4
  describe "sending batches of 1 message" do
5
5
  it "sends messages to all brokers" do
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
- describe "simple producer and consumer" do
3
+ RSpec.describe "simple producer and consumer", :type => :request do
4
4
 
5
5
  describe "writing and consuming one topic" do
6
6
  it "fetches produced messages" do
@@ -17,7 +17,7 @@ describe "simple producer and consumer" do
17
17
  messages = @consumer.fetch
18
18
  expect(messages.last.value).to eq("Hello World")
19
19
 
20
- @producer.shutdown
20
+ @producer.close
21
21
  end
22
22
 
23
23
  it "fetches only messages since the last offset" do
@@ -81,21 +81,21 @@ describe "simple producer and consumer" do
81
81
 
82
82
  @consumer = PartitionConsumer.new("test_consumer", "localhost", 9092,
83
83
  "topic_simple_producer_and_consumer", 0, -2)
84
-
84
+
85
85
  messages = []
86
86
  2000.times do
87
87
  messages << MessageToSend.new("topic_simple_producer_and_consumer",'KcjNyFBtqfSbpwjjcGKckMKLUCWz83IVcp21C8FQzs8JJKKTTrc4OLxSjLpYc5z7fsncX59te2cBn0sWDRaYmRuZyttRMLMHvXrM5o3QReKPIYUKzVCFahC4cb3Ivcbb5ZuS98Ohnb7Io42Bz9FucXwwGkQyFhJwyn3nD3BYs5r8TZM8Q76CGR2kTH1rjnFeB7J3hrRKukztxCrDY3smrQE1bbVR80IF3yWlhzkdfv3cpfwnD0TKadtt21sFJANFmORAJ0HKs6Z2262hcBQyF7WcWypC2RoLWVgKVQxbouVUP7yV6YYOAQEevYrl9sOB0Yi6h1mS8fTBUmRTmWLqyl8KzwbnbQvmCvgnX26F5JEzIoXsVaoDT2ks5eep9RyE1zm5yPtbYVmd2Sz7t5ru0wj6YiAmbF7Xgiw2l4VpNOxG0Ec6rFxXRXs0bahyBd2YtxpGyZBeruIK1RAN4n0t97xVXgZG5CGoVhL1oRDxw2pTbwEO1cvwHiiYXpXSqaxF7G9kiiPsQt24Vu7chXrJT7Xqv4RIg1aOT5Os5JVlISaJCmx8ZLtbC3OjAdGtF1ZkDuUeQHHohqeKh0qBJjw7Rv1oSDwcM0MRazjF36jijpYg26Qml9lSEnGYIFLQWHVDWKqqhl2GIntjxDXn1IyI')
88
88
  end
89
89
  expect(@producer.send_messages(messages)).to eq(true)
90
-
90
+
91
91
  messages = @consumer.fetch
92
- expect(messages.length).to be > 2
93
-
92
+ expect(messages.length).to be > 2
93
+
94
94
  @consumer = PartitionConsumer.new("test_consumer", "localhost", 9092,
95
95
  "topic_simple_producer_and_consumer", 0, -2)
96
96
  messages = @consumer.fetch(:max_bytes => 1400000)
97
97
  expect(messages.length).to be > 2
98
- end
98
+ end
99
99
  =end
100
100
  end
101
101
 
@@ -1,6 +1,6 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
- describe "truncated messages" do
3
+ RSpec.describe "truncated messages", :type => :request do
4
4
  before(:each) do
5
5
  @s1 = "a" * 335
6
6
  @s2 = "b" * 338
@@ -8,7 +8,7 @@ describe "truncated messages" do
8
8
  @producer = Producer.new(["localhost:9092"],
9
9
  "test_client",
10
10
  :type => :sync)
11
-
11
+
12
12
  @producer.send_messages([Message.new(:topic => 'test_max_bytes', :value => @s1), Message.new(:topic => 'test_max_bytes', :value => @s2)])
13
13
  end
14
14
 
@@ -25,7 +25,7 @@ describe "truncated messages" do
25
25
  consumer = PartitionConsumer.new("test_consumer", "localhost", 9092,
26
26
  "test_max_bytes", 0, :earliest_offset)
27
27
 
28
- messages = consumer.fetch(:max_bytes => n)
28
+ messages = consumer.fetch(:max_bytes => n)
29
29
  expect(messages.size).to eq(1)
30
30
  expect(messages.first.value).to eq(@s1)
31
31
  end
@@ -36,7 +36,7 @@ describe "truncated messages" do
36
36
  consumer = PartitionConsumer.new("test_consumer", "localhost", 9092,
37
37
  "test_max_bytes", 0, :earliest_offset)
38
38
 
39
- messages = consumer.fetch(:max_bytes => n)
39
+ messages = consumer.fetch(:max_bytes => n)
40
40
  expect(messages.size).to eq(2)
41
41
  expect(messages.map(&:value)).to eq([@s1, @s2])
42
42
  end
@@ -1,6 +1,6 @@
1
1
  require 'integration/simple/spec_helper'
2
2
 
3
- describe "unavailable broker scenarios:" do
3
+ RSpec.describe "unavailable broker scenarios:", :type => :request do
4
4
  context "producer with a dead broker in bootstrap list" do
5
5
  before(:each) do
6
6
  @p = Producer.new(["localhost:9091","localhost:9092"], "test")
@@ -5,19 +5,13 @@
5
5
  #
6
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
7
  RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
- config.run_all_when_everything_filtered = true
10
- config.filter_run :focus
11
-
12
8
  # Run specs in random order to surface order dependencies. If you find an
13
9
  # order dependency and want to debug it, you can fix the order by providing
14
10
  # the seed, which is printed after each run.
15
11
  # --seed 1234
16
12
  config.order = 'random'
17
13
 
18
- config.expect_with :rspec do |c|
19
- c.syntax = :expect
20
- end
14
+ config.disable_monkey_patching!
21
15
  end
22
16
 
23
17
  POSEIDON_PATH = File.absolute_path(File.dirname(__FILE__) + "/../")
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrokerPool do
3
+ RSpec.describe BrokerPool do
4
4
  context "empty broker list" do
5
5
  it "raises UnknownBroker error when trying to produce data" do
6
6
  expect { BrokerPool.new("test_client", [], 10_000).execute_api_call(0, :produce) }.to raise_error(BrokerPool::UnknownBroker)
@@ -14,9 +14,9 @@ describe BrokerPool do
14
14
  @broker = double('Poseidon::Connection', :topic_metadata => nil)
15
15
 
16
16
  expected_args = ["localhost", "9092", "test_client", 2_000]
17
- connection = stub('conn').as_null_object
17
+ connection = double('conn').as_null_object
18
18
 
19
- Connection.should_receive(:new).with(*expected_args).and_return(connection)
19
+ expect(Connection).to receive(:new).with(*expected_args).and_return(connection)
20
20
 
21
21
  @broker_pool.fetch_metadata(Set.new)
22
22
  end
@@ -34,20 +34,20 @@ describe BrokerPool do
34
34
  @broker_pool = BrokerPool.new("test_client", ["first:9092","second:9092"], 10_000)
35
35
  @broker_1 = double('Poseidon::Connection_1', :topic_metadata => nil, :close => nil)
36
36
  @broker_2 = double('Poseidon::Connection_2', :topic_metadata => double('topic_metadata').as_null_object, :close => nil)
37
- Connection.stub!(:new).and_return(@broker_1, @broker_2)
37
+ allow(Connection).to receive(:new).and_return(@broker_1, @broker_2)
38
38
  end
39
39
 
40
40
  context ", first doesn't have metadata" do
41
41
  it "asks the second" do
42
- @broker_2.should_receive(:topic_metadata)
42
+ expect(@broker_2).to receive(:topic_metadata)
43
43
 
44
44
  @broker_pool.fetch_metadata(Set.new)
45
45
  end
46
46
  end
47
47
 
48
48
  it "cleans up its connections" do
49
- @broker_1.should_receive(:close)
50
- @broker_2.should_receive(:close)
49
+ expect(@broker_1).to receive(:close)
50
+ expect(@broker_2).to receive(:close)
51
51
 
52
52
  @broker_pool.fetch_metadata(Set.new)
53
53
  end
@@ -63,27 +63,27 @@ describe BrokerPool do
63
63
  describe "when executing a call" do
64
64
 
65
65
  it "creates a connection for the correct broker" do
66
- c = stub('conn').as_null_object
66
+ c = double('conn').as_null_object
67
67
  expected_args = ["localhost", 9092, "test_client", 10_000]
68
68
 
69
- Connection.should_receive(:new).with(*expected_args).and_return(c)
69
+ expect(Connection).to receive(:new).with(*expected_args).and_return(c)
70
70
  @broker_pool.execute_api_call(0, :produce)
71
71
  end
72
72
 
73
73
  it "it does so on the correct broker" do
74
- c = stub('conn').as_null_object
75
- Connection.stub(:new).and_return(c)
74
+ c = double('conn').as_null_object
75
+ allow(Connection).to receive(:new).and_return(c)
76
76
 
77
- c.should_receive(:produce)
77
+ expect(c).to receive(:produce)
78
78
  @broker_pool.execute_api_call(0, :produce)
79
79
  end
80
80
  end
81
81
 
82
82
  describe "when executing two calls" do
83
83
  it "reuses the connection" do
84
- c = stub('conn').as_null_object
84
+ c = double('conn').as_null_object
85
85
 
86
- Connection.should_receive(:new).once.and_return(c)
86
+ expect(Connection).to receive(:new).once.and_return(c)
87
87
  @broker_pool.execute_api_call(0, :produce)
88
88
  @broker_pool.execute_api_call(0, :produce)
89
89
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  include Protocol
4
- describe ClusterMetadata do
4
+ RSpec.describe ClusterMetadata do
5
5
  describe "populated" do
6
6
  before(:each) do
7
7
  partitions = [
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Poseidon::Compression::GzipCodec do
5
+
6
+ let :data do
7
+ %({"a":"val1"}\n{"a":"val2"}\n{"a":"val3"})
8
+ end
9
+
10
+ it "should have an ID" do
11
+ expect(described_class.codec_id).to eq(1)
12
+ end
13
+
14
+ it "should compress" do
15
+ compressed = described_class.compress(data)
16
+ expect(compressed.size).to eq(41)
17
+ expect(compressed.encoding).to eq(Encoding::BINARY)
18
+ end
19
+
20
+ it "should decompress" do
21
+ original = described_class.decompress(described_class.compress(data))
22
+ expect(original).to eq(data)
23
+ expect(original.encoding).to eq(Encoding::UTF_8)
24
+ end
25
+
26
+ it "should decompress unicode messages" do
27
+ str = "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00c`\x80\x03\xE3I\x91\xD3|\x19\x18\xFE\x03\x01\x90\xA7Z\xAD\x94\xA8d\xA5\x14Z\x92XP\xEC\xE9\xE3\xE1\xEB\x12Y\xEE\xE8\x98\x16\xA4\xA4\xA3\x94\x04\x14~6}\xE9\xB39k\x94j\xA1Z\x19A\xDAm\f\xD9\xEF\x10\xD0\x1E\x8C\xA6\x1D\x00\x96\x98\x1E\xB9~\x00\x00\x00".force_encoding(Encoding::BINARY)
28
+ buf = Protocol::ResponseBuffer.new(described_class.decompress(str))
29
+ msg = MessageSet.read_without_size(buf).flatten
30
+ expect(msg.size).to eq(2)
31
+ expect(msg[0].value).to eq(%({"a":"UtapsILHMDYwAAfR","b":"日本"}))
32
+ end
33
+
34
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Poseidon::Compression::SnappyCodec do
5
+
6
+ let :data do
7
+ %({"a":"val1"}\n{"a":"val2"}\n{"a":"val3"})
8
+ end
9
+
10
+ it "should have an ID" do
11
+ expect(described_class.codec_id).to eq(2)
12
+ end
13
+
14
+ it "should compress" do
15
+ compressed = described_class.compress(data)
16
+ expect(compressed.size).to eq(34)
17
+ expect(compressed.encoding).to eq(Encoding::BINARY)
18
+ end
19
+
20
+ it "should decompress" do
21
+ original = described_class.decompress(described_class.compress(data))
22
+ expect(original).to eq(data)
23
+ end
24
+
25
+ it "should decompress streams" do
26
+ str = "\x82SNAPPY\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x1E#\x00\x00\x19\x01\\\x17\x8B\xA7x\xB9\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00\tPLAINDATA".force_encoding(Encoding::BINARY)
27
+ buf = Protocol::ResponseBuffer.new(described_class.decompress(str))
28
+ msg = MessageSet.read_without_size(buf).flatten
29
+ expect(msg.size).to eq(1)
30
+ expect(msg[0].value).to eq("PLAINDATA")
31
+ end
32
+
33
+ it "should decompress bulk streams" do
34
+ str = "\x82SNAPPY\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\xCA\xE8\x04\x00\x00\x19\x01\xA0L`\x9E\xD4(\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00>{\"a\":\"UtaaKYLHMCwiAA-l\",\"bF\x17\x00Dm\",\"c\":1389795881}\rW \x01\x00\x00\x00Ln\x14\x98\xA8zX\x00\x00nVX\x00\x00o^X\x00\x00\x02\x01X\b3\xF1\e~\xB0\x00\x00pVX\x00\x00q^X\x00\x00\x03\x01X\b.\xE5\x82~X\x00\x00tVX\x00\x00u^X\x00\x00\x04\x01X\b o\xCE~\b\x01\x00vVX\x00\x00w^X\x00\x00\x05\x01X\f\t\xD8)(z`\x01\x00xVX\x00\x00y^X\x00\x00\x06\x01X\f@\bf\xA6zX\x00\x00zVX\x00\x000BX\x00".force_encoding(Encoding::BINARY)
35
+ buf = Protocol::ResponseBuffer.new(described_class.decompress(str))
36
+ msg = MessageSet.read_without_size(buf).flatten
37
+ expect(msg.size).to eq(7)
38
+ expect(msg[0].value).to eq(%({"a":"UtaaKYLHMCwiAA-l","b":"UtaaKYLHMCwiAA-m","c":1389795881}))
39
+ end
40
+
41
+ it "should decompress unicode messages" do
42
+ str = "\x82SNAPPY\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00:?\x00\x00\x19\x01\xCC3\xBA?\x91\xFA\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00%{\"a\":\"UtaitILHMDAAAAfU\",\"b\":\"\xE6\x97\xA5\xE6\x9C\xAC\"}".force_encoding(Encoding::BINARY)
43
+ buf = Protocol::ResponseBuffer.new(described_class.decompress(str))
44
+ msg = MessageSet.read_without_size(buf).flatten
45
+ expect(msg.size).to eq(1)
46
+ expect(msg[0].value).to eq(%({"a":"UtaitILHMDAAAAfU","b":"日本"}))
47
+ end
48
+
49
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Compression do
3
+ RSpec.describe Compression do
4
4
  it 'returns GzipCompessor for codec_id of 1' do
5
5
  codec = Compression.find_codec(1)
6
6
  expect(codec).to eq(Compression::GzipCodec)
@@ -1,4 +1,4 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Connection do
3
+ RSpec.describe Connection do
4
4
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FetchedMessage do
3
+ RSpec.describe FetchedMessage do
4
4
  it "provides access to topic,value,key,offset" do
5
5
  mts = FetchedMessage.new("hello_topic", "Hello World", "key", 0)
6
6
  expect(mts.topic).to eq("hello_topic")
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  include Protocol
4
- describe MessageConductor do
4
+ RSpec.describe MessageConductor do
5
5
  context "two available partitions" do
6
6
  before(:each) do
7
7
  partitions = [
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MessageSet do
3
+ RSpec.describe MessageSet do
4
4
  describe "converting to a compressed message" do
5
5
  before(:each) do
6
6
  ms = MessageSet.new([Message.new(:value => "I will be compressed", :topic => "test")])
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'spec_helper'
3
3
 
4
- describe Message do
4
+ RSpec.describe Message do
5
5
  describe "when constructing a new message" do
6
6
  it 'raises an ArgumentError on unknown options' do
7
7
  expect { Message.new(:cow => "dog") }.to raise_error(ArgumentError)
@@ -100,7 +100,7 @@ describe Message do
100
100
 
101
101
  resp_buf = Protocol::ResponseBuffer.new(req_buf.to_s)
102
102
 
103
- expect(Message.read(resp_buf).value).to eq(s.force_encoding("ASCII-8BIT"))
103
+ expect(Message.read(resp_buf).value).to eq(s.force_encoding(Encoding::BINARY))
104
104
  end
105
105
  end
106
106
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MessageToSend do
3
+ RSpec.describe MessageToSend do
4
4
  it "provides access to topic,value,key" do
5
5
  mts = MessageToSend.new("hello_topic", "Hello World", "key")
6
6
  expect(mts.topic).to eq("hello_topic")
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MessagesForBroker do
3
+ RSpec.describe MessagesForBroker do
4
4
  context "twos message one to broker 0, partition 0, another to partition 1" do
5
5
  before(:each) do
6
6
  @messages = [ Message.new(:topic => "topic1",:value => "hi0"),
7
7
  Message.new(:topic => "topic1",:value => "hi1")]
8
8
 
9
- @compression_config = stub('compression_config',
9
+ @compression_config = double('compression_config',
10
10
  :compression_codec_for_topic => nil)
11
11
 
12
12
  @mfb = MessagesForBroker.new(0)
@@ -37,7 +37,7 @@ describe MessagesForBroker do
37
37
 
38
38
  context "and topic is compressed" do
39
39
  it "builds the protocol object correctly" do
40
- @compression_config.stub!(:compression_codec_for_topic => Compression::GzipCodec)
40
+ allow(@compression_config).to receive_messages(:compression_codec_for_topic => Compression::GzipCodec)
41
41
  protocol_object = @mfb.build_protocol_objects(@compression_config)
42
42
 
43
43
  messages_for_topics = [
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MessagesToSendBatch do
3
+ RSpec.describe MessagesToSendBatch do
4
4
  context "messages sent to two different brokers" do
5
5
  before(:each) do
6
- message_conductor = stub('message_conductor')
7
- message_conductor.stub!(:destination).and_return([0,0],[1,1])
6
+ message_conductor = double('message_conductor')
7
+ allow(message_conductor).to receive(:destination).and_return([0,0],[1,1])
8
8
 
9
9
  @messages = [
10
10
  Message.new(:topic => "topic1", :value => "hi"),
@@ -19,7 +19,7 @@ describe MessagesToSendBatch do
19
19
 
20
20
  it "has all messages in the returned message brokers" do
21
21
  messages = @batch.messages_for_brokers.map(&:messages).flatten
22
- expect(messages.to_set).to eq(@messages.to_set)
22
+ expect(messages.to_set).to eq(@messages.to_set)
23
23
  end
24
24
  end
25
25
  end