Skip to content

CI cleanup #2566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .buildkite/run-tests.sh

This file was deleted.

9 changes: 7 additions & 2 deletions CHANGELOG-9.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ The size of both `elasticsearch` and `elasticsearch-api` gems will be smaller, s

The required Ruby version is set to `2.6` to keep compatiblity wit JRuby 9.3. However, we only test the code against currently supported Ruby versions.

## Elasticsearch Serverless

The CI build now runs tests to ensure compatibility with Elasticsearch Serverless. You can use this gem for your Serverless deployments.

## Elasticsearch API

### Development

#### Testing

Migrated away from the Elasticsearch REST API tests and test runner in CI. We now run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby). This gives us more control on what we're testing and makes the Buildkite build way faster in Pull Requests and scheduled builds.
The gem migrated away from the Elasticsearch REST API tests and test runner in CI. We now run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby). This gives us more control on what we're testing and makes the Buildkite build way faster in Pull Requests and scheduled builds.

#### Rake tasks

Some old rake tasks that were not being used have been removed. The rest were streamlined, the `es` namespace has been streamlined to make it easier to run Elasticsearch with Docker during development. The `docker` namespace was merged into `es`.
* Some old rake tasks that were not being used have been removed. The rest were streamlined, the `es` namespace has been streamlined to make it easier to run Elasticsearch with Docker during development. The `docker` namespace was merged into `es`.
* Elasticsearch's REST API Spec tests can still be ran with `rake test:es_free` and `rake test:es_platinum`.
2 changes: 1 addition & 1 deletion elasticsearch-api/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace :test do
t.exclude_pattern = 'spec/platinum/**/*_spec.rb'
end

desc 'Run Rest API Spec tests'
desc 'Run Elasticsearch test suite free tests.'
RSpec::Core::RakeTask.new(:rest_api) do |t|
test_dir = Rake.application.original_dir
t.pattern = "#{test_dir}/spec/rest_api/rest_api_yaml_spec.rb"
Expand Down
6 changes: 5 additions & 1 deletion elasticsearch-api/api-spec-testing/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Rest API YAML Test Runner

The specs in `elasticsearch-api` automatically run the tests from [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite). The test runner is defined in the `spec` folder, starting with the `rest_api_yaml_spec.rb` file.
The integration tests on this project run the [Elasticsearch Client tests](https://github.com/elastic/elasticsearch-clients-tests/) with the [Elasticsearch Tests Runner](https://github.com/elastic/es-test-runner-ruby/) library. This runs in CI against an Elasticsearch cluster in Docker. The [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite) can still be ran following the instructions below:

## Elasticsearch Test Suite

The specs in `elasticsearch-api` can run the tests from [Elasticsearch's REST API Spec tests](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec/src/main/resources/rest-api-spec/test#test-suite). The test runner is defined in the `spec` folder, starting with the `rest_api_yaml_spec.rb` file.

You can run the tests with Rake. The main task is `rake test:rest_api`. This task will evaluate the `TEST_SUITE` environment variable. It will run either the `free` or `platinum` tests suites depending on the value of `TEST_SUITE`. If you don't set this value, the task will run the `free` test suite by default. To run the `platinum` test suite use:
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
#
module Elasticsearch
module API
module Inference
module Actions
# Perform inference using the Unified Schema
#
# @option arguments [String] :inference_id The inference Id
# @option arguments [String] :task_type The task type
# @option arguments [Hash] :headers Custom HTTP headers
# @option arguments [Hash] :body The inference payload
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/unified-inference-api.html
#
def unified_inference(arguments = {})
request_opts = { endpoint: arguments[:endpoint] || 'inference.unified_inference' }

defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]

arguments = arguments.clone
headers = arguments.delete(:headers) || {}

body = arguments.delete(:body)

_inference_id = arguments.delete(:inference_id)

_task_type = arguments.delete(:task_type)

method = Elasticsearch::API::HTTP_POST
path = if _task_type && _inference_id
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}/_unified"
else
"_inference/#{Utils.__listify(_inference_id)}/_unified"
end
params = {}

Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers, request_opts)
)
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require 'spec_helper'

describe 'client#inference.unified_inference' do
let(:expected_args) do
[
'POST',
'_inference/foo/bar/_unified',
{},
nil,
{},
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
endpoint: 'inference.unified_inference' }
]
end

it 'performs the request' do
expect(client_double.inference.unified_inference(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
end
end
8 changes: 4 additions & 4 deletions rake_tasks/test_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ namespace :test do
end
end

desc 'Run rest api tests'
task rest_api: ['es:wait_for_green'] do
desc 'Run Elasticsearch test suite free tests.'
task es_free: ['es:wait_for_green'] do
puts '-' * 80
sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && bundle exec rake test:rest_api"
puts "\n"
end

desc 'Run security (Platinum) rest api yaml tests'
task security: 'es:wait_for_green' do
desc 'Run Elasticsearch test suite platinum tests.'
task es_platinum: 'es:wait_for_green' do
puts '-' * 80
sh "cd #{CURRENT_PATH.join('elasticsearch-api')} && unset BUNDLE_GEMFILE && TEST_SUITE=platinum bundle exec rake test:rest_api"
puts "\n"
Expand Down
Loading