masaori335 opened a new pull request, #14087:
URL: https://github.com/apache/trafficserver/pull/14087

   # Motivation
   
   header_rewrite keeps gaining operators and conditions, and hrw4u does not 
always follow. `set-cc-alg` landed in
   header_rewrite without an hrw4u spelling, and nothing failed, so the gap is 
found later by a user. Whoever adds a name
   to header_rewrite should learn from CI that hrw4u needs a change too.
   
   # Approach
   
   - `plugins/header_rewrite/factory.cc` lists its operators and conditions in 
two `constexpr` tables (name → factory lambda) instead of if/else-if chains. 
Names, order and lookup behavior are unchanged; the factory only runs while a 
config is loaded.
   - A new hrw4u test, `tools/hrw4u/tests/test_header_rewrite_coverage.py`, 
reads those tables and checks that hrw4u can emit every name. hrw4u's names 
come from the maps in `tools/hrw4u/src/tables.py` and the state/session 
variable families in `types.py`, plus `GROUP`/`TRUE`/`FALSE`, which the test 
lists because the emitters write them directly. It runs with the rest of the 
hrw4u tests (`make test` in `tools/hrw4u`, the CI `HRW4U` stage).
   
   # What a header_rewrite author sees
   
   Adding a name to `factory.cc` without an hrw4u mapping fails with:
   
   ```
   header_rewrite has ['new-op'] but hrw4u cannot emit them. Map them in 
tools/hrw4u/src/tables.py, or add them to KNOWN_GAPS (or NOT_APPLICABLE, with a 
reason) in tools/hrw4u/tests/test_header_rewrite_coverage.py.
   ```
   
   - `KNOWN_GAPS` holds today's gaps, to be emptied over time: `add-cookie`, 
`set-cc-alg`, `set-effective-address`, `set-next-hop-strategy`, `timeout-out`.
   - `NOT_APPLICABLE` holds names hrw4u will not spell, each with a reason: 
`DBM` (dead code; never produces a value), `INTERNAL-TXN` (alias of 
`INTERNAL-TRANSACTION`), `URL` (the current request URL; `inbound.url.` is the 
pristine URL and `from.url.`/`to.url.` are the remap rule's).
   - A listed name that hrw4u now emits, or that header_rewrite no longer has, 
also fails, so the lists stay current.
   - The test cross-checks the number of names it parses against the number of 
factory lambdas, so a table row the parser misses fails.
   
   # Testing
   
   - `make test` in `tools/hrw4u`: all pass. Each check was shown to fail by 
editing the lists and `factory.cc`.
   - `ctest -R header_rewrite` and the header_rewrite Uranium tests pass, 
except `test_header_rewrite_bad_run_plugin`, which fails the same way on macOS 
without this change.


-- 
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]

Reply via email to