You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0782c78
Browse filesBrowse the repository at this point in the historyBrowse files
## Why
The protobuf test helper compiles every generated schema, even during
local unit tests. That added about 2.9 seconds to the protobuf suite on
this Mac. GraphQL tests already make extra schema validation opt-in, so
protobuf tests should follow the same pattern.
## What
Use `VALIDATE_SCHEMA_ARTIFACTS` for both GraphQL and protobuf schema
validation. Leave extra validation off by default locally and enable it
in the existing CI job.
## How
Rename `VALIDATE_GRAPHQL_SCHEMAS` and update its references. Check the
new flag once when each test helper loads. When enabled, prepend a
module that validates every generated protobuf schema for the rest of
the process. Always render the schema and assign field numbers. Explicit
encode/decode integration tests still run `protoc` without the flag.
Protobuf validation failures include the compiler diagnostics and
explain how to reproduce locally with `VALIDATE_SCHEMA_ARTIFACTS=1`.
The flag keeps the existing presence-based behavior: any set value
enables validation when the helper loads. Later changes to the
environment do not affect validation. The old flag no longer enables it.
## Risk
Low. This changes test support and CI configuration, not runtime
ingestion. Local commands that use the old flag must switch to
`VALIDATE_SCHEMA_ARTIFACTS`.
## Testing
Before this change, benchmarked `bundle exec rspec
elasticgraph-proto_ingestion/spec --seed 4247` four times per mode,
alternating run order. A temporary probe skipped only automatic
descriptor compilation; explicit encode/decode calls remained enabled.
Median command runtime was 9.50 seconds with compilation and 6.62
seconds without it. The probe recorded 63 automatic compiler calls,
taking about 2.59 seconds per run. These results are from an Apple
Silicon Mac using the bundled x86 compiler under Rosetta.
Manually checked the protobuf helper in fresh Ruby processes with the
flag absent and with `VALIDATE_SCHEMA_ARTIFACTS=0`. After loading the
helper, changed the flag to unset and then to `1`; validation stayed
fixed at its initial setting in both cases. Also passed an invalid
protobuf schema through the enabled helper and verified that the failure
included compiler diagnostics and `VALIDATE_SCHEMA_ARTIFACTS=1`. Empty
schemas still skip compilation.
## Bigger picture
Follow-up to #1405 and Myron's suggestion to share one validation flag
across generated schema artifacts.
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,7 +216,7 @@ Custom gems can be added via `Gemfile-custom` (see `Gemfile-custom.example`), th
216
216
- Use `expect_to_return_non_nil_values_from_all_attributes` to test wrapper classes (like `WarehouseLambda`, `GraphQL`, `Indexer`, etc.). This automatically exercises every zero-argument method and verifies all dependencies are built successfully.
217
217
- Use the `:capture_logs` RSpec tag instead of logger test doubles for verifying log output. Access logs with `logged_jsons_of_type(message_type)`.
218
218
- Use `build_*` helper methods from `spec/support/builds_*.rb` to construct test objects. These helpers provide sensible defaults while allowing selective overrides for testing specific scenarios.
219
-
- Only tag a spec with `:dont_validate_graphql_schema` when it's actually required for the test to pass under `VALIDATE_GRAPHQL_SCHEMAS=1` (the tag skips that validation). First try to fix the test's schema so it produces a valid GraphQL schema while still exercising what the test is meant to exercise; reach for the tag only when that isn't possible. Verify by running the spec with `VALIDATE_GRAPHQL_SCHEMAS=1`.
219
+
- Only tag a spec with `:dont_validate_graphql_schema` when it's actually required for the test to pass under `VALIDATE_SCHEMA_ARTIFACTS=1` (the tag skips that validation). First try to fix the test's schema so it produces a valid GraphQL schema while still exercising what the test is meant to exercise; reach for the tag only when that isn't possible. Verify by running the spec with `VALIDATE_SCHEMA_ARTIFACTS=1`.
Copy file name to clipboardExpand all lines: elasticgraph-json_ingestion/spec/unit/elastic_graph/json_ingestion/schema_definition/indexing/wrappers_spec.rb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ module SchemaDefinition
43
43
})
44
44
end
45
45
46
-
# `:dont_validate_graphql_schema` matters here: with `VALIDATE_GRAPHQL_SCHEMAS=1` (as on CI), the
46
+
# `:dont_validate_graphql_schema` matters here: with `VALIDATE_SCHEMA_ARTIFACTS=1` (as on CI), the
47
47
# eager SDL validation would raise this error during GraphQL schema generation, before the JSON
48
48
# schema generation path exercises the wrapped `FieldReference#resolve` nil return that this
0 commit comments