sensu-em 2.4.1-java → 2.5.0.beta-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +15 -5
  3. data/CHANGELOG.md +41 -1
  4. data/README.md +2 -3
  5. data/eventmachine.gemspec +2 -1
  6. data/ext/cmain.cpp +19 -3
  7. data/ext/ed.cpp +22 -8
  8. data/ext/em.cpp +123 -76
  9. data/ext/em.h +40 -6
  10. data/ext/eventmachine.h +2 -0
  11. data/ext/extconf.rb +16 -2
  12. data/ext/fastfilereader/extconf.rb +3 -0
  13. data/ext/fastfilereader/mapper.cpp +1 -1
  14. data/ext/project.h +11 -7
  15. data/ext/rubymain.cpp +38 -2
  16. data/ext/ssl.cpp +4 -1
  17. data/ext/ssl.h +4 -0
  18. data/java/src/com/rubyeventmachine/EventableChannel.java +8 -1
  19. data/lib/em/buftok.rb +34 -85
  20. data/lib/em/protocols/httpclient.rb +31 -11
  21. data/lib/em/protocols/line_and_text.rb +2 -3
  22. data/lib/em/protocols/linetext2.rb +0 -1
  23. data/lib/em/protocols/smtpserver.rb +32 -9
  24. data/lib/em/pure_ruby.rb +2 -2
  25. data/lib/em/tick_loop.rb +19 -19
  26. data/lib/em/version.rb +1 -1
  27. data/lib/eventmachine.rb +12 -4
  28. data/lib/jeventmachine.rb +22 -6
  29. data/lib/rubyeventmachine.jar +0 -0
  30. data/rakelib/package.rake +1 -1
  31. data/tests/em_test_helper.rb +4 -0
  32. data/tests/test_attach.rb +1 -0
  33. data/tests/test_basic.rb +14 -16
  34. data/tests/test_completion.rb +1 -0
  35. data/tests/test_connection_count.rb +1 -0
  36. data/tests/test_connection_write.rb +35 -0
  37. data/tests/test_epoll.rb +11 -14
  38. data/tests/test_httpclient.rb +43 -0
  39. data/tests/test_iterator.rb +6 -6
  40. data/tests/test_kb.rb +19 -25
  41. data/tests/test_many_fds.rb +22 -0
  42. data/tests/test_pause.rb +7 -2
  43. data/tests/test_pool.rb +2 -0
  44. data/tests/test_process_watch.rb +2 -0
  45. data/tests/test_processes.rb +7 -7
  46. data/tests/test_resolver.rb +33 -7
  47. data/tests/test_ssl_methods.rb +3 -4
  48. data/tests/test_ssl_verify.rb +62 -62
  49. data/tests/test_threaded_resource.rb +8 -0
  50. data/tmp/java/rubyeventmachine/.build +0 -0
  51. metadata +27 -10
@@ -37,8 +37,8 @@ class TestProcesses < Test::Unit::TestCase
37
37
  }
38
38
 
39
39
  assert( $out.length > 0 )
40
- assert_equal($status.exitstatus, 0)
41
- assert_equal($status.class, Process::Status)
40
+ assert_equal(0, $status.exitstatus)
41
+ assert_kind_of(Process::Status, $status)
42
42
  end
43
43
 
44
44
  def test_em_system_pid
@@ -57,8 +57,8 @@ class TestProcesses < Test::Unit::TestCase
57
57
  }
58
58
 
59
59
  assert( $out.length > 0 )
60
- assert_equal($status.exitstatus, 0)
61
- assert_equal($status.class, Process::Status)
60
+ assert_equal(0, $status.exitstatus)
61
+ assert_kind_of(Process::Status, $status)
62
62
  end
63
63
 
64
64
  def test_em_system_with_two_procs
@@ -111,9 +111,9 @@ class TestProcesses < Test::Unit::TestCase
111
111
  end
112
112
  end
113
113
 
114
- EM.run{
115
- EM.popen('cat /dev/random', test_client)
116
- }
114
+ EM.run do
115
+ EM.popen('echo 1', test_client)
116
+ end
117
117
 
118
118
  assert_equal 1, c_rx
119
119
  end
@@ -30,11 +30,11 @@ class TestResolver < Test::Unit::TestCase
30
30
 
31
31
  def test_a_pair
32
32
  EM.run {
33
- d = EM::DNS::Resolver.resolve "google.com"
34
- d.errback { assert false }
33
+ d = EM::DNS::Resolver.resolve "yahoo.com"
34
+ d.errback { |err| assert false, "failed to resolve yahoo.com: #{err}" }
35
35
  d.callback { |r|
36
- assert_equal(Array, r.class)
37
- assert r.size > 1
36
+ assert_kind_of(Array, r)
37
+ assert r.size > 1, "returned #{r.size} results: #{r.inspect}"
38
38
  EM.stop
39
39
  }
40
40
  }
@@ -45,11 +45,37 @@ class TestResolver < Test::Unit::TestCase
45
45
  d = EM::DNS::Resolver.resolve "localhost"
46
46
  d.errback { assert false }
47
47
  d.callback { |r|
48
- assert_equal("127.0.0.1", r.first)
49
- assert_equal(Array, r.class)
48
+ assert_include(["127.0.0.1", "::1"], r.first)
49
+ assert_kind_of(Array, r)
50
+
51
+ EM.stop
52
+ }
53
+ }
54
+ end
55
+
56
+ def test_timer_cleanup
57
+ EM.run {
58
+ d = EM::DNS::Resolver.resolve "google.com"
59
+ d.errback { |err| assert false, "failed to resolve google.com: #{err}" }
60
+ d.callback { |r|
61
+ # This isn't a great test, but it's hard to get more canonical
62
+ # confirmation that the timer is cancelled
63
+ assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer))
64
+
65
+ EM.stop
66
+ }
67
+ }
68
+ end
69
+
70
+ def test_failure_timer_cleanup
71
+ EM.run {
72
+ d = EM::DNS::Resolver.resolve "asdfasdf"
73
+ d.callback { assert false }
74
+ d.errback {
75
+ assert_nil(EM::DNS::Resolver.socket.instance_variable_get(:@timer))
50
76
 
51
77
  EM.stop
52
78
  }
53
79
  }
54
80
  end
55
- end
81
+ end
@@ -8,7 +8,6 @@ class TestSSLMethods < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  module ServerHandler
11
-
12
11
  def post_init
13
12
  start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt', :verify_peer => true)
14
13
  end
@@ -24,7 +23,6 @@ class TestSSLMethods < Test::Unit::TestCase
24
23
  end
25
24
 
26
25
  module ClientHandler
27
-
28
26
  def post_init
29
27
  start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
30
28
  end
@@ -34,10 +32,11 @@ class TestSSLMethods < Test::Unit::TestCase
34
32
  $server_cert_value = get_peer_cert
35
33
  EM.stop_event_loop
36
34
  end
37
-
38
35
  end
39
36
 
40
37
  def test_ssl_methods
38
+ omit_unless(EM.ssl?)
39
+ omit_if(rbx?)
41
40
  $server_called_back, $client_called_back = false, false
42
41
  $server_cert_value, $client_cert_value = nil, nil
43
42
 
@@ -53,4 +52,4 @@ class TestSSLMethods < Test::Unit::TestCase
53
52
  assert_equal($client_cert_from_file, $client_cert_value.gsub("\r", ""))
54
53
  end
55
54
 
56
- end if EM.ssl?
55
+ end
@@ -1,82 +1,82 @@
1
1
  require 'em_test_helper'
2
2
 
3
- if EM.ssl?
4
- class TestSslVerify < Test::Unit::TestCase
5
- def setup
6
- $dir = File.dirname(File.expand_path(__FILE__)) + '/'
7
- $cert_from_file = File.read($dir+'client.crt')
8
- end
3
+ class TestSslVerify < Test::Unit::TestCase
4
+ def setup
5
+ $dir = File.dirname(File.expand_path(__FILE__)) + '/'
6
+ $cert_from_file = File.read($dir+'client.crt')
7
+ end
9
8
 
10
- module Client
11
- def connection_completed
12
- start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
13
- end
9
+ module Client
10
+ def connection_completed
11
+ start_tls(:private_key_file => $dir+'client.key', :cert_chain_file => $dir+'client.crt')
12
+ end
14
13
 
15
- def ssl_handshake_completed
16
- $client_handshake_completed = true
17
- close_connection
18
- end
14
+ def ssl_handshake_completed
15
+ $client_handshake_completed = true
16
+ close_connection
17
+ end
19
18
 
20
- def unbind
21
- EM.stop_event_loop
22
- end
19
+ def unbind
20
+ EM.stop_event_loop
23
21
  end
22
+ end
24
23
 
25
- module AcceptServer
26
- def post_init
27
- start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt', :verify_peer => true)
28
- end
24
+ module AcceptServer
25
+ def post_init
26
+ start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt', :verify_peer => true)
27
+ end
29
28
 
30
- def ssl_verify_peer(cert)
31
- $cert_from_server = cert
32
- true
33
- end
29
+ def ssl_verify_peer(cert)
30
+ $cert_from_server = cert
31
+ true
32
+ end
34
33
 
35
- def ssl_handshake_completed
36
- $server_handshake_completed = true
37
- end
34
+ def ssl_handshake_completed
35
+ $server_handshake_completed = true
38
36
  end
37
+ end
39
38
 
40
- module DenyServer
41
- def post_init
42
- start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt', :verify_peer => true)
43
- end
39
+ module DenyServer
40
+ def post_init
41
+ start_tls(:private_key_file => $dir+'server.key', :cert_chain_file => $dir+'server.crt', :verify_peer => true)
42
+ end
44
43
 
45
- def ssl_verify_peer(cert)
46
- $cert_from_server = cert
47
- # Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed.
48
- false
49
- end
44
+ def ssl_verify_peer(cert)
45
+ $cert_from_server = cert
46
+ # Do not accept the peer. This should now cause the connection to shut down without the SSL handshake being completed.
47
+ false
48
+ end
50
49
 
51
- def ssl_handshake_completed
52
- $server_handshake_completed = true
53
- end
50
+ def ssl_handshake_completed
51
+ $server_handshake_completed = true
54
52
  end
53
+ end
55
54
 
56
- def test_accept_server
57
- $client_handshake_completed, $server_handshake_completed = false, false
58
- EM.run {
59
- EM.start_server("127.0.0.1", 16784, AcceptServer)
60
- EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature")
61
- }
55
+ def test_accept_server
56
+ omit_unless(EM.ssl?)
57
+ omit_if(rbx?)
58
+ $client_handshake_completed, $server_handshake_completed = false, false
59
+ EM.run {
60
+ EM.start_server("127.0.0.1", 16784, AcceptServer)
61
+ EM.connect("127.0.0.1", 16784, Client).instance_variable_get("@signature")
62
+ }
62
63
 
63
- assert_equal($cert_from_file, $cert_from_server.gsub("\r", ""))
64
- assert($client_handshake_completed)
65
- assert($server_handshake_completed)
66
- end
64
+ assert_equal($cert_from_file, $cert_from_server.gsub("\r", ""))
65
+ assert($client_handshake_completed)
66
+ assert($server_handshake_completed)
67
+ end
67
68
 
68
- def test_deny_server
69
- $client_handshake_completed, $server_handshake_completed = false, false
70
- EM.run {
71
- EM.start_server("127.0.0.1", 16784, DenyServer)
72
- EM.connect("127.0.0.1", 16784, Client)
73
- }
69
+ def test_deny_server
70
+ omit_unless(EM.ssl?)
71
+ omit_if(rbx?)
72
+ $client_handshake_completed, $server_handshake_completed = false, false
73
+ EM.run {
74
+ EM.start_server("127.0.0.1", 16784, DenyServer)
75
+ EM.connect("127.0.0.1", 16784, Client)
76
+ }
74
77
 
75
- assert_equal($cert_from_file, $cert_from_server.gsub("\r", ""))
76
- assert(!$client_handshake_completed)
77
- assert(!$server_handshake_completed)
78
- end
78
+ assert_equal($cert_from_file, $cert_from_server.gsub("\r", ""))
79
+ assert(!$client_handshake_completed)
80
+ assert(!$server_handshake_completed)
79
81
  end
80
- else
81
- warn "EM built without SSL support, skipping tests in #{__FILE__}"
82
82
  end
@@ -15,6 +15,10 @@ class TestThreadedResource < Test::Unit::TestCase
15
15
 
16
16
  def test_dispatch_completion
17
17
  EM.run do
18
+ EM.add_timer(3) do
19
+ EM.stop
20
+ fail 'Resource dispatch timed out'
21
+ end
18
22
  completion = resource.dispatch do |o|
19
23
  o[:foo] = :bar
20
24
  :foo
@@ -23,6 +27,10 @@ class TestThreadedResource < Test::Unit::TestCase
23
27
  assert_equal :foo, result
24
28
  EM.stop
25
29
  end
30
+ completion.errback do |error|
31
+ EM.stop
32
+ fail "Unexpected error: #{error.message}"
33
+ end
26
34
  end
27
35
  assert_equal :bar, object[:foo]
28
36
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-em
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0.beta
5
5
  platform: java
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -9,36 +9,50 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-05 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake-compiler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ name: test-unit
21
+ prerelease: false
22
+ type: :development
16
23
  version_requirements: !ruby/object:Gem::Requirement
17
24
  requirements:
18
25
  - - ~>
19
26
  - !ruby/object:Gem::Version
20
- version: 0.8.3
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
21
29
  requirement: !ruby/object:Gem::Requirement
22
30
  requirements:
23
31
  - - ~>
24
32
  - !ruby/object:Gem::Version
25
33
  version: 0.8.3
34
+ name: rake-compiler
26
35
  prerelease: false
27
36
  type: :development
28
- - !ruby/object:Gem::Dependency
29
- name: yard
30
37
  version_requirements: !ruby/object:Gem::Requirement
31
38
  requirements:
32
- - - '>='
39
+ - - ~>
33
40
  - !ruby/object:Gem::Version
34
- version: 0.8.5.2
41
+ version: 0.8.3
42
+ - !ruby/object:Gem::Dependency
35
43
  requirement: !ruby/object:Gem::Requirement
36
44
  requirements:
37
45
  - - '>='
38
46
  - !ruby/object:Gem::Version
39
47
  version: 0.8.5.2
48
+ name: yard
40
49
  prerelease: false
41
50
  type: :development
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.8.5.2
42
56
  description: |-
43
57
  EventMachine implements a fast, single-threaded engine for arbitrary network
44
58
  communications. It's extremely easy to use in Ruby. EventMachine wraps all
@@ -196,6 +210,7 @@ files:
196
210
  - tests/test_channel.rb
197
211
  - tests/test_completion.rb
198
212
  - tests/test_connection_count.rb
213
+ - tests/test_connection_write.rb
199
214
  - tests/test_defer.rb
200
215
  - tests/test_deferrable.rb
201
216
  - tests/test_epoll.rb
@@ -215,6 +230,7 @@ files:
215
230
  - tests/test_line_protocol.rb
216
231
  - tests/test_ltp.rb
217
232
  - tests/test_ltp2.rb
233
+ - tests/test_many_fds.rb
218
234
  - tests/test_next_tick.rb
219
235
  - tests/test_object_protocol.rb
220
236
  - tests/test_pause.rb
@@ -246,6 +262,7 @@ files:
246
262
  - tests/test_timers.rb
247
263
  - tests/test_ud.rb
248
264
  - tests/test_unbind_reason.rb
265
+ - tmp/java/rubyeventmachine/.build
249
266
  - lib/rubyeventmachine.jar
250
267
  homepage: http://rubyeventmachine.com
251
268
  licenses:
@@ -271,9 +288,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
288
  version: '0'
272
289
  required_rubygems_version: !ruby/object:Gem::Requirement
273
290
  requirements:
274
- - - '>='
291
+ - - '>'
275
292
  - !ruby/object:Gem::Version
276
- version: '0'
293
+ version: 1.3.1
277
294
  requirements: []
278
295
  rubyforge_project: eventmachine
279
296
  rubygems_version: 2.1.9