Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Enable RATS integration tests on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
suyograo committed Sep 23, 2016
1 parent 19fe5de commit 65435ba
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 30 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions ci/ci_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions ci/travis_integration_install.sh
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions ci/travis_integration_run.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion qa/integration/fixtures/beats_input_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ config:
}
}
input: how_sample.input
setup_script: download_input.sh
teardown_script:
10 changes: 0 additions & 10 deletions qa/integration/fixtures/download_input.sh

This file was deleted.

3 changes: 1 addition & 2 deletions qa/integration/fixtures/es_output_how_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ config: |-
elasticsearch {}
}
input: how.input
setup_script: download_input.sh
input: how_sample.input
teardown_script:
6 changes: 3 additions & 3 deletions qa/integration/services/elasticsearch_setup.sh
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
2 changes: 1 addition & 1 deletion qa/integration/services/elasticsearch_teardown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -ex
set -e
current_dir="$(dirname "$0")"

stop_es() {
Expand Down
6 changes: 3 additions & 3 deletions qa/integration/services/filebeat_setup.sh
Original file line number Diff line number Diff line change
@@ -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/.
Expand Down
8 changes: 5 additions & 3 deletions qa/integration/services/kafka_setup.sh
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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"
2 changes: 1 addition & 1 deletion qa/integration/services/kafka_teardown.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -ex
set -e
current_dir="$(dirname "$0")"

stop_kafka() {
Expand Down
4 changes: 2 additions & 2 deletions qa/integration/specs/es_output_how_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
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
2 changes: 1 addition & 1 deletion qa/integration/specs/kafka_input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "rspec/wait"

describe "Kafka Input" do
let(:timeout_seconds) { 5 }
let(:timeout_seconds) { 30 }
before(:all) {
@fixture = Fixture.new(__FILE__)
}
Expand Down

0 comments on commit 65435ba

Please sign in to comment.