Skip to content

Commit

Permalink
[XPACK] Fix logic for checking if a verison should be skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
estolfo committed Apr 5, 2019
1 parent c8a6ec4 commit aab9064
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
14 changes: 3 additions & 11 deletions elasticsearch-xpack/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,10 @@
SKIPPED_TESTS << { file: 'deprecation/10_basic.yml',
description: 'Test Deprecations' }


# TODO
SKIPPED_TESTS << { file: 'ml/forecast.yml',
description: 'Test forecast unknown job' }
# TODO
SKIPPED_TESTS << { file: 'ml/post_data.yml',
description: 'Test POST data with invalid parameters' }
# TODO
SKIPPED_TESTS << { file: 'ml/post_data.yml',
description: 'Test Flush data with invalid parameters' }

# The directory of rest api YAML files.
REST_API_YAML_FILES = SINGLE_TEST || Dir.glob("#{YAML_FILES_DIRECTORY}/**/*.yml")

# The features to skip
REST_API_YAML_SKIP_FEATURES = ['warnings'].freeze


Expand Down
12 changes: 6 additions & 6 deletions elasticsearch-xpack/spec/support/test_file/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def skip_test?(client, features_to_skip = test_file.features_to_skip)
if @skip
@skip.collect { |s| s['skip'] }.any? do |skip|
contains_features_to_skip?(features_to_skip, skip) ||
!version_requirement_met?(client, skip)
skip_version?(client, skip)
end
end
end
Expand All @@ -169,20 +169,20 @@ def pre_defined_skip?
end
end

def version_requirement_met?(client, skip_definition)
return false if skip_definition['version'] == 'all'
def skip_version?(client, skip_definition)
return true if skip_definition['version'] == 'all'
range_partition = /\s*-\s*/
if versions = skip_definition['version'] && skip_definition['version'].partition(range_partition)
low = versions[0]
high = versions[2] unless versions[2] == ''
range = low..high
begin
client_version = client.info['version']['number']
server_version = client.info['version']['number']
rescue
warn('Could not determine Elasticsearch version when checking if test should be skipped.')
end
range.cover?(client_version)
end || true
range.cover?(server_version)
end
end

def is_a_validation?(action)
Expand Down

0 comments on commit aab9064

Please sign in to comment.