elasticsearch-test-runner 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Rakefile +9 -1
- data/lib/elasticsearch/tests/code_runner.rb +13 -11
- data/lib/elasticsearch/tests/downloader.rb +3 -3
- data/lib/elasticsearch/tests/printer.rb +39 -14
- data/lib/elasticsearch/tests/test.rb +17 -0
- data/lib/elasticsearch/tests/test_runner.rb +5 -5
- data/lib/elasticsearch/tests/version.rb +1 -1
- metadata +31 -4
- data/lib/elasticsearch/tasks/download_test_suite.rake +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fdc3e700cee1701fdf46ac870a082c1f2e5442ec134861153a9a7810a228769
|
|
4
|
+
data.tar.gz: 261ad436f9db8d1d13b413df5967697ae1ac1f49a7886efcb97104c46fc07839
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8629d1d7d526dd7eee04b6fa9496d3d64d63f0da9c374c92f16c74023ff02f9a7c3a106d11a7bdd95b16e058d8c65eceecec6ba2fcdc768078640cf49417af91
|
|
7
|
+
data.tar.gz: 7bb09a1d76a6d3bf382a4e67e3c39687c29ef0b7709e0edb5f5df4ded87c6f19e931952c031b7a4fb8478ca78742ded533cb341ef77f70d0c783fae5aa3527c2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.14.0] - 2026-01-29
|
|
4
|
+
|
|
5
|
+
- Introduces Ruby TTY tools for better debugging when `ENV['DEBUG']` is set and general display improvements.
|
|
6
|
+
- Better information for actions in passing/erroring tests, showing actions instead of the test title.
|
|
7
|
+
|
|
8
|
+
## [0.13.0] - 2025-06-05
|
|
9
|
+
|
|
10
|
+
- Moves download tests file to Rakefile (namespace is unchanged).
|
|
11
|
+
- Updates Elasticsearch Clients Tests repo URL.
|
|
12
|
+
|
|
3
13
|
## [0.12.0] - 2025-01-14
|
|
4
14
|
|
|
5
15
|
- Check TEST_SUITE variable for `serverless`.
|
data/Rakefile
CHANGED
|
@@ -16,5 +16,13 @@
|
|
|
16
16
|
# under the License.
|
|
17
17
|
|
|
18
18
|
require 'bundler/gem_tasks'
|
|
19
|
+
require 'elasticsearch/tests/downloader'
|
|
19
20
|
task default: %i[]
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
namespace :es_tests do
|
|
23
|
+
desc 'Download YAML test files'
|
|
24
|
+
task :download do |_, args|
|
|
25
|
+
tests_path = args[:path] || File.expand_path('./tmp', __dir__)
|
|
26
|
+
Elasticsearch::Tests::Downloader::run(tests_path)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
2
4
|
# license agreements. See the NOTICE file distributed with
|
|
3
5
|
# this work for additional information regarding copyright
|
|
@@ -53,15 +55,14 @@ module Elasticsearch
|
|
|
53
55
|
client = @client.send(arrayed_method.first)
|
|
54
56
|
method = arrayed_method.last
|
|
55
57
|
end
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
params = process_params(params)
|
|
59
|
+
@response = client.send(method.to_sym, params)
|
|
60
|
+
print_debug_message(method.to_sym, params) if ENV['DEBUG']
|
|
58
61
|
@response
|
|
59
62
|
rescue StandardError => e
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
raise e
|
|
64
|
-
end
|
|
63
|
+
raise e unless expected_exception?(catchable, e)
|
|
64
|
+
|
|
65
|
+
puts "Catchable: #{e}\nResponse: #{@response}\n" if ENV['DEBUG']
|
|
65
66
|
end
|
|
66
67
|
|
|
67
68
|
def expected_exception?(error_type, e)
|
|
@@ -116,13 +117,14 @@ module Elasticsearch
|
|
|
116
117
|
|
|
117
118
|
def match_regexp(expected, result)
|
|
118
119
|
expected.is_a?(String) &&
|
|
119
|
-
expected.match?(
|
|
120
|
+
expected.match?(%r{^/}) &&
|
|
120
121
|
result.match?(Regexp.new(expected.gsub('/', '').strip))
|
|
121
122
|
end
|
|
122
123
|
|
|
123
124
|
def do_length(action)
|
|
124
125
|
k, v = action['length'].first
|
|
125
|
-
result = search_in_response(k)
|
|
126
|
+
result = search_in_response(k)
|
|
127
|
+
result = result.count
|
|
126
128
|
if result && result == v
|
|
127
129
|
print_success
|
|
128
130
|
else
|
|
@@ -208,11 +210,11 @@ module Elasticsearch
|
|
|
208
210
|
end
|
|
209
211
|
|
|
210
212
|
def set_param_variable(params, key, param)
|
|
211
|
-
return unless param.is_a?(String) && param.include?(
|
|
213
|
+
return unless param.is_a?(String) && param.include?('$')
|
|
212
214
|
|
|
213
215
|
# Param can be a single '$value' string or '{ something: $value }'
|
|
214
216
|
repleacable = param.match(/(\$[0-9a-z_-]+)/)[0]
|
|
215
|
-
value = instance_variable_get(repleacable.gsub(
|
|
217
|
+
value = instance_variable_get(repleacable.gsub('$', '@'))
|
|
216
218
|
content = param.gsub(repleacable, value)
|
|
217
219
|
params[key] = content
|
|
218
220
|
end
|
|
@@ -24,9 +24,9 @@ module Elasticsearch
|
|
|
24
24
|
class << self
|
|
25
25
|
FILENAME = 'tests.tar.gz'.freeze
|
|
26
26
|
|
|
27
|
-
def run(path, branch = 'main')
|
|
28
|
-
delete_files(path)
|
|
29
|
-
url = "https://api.github.com/repos/elastic/
|
|
27
|
+
def run(path, branch = 'main', delete: false)
|
|
28
|
+
delete_files(path) if delete
|
|
29
|
+
url = "https://api.github.com/repos/elastic/elasticsearch-clients-tests/tarball/#{branch}"
|
|
30
30
|
if download_tests(url)
|
|
31
31
|
puts "Successfully downloaded #{FILENAME}"
|
|
32
32
|
else
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# KIND, either express or implied. See the License for the
|
|
15
15
|
# specific language governing permissions and limitations
|
|
16
16
|
# under the License.
|
|
17
|
+
require 'tty-box'
|
|
18
|
+
require 'tty-screen'
|
|
17
19
|
require_relative 'errors'
|
|
18
20
|
|
|
19
21
|
module Elasticsearch
|
|
@@ -22,29 +24,39 @@ module Elasticsearch
|
|
|
22
24
|
# Functions to print out test results, errors, summary, etc.
|
|
23
25
|
#
|
|
24
26
|
module Printer
|
|
27
|
+
BOX_WIDTH = TTY::Screen.width * 0.8
|
|
28
|
+
|
|
25
29
|
def print_success
|
|
26
30
|
response = if [true, false].include? @response
|
|
27
31
|
@response
|
|
28
32
|
else
|
|
29
33
|
@response.status
|
|
30
34
|
end
|
|
31
|
-
if
|
|
35
|
+
if quiet?
|
|
32
36
|
print '🟢 '
|
|
33
37
|
else
|
|
34
|
-
puts "🟢 #{@short_name} #{@
|
|
38
|
+
puts "🟢 \e[#{33}m#{@short_name}\e[0m - #{@action} \e[#{32}mpassed\e[0m [#{response}]"
|
|
35
39
|
end
|
|
36
40
|
end
|
|
37
41
|
|
|
42
|
+
def quiet?
|
|
43
|
+
!ENV['QUIET'].nil? && ![false, 'false'].include?(ENV['QUIET'])
|
|
44
|
+
end
|
|
45
|
+
|
|
38
46
|
def print_failure(action, response)
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
if quiet?
|
|
48
|
+
print '🔴 '
|
|
49
|
+
else
|
|
50
|
+
puts "🔴 \e[#{33}m#{@short_name}\e[0m - #{@action} \e[#{31}mfailed\e[0m"
|
|
51
|
+
end
|
|
52
|
+
message = ["Expected result: #{action}"]
|
|
41
53
|
if defined?(ElasticsearchServerless) &&
|
|
42
54
|
response.is_a?(ElasticsearchServerless::API::Response) ||
|
|
43
55
|
defined?(Elasticsearch::API) && response.is_a?(Elasticsearch::API::Response)
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
message << 'Response:'
|
|
57
|
+
message << response.body
|
|
46
58
|
else
|
|
47
|
-
|
|
59
|
+
message << response
|
|
48
60
|
end
|
|
49
61
|
raise Elasticsearch::Tests::ActionError.new(response.body, @short_name, action)
|
|
50
62
|
end
|
|
@@ -63,7 +75,7 @@ module Elasticsearch
|
|
|
63
75
|
end
|
|
64
76
|
|
|
65
77
|
def print_error(error)
|
|
66
|
-
|
|
78
|
+
print TTY::Box.error("❌ ERROR: #{@short_name} #{@title} failed", width: BOX_WIDTH)
|
|
67
79
|
logger.error error.display
|
|
68
80
|
backtrace = error.backtrace.join("\n")
|
|
69
81
|
logger.error "#{backtrace}\n"
|
|
@@ -71,27 +83,40 @@ module Elasticsearch
|
|
|
71
83
|
end
|
|
72
84
|
|
|
73
85
|
def self.display_errors(errors, logger)
|
|
74
|
-
|
|
86
|
+
print TTY::Box.frame("❌ Errors/Failures: #{errors.count}", width: BOX_WIDTH, style: { border: { fg: :red } })
|
|
75
87
|
errors.map do |error|
|
|
76
88
|
message = []
|
|
77
89
|
message << "🧪 Test: #{error[:file]}"
|
|
78
90
|
message << "▶ Action: #{error[:action].first}" if error[:action]
|
|
79
91
|
message << "🔬 #{error.class} - #{error[:error].message}"
|
|
80
92
|
message << error[:error].backtrace.join("$/\n") if ENV['DEBUG']
|
|
81
|
-
|
|
93
|
+
print TTY::Box.frame(message.join("\n"), width: BOX_WIDTH, style: { border: { fg: :red } })
|
|
82
94
|
logger.error(message.join("\n"))
|
|
83
95
|
end
|
|
84
96
|
end
|
|
85
97
|
|
|
86
98
|
def self.display_summary(tests_count, errors_count, start_time, logger)
|
|
87
|
-
puts
|
|
88
99
|
summary = "🧪 Tests: #{tests_count} | Passed: #{tests_count - errors_count} | Failed: #{errors_count}"
|
|
89
100
|
logger.info summary
|
|
90
|
-
puts "--- #{summary}"
|
|
91
|
-
|
|
92
101
|
duration = "⏲ Elapsed time: #{Time.at(Time.now - start_time).utc.strftime('%H:%M:%S')}"
|
|
102
|
+
message = <<~MSG
|
|
103
|
+
#{summary}
|
|
104
|
+
#{duration}
|
|
105
|
+
MSG
|
|
106
|
+
print TTY::Box.frame(message, width: BOX_WIDTH, title: { top_left: '[SUMMARY]' }, style: { border: { fg: :cyan } })
|
|
93
107
|
logger.info duration
|
|
94
|
-
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def print_debug_message(method, params)
|
|
111
|
+
message = <<~MSG
|
|
112
|
+
Test File: #{$test_file}
|
|
113
|
+
Action: #{method}
|
|
114
|
+
Parameters: #{params}
|
|
115
|
+
Response: #{@response.status}
|
|
116
|
+
Response headers: #{@response.headers}
|
|
117
|
+
Response body: #{@response.body}
|
|
118
|
+
MSG
|
|
119
|
+
print TTY::Box.frame(message, width: BOX_WIDTH, title: { top_left: '[DEBUG]'})
|
|
95
120
|
end
|
|
96
121
|
end
|
|
97
122
|
end
|
|
@@ -59,18 +59,24 @@ module Elasticsearch
|
|
|
59
59
|
|
|
60
60
|
case definition
|
|
61
61
|
when 'do'
|
|
62
|
+
@action = "#{action['do'].keys.first}"
|
|
62
63
|
do_action(action['do'])
|
|
63
64
|
when 'set'
|
|
64
65
|
set_variable(action)
|
|
65
66
|
when 'match'
|
|
67
|
+
@action = "#{action.keys.first} #{format_action(action[action.keys.first])}"
|
|
66
68
|
do_match(action)
|
|
67
69
|
when 'length'
|
|
70
|
+
@action = format_action(action)
|
|
68
71
|
do_length(action)
|
|
69
72
|
when 'is_true'
|
|
73
|
+
@action = format_action(action)
|
|
70
74
|
is_true(action)
|
|
71
75
|
when 'is_false'
|
|
76
|
+
@action = format_action(action)
|
|
72
77
|
is_false(action)
|
|
73
78
|
when 'gt', 'gte', 'lt', 'lte'
|
|
79
|
+
@action = format_action(action)
|
|
74
80
|
compare(action)
|
|
75
81
|
end
|
|
76
82
|
rescue StandardError => e
|
|
@@ -106,6 +112,17 @@ module Elasticsearch
|
|
|
106
112
|
yaml.delete_at(i) if a.keys.first == 'teardown'
|
|
107
113
|
end.compact.first
|
|
108
114
|
end
|
|
115
|
+
|
|
116
|
+
private
|
|
117
|
+
|
|
118
|
+
def format_action(action)
|
|
119
|
+
action.to_s
|
|
120
|
+
.gsub(/^{/, '')
|
|
121
|
+
.gsub(' =>', ':')
|
|
122
|
+
.gsub('"', '')
|
|
123
|
+
.gsub('}', '')
|
|
124
|
+
.gsub('{', '|')
|
|
125
|
+
end
|
|
109
126
|
end
|
|
110
127
|
end
|
|
111
128
|
end
|
|
@@ -64,17 +64,17 @@ module Elasticsearch
|
|
|
64
64
|
@errors = []
|
|
65
65
|
|
|
66
66
|
@test_files.map do |test_path|
|
|
67
|
-
test_file = test_filename(test_path)
|
|
67
|
+
$test_file = test_filename(test_path)
|
|
68
68
|
build_and_run_tests(test_path)
|
|
69
69
|
rescue Psych::SyntaxError => e
|
|
70
|
-
@errors << { error: e, file: test_file }
|
|
71
|
-
@logger.warn("YAML error in #{test_file}")
|
|
70
|
+
@errors << { error: e, file: $test_file }
|
|
71
|
+
@logger.warn("YAML error in #{$test_file}")
|
|
72
72
|
@logger.warn e
|
|
73
73
|
rescue ActionError => e
|
|
74
|
-
@errors << { error: e, file: test_file, action: e.action }
|
|
74
|
+
@errors << { error: e, file: $test_file, action: e.action }
|
|
75
75
|
@logger.debug e
|
|
76
76
|
rescue StandardError => e
|
|
77
|
-
@errors << { error: e, file: test_file }
|
|
77
|
+
@errors << { error: e, file: $test_file }
|
|
78
78
|
@logger.debug e
|
|
79
79
|
rescue SystemExit, Interrupt
|
|
80
80
|
exit
|
metadata
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elasticsearch-test-runner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elastic Client Library Maintainers
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: tty-box
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: tty-screen
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
12
40
|
- !ruby/object:Gem::Dependency
|
|
13
41
|
name: elasticsearch
|
|
14
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,7 +80,6 @@ files:
|
|
|
52
80
|
- NOTICE
|
|
53
81
|
- README.md
|
|
54
82
|
- Rakefile
|
|
55
|
-
- lib/elasticsearch/tasks/download_test_suite.rake
|
|
56
83
|
- lib/elasticsearch/tests.rb
|
|
57
84
|
- lib/elasticsearch/tests/code_runner.rb
|
|
58
85
|
- lib/elasticsearch/tests/downloader.rb
|
|
@@ -82,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
82
109
|
- !ruby/object:Gem::Version
|
|
83
110
|
version: '0'
|
|
84
111
|
requirements: []
|
|
85
|
-
rubygems_version:
|
|
112
|
+
rubygems_version: 4.0.3
|
|
86
113
|
specification_version: 4
|
|
87
114
|
summary: Tool to test Elasticsearch clients against the YAML clients test suite.
|
|
88
115
|
test_files: []
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
2
|
-
# license agreements. See the NOTICE file distributed with
|
|
3
|
-
# this work for additional information regarding copyright
|
|
4
|
-
# ownership. Elasticsearch B.V. licenses this file to you under
|
|
5
|
-
# the Apache License, Version 2.0 (the "License"); you may
|
|
6
|
-
# not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing,
|
|
12
|
-
# software distributed under the License is distributed on an
|
|
13
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
# KIND, either express or implied. See the License for the
|
|
15
|
-
# specific language governing permissions and limitations
|
|
16
|
-
# under the License.
|
|
17
|
-
require 'elasticsearch/tests/downloader'
|
|
18
|
-
|
|
19
|
-
namespace :es_tests do
|
|
20
|
-
desc 'Download YAML test files'
|
|
21
|
-
task :download do |_, args|
|
|
22
|
-
tests_path = args[:path] || File.expand_path('../../tmp', __dir__)
|
|
23
|
-
Elasticsearch::Tests::Downloader::run(tests_path)
|
|
24
|
-
end
|
|
25
|
-
end
|