changes after review

Fixes #5917
This commit is contained in:
Suyog Rao 2016-09-20 15:37:59 -07:00
parent 4008a7ad7e
commit dfd6164edd
14 changed files with 55 additions and 30 deletions

View file

@ -6,5 +6,9 @@ set -e
# installing gems. See https://github.com/elastic/logstash/issues/5179 # installing gems. See https://github.com/elastic/logstash/issues/5179
export JRUBY_OPTS="-J-Xmx1g" export JRUBY_OPTS="-J-Xmx1g"
rake test:install-default rm -rf build/*
rake test:integration rake artifact:tar
cd build
tar xvf *.tar.gz
cd ../qa/integration
rspec

1
qa/integration/.rspec Normal file
View file

@ -0,0 +1 @@
--default-path specs/

View file

@ -12,13 +12,13 @@ config: |-
} }
} }
output { output {
#file { file {
# path => "kafka_input.output" path => "kafka_input.output"
# flush_interval => 0 flush_interval => 0
# codec => line { format => "%{message}" } codec => line { format => "%{message}" }
#} }
} }
input: how_sample.input input: how_sample.input
setup_script: download_input.sh actual_output: kafka_input.output
teardown_script: teardown_script:

View file

@ -57,7 +57,7 @@ class Fixture
end end
def teardown def teardown
File.delete(@actual_output) if @settings.is_set?(@actual_output) && output_exists? File.delete(@actual_output) if @settings.is_set?("actual_output") && output_exists?
puts "Tearing down services" puts "Tearing down services"
services = @settings.get("services") services = @settings.get("services")
services.each do |name| services.each do |name|

View file

@ -15,6 +15,11 @@ class TestSettings
@suite_settings = YAML.load_file(SUITE_SETTINGS_FILE) @suite_settings = YAML.load_file(SUITE_SETTINGS_FILE)
# Per test settings, where one can override stuff and define test specific config # Per test settings, where one can override stuff and define test specific config
@test_settings = YAML.load_file(@tests_settings_file) @test_settings = YAML.load_file(@tests_settings_file)
if verbose_mode?
puts "Test settings file: #{@tests_settings_file}"
puts "Suite settings file: #{SUITE_SETTINGS_FILE}"
end
if is_set?("config") if is_set?("config")
if get("config").is_a?(Hash) if get("config").is_a?(Hash)
@ -37,6 +42,10 @@ class TestSettings
@suite_settings[key] @suite_settings[key]
end end
end end
def verbose_mode?
@suite_settings["verbose_mode"]
end
def is_set?(key) def is_set?(key)
@suite_settings.key?(key) || @test_settings.key?(key) @suite_settings.key?(key) || @test_settings.key?(key)

View file

@ -22,7 +22,7 @@ setup_es() {
start_es() { start_es() {
es_args=$@ es_args=$@
$current_dir/elasticsearch/bin/elasticsearch $es_args -p $current_dir/elasticsearch.pid > /tmp/elasticsearch.log 2>/dev/null & $current_dir/elasticsearch/bin/elasticsearch $es_args -p $current_dir/elasticsearch/elasticsearch.pid > /tmp/elasticsearch.log 2>/dev/null &
count=120 count=120
echo "Waiting for elasticsearch to respond..." echo "Waiting for elasticsearch to respond..."
while ! curl --silent localhost:9200 && [[ $count -ne 0 ]]; do while ! curl --silent localhost:9200 && [[ $count -ne 0 ]]; do

View file

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
set -ex
my_dir="$(dirname "$0")" current_dir="$(dirname "$0")"
stop_es() { stop_es() {
pid=$(cat $current_dir/elasticsearch.pid) pid=$(cat $current_dir/elasticsearch/elasticsearch.pid)
[ "x$pid" != "x" ] && [ "$pid" -gt 0 ] [ "x$pid" != "x" ] && [ "$pid" -gt 0 ]
kill -SIGTERM $pid kill -SIGTERM $pid
} }

View file

@ -33,5 +33,5 @@ start_kafka
# Set up topics # Set up topics
$current_dir/kafka/bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic logstash_topic_plain --zookeeper localhost:2181 $current_dir/kafka/bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic logstash_topic_plain --zookeeper localhost:2181
cat $current_dir/kafka_input.input | $current_dir/kafka/bin/kafka-console-producer.sh --topic logstash_topic_plain --broker-list localhost:9092 cat $current_dir/../fixtures/how_sample.input | $current_dir/kafka/bin/kafka-console-producer.sh --topic logstash_topic_plain --broker-list localhost:9092
echo "Kafka Setup complete" echo "Kafka Setup complete"

View file

@ -8,7 +8,7 @@ require 'yaml'
# A locally started Logstash service # A locally started Logstash service
class LogstashService < Service class LogstashService < Service
LS_VERSION_FILE = File.expand_path(File.join("../../../",versions.yml), __FILE__) LS_VERSION_FILE = File.expand_path(File.join("../../../../", "versions.yml"), __FILE__)
LS_BIN = "bin/logstash" LS_BIN = "bin/logstash"
STDIN_CONFIG = "input {stdin {}} output { }" STDIN_CONFIG = "input {stdin {}} output { }"

View file

@ -6,7 +6,7 @@ require "rspec/wait"
require "yaml" require "yaml"
require "fileutils" require "fileutils"
describe "Beat Input", :integration => true do describe "Beat Input" do
before(:all) do before(:all) do
@fixture = Fixture.new(__FILE__) @fixture = Fixture.new(__FILE__)
end end

View file

@ -2,7 +2,7 @@ require_relative '../framework/fixture'
require_relative '../framework/settings' require_relative '../framework/settings'
require_relative '../services/logstash_service' require_relative '../services/logstash_service'
describe "a config which indexes data into Elasticsearch", :integration => true do describe "a config which indexes data into Elasticsearch" do
before(:all) { before(:all) {
@fixture = Fixture.new(__FILE__) @fixture = Fixture.new(__FILE__)

View file

@ -3,7 +3,7 @@ require_relative '../framework/settings'
require_relative '../services/logstash_service' require_relative '../services/logstash_service'
require "rspec/wait" require "rspec/wait"
describe "Kafka Input", :integration => true do describe "Kafka Input" do
let(:timeout_seconds) { 5 } let(:timeout_seconds) { 5 }
before(:all) { before(:all) {
@fixture = Fixture.new(__FILE__) @fixture = Fixture.new(__FILE__)
@ -17,10 +17,9 @@ describe "Kafka Input", :integration => true do
logstash_service = @fixture.get_service("logstash") logstash_service = @fixture.get_service("logstash")
logstash_service.start_background(@fixture.config) logstash_service.start_background(@fixture.config)
# TODO: File Output is busted so this test fails wait(timeout_seconds).for { @fixture.output_exists? }.to be true
#wait(timeout_seconds).for { @fixture.output_exists? }.to be true expect(@fixture.output_equals_expected?).to be true
#expect(@fixture.output_equals_expected?).to be true, lambda { "Expected File output to match what was ingested into Kafka." }
# lambda { "Expected File output to match what was ingested into Kafka." }
end end
end end

View file

@ -3,7 +3,7 @@ require_relative '../framework/settings'
require_relative '../services/logstash_service' require_relative '../services/logstash_service'
require "logstash/devutils/rspec/spec_helper" require "logstash/devutils/rspec/spec_helper"
describe "Monitoring API", :integration => true do describe "Monitoring API" do
before(:all) { before(:all) {
@fixture = Fixture.new(__FILE__) @fixture = Fixture.new(__FILE__)
} }
@ -11,15 +11,25 @@ describe "Monitoring API", :integration => true do
after(:all) { after(:all) {
@fixture.teardown @fixture.teardown
} }
let(:number_of_events) { 5 }
let(:max_retry) { 120 }
it "can retrieve event stats" do it "can retrieve event stats" do
logstash_service = @fixture.get_service("logstash") logstash_service = @fixture.get_service("logstash")
logstash_service.start_with_stdin logstash_service.start_with_stdin
5.times { logstash_service.write_to_stdin("Hello world") } number_of_events.times { logstash_service.write_to_stdin("Hello world") }
# check metrics
result = logstash_service.monitoring_api.event_stats begin
try { expect(result["in"]).to eq(5) } sleep(1) while (result = logstash_service.monitoring_api.event_stats).nil?
expect(result["in"]).to eq(5) rescue
retry
end
Stud.try(max_retry.times, RSpec::Expectations::ExpectationNotMetError) do
result = logstash_service.monitoring_api.event_stats
expect(result["in"]).to eq(number_of_events)
end
end end
end end

View file

@ -1,4 +1,6 @@
--- ---
ls_version: 5.0.0-alpha6 # Use this to output more debug-level information
snapshot: true verbose_mode: false
# Typically we use the binaries in LS_HOME/build. If you want to QA a LS in different location,
# use the absolute path below
#ls_home_abs_path: /tmp/logstash-5.0.0-alpha6 #ls_home_abs_path: /tmp/logstash-5.0.0-alpha6