From 9c068dd5f2a306f68fb108e3fe4fa8e6bce71a89 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 2 Sep 2024 09:50:01 +0100 Subject: [PATCH] YAML Tests: Download branch when in a release branch --- .buildkite/pipeline.yml | 1 + .buildkite/run-yaml-tests.sh | 1 + elasticsearch-api/spec/yaml-test-runner/run.rb | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index de000d3f6..a5bdaa0d5 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -67,6 +67,7 @@ steps: env: RUBY_VERSION: "3.3" STACK_VERSION: 8.15.0-SNAPSHOT + ES_YAML_TESTS_BRANCH: 8.15 TRANSPORT_VERSION: "8.3" RUBY_SOURCE: "ruby" TEST_SUITE: "platinum" diff --git a/.buildkite/run-yaml-tests.sh b/.buildkite/run-yaml-tests.sh index 2a967da7d..ba04b78ca 100644 --- a/.buildkite/run-yaml-tests.sh +++ b/.buildkite/run-yaml-tests.sh @@ -36,6 +36,7 @@ docker run \ --env "BUILDKITE=true" \ --env "TRANSPORT_VERSION=${TRANSPORT_VERSION}" \ --env "STACK_VERSION=${STACK_VERSION}" \ + --env "ES_YAML_TESTS_BRANCH=${ES_YAML_TESTS_BRANCH}" \ --volume $repo:/usr/src/app \ --name elasticsearch-ruby \ --rm \ diff --git a/elasticsearch-api/spec/yaml-test-runner/run.rb b/elasticsearch-api/spec/yaml-test-runner/run.rb index 28f7b8dc8..e2b75c59b 100644 --- a/elasticsearch-api/spec/yaml-test-runner/run.rb +++ b/elasticsearch-api/spec/yaml-test-runner/run.rb @@ -55,11 +55,13 @@ CLIENT = Elasticsearch::Client.new(host: host, transport_options: transport_options) end - tests_path = File.expand_path('./tmp', __dir__) logger = Logger.new($stdout) logger.level = Logger::WARN unless ENV['DEBUG'] -Elasticsearch::Tests::Downloader::run(tests_path) +# If we're running in a release branch, download the corresponding branch for tests +current_branch = `git rev-parse --abbrev-ref HEAD`.strip +branch = current_branch.match(/[0-9]\.[0-9]+/)&.[](0) || ENV['ES_YAML_TESTS_BRANCH'] || nil +Elasticsearch::Tests::Downloader::run(tests_path, branch) Elasticsearch::Tests::TestRunner.new(CLIENT, tests_path, logger).run