beanstalk_integration_tests 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# BeanstalkIntegrationTests
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/beanstalk_integration_tests.png)](http://badge.fury.io/rb/beanstalk_integration_tests)
|
2
3
|
|
3
4
|
A suite of integration tests to test adherence to the Beanstalkd protocol (https://github.com/kr/beanstalkd/blob/master/doc/protocol.md).
|
4
5
|
|
@@ -9,7 +9,28 @@ require 'timeout'
|
|
9
9
|
require 'beaneater'
|
10
10
|
|
11
11
|
|
12
|
+
if RUBY_PLATFORM == 'java'
|
13
|
+
module Timeout
|
14
|
+
def timeout(sec, klass=nil)
|
15
|
+
return yield(sec) if sec == nil or sec.zero?
|
16
|
+
thread = Thread.new { yield(sec) }
|
17
|
+
|
18
|
+
if thread.join(sec).nil?
|
19
|
+
java_thread = JRuby.reference(thread)
|
20
|
+
thread.kill
|
21
|
+
java_thread.native_thread.interrupt
|
22
|
+
thread.join(0.15)
|
23
|
+
raise (klass || Error), 'execution expired'
|
24
|
+
else
|
25
|
+
thread.value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
12
32
|
class BeanstalkIntegrationTest < MiniTest::Should::TestCase
|
33
|
+
include Timeout
|
13
34
|
|
14
35
|
class << self
|
15
36
|
|
@@ -26,7 +47,11 @@ class BeanstalkIntegrationTest < MiniTest::Should::TestCase
|
|
26
47
|
teardown do
|
27
48
|
cleanup_tubes
|
28
49
|
@clients.each do |client|
|
29
|
-
|
50
|
+
begin
|
51
|
+
client.close unless client.connection.nil?
|
52
|
+
rescue Errno::EBADF
|
53
|
+
# Timeouts in JRuby trash the client connection
|
54
|
+
end
|
30
55
|
end
|
31
56
|
end
|
32
57
|
|