From aab9064126ef82f59c516011713b89811379aac4 Mon Sep 17 00:00:00 2001 From: Emily Stolfo Date: Fri, 5 Apr 2019 15:06:54 +0200 Subject: [PATCH] [XPACK] Fix logic for checking if a verison should be skipped --- elasticsearch-xpack/spec/spec_helper.rb | 14 +++----------- elasticsearch-xpack/spec/support/test_file/test.rb | 12 ++++++------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/elasticsearch-xpack/spec/spec_helper.rb b/elasticsearch-xpack/spec/spec_helper.rb index 6ba8361f3f..53baba71bd 100644 --- a/elasticsearch-xpack/spec/spec_helper.rb +++ b/elasticsearch-xpack/spec/spec_helper.rb @@ -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 diff --git a/elasticsearch-xpack/spec/support/test_file/test.rb b/elasticsearch-xpack/spec/support/test_file/test.rb index 1790c04fd9..bb7041f3fd 100644 --- a/elasticsearch-xpack/spec/support/test_file/test.rb +++ b/elasticsearch-xpack/spec/support/test_file/test.rb @@ -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 @@ -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)