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
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def fetch_artifact_configuration(schema_artifacts, index_def_name)
end
end

context "when a concrete index has been derived from the template", :factories do
context "when a concrete index has been derived from the template", :factories, :ingests_json_data do
include ConcreteIndexAdapter

# our schema in the tests here is more limited than the main widget schema, so select only some fields.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def simulate_presence_of_extra_setting(admin, index_definition_name, name, value
end
end

RSpec.shared_examples_for IndexDefinitionConfigurator, :uses_datastore, :builds_indexer do
RSpec.shared_examples_for IndexDefinitionConfigurator, :uses_datastore do
let(:output_io) { StringIO.new }
let(:clock) { class_double(::Time, now: ::Time.utc(2024, 3, 20, 12, 0, 0)) }
let(:mapping_removal_note_snippet) { "extra fields listed here will not actually get removed" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module ElasticGraph
class DatastoreCore
module IndexDefinition
RSpec.describe RolloverIndexTemplate, :uses_datastore, :builds_indexer do
RSpec.describe RolloverIndexTemplate, :ingests_json_data do
# Use different index names than any other tests use, because most tests expect a specific index
# configuration (based on `config/schema.graphql`) and we do not want to mess with it here.
let(:index_prefix) { unique_index_name }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ class << self

self.camel_case_cluster_configured = false

RSpec.shared_context "ElasticGraph GraphQL acceptance support", :factories, :uses_datastore, :capture_logs, :builds_indexer, :builds_admin do
# We list the `:ingests_json_data` component tags (`:json_ingestion_schema_definition`,
# `:uses_datastore`, `:builds_indexer`) individually rather than using `:ingests_json_data`
# itself. Applying the derived `:ingests_json_data` tag to a `shared_context` and then combining
# it with `include_examples` crashes RSpec (`undefined method 'key?' for nil`), whereas literal
# tags are inherited correctly. Once https://github.com/rspec/rspec/issues/333 is fixed we can
# collapse these back to `:ingests_json_data`.
RSpec.shared_context "ElasticGraph GraphQL acceptance support", :factories, :json_ingestion_schema_definition, :uses_datastore, :builds_indexer, :capture_logs, :builds_admin do
include GraphQLSupport
include PreventSearchesFromUsingWriteRequests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

require "elastic_graph/graphql"
require "elastic_graph/indexer"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"
require "support/graphql"

module ElasticGraph
RSpec.describe "Querying an evolving schema", :uses_datastore, :factories, :capture_logs, :in_temp_dir, :rake_task do
RSpec.describe "Querying an evolving schema", :ingests_json_data, :factories, :capture_logs, :in_temp_dir, :rake_task do
include GraphQLSupport

let(:path_to_schema) { "config/schema.rb" }
Expand Down Expand Up @@ -66,7 +65,7 @@ def dump_schema_artifacts(json_schema_version:, team_extras: "")
run_rake "schema_artifacts:dump" do |output|
SchemaDefinition::RakeTasks.new(
schema_element_name_form: :snake_case,
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
extension_modules: json_ingestion_schema_definition_extension_modules,
index_document_sizes: true,
path_to_schema: path_to_schema,
schema_artifacts_directory: "config/schema/artifacts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ class GraphQL
# triggered a `null_pointer_exception` in one shard, which caused the datastore to
# return a partial response that our router handled by logging a warning. The
# `:capture_logs` here caused the tests to fail until we fixed that issue.
RSpec.shared_context "DatastoreQueryIntegrationSupport", :uses_datastore, :factories, :capture_logs do
#
# We list the `:ingests_json_data` component tags (`:json_ingestion_schema_definition`,
# `:uses_datastore`, `:builds_indexer`) individually rather than using `:ingests_json_data`
# itself. Applying the derived `:ingests_json_data` tag to a `shared_context` and then combining
# it with `include_examples` crashes RSpec (`undefined method 'key?' for nil`), whereas literal
# tags are inherited correctly. Once https://github.com/rspec/rspec/issues/333 is fixed we can
# collapse these back to `:ingests_json_data`.
RSpec.shared_context "DatastoreQueryIntegrationSupport", :json_ingestion_schema_definition, :uses_datastore, :builds_indexer, :factories, :capture_logs do
include AggregationsHelpers
include SortSupport

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
module ElasticGraph
class GraphQL
module Resolvers
RSpec.describe IndexedTypeRootFieldsResolver, :factories, :uses_datastore, :resolver do
RSpec.describe IndexedTypeRootFieldsResolver, :factories, :ingests_json_data, :resolver do
context "when the field being resolved is a relay connection field" do
let(:graphql) { build_graphql }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module ElasticGraph
class GraphQL
module Resolvers
RSpec.describe NestedRelationshipsSource, :factories, :uses_datastore, :capture_logs do
RSpec.describe NestedRelationshipsSource, :factories, :ingests_json_data, :capture_logs do
include AggregationsHelpers

let(:merged_queries_message_type) { "NestedRelationshipsMergedQueries" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
module ElasticGraph
class GraphQL
module Resolvers
RSpec.describe NestedRelationships, :factories, :uses_datastore, :capture_logs, :resolver do
RSpec.describe NestedRelationships, :factories, :ingests_json_data, :capture_logs, :resolver do
# :expect_search_routing because the relation we use here uses an outbaund foreign key, which
# is implemented via a filter on `id` (the search routing field)
context "when the field being resolved is a relay connection field", :expect_search_routing do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
module ElasticGraph
class GraphQL
module Resolvers
RSpec.describe QuerySource, :factories, :uses_datastore do
RSpec.describe QuerySource, :factories, :ingests_json_data do
let(:graphql) { build_graphql }

it "batches up multiple queries, sending an msearch request containing them all to the datastore" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ def resolve(field:, object:, args:, context:)

schema.scalar_type "Operands" do |t|
t.mapping type: nil
t.json_schema type: "null"
end

schema.object_type "Widget" do |t|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module Resolvers
self.schema_artifacts = generate_schema_artifacts do |schema|
schema.scalar_type "MyInt" do |t|
t.mapping type: "integer"
t.json_schema type: "integer"
end

schema.object_type "PersonIdentifiers" do |t|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module ScalarCoercionAdapters
RSpec.describe "NoOp" do
include_context("scalar coercion adapter support", "SomeCustomScalar", schema_definition: ->(schema) do
schema.scalar_type "SomeCustomScalar" do |t|
t.json_schema type: "null"
t.mapping type: nil
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ def search_index_definitions_from(type_name: "TheType")
schema = define_schema do |s|
s.scalar_type "CustomScalar" do |t|
t.mapping type: "keyword"
t.json_schema type: "string"
end
end

Expand All @@ -967,7 +966,6 @@ def search_index_definitions_from(type_name: "TheType")
schema = define_schema do |s|
s.scalar_type "CustomScalar" do |t|
t.mapping type: "keyword"
t.json_schema type: "string"
t.grouping_missing_value_placeholder "MISSING"
end
end
Expand All @@ -980,7 +978,6 @@ def search_index_definitions_from(type_name: "TheType")
schema = define_schema do |s|
s.scalar_type "CustomScalar" do |t|
t.mapping type: "keyword"
t.json_schema type: "string"
t.grouping_missing_value_placeholder nil
end
end
Expand All @@ -1007,7 +1004,6 @@ def search_index_definitions_from(type_name: "TheType")
t.field "name", "String"
t.field "count", "Int"
t.field "price", "Float"
t.field "big_number", "JsonSafeLong"
t.index "things"
end
end
Expand All @@ -1016,7 +1012,6 @@ def search_index_definitions_from(type_name: "TheType")
expect(schema.type_named("String").grouping_missing_value_placeholder).to eq MISSING_STRING_PLACEHOLDER_VALUE
expect(schema.type_named("Int").grouping_missing_value_placeholder).to eq MISSING_NUMERIC_PLACEHOLDER
expect(schema.type_named("Float").grouping_missing_value_placeholder).to eq MISSING_NUMERIC_PLACEHOLDER
expect(schema.type_named("JsonSafeLong").grouping_missing_value_placeholder).to eq MISSING_NUMERIC_PLACEHOLDER
end

it "returns nil for object types" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class GraphQL
define_schema do |schema|
schema.scalar_type "_FieldSet" do |t|
t.mapping type: "keyword"
t.json_schema type: "string"
end

schema.object_type "Widget" do |t|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "elasticgraph-admin", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-indexer", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

module ElasticGraph
module HealthCheck
RSpec.describe "HealthChecker", :uses_datastore, :factories, :builds_graphql, :capture_logs do
RSpec.describe "HealthChecker", :ingests_json_data, :factories, :builds_graphql, :capture_logs do
let(:now) { ::Time.iso8601("2022-02-14T12:30:00Z") }
let(:graphql) { build_graphql }
let(:health_checker) { HealthChecker.build_from(graphql) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# frozen_string_literal: true

module ElasticGraph
RSpec.describe "A derived indexing type", :uses_datastore, :factories, :capture_logs do
RSpec.describe "A derived indexing type", :ingests_json_data, :factories, :capture_logs do
let(:indexer) { build_indexer }

it "maintains derived fields, handling nested source and destination fields as needed" do
Expand Down
2 changes: 1 addition & 1 deletion elasticgraph-indexer/spec/acceptance/list_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# frozen_string_literal: true

module ElasticGraph
RSpec.describe "Indexing into list fields", :uses_datastore, :factories, :capture_logs do
RSpec.describe "Indexing into list fields", :ingests_json_data, :factories, :capture_logs do
let(:indexer) { build_indexer }

it "indexes counts of any list fields so we can later use it for filtering" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# frozen_string_literal: true

module ElasticGraph
RSpec.describe "Nested multi-source indexing", :uses_datastore, :factories, :capture_logs do
RSpec.describe "Nested multi-source indexing", :ingests_json_data, :factories, :capture_logs do
let(:indexer) { build_indexer }
let(:league) { "NBA" }
let(:formed_on) { "2019-04-23" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
# frozen_string_literal: true

require "elastic_graph/indexer"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"

module ElasticGraph
RSpec.describe "Indexing schema evolution", :uses_datastore, :factories, :capture_logs, :in_temp_dir, :rake_task do
RSpec.describe "Indexing schema evolution", :ingests_json_data, :factories, :capture_logs, :in_temp_dir, :rake_task do
let(:path_to_schema) { "config/schema.rb" }

before do
Expand Down Expand Up @@ -402,7 +401,7 @@ def dump_artifacts
run_rake "schema_artifacts:dump" do |output|
SchemaDefinition::RakeTasks.new(
schema_element_name_form: :snake_case,
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
extension_modules: json_ingestion_schema_definition_extension_modules,
index_document_sizes: true,
path_to_schema: path_to_schema,
schema_artifacts_directory: "config/schema/artifacts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# frozen_string_literal: true

module ElasticGraph
RSpec.describe "Top-level multi-source indexing", :uses_datastore, :factories, :capture_logs do
RSpec.describe "Top-level multi-source indexing", :ingests_json_data, :factories, :capture_logs do
let(:indexer) { build_indexer }

it "ingests data from multiple source types into a single document, regardless of the ingestion order" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

module ElasticGraph
class Indexer
RSpec.describe DatastoreIndexingRouter, :uses_datastore, :capture_logs do
RSpec.describe DatastoreIndexingRouter, :ingests_json_data, :capture_logs do
describe "#source_event_versions_in_index", :factories do
let(:indexer) { build_indexer }
let(:router) { indexer.datastore_router }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

module ElasticGraph
class Indexer
RSpec.describe Processor, :uses_datastore, :factories, :capture_logs do
RSpec.describe Processor, :ingests_json_data, :factories, :capture_logs do
let(:indexer) { build_indexer }

context "process non-rollover upsert events" do
Expand Down
2 changes: 1 addition & 1 deletion elasticgraph-indexer/spec/support/indexing_preparer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# For example, to see your indexing preparer being used, this requires that it is registered
# on your scalar type correctly, whereas if this directly called your indexing preparer
# it wouldn't require it to be correctly registered.
RSpec.shared_context "indexing preparer support" do |scalar_type|
RSpec.shared_context "indexing preparer support", :json_ingestion_schema_definition do |scalar_type|
before(:context) do
@record_preparer = build_indexer(clients_by_name: {}, schema_definition: lambda do |schema|
schema.object_type "MyType" do |t|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

module ElasticGraph
class Indexer
::RSpec.shared_context "MultipleVersionSupport" do
::RSpec.shared_context "MultipleVersionSupport", :json_ingestion_schema_definition do
include_context "SchemaDefinitionHelpers"

def build_indexer_with_multiple_schema_versions(schema_versions:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

module ElasticGraph
class Indexer
RSpec.describe DatastoreIndexingRouter, :capture_logs do
RSpec.describe DatastoreIndexingRouter, :json_ingestion_schema_definition, :capture_logs do
include SpecSupport::BuildsIndexerOperation

let(:main_datastore_client) { instance_spy(Elasticsearch::Client, cluster_name: "main") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
module ElasticGraph
class Indexer
module Operation
RSpec.describe Update do
RSpec.describe Update, :json_ingestion_schema_definition do
include SchemaArtifacts::RuntimeMetadata::RuntimeMetadataSupport

let(:indexer) { build_indexer }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

module ElasticGraph
class Indexer
RSpec.describe RecordPreparer::Factory do
RSpec.describe RecordPreparer::Factory, :json_ingestion_schema_definition do
include_context "MultipleVersionSupport"

let(:factory_with_multiple_versions) do
Expand Down Expand Up @@ -54,7 +54,7 @@ class Indexer
end
end

RSpec.describe RecordPreparer do
RSpec.describe RecordPreparer, :json_ingestion_schema_definition do
describe "#prepare_for_index" do
it "tolerates a `nil` value where an object would usually be" do
preparer = build_preparer do |s|
Expand Down Expand Up @@ -494,7 +494,7 @@ class Indexer
end
end

context "when working with events for an old JSON schema version" do
context "when working with events for an old JSON schema version", :json_ingestion_schema_definition do
include_context "SchemaDefinitionHelpers"

it "handles events for old versions before a field was deleted" do
Expand Down Expand Up @@ -578,7 +578,7 @@ def build_preparer_for_old_json_schema_version(v1_def:, v2_def:)
def define_schema(&schema_definition)
super(
schema_element_name_form: "snake_case",
extension_modules: [JSONIngestion::SchemaDefinition::APIExtension],
extension_modules: json_ingestion_schema_definition_extension_modules,
&schema_definition
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# frozen_string_literal: true

require "elastic_graph/constants"
require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/schema_definition/rake_tasks"
require "yaml"

Expand Down Expand Up @@ -620,7 +619,7 @@ def as_active_instance
index_document_sizes: true,
path_to_schema: "schema.rb",
schema_artifacts_directory: "config/schema/artifacts",
extension_modules: [APIExtension, extension_module],
extension_modules: json_ingestion_schema_definition_extension_modules([extension_module]),
output: output
)
end
Expand Down
11 changes: 11 additions & 0 deletions elasticgraph-json_ingestion/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@

# This file contains RSpec configuration for `elasticgraph-json_ingestion`.
# It is loaded by the shared spec helper at `spec_support/spec_helper.rb`.

require "elastic_graph/json_ingestion/schema_definition/api_extension"
require "elastic_graph/spec_support/schema_definition_helpers"

RSpec.configure do |config|
config.define_derived_metadata(absolute_file_path: %r{/elasticgraph-json_ingestion/}) do |meta|
meta[:json_ingestion_schema_definition] = true
end

config.include_context "SchemaDefinitionHelpers", :json_ingestion_schema_definition
end
Loading