Skip to content

Commit 758075f

Browse files
committed
[Client] Fixes tests
1 parent f10eeb8 commit 758075f

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

api-spec-testing/test_file.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ def clear_datastreams(client)
414414
client.xpack.indices.delete_data_stream(name: datastream['name'], expand_wildcards: 'all')
415415
end
416416
begin
417-
client.indices.delete_data_stream(name: '*', expand_wildcards: 'all')
417+
client.xpack.indices.delete_data_stream(name: '*', expand_wildcards: 'all')
418418
rescue StandardError => e
419419
LOGGER.error "Caught exception attempting to delete data streams: #{e}"
420-
client.indices.delete_data_stream(name: '*')
420+
client.xpack.indices.delete_data_stream(name: '*')
421421
end
422422
end
423423

elasticsearch-transport/Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace :test do
3232
sh '../scripts/wait-cluster.sh'
3333
end
3434

35-
task spec: :wait_for_green
3635
RSpec::Core::RakeTask.new(:spec)
3736

3837
Rake::TestTask.new(:unit) do |test|

elasticsearch-transport/spec/elasticsearch/transport/base_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@
7373
expect(logger).not_to receive(:fatal).with(/secret_password/)
7474

7575
expect {
76-
client.cluster.stats
76+
client.perform_request('GET', '_cluster/stats')
7777
}.to raise_exception(Faraday::SSLError)
7878
end
7979

8080
it 'replaces the password with the string \'REDACTED\'' do
8181
expect(logger).to receive(:fatal).with(/REDACTED/)
8282
expect {
83-
client.cluster.stats
83+
client.perform_request('GET', '_cluster/stats')
8484
}.to raise_exception(Faraday::SSLError)
8585
end
8686
else
@@ -103,14 +103,14 @@
103103
expect(logger).not_to receive(:fatal).with(/secret_password/)
104104

105105
expect {
106-
client.cluster.stats
106+
client.perform_request('GET', '_cluster/stats')
107107
}.to raise_exception(Faraday::SSLError)
108108
end
109109

110110
it 'replaces the password with the string \'REDACTED\'' do
111111
expect(logger).to receive(:fatal).with(/REDACTED/)
112112
expect {
113-
client.cluster.stats
113+
client.perform_request('GET', '_cluster/stats')
114114
}.to raise_exception(Faraday::SSLError)
115115
end
116116
else

elasticsearch-transport/spec/elasticsearch/transport/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@
15841584

15851585
context 'when a block is provided' do
15861586
let(:client) do
1587-
Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
1587+
described_class.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
15881588
client.headers['Accept'] = 'application/yaml'
15891589
end
15901590
end
@@ -1600,7 +1600,7 @@
16001600

16011601
context 'when the Faraday adapter is set in the block' do
16021602
let(:client) do
1603-
Elasticsearch::Client.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
1603+
described_class.new(host: ELASTICSEARCH_HOSTS.first, logger: logger) do |client|
16041604
client.adapter(:net_http_persistent)
16051605
end
16061606
end

elasticsearch-transport/spec/elasticsearch/transport/meta_header_spec.rb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ def meta_version
232232
if defined?(JRUBY_VERSION)
233233
context 'when using manticore' do
234234
let(:client) do
235-
Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore)
235+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Manticore).tap do |client|
236+
client.instance_variable_set('@verified', true)
237+
end
236238
end
237239
let(:subject) { client.transport.connections.first.connection.instance_variable_get("@options")[:headers]}
238240

@@ -244,7 +246,9 @@ def meta_version
244246
else
245247
context 'when using curb' do
246248
let(:client) do
247-
Elasticsearch::Client.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb)
249+
described_class.new(transport_class: Elasticsearch::Transport::Transport::HTTP::Curb).tap do |client|
250+
client.instance_variable_set('@verified', true)
251+
end
248252
end
249253

250254
it 'sets curb in the metaheader' do
@@ -255,15 +259,13 @@ def meta_version
255259
end
256260

257261
context 'when using custom transport implementation' do
258-
let (:transport_class) do
262+
let(:transport_class) do
259263
Class.new do
260-
include Elasticsearch::Transport::Transport::Base
261-
262264
def initialize(args)
263265
end
264266
end
265267
end
266-
let(:client) { Elasticsearch::Client.new(transport_class: transport_class) }
268+
let(:client) { Elasticsearch::Transport::Client.new(transport_class: transport_class) }
267269
let(:subject) { client.instance_variable_get('@arguments')[:transport_options][:headers] }
268270
let(:meta_header) do
269271
if jruby?
@@ -284,7 +286,11 @@ def initialize(args)
284286
stub_const('Elastic::ELASTICSEARCH_SERVICE_VERSION', [:ent, '8.0.0'])
285287
end
286288

287-
let(:client) { Elasticsearch::Client.new }
289+
let(:client) do
290+
described_class.new.tap do |client|
291+
client.instance_variable_set('@verified', true)
292+
end
293+
end
288294

289295
it 'sets the service version in the metaheader' do
290296
expect(subject['x-elastic-client-meta']).to match(regexp)

0 commit comments

Comments
 (0)