Sha256: 761ba529d82e744832779611a1e6c25b6cd910f2dc391da4281a88adfa3c6305
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
# encoding: utf-8 require "logstash/inputs/metrics" require "spec_helper" describe LogStash::Inputs::Metrics do let(:collector) { LogStash::Instrument::Collector.new } let(:metric) { LogStash::Instrument::Metric.new(collector) } let(:queue) { [] } before :each do allow(subject).to receive(:metric).and_return(metric) end describe "#run" do it "should register itself to the collector observer" do expect(collector).to receive(:add_observer).with(subject) t = Thread.new { subject.run(queue) } sleep(0.1) # give a bit of time to the thread to start subject.stop end end describe "#update" do it "should fill up the queue with received events" do Thread.new { subject.run(queue) } sleep(0.1) subject.stop metric.increment([:root, :test], :plugin) subject.update(collector.snapshot_metric) expect(queue.count).to eq(1) end end describe "#stop" do it "should remove itself from the the collector observer" do expect(collector).to receive(:delete_observer).with(subject) t = Thread.new { subject.run(queue) } sleep(0.1) # give a bit of time to the thread to start subject.stop end it "should unblock the input" do t = Thread.new { subject.run(queue) } sleep(0.1) # give a bit of time to the thread to start subject.do_stop wait_for { t.status }.to be_falsey end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logstash-core-5.0.0.alpha4.snapshot3-java | spec/logstash/inputs/metrics_spec.rb |
logstash-core-5.0.0.alpha4.snapshot2-java | spec/logstash/inputs/metrics_spec.rb |