add ExpectationNotMetError to Stud.try on monitoring_api_spec

in some tests against metrics api it's possible the values aren't there,
making the assertion fail. By default Stud.try only catches StandardError,
but rspec throws a RSpec::Expectations::ExpectationNotMetError on a failed
assertion, and this exception inherits directly from Exception.

This commit explicitly adds this exception to the list of Stud.try exceptions

Fixes #7177
This commit is contained in:
Joao Duarte 2017-05-22 10:55:45 +01:00 committed by João Duarte
parent 7537b62c8d
commit 412dd7bc08

View file

@ -26,7 +26,7 @@ describe "Test Monitoring API" do
logstash_service.wait_for_logstash
number_of_events.times { logstash_service.write_to_stdin("Hello world") }
Stud.try(max_retry.times) do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
# event_stats can fail if the stats subsystem isn't ready
result = logstash_service.monitoring_api.event_stats rescue nil
expect(result).not_to be_nil
@ -39,7 +39,7 @@ describe "Test Monitoring API" do
logstash_service.start_with_stdin
logstash_service.wait_for_logstash
Stud.try(max_retry.times) do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
# node_stats can fail if the stats subsystem isn't ready
result = logstash_service.monitoring_api.node_stats rescue nil
expect(result).not_to be_nil
@ -53,7 +53,7 @@ describe "Test Monitoring API" do
logstash_service.start_with_stdin
logstash_service.wait_for_logstash
Stud.try(max_retry.times) do
Stud.try(max_retry.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
# node_stats can fail if the stats subsystem isn't ready
result = logstash_service.monitoring_api.node_stats rescue nil
expect(result).not_to be_nil