elasticsearch-test-runner 0.17.0 โ 0.18.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 +6 -0
- data/lib/elasticsearch/tests/code_runner.rb +26 -7
- data/lib/elasticsearch/tests/printer.rb +29 -12
- data/lib/elasticsearch/tests/test_runner.rb +0 -2
- data/lib/elasticsearch/tests/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 897b6c6fd42ff59d4a4a03ad00fd86ada140707095ded6dbdc16e24b1d1c7e57
|
|
4
|
+
data.tar.gz: 680d531cb3c7f06aa35b693c91d0b61f34e8a1aac5e5ba5fd89421b60a8589c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 898b06aad5b5f1b4def588adccb9099e5618570884654650ab2704c471573b4fda55c3aa7fa3d4254cc9913c325f85d30b7160fecfe5e7f23fbff913370a972c
|
|
7
|
+
data.tar.gz: f8c9e058b5e78e69eac3ae80f3519572bd0166e4c1b3ddf785b3502e1cd8cff1824fd85d861254e195652dc399e8d7d116a80b3ca3de7cc06c5f1f3acf85b50e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.18.0] - 2026-03-05
|
|
4
|
+
|
|
5
|
+
- Lots of improvements when displaying errors. Fixes missing exceptions during particular failures. The display for errors and failures is now more detailed and comfortable to read.
|
|
6
|
+
- Fixes printing a success when there's no response object, for instance when catching an expected exception.
|
|
7
|
+
- The code for catching exceptions was refactored and made more reliable, including showing better information as previously mentioned.
|
|
8
|
+
|
|
3
9
|
## [0.17.0] - 2026-03-04
|
|
4
10
|
|
|
5
11
|
- Better debugging detection, check for `ENV['DEBUG']` to be equal to `true`, not just if it's set.
|
|
@@ -60,11 +60,19 @@ module Elasticsearch
|
|
|
60
60
|
print_debug_message(method.to_sym, params) if debug?
|
|
61
61
|
@response
|
|
62
62
|
rescue StandardError => e
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
# Raise if it's an actual error:
|
|
64
|
+
unless expected_exception?(catchable, e)
|
|
65
|
+
print_failure(action, @response)
|
|
66
|
+
raise e
|
|
67
|
+
end
|
|
68
|
+
# Show success if we caught an expected exception:
|
|
69
|
+
print_success
|
|
70
|
+
print_debug_catchable(e) if debug?
|
|
66
71
|
end
|
|
67
72
|
|
|
73
|
+
# The keyword `catch` is used in the yaml tests to catch exceptions. This code looks at the
|
|
74
|
+
# expected error and the response error to compare them and check that we got the expected
|
|
75
|
+
# exception.
|
|
68
76
|
def expected_exception?(error_type, e)
|
|
69
77
|
return false if error_type.nil?
|
|
70
78
|
|
|
@@ -86,14 +94,14 @@ module Elasticsearch
|
|
|
86
94
|
when 'forbidden'
|
|
87
95
|
e.is_a?(Elastic::Transport::Transport::Errors::Forbidden)
|
|
88
96
|
when /error parsing field/, /illegal_argument_exception/
|
|
89
|
-
e.message
|
|
97
|
+
e.message.match?(/\[400\]/) ||
|
|
90
98
|
e.is_a?(Elastic::Transport::Transport::Errors::BadRequest)
|
|
91
99
|
when /NullPointerException/
|
|
92
|
-
e.message
|
|
100
|
+
e.message.match?(/\[400\]/)
|
|
93
101
|
when /status_exception/
|
|
94
|
-
e.message
|
|
102
|
+
e.message.match?(/\[409\]/)
|
|
95
103
|
else
|
|
96
|
-
e.message
|
|
104
|
+
e.message.match?(/#{error_type}/)
|
|
97
105
|
end
|
|
98
106
|
end
|
|
99
107
|
|
|
@@ -112,6 +120,8 @@ module Elasticsearch
|
|
|
112
120
|
print_success
|
|
113
121
|
else
|
|
114
122
|
print_match_failure(action)
|
|
123
|
+
message = "Match failure\nExpected #{k}: #{v}.\nResult: #{result}"
|
|
124
|
+
raise ActionError.new(message, $test_file, action)
|
|
115
125
|
end
|
|
116
126
|
end
|
|
117
127
|
|
|
@@ -129,6 +139,8 @@ module Elasticsearch
|
|
|
129
139
|
print_success
|
|
130
140
|
else
|
|
131
141
|
print_failure(action, @response)
|
|
142
|
+
message = "do_length failure\nExpected #{k}: #{v}.\nResult: #{result}"
|
|
143
|
+
raise ActionError.new(message, $test_file, action)
|
|
132
144
|
end
|
|
133
145
|
end
|
|
134
146
|
|
|
@@ -147,6 +159,8 @@ module Elasticsearch
|
|
|
147
159
|
print_success
|
|
148
160
|
else
|
|
149
161
|
print_failure(action, @response)
|
|
162
|
+
message = "is_true failure\nResponse: #{response_value || @response}."
|
|
163
|
+
raise ActionError.new(message, $test_file, action)
|
|
150
164
|
end
|
|
151
165
|
end
|
|
152
166
|
|
|
@@ -156,6 +170,8 @@ module Elasticsearch
|
|
|
156
170
|
print_success
|
|
157
171
|
else
|
|
158
172
|
print_failure(action, @response)
|
|
173
|
+
message = "is_false failure\nResponse: #{response_value || @response}."
|
|
174
|
+
raise ActionError.new(message, $test_file, action)
|
|
159
175
|
end
|
|
160
176
|
end
|
|
161
177
|
|
|
@@ -166,11 +182,14 @@ module Elasticsearch
|
|
|
166
182
|
#
|
|
167
183
|
def compare(action)
|
|
168
184
|
operator, value = action.first
|
|
185
|
+
|
|
169
186
|
result = search_in_response(value.keys.first)
|
|
170
187
|
if result&.send(COMPARATORS[operator], value[value.keys.first])
|
|
171
188
|
print_success
|
|
172
189
|
else
|
|
173
190
|
print_failure(action, @response)
|
|
191
|
+
message = "comparision failure\n#{result} #{COMPARATORS[operator]} #{value[value.keys.first]}"
|
|
192
|
+
raise ActionError.new(message, $test_file, action)
|
|
174
193
|
end
|
|
175
194
|
end
|
|
176
195
|
|
|
@@ -30,8 +30,13 @@ module Elasticsearch
|
|
|
30
30
|
if quiet?
|
|
31
31
|
print '๐ข '
|
|
32
32
|
else
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
msg = "๐ข \e[33m#{@short_name}\e[0m - #{@action} \e[32mpassed\e[0m"
|
|
34
|
+
if @response.nil?
|
|
35
|
+
puts msg
|
|
36
|
+
else
|
|
37
|
+
status = boolean_response? ? @response : @response.status
|
|
38
|
+
puts "#{msg} [#{status}]"
|
|
39
|
+
end
|
|
35
40
|
end
|
|
36
41
|
end
|
|
37
42
|
|
|
@@ -46,23 +51,24 @@ module Elasticsearch
|
|
|
46
51
|
puts "๐ด \e[33m#{@short_name}\e[0m - #{@action} \e[31mfailed\e[0m"
|
|
47
52
|
end
|
|
48
53
|
message = ["Expected result: #{action}"]
|
|
49
|
-
if
|
|
50
|
-
response.is_a?(ElasticsearchServerless::API::Response) ||
|
|
51
|
-
defined?(Elasticsearch::API) && response.is_a?(Elasticsearch::API::Response)
|
|
52
|
-
message << 'Response:'
|
|
54
|
+
if response&.body
|
|
53
55
|
message << response.body
|
|
54
56
|
else
|
|
55
57
|
message << response
|
|
56
58
|
end
|
|
57
|
-
raise Elasticsearch::Tests::ActionError.new(response.body, @short_name, action)
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def print_match_failure(action)
|
|
61
62
|
keys = action['match'].keys.first
|
|
62
63
|
value = action['match'].values.first
|
|
63
64
|
|
|
65
|
+
if quiet?
|
|
66
|
+
print '๐ด '
|
|
67
|
+
else
|
|
68
|
+
puts "๐ด \e[33m#{@short_name} (match)\e[0m - \e[32;9m#{keys}: #{value}\e[0m \e[95m#{keys}: #{search_in_response(action['match'].keys.first)}\e[0m \e[31mfailed\e[0m"
|
|
69
|
+
end
|
|
64
70
|
message = <<~MSG
|
|
65
|
-
|
|
71
|
+
#{@short_name} #{@title} failed
|
|
66
72
|
Expected: { #{keys}: #{value} }
|
|
67
73
|
Actual : { #{keys}: #{search_in_response(action['match'].keys.first)} }
|
|
68
74
|
Response: #{@response}
|
|
@@ -79,14 +85,16 @@ module Elasticsearch
|
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
def self.display_errors(errors, logger)
|
|
88
|
+
puts
|
|
82
89
|
print TTY::Box.frame("โ Errors/Failures: #{errors.count}", width: BOX_WIDTH, style: { border: { fg: :red } })
|
|
83
|
-
|
|
90
|
+
|
|
91
|
+
errors.each do |error|
|
|
92
|
+
print TTY::Box.frame("๐งช Test: #{error[:file]}", width: BOX_WIDTH * 0.6, style: { border: { fg: :red } })
|
|
84
93
|
message = []
|
|
85
|
-
message << "๐งช Test: #{error[:file]}"
|
|
86
94
|
message << "โถ Action: #{error[:action].first}" if error[:action]
|
|
87
|
-
message << "๐ฌ #{error.class} - #{error[:error].message}"
|
|
95
|
+
message << "๐ฌ #{error[:error].class} - #{error[:error].message}"
|
|
88
96
|
message << error[:error].backtrace.join("$/\n") if ENV['DEBUG'] == 'true'
|
|
89
|
-
|
|
97
|
+
puts message.join("\n")
|
|
90
98
|
logger.error(message.join("\n"))
|
|
91
99
|
end
|
|
92
100
|
end
|
|
@@ -99,6 +107,7 @@ module Elasticsearch
|
|
|
99
107
|
#{summary}
|
|
100
108
|
#{duration}
|
|
101
109
|
MSG
|
|
110
|
+
puts
|
|
102
111
|
print TTY::Box.frame(message, width: BOX_WIDTH, title: { top_left: '[SUMMARY]' }, style: { border: { fg: :cyan } })
|
|
103
112
|
logger.info duration
|
|
104
113
|
end
|
|
@@ -132,6 +141,14 @@ module Elasticsearch
|
|
|
132
141
|
end
|
|
133
142
|
end
|
|
134
143
|
|
|
144
|
+
def print_debug_catchable(exception)
|
|
145
|
+
puts TTY::Box.frame(
|
|
146
|
+
"Catchable: #{exception}\nResponse: #{@response}\n",
|
|
147
|
+
width: BOX_WIDTH,
|
|
148
|
+
title: { top_left: '[DEBUG]' }
|
|
149
|
+
)
|
|
150
|
+
end
|
|
151
|
+
|
|
135
152
|
private
|
|
136
153
|
|
|
137
154
|
def boolean_response?
|