Sha256: f55c1fc76eafed32f8b888cacd59cc766daeb40d6e00874db748154834330ae2

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 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
    subject.metric = 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

20 entries across 20 versions & 4 rubygems

Version Path
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/logstash-core-5.0.0-java/spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.2-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.1-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.pre.rc1-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.pre.beta1-java spec/logstash/inputs/metrics_spec.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/logstash-core-5.0.0.alpha6.snapshot5-java/spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha6.snapshot5-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha6.snapshot4-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha6.snapshot3-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha6.snapshot2-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha6.snapshot1-java spec/logstash/inputs/metrics_spec.rb
logstash-core-5.0.0.alpha5.snapshot1-java spec/logstash/inputs/metrics_spec.rb