From 21a47b8db9ca7059586cfaf59609e5255c87b4b0 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Thu, 2 Jun 2016 10:43:06 -0400 Subject: [PATCH] Fix an issue when data was not present in the collector When you ran this test in isolation it failed to find the corresponding metric, Changed the behavior to force a collect before running the tests. Fixes #5446 --- .../spec/logstash/instrument/periodic_poller/jvm_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/logstash-core/spec/logstash/instrument/periodic_poller/jvm_spec.rb b/logstash-core/spec/logstash/instrument/periodic_poller/jvm_spec.rb index 649e711d1..7506d3516 100644 --- a/logstash-core/spec/logstash/instrument/periodic_poller/jvm_spec.rb +++ b/logstash-core/spec/logstash/instrument/periodic_poller/jvm_spec.rb @@ -1,8 +1,10 @@ -require 'spec_helper' -require 'logstash/instrument/periodic_poller/jvm' +# encoding: utf-8 +require "spec_helper" +require "logstash/instrument/periodic_poller/jvm" +require "logstash/instrument/collector" describe LogStash::Instrument::PeriodicPoller::JVM do - let(:metric) { LogStash::Instrument::Metric.new } + let(:metric) { LogStash::Instrument::Metric.new(LogStash::Instrument::Collector.new) } let(:options) { {} } subject(:jvm) { described_class.new(metric, options) } @@ -18,6 +20,7 @@ describe LogStash::Instrument::PeriodicPoller::JVM do end describe "metrics" do + before(:each) { jvm.collect } let(:snapshot_store) { metric.collector.snapshot_metric.metric_store } subject(:jvm_metrics) { snapshot_store.get_shallow(:jvm, :process) }