Skip to content

Commit 5610dd7

Browse files
authored
[Build] Update build scripts to support downloading ES >= 6.3 (logstash-plugins#799)
* Update build scripts to support downloading ES >= 6.3 * Update travis build target * Update artifact downloads to pull oss and standard versions of Elasticsearch when version >= 6.3.0 * Update method to add users for ES > 6.3.0 * Remove redundant test for 6.2.4 * Use rake `12.2.1` for builds using jruby-1.7.x * Tidy up, and fix secure integration tests * Adds a DISTRIBUTION environment variable, which can be: legacy: OSS < 6.3 legacyxpack: < 6.3 with xpack plugin oss: OSS >= 6.3 default: standard distribution >= 6.3 * Removes the exclusion filter for `secure_integration` - this was stopping secure integration tests from running even with tags on * Updates logstash branch in travis.yml to 6.4 * Update version of Gradle used to build es Later versions of Elasticsearch require a later version of Gradle in order to build * Fix for flaky tests Build the client, and set the mocks on that client before calling register to avoid race conditions * Remove unnecessary add-on from Travis build
1 parent fd1df9a commit 5610dd7

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed

.travis.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ language: ruby
44
cache: bundler
55
env:
66
- INTEGRATION=false
7-
- INTEGRATION=true ES_VERSION=1.7.6 TEST_DEBUG=true
8-
- INTEGRATION=true ES_VERSION=2.4.4 TEST_DEBUG=true
9-
- INTEGRATION=true ES_VERSION=5.6.9 TEST_DEBUG=true
10-
- INTEGRATION=true ES_VERSION=6.2.4 TEST_DEBUG=true
11-
- INTEGRATION=true ES_VERSION=master TEST_DEBUG=true
12-
- SECURE_INTEGRATION=true INTEGRATION=true ES_VERSION=5.6.9 TEST_DEBUG=true
13-
- SECURE_INTEGRATION=true INTEGRATION=true ES_VERSION=6.2.4 TEST_DEBUG=true
7+
- DISTRIBUTION=legacy INTEGRATION=true ES_VERSION=1.7.6 TEST_DEBUG=true
8+
- DISTRIBUTION=legacy INTEGRATION=true ES_VERSION=2.4.4 TEST_DEBUG=true
9+
- DISTRIBUTION=legacy INTEGRATION=true ES_VERSION=5.6.9 TEST_DEBUG=true
10+
- DISTRIBUTION=oss INTEGRATION=true ES_VERSION=6.4.2 TEST_DEBUG=true
11+
- DISTRIBUTION=default INTEGRATION=true ES_VERSION=6.4.2 TEST_DEBUG=true
12+
- DISTRIBUTION=default INTEGRATION=true ES_VERSION=master TEST_DEBUG=true
13+
- DISTRIBUTION=legacyxpack SECURE_INTEGRATION=true INTEGRATION=true ES_VERSION=5.6.9 TEST_DEBUG=true
14+
- DISTRIBUTION=default SECURE_INTEGRATION=true INTEGRATION=true ES_VERSION=6.4.2 TEST_DEBUG=true
15+
1416
rvm:
1517
- jruby-1.7.25
1618
matrix:
@@ -20,16 +22,13 @@ matrix:
2022
- rvm: jruby-9.1.13.0
2123
env: LOGSTASH_BRANCH=6.x
2224
- rvm: jruby-9.1.13.0
23-
env: LOGSTASH_BRANCH=6.2
25+
env: LOGSTASH_BRANCH=6.4
2426
- rvm: jruby-1.7.27
2527
env: LOGSTASH_BRANCH=5.6
2628
allow_failures:
27-
- env: INTEGRATION=true ES_VERSION=master TEST_DEBUG=true
29+
- env: DISTRIBUTION=default INTEGRATION=true ES_VERSION=master TEST_DEBUG=true
2830
fast_finish: true
2931
install: true
3032
script: ci/build.sh
3133
jdk: oraclejdk8
32-
addons:
33-
apt:
34-
packages:
35-
- oracle-java8-installer
34+

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ if Dir.exist?(logstash_path) && use_logstash_source
99
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
1010
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
1111
end
12+
13+
if RUBY_VERSION == "1.9.3"
14+
gem 'rake', '12.2.1'
15+
end

ci/run.sh

+29-9
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ setup_es() {
3030
cp $BUILD_DIR/spec/fixtures/scripts/painless/* elasticsearch/config/scripts
3131

3232
# If we're running with xpack SSL/Users enabled...
33-
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
33+
# Note that 6.3.0 releases and above do not require an x-pack plugin install
34+
35+
if [[ "$DISTRIBUTION" == "legacyxpack" ]]; then
3436
if [[ "$xpack_download_url" == "" ]]; then
3537
yes y | elasticsearch/bin/elasticsearch-plugin install x-pack
3638
else
3739
curl -sL $xpack_download_url > elasticsearch/xpack.zip
3840
yes y | elasticsearch/bin/elasticsearch-plugin install file://$BUILD_DIR/elasticsearch/xpack.zip
3941
fi
42+
fi
4043

44+
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
4145
es_yml=elasticsearch/config/elasticsearch.yml
4246
cp -rv $BUILD_DIR/spec/fixtures/test_certs elasticsearch/config/test_certs
4347
echo "xpack.security.http.ssl.enabled: true" >> $es_yml
@@ -55,12 +59,17 @@ start_es() {
5559
es_url="http://localhost:9200"
5660
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
5761
es_url="https://localhost:9200 -k"
58-
59-
# Needed for travis. On travis the `users` script will fail because it will first try and write
60-
# to /etc/elasticsearch
61-
export CONF_DIR=$BUILD_DIR/elasticsearch/config
62-
elasticsearch/bin/x-pack/users useradd simpleuser -p abc123 -r superuser
63-
elasticsearch/bin/x-pack/users useradd 'f@ncyuser' -p 'ab%12#' -r superuser
62+
fi
63+
# Needed for travis. On travis the `users` script will fail because it will first try and write
64+
# to /etc/elasticsearch
65+
export CONF_DIR=$BUILD_DIR/elasticsearch/config
66+
67+
if [[ "$DISTRIBUTION" == "default" ]]; then
68+
elasticsearch/bin/elasticsearch-users useradd simpleuser -p abc123 -r superuser
69+
elasticsearch/bin/elasticsearch-users useradd 'f@ncyuser' -p 'ab%12#' -r superuser
70+
elif [[ "$DISTRIBUTION" == "legacyxpack" ]]; then
71+
elasticsearch/bin/x-pack/users useradd simpleuser -p abc123 -r superuser
72+
elasticsearch/bin/x-pack/users useradd 'f@ncyuser' -p 'ab%12#' -r superuser
6473
fi
6574

6675
while ! curl --silent $es_url && [[ $count -ne 0 ]]; do
@@ -83,7 +92,7 @@ get_es_distribution_version() {
8392
# not here because this script runs in a different bash shell.
8493
download_gradle() {
8594
echo $PWD
86-
local version="4.3"
95+
local version="4.10"
8796
curl -sL https://services.gradle.org/distributions/gradle-$version-bin.zip > gradle.zip
8897
unzip -d . gradle.zip
8998
mv gradle-* gradle
@@ -123,12 +132,23 @@ else
123132
fi
124133

125134
case "$ES_VERSION" in
126-
6.*)
135+
6.[0-2]*)
127136
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-${ES_VERSION}.zip
128137
es_distribution_version=$(get_es_distribution_version)
129138
start_es
130139
bundle exec rspec -fd $extra_tag_args --tag update_tests:painless --tag update_tests:groovy --tag es_version:$es_distribution_version $spec_path
131140
;;
141+
6.*)
142+
if [[ "$DISTRIBUTION" == "oss" ]]; then
143+
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-${ES_VERSION}.tar.gz
144+
elif [[ "$DISTRIBUTION" == "default" ]]; then
145+
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
146+
fi
147+
es_distribution_version=$(get_es_distribution_version)
148+
start_es
149+
bundle exec rspec -fd $extra_tag_args --tag update_tests:painless --tag update_tests:groovy --tag es_version:$es_distribution_version $spec_path
150+
;;
151+
132152
5.*)
133153
setup_es https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
134154
es_distribution_version=$(get_es_distribution_version)

spec/es_spec_helper.rb

-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
require 'manticore'
33
require 'elasticsearch'
44

5-
# by default exclude secure_integration tests unless requested
6-
# normal integration specs are already excluded by devutils' spec helper
7-
RSpec.configure do |config|
8-
config.filter_run_excluding config.exclusion_filter.add(:secure_integration => true)
9-
end
10-
115
module ESHelper
126
def get_host_port
137
"127.0.0.1:9200"

spec/unit/outputs/elasticsearch_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
before(:each) do
1313
if do_register
14-
subject.register
14+
# Build the client and set mocks before calling register to avoid races.
15+
subject.build_client
1516

1617
# Rspec mocks can't handle background threads, so... we can't use any
1718
allow(subject.client.pool).to receive(:start_resurrectionist)
1819
allow(subject.client.pool).to receive(:start_sniffer)
1920
allow(subject.client.pool).to receive(:healthcheck!)
2021
allow(subject.client).to receive(:maximum_seen_major_version).at_least(:once).and_return(maximum_seen_major_version)
22+
subject.register
2123
subject.client.pool.adapter.manticore.respond_with(:body => "{}")
2224
end
2325
end

0 commit comments

Comments
 (0)