Skip to content

Commit 57bc8ae

Browse files
jwilsmyronmarston
andauthored
Run indexer acceptance and integration specs against each ingestion format (#1412)
## Why Protobuf ingestion should support everything JSON ingestion does. The indexer acceptance and integration specs are the best record of what JSON ingestion supports, but they only run against JSON. Running them against protobuf too would show each gap as the protobuf stack closes it. ## What Run all indexer acceptance and integration specs once per ingestion format, in `with json ingestion` and `with proto ingestion` contexts. The protobuf examples are `pending` because the indexer cannot ingest protobuf events yet. RSpec still runs pending examples and fails any that pass. As protobuf ingestion lands, the blanket `pending` gives way to `pending` metadata on the examples that still fail. RSpec then flags each of those examples as its gap closes. ## How A new `spec_support/.../ingestion_formats.rb` provides `for_each_ingestion_format`, which defines a context per format. Examples keep building events with the JSON factories. They process them through `process_indexing_events`, which calls `round_trip_indexing_events` (and `index_records` for the derived-type spec). For JSON, the round trip returns the events unchanged. For protobuf, it raises `NotImplementedError` for now; the protobuf stack will replace that with publishing to and decoding from protobuf. The names match the harness in #1388 so the stack can rebase onto this. The protobuf contexts build indexers from the stock schema defined with the protobuf extension, cached once per process. `schema_evolution_spec` dumps protobuf-only artifacts and leaves out `json_schema_version`. The malformed-event examples in `processor_spec` run only for JSON. Their events have wrong primitive types (e.g. `name: 17`), which a protobuf publisher can't encode. This also fixes the VCR hook. It skipped recording a cassette only when `ex.exception` was set. RSpec stores the expected failure of a pending example in `execution_result.pending_exception` instead, so failing pending examples got recorded. After a gap closed, replaying that cassette would fail the example with a VCR error, so it stayed pending and RSpec never reported it fixed. I checked this locally by making the protobuf round trip return events unchanged: before the fix, examples stayed pending; after it, RSpec reports them `FIXED`. ## Risk Low. Only specs and spec support change. The JSON examples are the same 52 as before. ## Testing No manual testing. On main, the proto variants already show real gaps beyond the stubbed round trip. Protobuf-only artifacts give "No ingestion adapters are available". Removing a field or type doesn't abort the dump the way the JSON schema version check does. ## Bigger picture This follows up on Myron's suggestion to run the indexer specs against both formats and use `pending` for the gaps. The protobuf ingestion stack (#1405 → #1408 → #1406 → #1388) can rebase onto this, implement `round_trip_indexing_events` for protobuf, and replace the blanket `pending` with per-example metadata. Schema evolution for protobuf will also need to encode old events with the old compiled descriptors. --------- Co-authored-by: myronmarston-toast <myron.marston@toasttab.com>
1 parent bcea332 commit 57bc8ae

13 files changed

Lines changed: 1840 additions & 1702 deletions

File tree

‎config/schema.rb‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
# frozen_string_literal: true
88

99
ElasticGraph.define_schema do |schema|
10-
schema.json_schema_version 1
11-
schema.enforce_json_schema_version false
10+
# Specs also load this schema with only the protobuf ingestion extension, which does not define these methods.
11+
if schema.respond_to?(:json_schema_version)
12+
schema.json_schema_version 1
13+
schema.enforce_json_schema_version false
14+
end
1215
end
1316

1417
# Note: anytime you add a file to load here, you'll also have to update the list here:

‎elasticgraph-indexer/elasticgraph-indexer.gemspec‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ Gem::Specification.new do |spec|
5050
spec.add_development_dependency "elasticgraph-elasticsearch", ElasticGraph::VERSION
5151
spec.add_development_dependency "elasticgraph-json_ingestion", ElasticGraph::VERSION
5252
spec.add_development_dependency "elasticgraph-opensearch", ElasticGraph::VERSION
53+
spec.add_development_dependency "elasticgraph-proto_ingestion", ElasticGraph::VERSION
5354
spec.add_development_dependency "elasticgraph-schema_definition", ElasticGraph::VERSION
5455
end

‎elasticgraph-indexer/spec/acceptance/derived_indexing_types_spec.rb‎

Lines changed: 277 additions & 277 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/acceptance/list_fields_spec.rb‎

Lines changed: 360 additions & 360 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/acceptance/nested_multi_source_indexing_spec.rb‎

Lines changed: 263 additions & 262 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/acceptance/schema_evolution_spec.rb‎

Lines changed: 328 additions & 326 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/acceptance/top_level_multi_source_indexing_spec.rb‎

Lines changed: 232 additions & 232 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/integration/elastic_graph/indexer/datastore_indexing_router_spec.rb‎

Lines changed: 118 additions & 117 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/integration/elastic_graph/indexer/processor_spec.rb‎

Lines changed: 123 additions & 122 deletions
Large diffs are not rendered by default.

‎elasticgraph-indexer/spec/spec_helper.rb‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
config.define_derived_metadata(absolute_file_path: %r{/elasticgraph-indexer/}) do |meta|
1515
meta[:builds_indexer] = true
1616
end
17+
18+
# Every indexer integration and acceptance spec must run against each ingestion format.
19+
config.define_derived_metadata(absolute_file_path: %r{/elasticgraph-indexer/spec/(acceptance|integration)/}) do |meta|
20+
require "support/ingestion_formats"
21+
meta[:ingests_data] = true
22+
end
1723
end

0 commit comments

Comments
 (0)