Skip to content

Commit 9e81734

Browse files
committed
[API] Test Runner: Refactor skipped tests into yml file
1 parent 61ccbf5 commit 9e81734

File tree

2 files changed

+56
-39
lines changed

2 files changed

+56
-39
lines changed

elasticsearch-api/spec/rest_yaml_tests_helper.rb

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -64,48 +64,21 @@
6464
end
6565
end
6666

67-
skipped_tests = []
6867

69-
# Response from Elasticsearch is just a String, so it's not possible to compare using headers.
70-
skipped_tests << { file: 'cat.aliases/20_headers.yml',
71-
description: 'Simple alias with yaml body through Accept header' }
72-
73-
# Check version skip logic
74-
skipped_tests << { file: 'create/15_without_id.yml',
75-
description: 'Create without ID' }
76-
77-
# No error is raised
78-
skipped_tests << { file: 'create/15_without_id_with_types.yml',
79-
description: 'Create without ID' }
80-
81-
# Error message doesn't match
82-
skipped_tests << { file: 'tasks.get/10_basic.yml',
83-
description: 'get task test' }
84-
85-
# No error is raised
86-
skipped_tests << { file: 'cat.allocation/10_basic.yml',
87-
description: '*' }
88-
89-
# Figure out how to match response when there is an error
90-
skipped_tests << { file: 'delete/70_mix_typeless_typeful.yml',
91-
description: '*' }
92-
93-
# Figure out how to match response when there is an error
94-
skipped_tests << { file: 'cat.templates/10_basic.yml',
95-
description: '*' }
96-
97-
# Responses are there but not equal (eg.: yellow status)
98-
skipped_tests << { file: 'cluster.health/10_basic.yml',
99-
description: 'cluster health with closed index (pre 7.2.0)' }
100-
101-
# Regular expression not catching exact match:
102-
skipped_tests << { file: 'cat.indices/10_basic.yml',
103-
description: 'Test cat indices output for closed index (pre 7.2.0)' }
104-
105-
SKIPPED_TESTS = skipped_tests
68+
# Skipped tests
69+
file = File.expand_path(__dir__ + '/skipped_tests.yml')
70+
skipped_tests = YAML.load_file(file)
10671

10772
# The directory of rest api YAML files.
108-
REST_API_YAML_FILES = SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
73+
REST_API_YAML_FILES = if ENV['RUN_SKIPPED_TESTS'] # only run the skipped tests if true
74+
SKIPPED_TESTS = []
75+
skipped_tests.map { |test| "#{YAML_FILES_DIRECTORY}/#{test[:file]}" }
76+
else
77+
# If not, define the skipped tests constant and try the single test or all
78+
# the tests
79+
SKIPPED_TESTS = skipped_tests
80+
SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")
81+
end
10982

11083
# The features to skip
11184
REST_API_YAML_SKIP_FEATURES = ['warnings', 'node_selector'].freeze
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Response from Elasticsearch is just a String, so it's not possible to compare using headers.
2+
-
3+
:file: 'cat.aliases/20_headers.yml'
4+
:description: 'Simple alias with yaml body through Accept header'
5+
6+
# Check version skip logic
7+
-
8+
:file: 'create/15_without_id.yml'
9+
:description: 'Create without ID'
10+
11+
# No error is raised
12+
-
13+
:file: 'create/15_without_id_with_types.yml'
14+
:description: 'Create without ID'
15+
16+
# Error message doesn't match
17+
-
18+
:file: 'tasks.get/10_basic.yml'
19+
:description: 'get task test'
20+
21+
# No error is raised
22+
-
23+
:file: 'cat.allocation/10_basic.yml'
24+
:description: '*'
25+
26+
# Figure out how to match response when there is an error
27+
-
28+
:file: 'delete/70_mix_typeless_typeful.yml'
29+
:description: '*'
30+
31+
# Figure out how to match response when there is an error
32+
-
33+
:file: 'cat.templates/10_basic.yml'
34+
:description: '*'
35+
36+
# Responses are there but not equal (eg.: yellow status)
37+
-
38+
:file: 'cluster.health/10_basic.yml'
39+
:description: 'cluster health with closed index (pre 7.2.0)'
40+
41+
# Regular expression not catching exact match:
42+
-
43+
:file: 'cat.indices/10_basic.yml'
44+
:description: 'Test cat indices output for closed index (pre 7.2.0)'

0 commit comments

Comments
 (0)