sensu-transport 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sensu/transport/rabbitmq.rb +2 -1
- data/sensu-transport.gemspec +1 -1
- data/spec/base_spec.rb +22 -22
- data/spec/rabbitmq_spec.rb +36 -21
- data/spec/transport_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243e8eb1bf19bad3b76515bcebad17dcaf132534
|
4
|
+
data.tar.gz: a193c06b33d7b5d33b3e72cc4aafc1a1f7117ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1096bd23af4e5ad5166ca99477b02da0144e7370b3f72131e56bbfb8ff990d140e2bf5fa44a55752e48ae5c5d2dafc359fc24c89f58b69fe40bf7e6ef486dcf
|
7
|
+
data.tar.gz: 4597ad573b8c4edd1193d2d43520976e89cc55d3b147a4ea09b5457b568e0879615aaf6e7468d674b3639f0ef4dd5444e5866190e71d69d84f1ff0f52a3f4b38
|
data/sensu-transport.gemspec
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -9,31 +9,31 @@ describe "Sensu::Transport::Base" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "provides a transport API (noop)" do
|
12
|
-
@transport.
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
expect(@transport).to respond_to(:on_error, :before_reconnect, :after_reconnect,
|
13
|
+
:connect, :reconnect, :connected?, :close,
|
14
|
+
:publish, :subscribe, :unsubscribe,
|
15
|
+
:acknowledge, :ack, :stats)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "behaves as expected" do
|
19
19
|
callback = Proc.new { true }
|
20
|
-
@transport.on_error(&callback).
|
21
|
-
@transport.before_reconnect(&callback).
|
22
|
-
@transport.after_reconnect(&callback).
|
23
|
-
@transport.connect.
|
24
|
-
@transport.connect({}).
|
25
|
-
@transport.reconnect.
|
26
|
-
@transport.connected
|
27
|
-
@transport.close.
|
28
|
-
@transport.publish("foo", "bar", "baz").
|
29
|
-
@transport.publish("foo", "bar", "baz", {}, &callback).
|
30
|
-
@transport.subscribe("foo", "bar", nil, {}, &callback).
|
31
|
-
@transport.unsubscribe.
|
32
|
-
@transport.unsubscribe(&callback).
|
33
|
-
@transport.acknowledge({}).
|
34
|
-
@transport.ack({}).
|
35
|
-
@transport.acknowledge({}, &callback).
|
36
|
-
@transport.ack({}, &callback).
|
37
|
-
@transport.stats("foo", &callback).
|
20
|
+
expect(@transport.on_error(&callback)).to be_kind_of(Proc)
|
21
|
+
expect(@transport.before_reconnect(&callback)).to be_an_instance_of(Proc)
|
22
|
+
expect(@transport.after_reconnect(&callback)).to be_an_instance_of(Proc)
|
23
|
+
expect(@transport.connect).to eq(nil)
|
24
|
+
expect(@transport.connect({})).to eq(nil)
|
25
|
+
expect(@transport.reconnect).to eq(nil)
|
26
|
+
expect(@transport.connected?).to eq(false)
|
27
|
+
expect(@transport.close).to eq(nil)
|
28
|
+
expect(@transport.publish("foo", "bar", "baz")).to eq(nil)
|
29
|
+
expect(@transport.publish("foo", "bar", "baz", {}, &callback)).to eq(true)
|
30
|
+
expect(@transport.subscribe("foo", "bar", nil, {}, &callback)).to eq(true)
|
31
|
+
expect(@transport.unsubscribe).to eq(nil)
|
32
|
+
expect(@transport.unsubscribe(&callback)).to eq(true)
|
33
|
+
expect(@transport.acknowledge({})).to eq(nil)
|
34
|
+
expect(@transport.ack({})).to eq(nil)
|
35
|
+
expect(@transport.acknowledge({}, &callback)).to eq(true)
|
36
|
+
expect(@transport.ack({}, &callback)).to eq(true)
|
37
|
+
expect(@transport.stats("foo", &callback)).to eq(true)
|
38
38
|
end
|
39
39
|
end
|
data/spec/rabbitmq_spec.rb
CHANGED
@@ -12,17 +12,17 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "provides a transport API" do
|
15
|
-
@transport.
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
expect(@transport).to respond_to(:on_error, :before_reconnect, :after_reconnect,
|
16
|
+
:connect, :reconnect, :connected?, :close,
|
17
|
+
:publish, :subscribe, :unsubscribe,
|
18
|
+
:acknowledge, :ack, :stats)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "can publish and subscribe" do
|
22
22
|
async_wrapper do
|
23
23
|
@transport.connect
|
24
24
|
callback = Proc.new do |message|
|
25
|
-
message.
|
25
|
+
expect(message).to eq("msg")
|
26
26
|
timer(0.5) do
|
27
27
|
async_done
|
28
28
|
end
|
@@ -31,8 +31,8 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
31
31
|
@transport.subscribe("direct", "bar", "baz", {}, &callback)
|
32
32
|
timer(1) do
|
33
33
|
@transport.publish("direct", "foo", "msg") do |info|
|
34
|
-
info.
|
35
|
-
info.
|
34
|
+
expect(info).to be_kind_of(Hash)
|
35
|
+
expect(info).to be_empty
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -47,7 +47,22 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
47
47
|
timer(1) do
|
48
48
|
@transport.unsubscribe do
|
49
49
|
@transport.close
|
50
|
-
@transport.connected
|
50
|
+
expect(@transport.connected?).to be(false)
|
51
|
+
async_done
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "can open and close the connection immediately" do
|
58
|
+
async_wrapper do
|
59
|
+
@transport.connect
|
60
|
+
@transport.close
|
61
|
+
expect(@transport.connected?).to be(false)
|
62
|
+
EM.next_tick do
|
63
|
+
expect(@transport.connected?).to be(false)
|
64
|
+
timer(1) do
|
65
|
+
expect(@transport.connected?).to be(false)
|
51
66
|
async_done
|
52
67
|
end
|
53
68
|
end
|
@@ -66,8 +81,8 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
66
81
|
end
|
67
82
|
timer(1) do
|
68
83
|
@transport.publish("direct", "foo", "msg") do |info|
|
69
|
-
info.
|
70
|
-
info.
|
84
|
+
expect(info).to be_kind_of(Hash)
|
85
|
+
expect(info).to be_empty
|
71
86
|
end
|
72
87
|
end
|
73
88
|
end
|
@@ -77,9 +92,9 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
77
92
|
async_wrapper do
|
78
93
|
@transport.connect
|
79
94
|
@transport.stats("bar") do |info|
|
80
|
-
info.
|
81
|
-
info[:messages].
|
82
|
-
info[:consumers].
|
95
|
+
expect(info).to be_kind_of(Hash)
|
96
|
+
expect(info[:messages]).to eq(0)
|
97
|
+
expect(info[:consumers]).to eq(0)
|
83
98
|
async_done
|
84
99
|
end
|
85
100
|
end
|
@@ -88,7 +103,7 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
88
103
|
it "can fail to connect" do
|
89
104
|
async_wrapper do
|
90
105
|
@transport.connect(:port => 5555)
|
91
|
-
@transport.connected
|
106
|
+
expect(@transport.connected?).to be(false)
|
92
107
|
async_done
|
93
108
|
end
|
94
109
|
end
|
@@ -97,14 +112,14 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
97
112
|
ssl_dir = File.join(File.dirname(__FILE__), "assets", "ssl", "client")
|
98
113
|
async_wrapper do
|
99
114
|
@transport.connect(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
115
|
+
:port => 5671,
|
116
|
+
:ssl => {
|
117
|
+
:cert_chain_file => File.join(ssl_dir, "cert.pem"),
|
118
|
+
:private_key_file => File.join(ssl_dir, "key.pem")
|
119
|
+
}
|
120
|
+
)
|
106
121
|
timer(2) do
|
107
|
-
@transport.connected
|
122
|
+
expect(@transport.connected?).to be(true)
|
108
123
|
async_done
|
109
124
|
end
|
110
125
|
end
|
data/spec/transport_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe "Sensu::Transport" do
|
|
10
10
|
options = {}
|
11
11
|
transport = Sensu::Transport.connect("rabbitmq", options)
|
12
12
|
timer(1) do
|
13
|
-
transport.connected
|
13
|
+
expect(transport.connected?).to be(true)
|
14
14
|
async_done
|
15
15
|
end
|
16
16
|
end
|
@@ -21,8 +21,8 @@ describe "Sensu::Transport" do
|
|
21
21
|
logger = Logger.new(STDOUT)
|
22
22
|
Sensu::Transport.logger = logger
|
23
23
|
transport = Sensu::Transport.connect("rabbitmq")
|
24
|
-
transport.logger.
|
25
|
-
transport.logger.
|
24
|
+
expect(transport.logger).to eq(logger)
|
25
|
+
expect(transport.logger).to respond_to(:error)
|
26
26
|
async_done
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-em
|