serhiy-bzhezytskyy opened a new pull request, #76:
URL: https://github.com/apache/solr-orbit/pull/76
### Description
`--randomization-enabled` had no effect on a Solr workload: every client
sent the one query written in `operations/*.json` for the whole run, and the
log said randomization was on.
`extract_fields_and_paths` walks `params["body"]["query"]` as an object tree
looking for a `range` key, which is the OpenSearch query DSL. Solr's JSON DSL
states the query as a string, so the walk reached a leaf immediately and
returned no fields; with no fields no standard value source is called and
`set_range` never runs.
On `main` at f0883807, the same nyc_taxis `range` operation in both shapes:
```
Solr JSON DSL -> []
OpenSearch query DSL -> [('total_amount', ['bool', 'filter', 'range'])]
get_randomized_values -> total_amount:[5 TO 15} # the value source
returned {"gte": 3, "lte": 7}
```
This finds range terms in the query string and in each entry of the `filter`
list, since nyc_taxis' `distance_amount_facet` states its range there, and
substitutes only the bounds:
```
total_amount:[5 TO 15} -> total_amount:[3 TO 7}
["trip_distance:[0 TO 50}"] -> ["trip_distance:[3 TO
7}"]
```
The brackets the query already states are kept, so an exclusive bound stays
exclusive — the same way the object path keeps whichever of `lt`/`lte` it found.
Three deliberate details:
**A term that leaves a bound open is left alone.** `*` is Solr's spelling of
a bound the query does not state, and the object path does not randomize a
one-sided range either: `check_one_of_each_name_present` requires one name from
each of `gte`/`gt` and `lte`/`lt`, so such a field is never collected.
`total_amount:[5 TO *]` is therefore untouched.
**The skip is applied in the substitution as well as the extraction.** A
term visited by the regexp but absent from `fields_and_paths` would otherwise
consume the value meant for the next term and write it to the wrong field:
`total_amount:[* TO 15} AND trip_distance:[1 TO 9}` with one value gave
`total_amount:[3 TO 7} AND trip_distance:[1 TO 9}`.
**Bounds are read by name, not with a default.** A value source that returns
unexpected keys raises `KeyError` rather than silently leaving the query as
written — the same failure the object path gives, and the same silent no-op
this PR removes.
### Measured
Not only unit tests. 450 randomized queries over the five nyc_taxis
operations that register a value source, across six seeds, against Solr 10.0.0
with 300,649 documents: all HTTP 200, and every matched document lands in a
facet bucket — `sum(bucket counts) == numFound` throughout, 0 violations. The
only queries that match nothing are `trip_distance:[N TO N}`, which upstream
produces just as often from `gte: 5, lt: 5`.
I also checked the wider blast radius, since this makes a previously dead
path live: an operation with a two-sided range term but no registered value
source now fails a run with `SystemSetupError` from
`params.generate_standard_values_if_absent`. Scanning every operations file in
`solr-orbit-workloads`: 5 range terms, all 5 registered, 0 missing; `geonames`
has none. So no existing workload starts failing.
⚠️ It does make two latent defects in `solr-orbit-workloads`
`nyc_taxis/workload.py` reachable — `random_money_values` passes a float to
`random.randrange`, which raises `TypeError` on every Python this project
supports, so the `range` operation dies immediately. I have those ready and
will open them against `solr-orbit-workloads` alongside this; they should land
together with it.
### Issues Resolved
Fixes #75
### Testing
- [x] New functionality includes testing
Six tests in `tests/workload/loader_test.py`: range terms found in a query
string and in the `filter` list, the brackets preserved through `set_range`,
the whole `get_randomized_values` path on a string query, an open bound left
alone, a skipped term not taking another term's value, and a mis-keyed value
source raising.
Each of the three details above was mutation-checked — reverting it fails
exactly the test that covers it:
| reverted | test that fails |
|---|---|
| guard in `extract_solr_range_terms` |
`..._leaves_a_bound_open_is_not_randomized`: `[('total_amount', ('query',))] !=
[]` |
| guard inside `replace()` | `..._does_not_take_another_terms_value`: value
written to the wrong field |
| direct indexing → `.get(name, old)` |
`..._omits_a_bound_is_not_silently_ignored`: `KeyError not raised` |
`ruff check` clean; full unit suite 1116 passed / 5 skipped. `make it` was
not run.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]