Skip to content

Commit 4f0b8b0

Browse files
committed
[CI] Redefine clients in tests when using 8.0
1 parent 5400226 commit 4f0b8b0

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

elasticsearch-api/spec/rest_yaml_tests_helper.rb

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,38 @@
3535
TEST_HOST, TEST_PORT = 'localhost', '9200'
3636
end
3737

38+
test_suite = ENV['TEST_SUITE'] || 'free'
39+
password = ENV['ELASTIC_PASSWORD'] || 'changeme'
40+
user = ENV['ELASTIC_USER'] || 'elastic'
41+
3842
if defined?(TEST_HOST) && defined?(TEST_PORT)
39-
URL = "http://#{TEST_HOST}:#{TEST_PORT}"
43+
URL = "http://#{TEST_HOST}:#{TEST_PORT}".freeze
4044

4145
if STACK_VERSION.match?(/^8\./)
42-
user = 'elastic'.freeze
43-
password = 'changeme'.freeze
44-
ADMIN_CLIENT = Elasticsearch::Client.new(
45-
host: URL,
46-
transport_options: TRANSPORT_OPTIONS,
47-
user: user,
48-
password: password
49-
)
46+
if ENV['TEST_SUITE'] == 'platinum'
47+
raw_certificate = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.crt'))
48+
certificate = OpenSSL::X509::Certificate.new(raw_certificate)
49+
raw_key = File.read(File.join(PROJECT_PATH, '../.ci/certs/testnode.key'))
50+
key = OpenSSL::PKey::RSA.new(raw_key)
51+
ca_file = File.expand_path(File.join(PROJECT_PATH, '/.ci/certs/ca.crt'))
52+
host = "https://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
53+
transport_options = { ssl: { verify: false, client_cert: certificate, client_key: key, ca_file: ca_file } }
54+
else
55+
host = "http://elastic:#{password}@#{uri.host}:#{uri.port}".freeze
56+
transport_options = {}
57+
end
58+
59+
ADMIN_CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options)
60+
61+
DEFAULT_CLIENT = if ENV['QUIET'] == 'true'
62+
Elasticsearch::Client.new(host: host, transport_options: transport_options)
63+
else
64+
Elasticsearch::Client.new(
65+
host: host,
66+
tracer: Logger.new($stdout),
67+
transport_options: transport_options
68+
)
69+
end
5070

5171
if ENV['QUIET'] == 'true'
5272
DEFAULT_CLIENT = Elasticsearch::Client.new(

0 commit comments

Comments
 (0)