loggregator_emitter 0.0.15.pre → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- loggregator_emitter (0.0.15.pre)
4
+ loggregator_emitter (0.0.16)
5
5
  beefcake (~> 0.3.7)
6
6
 
7
7
  GEM
@@ -31,10 +31,10 @@ module LoggregatorEmitter
31
31
  end
32
32
 
33
33
  def emit_message(app_id, message, type)
34
- if app_id
35
- lm = create_log_message(app_id, message, type)
36
- send_message(lm)
37
- end
34
+ return unless app_id && message && message.strip.length > 0
35
+
36
+ lm = create_log_message(app_id, message, type)
37
+ send_message(lm)
38
38
  end
39
39
 
40
40
  def create_log_message(app_id, message, type)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "loggregator_emitter"
5
- spec.version = '0.0.15.pre'
5
+ spec.version = '0.0.16'
6
6
  spec.authors = ["Pivotal"]
7
7
  spec.email = ["cf-eng@pivotallabs.com"]
8
8
  spec.description = "Library to emit data to Loggregator"
@@ -53,13 +53,17 @@ describe LoggregatorEmitter do
53
53
  @server.start
54
54
  end
55
55
 
56
+ after do
57
+ @server.stop
58
+ end
59
+
56
60
  it "successfully writes protobuffers using ipv4" do
57
61
  emitter = make_emitter("0.0.0.0")
58
62
  emitter.send(emit_method, "my_app_id", "Hello there!")
59
63
  emitter.send(emit_method, "my_app_id", "Hello again!")
60
64
  emitter.send(emit_method, nil, "Hello again!")
61
65
 
62
- @server.wait_for_messages_and_stop(2)
66
+ @server.wait_for_messages(2)
63
67
 
64
68
  messages = @server.messages
65
69
 
@@ -79,7 +83,7 @@ describe LoggregatorEmitter do
79
83
  emitter = make_emitter("::1")
80
84
  emitter.send(emit_method, "my_app_id", "Hello there!")
81
85
 
82
- @server.wait_for_messages_and_stop(1)
86
+ @server.wait_for_messages(1)
83
87
 
84
88
  messages = @server.messages
85
89
  expect(messages.length).to eq 1
@@ -90,25 +94,43 @@ describe LoggregatorEmitter do
90
94
  emitter = make_emitter("localhost")
91
95
  emitter.send(emit_method, "my_app_id", "Hello there!")
92
96
 
93
- @server.wait_for_messages_and_stop(1)
97
+ @server.wait_for_messages(1)
94
98
 
95
99
  messages = @server.messages
96
100
  expect(messages.length).to eq 1
97
101
  expect(messages[0].message).to eq "Hello there!"
98
102
  end
103
+
104
+ it "swallows empty messages" do
105
+ emitter = make_emitter("localhost")
106
+ emitter.send(emit_method, "my_app_id", nil)
107
+ emitter.send(emit_method, "my_app_id", "")
108
+ emitter.send(emit_method, "my_app_id", " ")
109
+
110
+ sleep 0.5
111
+
112
+ messages = @server.messages
113
+ expect(messages.length).to eq 0
114
+ end
99
115
  end
100
116
  end
101
117
 
102
118
  describe "source id" do
103
- let(:emit_message) do
104
- server = FakeLoggregatorServer.new(free_port)
105
- server.start
119
+ before do
120
+ @server = FakeLoggregatorServer.new(free_port)
121
+ @server.start
122
+ end
106
123
 
107
- @emitter.emit_error("my_app_id", "Hello there!")
124
+ after do
125
+ @server.stop
126
+ end
127
+
128
+ let(:emit_message) do
129
+ @emitter.emit_error("my_app_id", "Hello there!")
108
130
 
109
- server.wait_for_messages_and_stop(2)
131
+ @server.wait_for_messages(2)
110
132
 
111
- server.messages[0]
133
+ @server.messages[0]
112
134
  end
113
135
 
114
136
  it "can be nil" do
@@ -19,14 +19,16 @@ class FakeLoggregatorServer
19
19
  bind_and_record(0, @sockets[1], "::1")
20
20
  end
21
21
 
22
- def wait_for_messages_and_stop(number_expected_messages)
22
+ def wait_for_messages(number_expected_messages)
23
23
  max_tries = 0
24
24
  while messages.length < number_expected_messages
25
25
  sleep 0.2
26
26
  max_tries += 1
27
27
  break if max_tries > 10
28
28
  end
29
+ end
29
30
 
31
+ def stop
30
32
  @sockets.each { |socket| socket.close}
31
33
  @threads.each { |thread| Thread.kill(thread) }
32
34
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggregator_emitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15.pre
5
- prerelease: 7
4
+ version: 0.0.16
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pivotal
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-09 00:00:00.000000000 Z
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
@@ -114,9 +114,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
117
- - - ! '>'
117
+ - - ! '>='
118
118
  - !ruby/object:Gem::Version
119
- version: 1.3.1
119
+ version: '0'
120
+ segments:
121
+ - 0
122
+ hash: -297387469996156866
120
123
  requirements: []
121
124
  rubyforge_project:
122
125
  rubygems_version: 1.8.25