elasticsearch-test-runner 0.10.0 → 0.11.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: 74628e9c64f4c668f6e4ef87c94afa47ee6539b22ab3a28ce4fd25e8ae69d457
4
- data.tar.gz: e9fc240ffa3a200f1e3cb257ba73b297145117a75c19c38e4a7194695e3e5ddb
3
+ metadata.gz: '0271385db599d8551f6a83a8cc3c349fb9e9e419404e2a6551ad1a79a609530b'
4
+ data.tar.gz: d7c7a28831431f41c3b60b63fa6a0f56ce6683b87bbaabd7531414e3cd45e12b
5
5
  SHA512:
6
- metadata.gz: 27b6f144c51341b040891a80a23353b328f1378a3ba33503e3dfbe6f6cf86dc501f45717fb4af9a3b7dd72fe8fa21eae2c5ce91d7e4764a7a877e3fd48ef0590
7
- data.tar.gz: e94c3308a4733421362d13af89915db5b010ec72d76218ccd7d8efa25a3bf1c8f9e0ea1a19b0e798ba44655b7e8a2df2feab8cc7642c4d97ed1f8aeb353901ff
6
+ metadata.gz: bf8130ff5fd1161285c9f9c0bcecd545ea10e2c28788febf0e19ff180c3088eec9090b7dc73da0d7902f7c3cef88a0617aa24079ac737ec80e7733662606dfa7
7
+ data.tar.gz: 296a138149fb4c1fd8388dff6ab0ebcf492daf07650c5b2c5df865d7bf99227dc3b450097474a6c55be2bb511a6bb1e6cc38c93a3358a88a86d357855c880e8f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0] - 2024-12-12
4
+
5
+ - Adds skipping tests.
6
+
7
+ ## [0.10.1] - 2024-11-13
8
+
9
+ - Creates directory for tests if it doesn't exist.
10
+
3
11
  ## [0.10.0] - 2024-11-13
4
12
 
5
13
  - Using tar.gz file for downloaded tests instead of zip file.
data/README.md CHANGED
@@ -29,6 +29,9 @@ Elasticsearch::Tests::TestRunner.new(client, tests_path).run
29
29
 
30
30
  [The tests](https://github.com/elastic/elasticsearch-clients-tests) are designed for the Elasticsearch REST API and the Elasticsearch Serverless REST API. If you pass in an `ElasticsearchServerless::Client`, it will only run the tests that have the `requires.serverless: true` statement. Otherwise, it will only run the ones with `requires.stack: true`.
31
31
 
32
+
33
+ ### Logging
34
+
32
35
  You can optionally pass in an object that implements Ruby's Logger to the `TestRunner` initializer. This will log more information, particularly useful in the case of errors where it'll log stacktraces for exceptions and more:
33
36
 
34
37
  ```ruby
@@ -39,6 +42,8 @@ runner = Elasticsearch::Tests::TestRunner.new(client, tests_path, logger)
39
42
  runner.run
40
43
  ```
41
44
 
45
+ ### Running particular tests
46
+
42
47
  When you run the tests, you can pass in the name of a particular test or a whole test folder, to run only those tests. Tests in the clients project are located [in the `tests` directory](https://github.com/elastic/elasticsearch-clients-tests/tree/main/tests) either as single yaml files or inside a specific directory, referring to a specific namespace. For example [`tests/get.yml`](https://github.com/elastic/elasticsearch-clients-tests/blob/main/tests/get.yml) and [`tests/bulk/10_basic.yml`](https://github.com/elastic/elasticsearch-clients-tests/blob/main/tests/bulk/10_basic.yml). If you want to run the `get.yml` test, you can pass in the file name to `run`:
43
48
 
44
49
  ```ruby
@@ -59,6 +64,18 @@ runner.run('indices')
59
64
 
60
65
  This will run all the tests in [`tests/indices`](https://github.com/elastic/elasticsearch-clients-tests/tree/main/tests/indices) such as `alias.yml`, `analyze.yml`, and so on.
61
66
 
67
+ ### Skipping tests
68
+
69
+ If you want to skip any given tests, you can do it using `add_tests_to_skip` before calling `run` like this:
70
+
71
+ ```ruby
72
+ runner.add_tests_to_skip(['bulk/10_basic.yml', 'get.yml'])
73
+ ```
74
+
75
+ You need to pass in an Array of file or folder names, or a single test file as a String.
76
+
77
+ ### Downloading the test suite
78
+
62
79
  You can **download the YAML test files** from [the clients tests project](https://github.com/elastic/elasticsearch-clients-tests) with the following code:
63
80
 
64
81
  ```ruby
@@ -52,6 +52,7 @@ module Elasticsearch
52
52
  def untar_file(path)
53
53
  puts 'Extracting tar files'
54
54
  puts path
55
+ FileUtils.mkdir_p(path) unless File.directory?(path)
55
56
  `tar -zxf #{FILENAME} --strip-components=1 -C #{path}/`
56
57
  puts 'Removing tar file'
57
58
  end
@@ -32,6 +32,15 @@ module Elasticsearch
32
32
  @serverless = defined?(::ElasticsearchServerless) && client.is_a?(::ElasticsearchServerless::Client)
33
33
  @path = path || File.expand_path('./tmp', __dir__)
34
34
  @logger = logger || LOGGER
35
+ @tests_to_skip = []
36
+ end
37
+
38
+ def add_tests_to_skip(tests)
39
+ if tests.is_a? String
40
+ @tests_to_skip << tests
41
+ else
42
+ @tests_to_skip.merge!(tests)
43
+ end
35
44
  end
36
45
 
37
46
  def run(test_files = [])
@@ -97,7 +106,13 @@ module Elasticsearch
97
106
  else
98
107
  "#{@path}/#{test_files}/*.yml"
99
108
  end
100
- Dir.glob(tests_path)
109
+ tests = Dir.glob(tests_path)
110
+ tests.each do |test|
111
+ @tests_to_skip.each do |skip|
112
+ tests.delete(test) if test.match?(skip)
113
+ end
114
+ end
115
+ tests
101
116
  end
102
117
 
103
118
  def extract_requires!(yaml)
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Elasticsearch
21
21
  module Tests
22
- VERSION = '0.10.0'
22
+ VERSION = '0.11.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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic Client Library Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch