Skip to content
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
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ require 'pathname'
CURRENT_PATH = Pathname(File.expand_path(__dir__))
SUBPROJECTS = [
'elasticsearch',
'elasticsearch-api',
'elasticsearch-api/utils'
'elasticsearch-api'
].freeze

RELEASE_TOGETHER = [
Expand Down
10 changes: 4 additions & 6 deletions elasticsearch-api/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require 'simplecov'
SimpleCov.start do
add_filter %r{^/test|spec/}
add_filter 'utils/thor'
end
end

Expand All @@ -27,14 +26,13 @@
else
require 'debug'
end
require 'yaml'
# require 'active_support/isolated_execution_state' unless RUBY_VERSION < '2.7.0'
require 'jbuilder'
require 'jsonify'
require 'elasticsearch'
require 'elasticsearch-api'
require 'openssl'
require 'jbuilder'
require 'jsonify'
require 'logger'
require 'openssl'
require 'yaml'

tracer = ::Logger.new(STDERR)
tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n } }\n" }
Expand Down
53 changes: 47 additions & 6 deletions elasticsearch-api/spec/unit/perform_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,55 @@
require 'elastic-transport'
require 'spec_helper'

require_relative File.expand_path('../../utils/thor/endpoint_spec', __dir__)
require_relative File.expand_path('../../utils/thor/generator/files_helper', __dir__)
# Helper Class to replace the EndpointSpec class from the old code generator. The created object
# will store some relevant data to the endpoint specification so that it can be used to test
# OpenTelemetry.
class EndpointSpec
attr_reader :module_namespace,
:method_name,
:endpoint_name,
:visibility

def initialize(filepath)
@path = Pathname(filepath)
json = MultiJson.load(File.read(@path))
@endpoint_name = json.keys.first

full_namespace = parse_full_namespace
@namespace_depth = full_namespace.size.positive? ? full_namespace.size - 1 : 0
@module_namespace = full_namespace[0, @namespace_depth]
@visivility = json.values.first['visibility']
end

def parse_full_namespace
names = @endpoint_name.split('.')
# Return an array to expand 'ccr', 'ilm', 'ml' and 'slm'
names.map do |name|
name
.gsub(/^ml$/, 'machine_learning')
.gsub(/^ilm$/, 'index_lifecycle_management')
.gsub(/^ccr/, 'cross_cluster_replication')
.gsub(/^slm/, 'snapshot_lifecycle_management')
end
end
end

# JSON spec files to test
# This is a helper which used to be in the FilesHelper module in the old code generator. It goes
# through the files in the Elasticsearch JSON specification to see which methods need to be tested
# and how.
def files
src_path = File.expand_path('../../../tmp/rest-api-spec/api/', __dir__)

Dir.entries(src_path).reject do |file|
File.extname(file) != '.json' ||
File.basename(file) == '_common.json'
end.map { |file| "#{src_path}/#{file}" }
end

describe 'Perform request args' do
Elasticsearch::API::FilesHelper.files.each do |filepath|
spec = Elasticsearch::API::EndpointSpec.new(filepath)
files.each do |filepath|
spec = EndpointSpec.new(filepath)
next if spec.module_namespace.flatten.first == '_internal' ||
spec.visibility != 'public' ||
# TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed
Expand Down Expand Up @@ -56,8 +99,6 @@
params.merge(part.to_sym => 'testing')
end

required_params.merge!(body: {}) if ['inference.put', 'inference.update', 'inference.chat_completion_unified'].include? spec.endpoint_name

let(:client_double) do
Class.new { include Elasticsearch::API }.new.tap do |client|
expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params|
Expand Down
28 changes: 0 additions & 28 deletions elasticsearch-api/utils/Gemfile

This file was deleted.

48 changes: 0 additions & 48 deletions elasticsearch-api/utils/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions elasticsearch-api/utils/Thorfile

This file was deleted.

4 changes: 0 additions & 4 deletions elasticsearch-api/utils/thor/.rubocop.yml

This file was deleted.

201 changes: 0 additions & 201 deletions elasticsearch-api/utils/thor/endpoint_spec.rb

This file was deleted.

Loading