diff --git a/.travis.yml b/.travis.yml index 5457ec761..702460c6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,18 @@ rvm: - jruby-1.7.25 jdk: - oraclejdk8 +env: + - INTEGRATION=true +before_install: + # Force bundler 1.12.5 because version 1.13 has issues, see https://github.com/fastlane/fastlane/issues/6065#issuecomment-246044617 + - gem uninstall -i /home/travis/.rvm/gems/jruby-1.7.25@global bundler + - gem install bundler -v 1.12.5 --no-rdoc --no-ri --no-document --quiet install: - rake test:install-core + - ci/travis_integration_install.sh before_script: - echo "--order rand" > .rspec - echo "--format documentation" >> .rspec -script: rake test:core +script: + - rake test:core + - ci/travis_integration_run.sh diff --git a/ci/ci_integration.sh b/ci/ci_integration.sh index 088a1884b..ff343cf84 100755 --- a/ci/ci_integration.sh +++ b/ci/ci_integration.sh @@ -6,9 +6,18 @@ set -e # installing gems. See https://github.com/elastic/logstash/issues/5179 export JRUBY_OPTS="-J-Xmx1g" -rm -rf build/* +echo "Running integration tests from qa/integration" +if [[ ! -d "build" ]]; then + mkdir build +fi +rm -rf build/* +echo "Building logstash tar file in build/" rake artifact:tar cd build -tar xvf *.tar.gz +echo "Extracting logstash tar file in build/" +tar xf *.tar.gz cd ../qa/integration +# to install test dependencies +bundle install +# runs all tests rspec diff --git a/ci/travis_integration_install.sh b/ci/travis_integration_install.sh new file mode 100755 index 000000000..2b8a63ac4 --- /dev/null +++ b/ci/travis_integration_install.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -e + +# This file sets up the environment for travis integration tests + + +if [[ "$INTEGRATION" != "true" ]]; then + exit +fi + +echo "Setting up integration tests" +if [[ ! -d "build" ]]; then + mkdir build +fi +rm -rf build/* +echo "Building logstash tar file in build/" +rake artifact:tar +cd build +echo "Extracting logstash tar file in build/" +tar xf *.tar.gz +cd ../qa/integration +pwd +echo $BUNDLE_GEMFILE +# to install test dependencies +bundle install --gemfile="Gemfile" \ No newline at end of file diff --git a/ci/travis_integration_run.sh b/ci/travis_integration_run.sh new file mode 100755 index 000000000..f65c712b1 --- /dev/null +++ b/ci/travis_integration_run.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +if [[ "$INTEGRATION" != "true" ]]; then + exit +fi + +echo "Running integration tests from qa/integration directory" +cd qa/integration +rspec diff --git a/qa/integration/fixtures/beats_input_spec.yml b/qa/integration/fixtures/beats_input_spec.yml index da8811e49..0b1a4161e 100644 --- a/qa/integration/fixtures/beats_input_spec.yml +++ b/qa/integration/fixtures/beats_input_spec.yml @@ -29,5 +29,4 @@ config: } } input: how_sample.input -setup_script: download_input.sh teardown_script: diff --git a/qa/integration/fixtures/download_input.sh b/qa/integration/fixtures/download_input.sh deleted file mode 100755 index 280cfe5ad..000000000 --- a/qa/integration/fixtures/download_input.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -ex -current_dir="$(dirname "$0")" -HOW_DATA_SET_URL=https://s3.amazonaws.com/data.elasticsearch.org/logstash/logs.gz - -if [ ! -f ${current_dir}/how.input ]; then - curl -sL $HOW_DATA_SET_URL > ${current_dir}/logs.gz - gunzip ${current_dir}/logs.gz - mv ${current_dir}/logs ${current_dir}/how.input -fi \ No newline at end of file diff --git a/qa/integration/fixtures/es_output_how_spec.yml b/qa/integration/fixtures/es_output_how_spec.yml index 566e781d0..cf2c436b6 100644 --- a/qa/integration/fixtures/es_output_how_spec.yml +++ b/qa/integration/fixtures/es_output_how_spec.yml @@ -30,6 +30,5 @@ config: |- elasticsearch {} } -input: how.input -setup_script: download_input.sh +input: how_sample.input teardown_script: diff --git a/qa/integration/services/elasticsearch_setup.sh b/qa/integration/services/elasticsearch_setup.sh index 65078ab0d..1172e45b0 100755 --- a/qa/integration/services/elasticsearch_setup.sh +++ b/qa/integration/services/elasticsearch_setup.sh @@ -1,18 +1,18 @@ #!/bin/bash -set -ex +set -e current_dir="$(dirname "$0")" if [ -n "${ES_VERSION+1}" ]; then echo "Elasticsearch version is $ES_VERSION" version=$ES_VERSION else - version=5.0.0-alpha5 + version=5.0.0-beta1 fi setup_es() { if [ ! -d $current_dir/elasticsearch ]; then local version=$1 - download_url=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$version/elasticsearch-$version.tar.gz + download_url=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$version.tar.gz curl -sL $download_url > $current_dir/elasticsearch.tar.gz mkdir $current_dir/elasticsearch tar -xzf $current_dir/elasticsearch.tar.gz --strip-components=1 -C $current_dir/elasticsearch/. diff --git a/qa/integration/services/elasticsearch_teardown.sh b/qa/integration/services/elasticsearch_teardown.sh index 5d59f30fa..9792f0ea0 100755 --- a/qa/integration/services/elasticsearch_teardown.sh +++ b/qa/integration/services/elasticsearch_teardown.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -ex +set -e current_dir="$(dirname "$0")" stop_es() { diff --git a/qa/integration/services/filebeat_setup.sh b/qa/integration/services/filebeat_setup.sh index f59defc19..ba113ecb4 100755 --- a/qa/integration/services/filebeat_setup.sh +++ b/qa/integration/services/filebeat_setup.sh @@ -1,19 +1,19 @@ #!/bin/bash -set -ex +set -e current_dir="$(dirname "$0")" if [ -n "${FILEBEAT_VERSION}" ]; then echo "Filebeat version is $FILEBEAT_VERSION" version=$FILEBEAT_VERSION else - version=5.0.0-alpha5 + version=5.0.0-beta1 fi setup_fb() { local version=$1 platform=`uname -s | tr '[:upper:]' '[:lower:]'` architecture=`uname -m | tr '[:upper:]' '[:lower:]'` - download_url=https://download.elastic.co/beats/filebeat/filebeat-$version-$platform-$architecture.tar.gz + download_url=https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-$version-$platform-$architecture.tar.gz curl -sL $download_url > $current_dir/filebeat.tar.gz mkdir $current_dir/filebeat tar -xzf $current_dir/filebeat.tar.gz --strip-components=1 -C $current_dir/filebeat/. diff --git a/qa/integration/services/kafka_setup.sh b/qa/integration/services/kafka_setup.sh index 26740d693..ec687bb2a 100755 --- a/qa/integration/services/kafka_setup.sh +++ b/qa/integration/services/kafka_setup.sh @@ -1,12 +1,12 @@ #!/bin/bash -set -ex +set -e current_dir="$(dirname "$0")" if [ -n "${KAFKA_VERSION+1}" ]; then echo "KAFKA_VERSION is $KAFKA_VERSION" version=$KAFKA_VERSION else - version=0.10.0.0 + version=0.10.0.1 fi setup_kafka() { @@ -30,8 +30,10 @@ start_kafka() { setup_kafka $version start_kafka - +sleep 3 # Set up topics $current_dir/kafka/bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic logstash_topic_plain --zookeeper localhost:2181 +sleep 1 cat $current_dir/../fixtures/how_sample.input | $current_dir/kafka/bin/kafka-console-producer.sh --topic logstash_topic_plain --broker-list localhost:9092 +sleep 1 echo "Kafka Setup complete" diff --git a/qa/integration/services/kafka_teardown.sh b/qa/integration/services/kafka_teardown.sh index 57c0ce76d..1120b340c 100755 --- a/qa/integration/services/kafka_teardown.sh +++ b/qa/integration/services/kafka_teardown.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -ex +set -e current_dir="$(dirname "$0")" stop_kafka() { diff --git a/qa/integration/specs/es_output_how_spec.rb b/qa/integration/specs/es_output_how_spec.rb index 27f2ef2d4..db0a72332 100644 --- a/qa/integration/specs/es_output_how_spec.rb +++ b/qa/integration/specs/es_output_how_spec.rb @@ -17,13 +17,13 @@ describe "a config which indexes data into Elasticsearch" do it "can ingest 300K log lines" do logstash_service = @fixture.get_service("logstash") es_service = @fixture.get_service("elasticsearch") - puts "Ingesting 300K lines of apache logs to ES. This may make your CPU sing.." + puts "Ingesting 37 apache log lines to ES." logstash_service.start_with_input(@fixture.config, @fixture.input) es_client = es_service.get_client # now we test if all data was indexed by ES, but first refresh manually es_client.indices.refresh result = es_client.search(index: 'logstash-*', size: 0, q: '*') - expect(result["hits"]["total"]).to eq(300000) + expect(result["hits"]["total"]).to eq(37) end end diff --git a/qa/integration/specs/kafka_input_spec.rb b/qa/integration/specs/kafka_input_spec.rb index 2cd52e9e4..e0ce8dbd2 100644 --- a/qa/integration/specs/kafka_input_spec.rb +++ b/qa/integration/specs/kafka_input_spec.rb @@ -4,7 +4,7 @@ require_relative '../services/logstash_service' require "rspec/wait" describe "Kafka Input" do - let(:timeout_seconds) { 5 } + let(:timeout_seconds) { 30 } before(:all) { @fixture = Fixture.new(__FILE__) }