Generate iRule Test
Framework: rust/tcl-irule-test/tcl/orchestrator.tcl; contract
docs/design/contracts/irule-test-framework.md; worked examples
example_test.tcl and example_multi_tmm_test.tcl beside the framework.
Steps
- Read the iRule. Call
mcp__tcl-lsp__irule_cfg_pathswith its contents as
source: every path to a terminal action (pool / reject / redirect …)
with its branch conditions, priority, taint warnings, and
test-generation questions. Prioritise security-sensitive actions and the
else / default paths — those are the under-tested ones.
- Call
mcp__tcl-lsp__generate_irule_testwith the samesource. It
returns a runnable scaffold: the framework source chain,
::orch::configure_tests with profiles, iRule, and setup, one
::orch::test per event and per CFG path with request parameters derived
from the conditions, pool / data-group / header assertions, and a
multi-TMM scenario when it sees static:: writes outside RULE_INIT,
static:: counters, or table incr / table set shared state.
- Tighten the scaffold: answer the generator's questions, replace
placeholders with values the conditions actually select, delete cases the
iRule cannot reach, add assertions the scaffold could not infer.
- Multi-TMM: plan sources with
mcp__tcl-lsp__fakecmp_suggest_sources
(tmm_count, count) and confirm a tuple with fakecmp_which_tmm. Write
the test for the desired behaviour — a CMP bug (a static:: counter
with 4 TMMs allows 4× the limit) should fail it.
- Write the file and run it:
tclsh test_<name>.tcl;::orch::doneexits
non-zero on failure.
Framework API
| Command | Purpose |
|---|---|
| ::orch::configure_tests -profiles {TCP HTTP} -irule {…} -setup {…} [-tmm_count N -tmm_select auto] | defaults for every test; -tmm_select auto hashes with fakeCMP |
| ::orch::test "name" "desc" -body {…} | isolated case, state reset |
| ::orch::run_http_request -host … -uri … -method …, ::orch::run_next_request | simulate a request, keep-alive follow-up |
| ::orch::assert_that <subject> <verb> <value> | subjects pool_selected, http_uri, http_host, http_path, http_method, http_status, http_header "Name", decision <cat> <action>, log, event, var <name>; verbs equals, not_equals, contains, starts_with, ends_with, matches, was_called, was_called_with, was_not_called |
| ::orch::assert_pool_selected, assert_equal, assert {expr} msg | classic assertions |
| ::orch::fakecmp_suggest_sources -count N, fakecmp_which_tmm a p da dp, tmm_ids | multi-TMM planning |
| ::orch::done | summary and exit code |
$ARGUMENTS