elasticsearch-test-runner 0.13.0 → 0.15.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/lib/elasticsearch/tests/code_runner.rb +13 -11
- data/lib/elasticsearch/tests/printer.rb +50 -19
- 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 +30 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f1a68e71ff468b2803f7196ec372bbb64519335c886220eded85925917006a9
|
|
4
|
+
data.tar.gz: d4a039160642905c738025ec977df3f8d5b8d33d34180ab3c75709c1cf308bf2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d446246da04e24d355283e7a7b102b737346376c80e94ec899a98e1d8c209487469bf7b2b028ebfa7893015f739413a33b2ebb3d8c3a3bb8494851532c470f7
|
|
7
|
+
data.tar.gz: fd59fa83bec9baae0ff4037c156a28e819eacd068e0ba67ea35a7dbe0696b22874925c0befcbbd27aaa930dbd72ad1798062e596ccaa6db1eac37a528d795535
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.15.0] - 2026-01-29
|
|
4
|
+
|
|
5
|
+
- Bugfix: refactors response display for boolean responses (ping, exists) when in debug mode.
|
|
6
|
+
- Sets boxes screen size to whole screen.
|
|
7
|
+
|
|
8
|
+
## [0.14.0] - 2026-01-29
|
|
9
|
+
|
|
10
|
+
- Introduces Ruby TTY tools for better debugging when `ENV['DEBUG']` is set and general display improvements.
|
|
11
|
+
- Better information for actions in passing/erroring tests, showing actions instead of the test title.
|
|
12
|
+
|
|
3
13
|
## [0.13.0] - 2025-06-05
|
|
4
14
|
|
|
5
15
|
- Moves download tests file to Rakefile (namespace is unchanged).
|
|
@@ -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
|
|
@@ -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,35 @@ 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
|
|
28
|
+
|
|
25
29
|
def print_success
|
|
26
|
-
|
|
27
|
-
@response
|
|
28
|
-
else
|
|
29
|
-
@response.status
|
|
30
|
-
end
|
|
31
|
-
if ENV['QUIET'] == 'true'
|
|
30
|
+
if quiet?
|
|
32
31
|
print '🟢 '
|
|
33
32
|
else
|
|
34
|
-
|
|
33
|
+
status = boolean_response? ? @response : @response.status
|
|
34
|
+
puts "🟢 \e[33m#{@short_name}\e[0m - #{@action} \e[32mpassed\e[0m [#{status}]"
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def quiet?
|
|
39
|
+
!ENV['QUIET'].nil? && ![false, 'false'].include?(ENV['QUIET'])
|
|
40
|
+
end
|
|
41
|
+
|
|
38
42
|
def print_failure(action, response)
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
if quiet?
|
|
44
|
+
print '🔴 '
|
|
45
|
+
else
|
|
46
|
+
puts "🔴 \e[33m#{@short_name}\e[0m - #{@action} \e[31mfailed\e[0m"
|
|
47
|
+
end
|
|
48
|
+
message = ["Expected result: #{action}"]
|
|
41
49
|
if defined?(ElasticsearchServerless) &&
|
|
42
50
|
response.is_a?(ElasticsearchServerless::API::Response) ||
|
|
43
51
|
defined?(Elasticsearch::API) && response.is_a?(Elasticsearch::API::Response)
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
message << 'Response:'
|
|
53
|
+
message << response.body
|
|
46
54
|
else
|
|
47
|
-
|
|
55
|
+
message << response
|
|
48
56
|
end
|
|
49
57
|
raise Elasticsearch::Tests::ActionError.new(response.body, @short_name, action)
|
|
50
58
|
end
|
|
@@ -63,7 +71,7 @@ module Elasticsearch
|
|
|
63
71
|
end
|
|
64
72
|
|
|
65
73
|
def print_error(error)
|
|
66
|
-
|
|
74
|
+
print TTY::Box.error("❌ ERROR: #{@short_name} #{@title} failed", width: BOX_WIDTH)
|
|
67
75
|
logger.error error.display
|
|
68
76
|
backtrace = error.backtrace.join("\n")
|
|
69
77
|
logger.error "#{backtrace}\n"
|
|
@@ -71,27 +79,50 @@ module Elasticsearch
|
|
|
71
79
|
end
|
|
72
80
|
|
|
73
81
|
def self.display_errors(errors, logger)
|
|
74
|
-
|
|
82
|
+
print TTY::Box.frame("❌ Errors/Failures: #{errors.count}", width: BOX_WIDTH, style: { border: { fg: :red } })
|
|
75
83
|
errors.map do |error|
|
|
76
84
|
message = []
|
|
77
85
|
message << "🧪 Test: #{error[:file]}"
|
|
78
86
|
message << "▶ Action: #{error[:action].first}" if error[:action]
|
|
79
87
|
message << "🔬 #{error.class} - #{error[:error].message}"
|
|
80
88
|
message << error[:error].backtrace.join("$/\n") if ENV['DEBUG']
|
|
81
|
-
|
|
89
|
+
print TTY::Box.frame(message.join("\n"), width: BOX_WIDTH, style: { border: { fg: :red } })
|
|
82
90
|
logger.error(message.join("\n"))
|
|
83
91
|
end
|
|
84
92
|
end
|
|
85
93
|
|
|
86
94
|
def self.display_summary(tests_count, errors_count, start_time, logger)
|
|
87
|
-
puts
|
|
88
95
|
summary = "🧪 Tests: #{tests_count} | Passed: #{tests_count - errors_count} | Failed: #{errors_count}"
|
|
89
96
|
logger.info summary
|
|
90
|
-
puts "--- #{summary}"
|
|
91
|
-
|
|
92
97
|
duration = "⏲ Elapsed time: #{Time.at(Time.now - start_time).utc.strftime('%H:%M:%S')}"
|
|
98
|
+
message = <<~MSG
|
|
99
|
+
#{summary}
|
|
100
|
+
#{duration}
|
|
101
|
+
MSG
|
|
102
|
+
print TTY::Box.frame(message, width: BOX_WIDTH, title: { top_left: '[SUMMARY]' }, style: { border: { fg: :cyan } })
|
|
93
103
|
logger.info duration
|
|
94
|
-
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def print_debug_message(method, params)
|
|
107
|
+
message = <<~MSG
|
|
108
|
+
Test File: #{$test_file}
|
|
109
|
+
Action: #{method}
|
|
110
|
+
Parameters: #{params}
|
|
111
|
+
MSG
|
|
112
|
+
if boolean_response?
|
|
113
|
+
message << "Response: #{@response}"
|
|
114
|
+
else
|
|
115
|
+
message << "Response: #{@response.status}" \
|
|
116
|
+
"Response headers: #{@response.headers}" \
|
|
117
|
+
"Response body: #{@response.body}"
|
|
118
|
+
end
|
|
119
|
+
print TTY::Box.frame(message, width: BOX_WIDTH, title: { top_left: '[DEBUG]'})
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
def boolean_response?
|
|
125
|
+
[true, false].include? @response
|
|
95
126
|
end
|
|
96
127
|
end
|
|
97
128
|
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,7 +1,7 @@
|
|
|
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.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elastic Client Library Maintainers
|
|
@@ -9,6 +9,34 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
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
|
|
@@ -81,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
109
|
- !ruby/object:Gem::Version
|
|
82
110
|
version: '0'
|
|
83
111
|
requirements: []
|
|
84
|
-
rubygems_version:
|
|
112
|
+
rubygems_version: 4.0.3
|
|
85
113
|
specification_version: 4
|
|
86
114
|
summary: Tool to test Elasticsearch clients against the YAML clients test suite.
|
|
87
115
|
test_files: []
|