spec/outputs/statsd_spec.rb in logstash-output-statsd-1.1.0 vs spec/outputs/statsd_spec.rb in logstash-output-statsd-1.1.1

- old
+ new

@@ -3,11 +3,12 @@ require_relative "../spec_helper" describe LogStash::Outputs::Statsd do let(:host) { "localhost" } - let(:port) { @server.port } + let(:port) { rand(2000..10000) } + let!(:server) { StatsdServer.new.run(port) } describe "registration and teardown" do it "should register without errors" do output = LogStash::Plugin.lookup("output", "statsd").new @@ -36,10 +37,15 @@ subject.register end it "should receive data send to the server" do subject.receive(event) - expect(@server.received).to include("logstash.spec.foo.bar:0.1|c") + # Since we are dealing with threads and networks, + # we might experience delays or timing issues. + # lets try a few times before giving up completely. + try { + expect(server.received).to include("logstash.spec.foo.bar:0.1|c") + } end end end