Skip to content

Commit 7f1099e

Browse files
authored
Adapt CI to run with security enabled when testing with Elasticsearch > 8 (#1039)
This commit enables SECURE_INTEGRATION environment flag for stack version 8 because ES 8 has security enabled by default. Furthermore fixes the integration test to effectively read the ELASTIC_STACK_VERSION environment variable
1 parent 91b2de5 commit 7f1099e

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.ci/docker-compose.override.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
environment:
1111
- INTEGRATION=${INTEGRATION:-false}
1212
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
13+
- ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
1314

1415
elasticsearch:
1516
build:

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ env:
77
- INTEGRATION=true ELASTIC_STACK_VERSION=6.x
88
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x
99
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
10-
- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
10+
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
1111
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x

spec/es_spec_helper.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def self.es_version
8080
end
8181

8282
def self.es_version_satisfies?(*requirement)
83-
es_version = RSpec.configuration.filter[:es_version] || ENV['ES_VERSION'] || ENV['ELASTIC_STACK_VERSION']
83+
es_version = nilify(RSpec.configuration.filter[:es_version]) || nilify(ENV['ES_VERSION']) || nilify(ENV['ELASTIC_STACK_VERSION'])
8484
if es_version.nil?
8585
puts "Info: ES_VERSION, ELASTIC_STACK_VERSION or 'es_version' tag wasn't set. Returning false to all `es_version_satisfies?` call."
8686
return false
@@ -89,6 +89,15 @@ def self.es_version_satisfies?(*requirement)
8989
Gem::Requirement.new(requirement).satisfied_by?(es_release_version)
9090
end
9191

92+
private
93+
def self.nilify(str)
94+
if str.nil?
95+
return str
96+
end
97+
str.empty? ? nil : str
98+
end
99+
100+
public
92101
def clean(client)
93102
client.indices.delete_template(:name => "*")
94103
client.indices.delete_index_template(:name => "logstash*") rescue nil

0 commit comments

Comments
 (0)