davsclaus opened a new pull request, #29392:
URL: https://github.com/apache/camel/pull/29392

   ## Description
   
   [CAMEL-26722](https://issues.apache.org/jira/browse/CAMEL-26722): W-1 
(scenarios) and W-2 (CI mode) of the stage 2 decisions on CAMEL-26607.
   
   ### Scenarios
   
   A scenario keeps the rules of an experiment in a file of the project, so it 
can be run again and shared:
   
   ```
   # chaos/outage.chaos: the stock service is down for a minute, then slow for 
a minute
   seed=42
   endpoint=http:stock* error status=503 until=1m
   endpoint=http:stock* delay duration=2s from=1m until=1m
   endpoint=http:stock* error rate=0.01 expect=orders:50 within=3m
   ```
   
   - One rule per line, `#` comment lines, and an optional `seed=` line. The 
phases come from `from=`/`until=`.
   - `ChaosScenario` and `ChaosManager.loadScenario`: loading a scenario starts 
a new report (as `chaos-clear --reset`), then adds all its rules or none. A 
line that is not valid is refused with its line number, and the rules there are 
stay.
   - A rule of a scenario draws from the seed of the scenario by its place in 
it, so the scenario fails the same messages wherever it is loaded (also after 
other rules took the low ids). Without `seed=` it draws from the seed of the 
application.
   - The report says which scenario a rule came from, and where the seed came 
from (`seedFrom`: `camel.chaos.seed` or `scenario outage.chaos`).
   - `camel.chaos.scenario` (camel-main option, `insecure:dev` like 
`camel.chaos.rules`, also in `SecurityUtils`) loads one at startup, before 
`camel.chaos.rules`; `camel.chaos.seed` wins over the scenario's seed.
   - `camel cmd chaos-load <file> [name]`, through a new `load` command of the 
`chaos` action of the CLI connector.
   - `camel run --chaos=<file>`: `--chaos` takes a value only when it ends with 
`.chaos` (or is `true`/`false`), so `camel run --chaos Shop.java` still runs 
`Shop.java`.
   - `camel run *` and `camel export` skip `.chaos` files 
(`RunFiles.skipFile`). The root pom maps `.chaos` to the `#` license header 
style.
   
   ### CI mode
   
   - `camel.chaos.reportFile` (camel-main option): camel-chaos writes the 
report as JSON when the context stops, also without rules.
   - `camel run --chaos-report=<file>` sets it. A run with chaos in the 
foreground (jbang runtime or `--runtime=main`) reads the report when it ends, 
its own file or a temporary one in `~/.camel`:
     - FAIL: exit code 1, with the reasons. A run that failed for another 
reason keeps its own exit code.
     - PASS: exit code 0, and `Chaos verdict: PASS (1 expectation met)`.
     - No expectation, or the run ended before one was decided: exit code 0, 
and a line that says there is no verdict.
   - `--chaos-report` without `--chaos` is a usage error (exit 2); a missing 
scenario is exit 66.
   
   ### Docs
   
   - camel-chaos: new sections "Scenarios" and "Chaos in a pipeline", the two 
new options, the security note.
   - CLI managing page ("Chaos scenarios"), running page, the generated 
`chaos-load` command page, main options, security model (page + YAML), 
`design/chaos.adoc`, the chaos screen help.
   
   ### Not in this PR
   
   - "Save as scenario" on the chaos screen: a follow-up, once the CLI side has 
been tried.
   
   ## Tests
   
   - camel-chaos: `ChaosScenarioTest` (format, load, all-or-none, the seed 
replays wherever loaded), `ChaosScenarioMainTest` (file and classpath scenario, 
seed order, a missing or invalid scenario stops the start, the report file); 
all 780 tests green.
   - camel-main `ChaosConfigurationPropertiesTest` (incl. profile prod refuses 
a scenario), camel-util `SecurityUtilsTest`; camel-cli-connector 94 green (load 
command).
   - camel-jbang-run 259 green (skip `.chaos`, the Camel Main `-D` args); 
camel-jbang-core: `RunTest` (the `--chaos` forms, the checks), 
`ChaosVerdictTest`, `CamelChaosActionTest` (chaos-load), goldens updated (the 
golden test now normalizes `${camel.dir}` and the temporary report name). Two 
`DoctorRepositoryTest` failures locally, in code this PR does not touch (they 
fail the same way without offline mode; not checked on a clean main).
   - TUI chaos and help tests: 140 green.
   
   Tried live with the chaos demo: a scenario that loses every order exits 1 
(`route shipping completed 0 of 20 exchanges within 20s (rule r1): 20 lost`), a 
passing one exits 0 with PASS, one without an expectation exits 0 with the 
no-verdict line, a broken one stops the start with its line number, and 
`chaos-load` replaces the rules of a running integration (a broken one is 
refused and the rules stay).
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


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