From d357a6f25b4f363cbc5d1054247e2217ab752a00 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 06:05:25 +0000 Subject: [PATCH 1/6] [CI] Bumps stack to version 9.0.0-SNAPSHOT in tests Branch 8.x has been created to follow 8.x releases and main will now target 9.0.0 --- .github/workflows/main.yml | 4 ++-- .github/workflows/otel.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 766ef5fe2..6b08d2071 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.16.0-SNAPSHOT + stack-version: 9.0.0-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: @@ -40,4 +40,4 @@ jobs: - name: elasticsearch run: cd elasticsearch && bundle exec rake test:all - name: elasticsearch-api - run: rake es:download_artifacts[8.16.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit + run: rake es:download_artifacts[9.0.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit diff --git a/.github/workflows/otel.yml b/.github/workflows/otel.yml index 56d6b9a5f..238305e75 100644 --- a/.github/workflows/otel.yml +++ b/.github/workflows/otel.yml @@ -28,7 +28,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.16.0-SNAPSHOT + stack-version: 9.0.0-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: @@ -42,4 +42,4 @@ jobs: - name: elasticsearch run: cd elasticsearch && bundle exec rake test:all - name: elasticsearch-api - run: rake es:download_artifacts[8.16.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit + run: rake es:download_artifacts[9.0.0-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:spec test:platinum:unit From 09ed4782ae4f7d964e423386ba93fa864cd570dd Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 08:40:14 +0100 Subject: [PATCH 2/6] Bumps main to 9.0.0 --- elasticsearch-api/lib/elasticsearch/api/version.rb | 2 +- elasticsearch/elasticsearch.gemspec | 2 +- elasticsearch/lib/elasticsearch/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index e43ee587d..a8d55bf70 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module API - VERSION = '8.14.0'.freeze + VERSION = '9.0.0'.freeze end end diff --git a/elasticsearch/elasticsearch.gemspec b/elasticsearch/elasticsearch.gemspec index d7dbdc900..c30c83e26 100644 --- a/elasticsearch/elasticsearch.gemspec +++ b/elasticsearch/elasticsearch.gemspec @@ -46,7 +46,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.5' s.add_dependency 'elastic-transport', '~> 8.3' - s.add_dependency 'elasticsearch-api', '8.14.0' + s.add_dependency 'elasticsearch-api', '9.0.0' s.add_development_dependency 'base64' s.add_development_dependency 'bundler' diff --git a/elasticsearch/lib/elasticsearch/version.rb b/elasticsearch/lib/elasticsearch/version.rb index 099a40a40..33758a094 100644 --- a/elasticsearch/lib/elasticsearch/version.rb +++ b/elasticsearch/lib/elasticsearch/version.rb @@ -16,5 +16,5 @@ # under the License. module Elasticsearch - VERSION = '8.14.0'.freeze + VERSION = '9.0.0'.freeze end From 285a9e6a82b6324dbc1148139e54566c7520f1ba Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 08:40:32 +0100 Subject: [PATCH 3/6] Removes 2.7 deprecated code in es-api gemspec --- elasticsearch-api/elasticsearch-api.gemspec | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/elasticsearch-api/elasticsearch-api.gemspec b/elasticsearch-api/elasticsearch-api.gemspec index a458ed60d..f2149ebda 100644 --- a/elasticsearch-api/elasticsearch-api.gemspec +++ b/elasticsearch-api/elasticsearch-api.gemspec @@ -59,15 +59,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'yard' # Gems for testing integrations - s.add_development_dependency 'jsonify' + s.add_development_dependency 'activesupport' s.add_development_dependency 'hashie' - # Temporary support for Ruby 2.6, since it's EOL March 2022: - if RUBY_VERSION < '2.7.0' - s.add_development_dependency 'jbuilder', '< 7.0.0' - else - s.add_development_dependency 'activesupport' - s.add_development_dependency 'jbuilder' - end + s.add_development_dependency 'jbuilder' + s.add_development_dependency 'jsonify' s.add_development_dependency 'cane' s.add_development_dependency 'escape_utils' unless defined? JRUBY_VERSION From 6191b9b4e44254d6a2458d38c0853f379c593a7e Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 15:02:28 +0100 Subject: [PATCH 4/6] [CI] Updates Buildkite STACK_VERSION to 9.0.0-SNAPSHOT --- .buildkite/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index fb64720c2..d7b614666 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -5,7 +5,7 @@ steps: env: RUBY_VERSION: "{{ matrix.ruby }}" TEST_SUITE: "{{ matrix.suite }}" - STACK_VERSION: 8.16.0-SNAPSHOT + STACK_VERSION: 9.0.0-SNAPSHOT TRANSPORT_VERSION: "{{ matrix.transport }}" RUBY_SOURCE: "{{ matrix.ruby_source }}" QUIET: false @@ -67,7 +67,7 @@ steps: provider: "gcp" env: RUBY_VERSION: "3.3" - STACK_VERSION: 8.16.0-SNAPSHOT + STACK_VERSION: 9.0.0-SNAPSHOT ES_YAML_TESTS_BRANCH: main TRANSPORT_VERSION: "8.3" RUBY_SOURCE: "ruby" From e0b9eedd67c5d7e5ba5550fbd968764e37e631db Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 16:02:49 +0100 Subject: [PATCH 5/6] Generator: Refactors code generation for visibility Temporary backport from 8x while we haven't switched generators for 9x --- elasticsearch-api/utils/thor/endpoint_spec.rb | 31 +++++++++++++++++-- .../utils/thor/generate_source.rb | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/elasticsearch-api/utils/thor/endpoint_spec.rb b/elasticsearch-api/utils/thor/endpoint_spec.rb index 30a06a556..a309cbb9e 100644 --- a/elasticsearch-api/utils/thor/endpoint_spec.rb +++ b/elasticsearch-api/utils/thor/endpoint_spec.rb @@ -24,6 +24,23 @@ module API class EndpointSpec include EndpointSpecifics + # These APIs are private, but were added in 8.x since the generator didn't consider + # visibility. They will be removed in 9.x since we're using a different generator that + # considers visibility. But new private APIs code won't be generated for the client. + EXCLUDED_8X = [ + 'autoscaling.delete_autoscaling_policy', 'autoscaling.get_autoscaling_capacity', + 'autoscaling.get_autoscaling_policy', 'autoscaling.put_autoscaling_policy', 'capabilities', + 'connector.secret_delete', 'connector.secret_get', 'connector.secret_post', + 'connector.secret_put', 'fleet.delete_secret', 'fleet.get_secret', 'fleet.post_secret', + 'ml.validate', 'ml.validate_detector', 'monitoring.bulk', 'profiling.flamegraph', + 'profiling.stacktraces', 'profiling.status', 'profiling.topn_functions', + 'security.activate_user_profile', 'security.disable_user_profile', + 'security.enable_user_profile', 'security.get_user_profile', + 'security.has_privileges_user_profile', 'security.suggest_user_profiles', + 'security.update_user_profile_data', 'shutdown.delete_node', 'shutdown.get_node', + 'shutdown.put_node' + ].freeze + def initialize(filepath) @path = Pathname(filepath) json = MultiJson.load(File.read(@path)) @@ -31,14 +48,14 @@ def initialize(filepath) @endpoint_name = json.keys.first full_namespace = parse_full_namespace - @namespace_depth = full_namespace.size > 0 ? full_namespace.size - 1 : 0 + @namespace_depth = full_namespace.size.positive? ? full_namespace.size - 1 : 0 @module_namespace = full_namespace[0, @namespace_depth] @method_name = full_namespace.last @path_parts = parse_endpoint_parts(@spec) @params = @spec['params'] || {} @paths = @spec['url']['paths'].map { |b| b['path'] } if @spec['url'] - @path_params = path_variables.flatten.uniq.collect(&:to_sym) + @path_params = path_variables.flatten.uniq.collect(&:to_sym) @http_method = parse_http_method(@spec) @deprecation_note = @spec['url']['paths'].last&.[]('deprecated') @http_path = parse_http_path(@paths) @@ -71,6 +88,16 @@ def stability @spec['stability'] end + def visibility + @spec['visibility'] + end + + def skippable? + return true if module_namespace.flatten.first == '_internal' + + visibility != 'public' && !EXCLUDED_8X.include?(endpoint_name) + end + # Function that adds the listified h param code def specific_params super(@module_namespace.first, @method_name) diff --git a/elasticsearch-api/utils/thor/generate_source.rb b/elasticsearch-api/utils/thor/generate_source.rb index df60b0004..acdf8bb41 100644 --- a/elasticsearch-api/utils/thor/generate_source.rb +++ b/elasticsearch-api/utils/thor/generate_source.rb @@ -68,7 +68,7 @@ def generate_source @spec = EndpointSpec.new(filepath) say_status 'json', @spec.path, :yellow # Don't generate code for internal APIs: - next if @spec.module_namespace.flatten.first == '_internal' + next if @spec.skippable? path_to_file = output.join(@spec.module_namespace.join('/')).join("#{@spec.method_name}.rb") dir = output.join(@spec.module_namespace.join('/')) From fe3cc221d8f5f64dfb6c24cf2ad3818bba3286b3 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Sep 2024 17:07:56 +0100 Subject: [PATCH 6/6] Skips APIs that are not public in OTel tests --- .../spec/elasticsearch/api/perform_request_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-api/spec/elasticsearch/api/perform_request_spec.rb b/elasticsearch-api/spec/elasticsearch/api/perform_request_spec.rb index a075ce257..44b3fa288 100644 --- a/elasticsearch-api/spec/elasticsearch/api/perform_request_spec.rb +++ b/elasticsearch-api/spec/elasticsearch/api/perform_request_spec.rb @@ -23,7 +23,7 @@ describe 'Perform request args' do Elasticsearch::API::FilesHelper.files.each do |filepath| spec = Elasticsearch::API::EndpointSpec.new(filepath) - next if spec.module_namespace.flatten.first == '_internal' + next if spec.module_namespace.flatten.first == '_internal' || spec.visibility != 'public' # These are the path parts defined by the user in the method argument defined_path_parts = spec.path_params.inject({}) do |params, part|