beetle 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7361b4a6ff5f5336fc8886999afda357bc63e86
4
- data.tar.gz: 22b0f8c05040e216b8ba21cdd73c882a48c8bad9
3
+ metadata.gz: 11f94ebbdbb2e69a8f9253fd4bae0141b8c461ed
4
+ data.tar.gz: 6fb4333ff041cc5451ddeee58b9f1dda90287b40
5
5
  SHA512:
6
- metadata.gz: 2bcb76c73b2cf8b8da54a34fce694a47e33c5be0251869ba74e488402968f6db41dfe0548640c739ff815007d38c62e440fd90fdccde23d895f390c92984ab28
7
- data.tar.gz: 573787dbdbb962e27ad26f80df5c0ea0f05a3171c9aa41b116873c328f53a3393b630388a6d20937d44046b5113384e831571fc3ced81f7a52d85fcc60618089
6
+ metadata.gz: 26833cddbdca71091b8b4be60ffa8880e10542999aac278fd2ac64af27760ba9024f80f2716fccea7a2a57c26db0618b0425f01c831c2c6f66536aa13ba06f9a
7
+ data.tar.gz: b226d364d7aa0e135a8d5cebaf5ab5ac1ac7b7eab6d2758ddbb8032a2a3b6b37261b5ed738a680d3d252171ad8d0418590d4f9ecb940bd91d6083dccad0befe0
@@ -60,6 +60,19 @@ To set up a redundant messaging system you will need
60
60
  * at least 2 AMQP servers (we use {RabbitMQ}[http://www.rabbitmq.com/])
61
61
  * at least one {Redis}[http://github.com/antirez/redis] server (better are two in a master/slave setup, see REDIS_AUTO_FAILOVER.rdoc)
62
62
 
63
+ == Test environment
64
+
65
+ For testing purposes, you will need a MySQL database with the database
66
+ `beetle_test` created. This is needed to test special cases in which
67
+ Beetle handles the connection with ActiveRecord:
68
+
69
+ mysql -e 'create database beetle_test;'
70
+
71
+ You also need a Redis instance running. The default configuration of Redis will work:
72
+
73
+ redis-server
74
+
75
+
63
76
  == Gem Dependencies
64
77
 
65
78
  At runtime, Beetle will use
@@ -70,7 +83,7 @@ At runtime, Beetle will use
70
83
  * {amqp}[http://github.com/ruby-amqp/amqp]
71
84
  (which is based on {eventmachine}[http://github.com/eventmachine/eventmachine])
72
85
  * {daemons}[http://daemons.rubyforge.org/]
73
- * activesupport
86
+ * {activesupport}[https://github.com/rails/rails/tree/master/activesupport]
74
87
 
75
88
  For development, you'll need
76
89
  * {mocha}[http://github.com/floehopper/mocha]
@@ -78,6 +91,10 @@ For development, you'll need
78
91
  * {cucumber}[http://github.com/aslakhellesoy/cucumber]
79
92
  * {daemon_controller}[http://github.com/FooBarWidget/daemon_controller]
80
93
 
94
+ For tests, you'll need
95
+ * {activerecord}[https://github.com/rails/rails/tree/master/activerecord]
96
+ * {mysql2}[https://github.com/brianmario/mysql2/]
97
+
81
98
  == Authors
82
99
 
83
100
  {Stefan Kaes}[http://github.com/skaes],
@@ -292,6 +292,7 @@ module Beetle
292
292
  Timer.timeout(@timeout.to_f) { @handler_result = handler.call(self) }
293
293
  RC::OK
294
294
  rescue Exception => @exception
295
+ ActiveRecord::Base.clear_all_connections! if defined?(ActiveRecord)
295
296
  Beetle::reraise_expectation_errors!
296
297
  logger.debug "Beetle: message handler crashed on #{msg_id}"
297
298
  RC::HandlerCrash
@@ -1,3 +1,3 @@
1
1
  module Beetle
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
@@ -622,6 +622,46 @@ module Beetle
622
622
 
623
623
  end
624
624
 
625
+ class MySQLFailoverTest < MiniTest::Unit::TestCase
626
+ require "active_record"
627
+
628
+ def setup
629
+ @store = DeduplicationStore.new
630
+ @store.flushdb
631
+
632
+ ActiveRecord::Base.establish_connection(
633
+ adapter: "mysql2",
634
+ database: "beetle_test",
635
+ username: "root",
636
+ encoding: "utf8"
637
+ )
638
+ end
639
+
640
+ test "a handler that drops a MySQL query ensures the connection still works" do
641
+ header = header_with_params({})
642
+ header.expects(:ack)
643
+ message = Message.new("somequeue", header, "foo", :timeout => 1.second, :attempts => 2, :store => @store)
644
+ action = lambda do |*args|
645
+ # the timeout should stop the query before it finishes.
646
+ ActiveRecord::Base.connection.execute("select sleep(6);")
647
+ end
648
+ handler = Handler.create(action)
649
+ result = message.process(handler)
650
+ assert_equal RC::ExceptionsLimitReached, result
651
+
652
+ # second message should process without problems
653
+ second_header = header_with_params({})
654
+ second_header.expects(:ack)
655
+ second_message = Message.new("somequeue", second_header, "foo2", :timeout => 2.seconds, :attempts => 1, :store => @store)
656
+ second_action = lambda do |*args|
657
+ ActiveRecord::Base.connection.execute("select 1;")
658
+ end
659
+ second_handler = Handler.create(second_action)
660
+ second_result = second_message.process(second_handler)
661
+ assert_equal RC::OK, second_result
662
+ end
663
+ end
664
+
625
665
  class SettingsTest < MiniTest::Unit::TestCase
626
666
  def setup
627
667
  @store = DeduplicationStore.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beetle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-12-01 00:00:00.000000000 Z
15
+ date: 2014-12-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: uuid4r
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: 1.3.7
269
269
  requirements: []
270
270
  rubyforge_project:
271
- rubygems_version: 2.2.2
271
+ rubygems_version: 2.4.3
272
272
  signing_key:
273
273
  specification_version: 3
274
274
  summary: High Availability AMQP Messaging with Redundant Queues