elasticsearch-test-runner 0.8.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d09d996ce00f24cbdd34e54d447eff53c19a0a023fa55a61043a5215626e21a8
4
- data.tar.gz: 77fc59d5846f32c165dcb3ac72bf475c0e572a12f03e7aab80a85030b6e6d7c0
3
+ metadata.gz: 74628e9c64f4c668f6e4ef87c94afa47ee6539b22ab3a28ce4fd25e8ae69d457
4
+ data.tar.gz: e9fc240ffa3a200f1e3cb257ba73b297145117a75c19c38e4a7194695e3e5ddb
5
5
  SHA512:
6
- metadata.gz: 69587a3c06c098c03c74e2b26f114228012ee97d73267a5623e44e0d689e776d0c9dc85a1cc503a0ac397c68d9939c338bd6a88bcaf0ffacf2cbf77a31d0cc17
7
- data.tar.gz: 4b4e6315e953fbc534b8fdbc06db5462e7656cee80c1f5edfbd21cbede0956513e2f7d45faff87c77b5cf61a34526d89d9a9b907d4887ff8e9d4cbf4258b6b1b
6
+ metadata.gz: 27b6f144c51341b040891a80a23353b328f1378a3ba33503e3dfbe6f6cf86dc501f45717fb4af9a3b7dd72fe8fa21eae2c5ce91d7e4764a7a877e3fd48ef0590
7
+ data.tar.gz: e94c3308a4733421362d13af89915db5b010ec72d76218ccd7d8efa25a3bf1c8f9e0ea1a19b0e798ba44655b7e8a2df2feab8cc7642c4d97ed1f8aeb353901ff
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.0] - 2024-11-13
4
+
5
+ - Using tar.gz file for downloaded tests instead of zip file.
6
+ - Updates logging and debug information. More information being logged for different levels of Logger.
7
+
8
+ ## [0.9.0] - 2024-08-15
9
+
10
+ - Better display of action and response when `ENV['DEBUG']` is true.
11
+ - Checks for more error types when catching exceptions.
12
+ - Better matching for regular expressions.
13
+ - Refactors `set_param_variable` for better substitution.
14
+
3
15
  ## [0.8.0] - 2024-08-14
4
16
 
5
17
  - Adds support for variable keys (`$`).
@@ -54,10 +54,14 @@ module Elasticsearch
54
54
  method = arrayed_method.last
55
55
  end
56
56
  @response = client.send(method.to_sym, process_params(params))
57
- puts @response if ENV['DEBUG']
57
+ puts "Action: #{action}\nResponse: #{@response}\n\n" if ENV['DEBUG']
58
58
  @response
59
59
  rescue StandardError => e
60
- raise e unless expected_exception?(catchable, e)
60
+ if expected_exception?(catchable, e)
61
+ puts "Catchable: #{e}\nResponse: #{@response}\n" if ENV['DEBUG']
62
+ else
63
+ raise e
64
+ end
61
65
  end
62
66
 
63
67
  def expected_exception?(error_type, e)
@@ -66,7 +70,7 @@ module Elasticsearch
66
70
  case error_type
67
71
  when 'request_timeout'
68
72
  e.is_a?(Elastic::Transport::Transport::Errors::RequestTimeout)
69
- when 'missing'
73
+ when 'missing', /resource_not_found_exception/
70
74
  e.is_a?(Elastic::Transport::Transport::Errors::NotFound)
71
75
  when 'conflict'
72
76
  e.is_a?(Elastic::Transport::Transport::Errors::Conflict)
@@ -85,6 +89,8 @@ module Elasticsearch
85
89
  e.is_a?(Elastic::Transport::Transport::Errors::BadRequest)
86
90
  when /NullPointerException/
87
91
  e.message =~ /\[400\]/
92
+ when /status_exception/
93
+ e.message =~ /\[409\]/
88
94
  else
89
95
  e.message =~ /#{error_type}/
90
96
  end
@@ -109,7 +115,9 @@ module Elasticsearch
109
115
  end
110
116
 
111
117
  def match_regexp(expected, result)
112
- expected.is_a?(String) && expected.match?(/^\//) && result.match?(Regexp.new(expected.gsub('/', '')))
118
+ expected.is_a?(String) &&
119
+ expected.match?(/^\//) &&
120
+ result.match?(Regexp.new(expected.gsub('/', '').strip))
113
121
  end
114
122
 
115
123
  def do_length(action)
@@ -200,7 +208,13 @@ module Elasticsearch
200
208
  end
201
209
 
202
210
  def set_param_variable(params, key, param)
203
- params[key] = instance_variable_get(param.gsub('$', '@')) if param.is_a?(String) && param.include?('$')
211
+ return unless param.is_a?(String) && param.include?("$")
212
+
213
+ # Param can be a single '$value' string or '{ something: $value }'
214
+ repleacable = param.match(/(\$[0-9a-z_-]+)/)[0]
215
+ value = instance_variable_get(repleacable.gsub("$", "@"))
216
+ content = param.gsub(repleacable, value)
217
+ params[key] = content
204
218
  end
205
219
 
206
220
  # Given a list of keys, find the value in a recursively nested document.
@@ -22,18 +22,18 @@ module Elasticsearch
22
22
  # Module for downloading the test files
23
23
  module Downloader
24
24
  class << self
25
- FILENAME = 'tests.zip'.freeze
25
+ FILENAME = 'tests.tar.gz'.freeze
26
26
 
27
27
  def run(path, branch = 'main')
28
28
  delete_files(path)
29
- url = "https://api.github.com/repos/elastic/serverless-clients-tests/zipball/#{branch}"
29
+ url = "https://api.github.com/repos/elastic/serverless-clients-tests/tarball/#{branch}"
30
30
  if download_tests(url)
31
31
  puts "Successfully downloaded #{FILENAME}"
32
32
  else
33
33
  warn "[!] Couldn't download #{FILENAME}"
34
34
  return
35
35
  end
36
- unzip_file(path)
36
+ untar_file(path)
37
37
  File.delete(FILENAME)
38
38
  end
39
39
 
@@ -49,11 +49,11 @@ module Elasticsearch
49
49
 
50
50
  private
51
51
 
52
- def unzip_file(path)
53
- puts 'Unzipping files'
52
+ def untar_file(path)
53
+ puts 'Extracting tar files'
54
54
  puts path
55
- `unzip #{FILENAME} -d #{path}/`
56
- puts 'Removing zip file'
55
+ `tar -zxf #{FILENAME} --strip-components=1 -C #{path}/`
56
+ puts 'Removing tar file'
57
57
  end
58
58
 
59
59
  def delete_files(path)
@@ -70,21 +70,28 @@ module Elasticsearch
70
70
  raise error
71
71
  end
72
72
 
73
- def self.display_errors(errors)
73
+ def self.display_errors(errors, logger)
74
74
  puts "+++ ❌ Errors/Failures: #{errors.count}"
75
75
  errors.map do |error|
76
- puts "🧪 Test: #{error[:file]}"
77
- puts " Action: #{error[:action].first}" if error[:action]
78
- puts "🔬 #{error.class} - #{error[:error].message}"
79
- pp error[:error].backtrace.join("$/\n") if ENV['DEBUG']
80
- puts
76
+ message = []
77
+ message << "🧪 Test: #{error[:file]}"
78
+ message << " Action: #{error[:action].first}" if error[:action]
79
+ message << "🔬 #{error.class} - #{error[:error].message}"
80
+ message << error[:error].backtrace.join("$/\n") if ENV['DEBUG']
81
+ puts message.join("\n")
82
+ logger.error(message.join("\n"))
81
83
  end
82
84
  end
83
85
 
84
- def self.display_summary(tests_count, errors_count, start_time)
86
+ def self.display_summary(tests_count, errors_count, start_time, logger)
85
87
  puts
86
- puts "--- 🧪 Tests: #{tests_count} | Passed: #{tests_count - errors_count} | Failed: #{errors_count}"
87
- puts "--- ⏲ Elapsed time: #{Time.at(Time.now - start_time).utc.strftime("%H:%M:%S")}"
88
+ summary = "🧪 Tests: #{tests_count} | Passed: #{tests_count - errors_count} | Failed: #{errors_count}"
89
+ logger.info summary
90
+ puts "--- #{summary}"
91
+
92
+ duration = "⏲ Elapsed time: #{Time.at(Time.now - start_time).utc.strftime('%H:%M:%S')}"
93
+ logger.info duration
94
+ puts "--- #{duration}"
88
95
  end
89
96
  end
90
97
  end
@@ -25,7 +25,7 @@ module Elasticsearch
25
25
  # Main YAML test runner
26
26
  class TestRunner
27
27
  LOGGER = Logger.new($stdout)
28
- LOGGER.level = Logger::WARN unless ENV['DEBUG']
28
+ LOGGER.level = ENV['DEBUG'] ? Logger::DEBUG : Logger::WARN
29
29
 
30
30
  def initialize(client, path = nil, logger = nil)
31
31
  @client = client
@@ -39,8 +39,8 @@ module Elasticsearch
39
39
 
40
40
  @test_files = select_test_files(test_files)
41
41
  run_the_tests
42
- Elasticsearch::Tests::Printer::display_errors(@errors) unless @errors.empty?
43
- Elasticsearch::Tests::Printer::display_summary(@tests_count, @errors.count, @start_time)
42
+ Elasticsearch::Tests::Printer::display_errors(@errors, @logger) unless @errors.empty?
43
+ Elasticsearch::Tests::Printer::display_summary(@tests_count, @errors.count, @start_time, @logger)
44
44
  if @errors.empty?
45
45
  exit 0
46
46
  else
@@ -93,7 +93,7 @@ module Elasticsearch
93
93
  tests_path = if test_files.empty?
94
94
  "#{@path}/**/*.yml"
95
95
  elsif test_files.include?('yml')
96
- "#{@path}/#{test_files}"
96
+ return ["#{@path}/tests/#{test_files}"]
97
97
  else
98
98
  "#{@path}/#{test_files}/*.yml"
99
99
  end
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Elasticsearch
21
21
  module Tests
22
- VERSION = '0.8.0'
22
+ VERSION = '0.10.0'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-test-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch
@@ -69,7 +69,7 @@ metadata:
69
69
  homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
70
70
  changelog_uri: https://github.com/elastic/es-test-runner-ruby/blob/main/CHANGELOG.md
71
71
  source_code_uri: https://github.com/elastic/es-test-runner-ruby/tree/main
72
- post_install_message:
72
+ post_install_message:
73
73
  rdoc_options: []
74
74
  require_paths:
75
75
  - lib
@@ -84,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.5.11
88
- signing_key:
87
+ rubygems_version: 3.5.20
88
+ signing_key:
89
89
  specification_version: 4
90
90
  summary: Tool to test Elasticsearch clients against the YAML clients test suite.
91
91
  test_files: []