Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in dev mode, so with `--runtime=spring-boot` and `--runtime=quarkus` the run swi
have it. A project of your own (`camel run pom.xml`) also gets chaos added for the run: plain `camel-chaos` for Spring
Boot (there is no starter), and the `camel-quarkus-chaos` extension for Quarkus, which needs a Camel Quarkus release on
Camel 4.24 (https://github.com/apache/camel-quarkus/issues/9459). Then add rules while it runs with `camel cmd chaos-add` (see <<_control_while_it_runs,Control while it runs>>), or
start with the rules of a scenario file with `--chaos=chaos/outage.chaos` (see <<_scenarios,Scenarios>>).
start with the rules of a scenario file with `--chaos=test/chaos/outage.chaos` (see <<_scenarios,Scenarios>>).
* A plain `Main` or a test: add the `camel-chaos` dependency and set `camel.chaos.enabled=true`, for example in a
`CamelTestSupport` test with
`camelContextConfiguration.withUseOverridePropertiesWithPropertiesComponent(props)`, where `props` has
Expand Down Expand Up @@ -80,7 +80,7 @@ include the startup.
|`camel.chaos.maxDuration` |`10m` |The longest time a rule runs: a rule without an `until` duration ends after it, and
a longer `until` duration, `delay`, or `duration` of `stall` and `lifecycle`, is rejected when the rule is added.
|`camel.chaos.scenario` | |A scenario to load at startup: a file with one rule per line (see
<<_scenarios,Scenarios>>), such as `chaos/outage.chaos`, or `classpath:` and a name. Its rules are added before those of
<<_scenarios,Scenarios>>), such as `test/chaos/outage.chaos`, or `classpath:` and a name. Its rules are added before those of
`camel.chaos.rules`, and its `seed=` is used unless `camel.chaos.seed` is set. A scenario that cannot be read, or has a
line that is not valid, stops the application from starting.
|`camel.chaos.reportOnShutdown` |`true` |Log the report when the context stops, if any rule was added.
Expand Down Expand Up @@ -111,7 +111,7 @@ List<String> warnings = chaos.checkRule(id);
chaos.removeRule(id);
List<String> ids = chaos.addRules("endpoint=seda:dlq error at=dlq; endpoint=https:inventory* error status=503");
String text = chaos.report().toText();
List<String> loaded = chaos.loadScenario("outage.chaos", Files.readString(Path.of("chaos/outage.chaos")));
List<String> loaded = chaos.loadScenario("outage.chaos", Files.readString(Path.of("test/chaos/outage.chaos")));
----

`addRules` adds rules separated by `;`, as in `camel.chaos.rules`, all of them or none when one is not valid, so they
Expand All @@ -129,7 +129,7 @@ camel cmd chaos-change --id=r1 --rule='endpoint=kafka:orders* delay duration=5s
camel cmd chaos-remove myapp --id=r1
camel cmd chaos-clear
camel cmd chaos-clear myapp --reset
camel cmd chaos-load chaos/outage.chaos
camel cmd chaos-load test/chaos/outage.chaos
camel cmd chaos-suggest
camel get chaos
camel get chaos myapp --report
Expand Down Expand Up @@ -289,12 +289,14 @@ serves over HTTP have only the list and the report (not the check either: the in
== Scenarios

A scenario is the rules of an experiment in a file of the project, so it can be run again, shared and kept with the
code, instead of rules typed once at the command line. By convention it is in a `chaos` folder, with the extension
`.chaos`:
code, instead of rules typed once at the command line. By convention it is in the folder `test/chaos` of the project,
with the extension `.chaos`. The Camel CLI leaves the `test` folder alone: `camel run` does not load it, a run in dev
mode does not reload when a file there changes, and `camel export` copies only the Citrus tests from it. A scenario is
a test too, next to the Citrus tests of the project:

[source]
----
# chaos/outage.chaos: the stock service is down for a minute, then slow for a minute
# test/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
Expand All @@ -319,7 +321,7 @@ To start an application with a scenario:

[source,bash]
----
camel run * --chaos=chaos/outage.chaos
camel run * --chaos=test/chaos/outage.chaos
----

`--chaos=<file>` adds camel-chaos as `--chaos` does, and sets `camel.chaos.scenario` to the file (it must end with
Expand All @@ -330,7 +332,7 @@ To load a scenario into an application that runs:

[source,bash]
----
$ camel cmd chaos-load chaos/outage.chaos
$ camel cmd chaos-load test/chaos/outage.chaos
Loaded chaos scenario outage.chaos: 3 rules (the rules there were are removed, and the report starts again)
r4: fail every send to http:stock* with HTTP status 503, for 1 minute
r5: delay every send and poll of http:stock* by 2 seconds, starting after 1 minute, for 1 minute
Expand Down Expand Up @@ -969,7 +971,7 @@ A run with chaos ends with the verdict of the report as its exit code, so a scen

[source,bash]
----
camel run * --chaos=chaos/outage.chaos --max-seconds=240 --chaos-report=target/chaos-report.json
camel run * --chaos=test/chaos/outage.chaos --max-seconds=240 --chaos-report=target/chaos-report.json
----

* The verdict FAIL ends the run with exit code 1, and the reasons are printed (an unmet expectation, messages lost at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ The camel.chaos supports 7 options, which are listed below.
| `camel.chaos.reportFile` | A file to write the chaos report to as JSON when the CamelContext stops, such as target/chaos-report.json. | | String
| `camel.chaos.reportOnShutdown` | Whether to log the chaos report when the CamelContext stops, if any rule was added. | true | boolean
| `camel.chaos.rules` | Rules to add at startup, in the one-line text form of a rule, separated by semicolons. | | String
| `camel.chaos.scenario` | A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set. | | String
| `camel.chaos.scenario` | A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as test/chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set. | | String
| `camel.chaos.seed` | The seed of the random draws of the rules. Without it a seed is picked at startup, and shown in the report. | | Long
|===

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
{ "name": "camel.chaos.reportFile", "required": false, "description": "A file to write the chaos report to as JSON when the CamelContext stops, such as target\/chaos-report.json.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.chaos.reportOnShutdown", "required": false, "description": "Whether to log the chaos report when the CamelContext stops, if any rule was added.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.chaos.rules", "required": false, "description": "Rules to add at startup, in the one-line text form of a rule, separated by semicolons.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.scenario", "required": false, "description": "A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as chaos\/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.scenario", "required": false, "description": "A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as test\/chaos\/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.seed", "required": false, "description": "The seed of the random draws of the rules. Without it a seed is picked at startup, and shown in the report.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "integer", "javaType": "java.lang.Long", "secret": false },
{ "name": "camel.cluster.consul.aclToken", "required": false, "description": "Sets the ACL token to be used with Consul", "sourceType": "org.apache.camel.component.consul.cluster.ConsulClusterService", "type": "string", "javaType": "java.lang.String", "secret": true, "security": "secret" },
{ "name": "camel.cluster.consul.blockSeconds", "required": false, "description": "The second to wait for a watch event, default 10 seconds", "sourceType": "org.apache.camel.component.consul.cluster.ConsulClusterService", "type": "integer", "javaType": "int", "defaultValue": 10, "secret": false },
Expand Down
22 changes: 12 additions & 10 deletions components/camel-chaos/src/main/docs/chaos.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in dev mode, so with `--runtime=spring-boot` and `--runtime=quarkus` the run swi
have it. A project of your own (`camel run pom.xml`) also gets chaos added for the run: plain `camel-chaos` for Spring
Boot (there is no starter), and the `camel-quarkus-chaos` extension for Quarkus, which needs a Camel Quarkus release on
Camel 4.24 (https://github.com/apache/camel-quarkus/issues/9459). Then add rules while it runs with `camel cmd chaos-add` (see <<_control_while_it_runs,Control while it runs>>), or
start with the rules of a scenario file with `--chaos=chaos/outage.chaos` (see <<_scenarios,Scenarios>>).
start with the rules of a scenario file with `--chaos=test/chaos/outage.chaos` (see <<_scenarios,Scenarios>>).
* A plain `Main` or a test: add the `camel-chaos` dependency and set `camel.chaos.enabled=true`, for example in a
`CamelTestSupport` test with
`camelContextConfiguration.withUseOverridePropertiesWithPropertiesComponent(props)`, where `props` has
Expand Down Expand Up @@ -80,7 +80,7 @@ include the startup.
|`camel.chaos.maxDuration` |`10m` |The longest time a rule runs: a rule without an `until` duration ends after it, and
a longer `until` duration, `delay`, or `duration` of `stall` and `lifecycle`, is rejected when the rule is added.
|`camel.chaos.scenario` | |A scenario to load at startup: a file with one rule per line (see
<<_scenarios,Scenarios>>), such as `chaos/outage.chaos`, or `classpath:` and a name. Its rules are added before those of
<<_scenarios,Scenarios>>), such as `test/chaos/outage.chaos`, or `classpath:` and a name. Its rules are added before those of
`camel.chaos.rules`, and its `seed=` is used unless `camel.chaos.seed` is set. A scenario that cannot be read, or has a
line that is not valid, stops the application from starting.
|`camel.chaos.reportOnShutdown` |`true` |Log the report when the context stops, if any rule was added.
Expand Down Expand Up @@ -111,7 +111,7 @@ List<String> warnings = chaos.checkRule(id);
chaos.removeRule(id);
List<String> ids = chaos.addRules("endpoint=seda:dlq error at=dlq; endpoint=https:inventory* error status=503");
String text = chaos.report().toText();
List<String> loaded = chaos.loadScenario("outage.chaos", Files.readString(Path.of("chaos/outage.chaos")));
List<String> loaded = chaos.loadScenario("outage.chaos", Files.readString(Path.of("test/chaos/outage.chaos")));
----

`addRules` adds rules separated by `;`, as in `camel.chaos.rules`, all of them or none when one is not valid, so they
Expand All @@ -129,7 +129,7 @@ camel cmd chaos-change --id=r1 --rule='endpoint=kafka:orders* delay duration=5s
camel cmd chaos-remove myapp --id=r1
camel cmd chaos-clear
camel cmd chaos-clear myapp --reset
camel cmd chaos-load chaos/outage.chaos
camel cmd chaos-load test/chaos/outage.chaos
camel cmd chaos-suggest
camel get chaos
camel get chaos myapp --report
Expand Down Expand Up @@ -289,12 +289,14 @@ serves over HTTP have only the list and the report (not the check either: the in
== Scenarios

A scenario is the rules of an experiment in a file of the project, so it can be run again, shared and kept with the
code, instead of rules typed once at the command line. By convention it is in a `chaos` folder, with the extension
`.chaos`:
code, instead of rules typed once at the command line. By convention it is in the folder `test/chaos` of the project,
with the extension `.chaos`. The Camel CLI leaves the `test` folder alone: `camel run` does not load it, a run in dev
mode does not reload when a file there changes, and `camel export` copies only the Citrus tests from it. A scenario is
a test too, next to the Citrus tests of the project:

[source]
----
# chaos/outage.chaos: the stock service is down for a minute, then slow for a minute
# test/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
Expand All @@ -319,7 +321,7 @@ To start an application with a scenario:

[source,bash]
----
camel run * --chaos=chaos/outage.chaos
camel run * --chaos=test/chaos/outage.chaos
----

`--chaos=<file>` adds camel-chaos as `--chaos` does, and sets `camel.chaos.scenario` to the file (it must end with
Expand All @@ -330,7 +332,7 @@ To load a scenario into an application that runs:

[source,bash]
----
$ camel cmd chaos-load chaos/outage.chaos
$ camel cmd chaos-load test/chaos/outage.chaos
Loaded chaos scenario outage.chaos: 3 rules (the rules there were are removed, and the report starts again)
r4: fail every send to http:stock* with HTTP status 503, for 1 minute
r5: delay every send and poll of http:stock* by 2 seconds, starting after 1 minute, for 1 minute
Expand Down Expand Up @@ -969,7 +971,7 @@ A run with chaos ends with the verdict of the report as its exit code, so a scen

[source,bash]
----
camel run * --chaos=chaos/outage.chaos --max-seconds=240 --chaos-report=target/chaos-report.json
camel run * --chaos=test/chaos/outage.chaos --max-seconds=240 --chaos-report=target/chaos-report.json
----

* The verdict FAIL ends the run with exit code 1, and the reasons are printed (an unmet expectation, messages lost at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.List;

/**
* A chaos scenario: the rules of an experiment in a file of the project, such as {@code chaos/outage.chaos}, so it can
* be run again and shared. It has one rule per line, in the one-line form of {@code camel.chaos.rules}; a line that
* A chaos scenario: the rules of an experiment in a file of the project, such as {@code test/chaos/outage.chaos}, so it
* can be run again and shared. It has one rule per line, in the one-line form of {@code camel.chaos.rules}; a line that
* starts with {@code #} is a comment, and a line {@code seed=<number>} fixes the random draws of its rules, so the
* scenario fails the same messages each time. The phases of an experiment come from {@code from=} and {@code until=} of
* its rules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
{ "name": "camel.chaos.reportFile", "required": false, "description": "A file to write the chaos report to as JSON when the CamelContext stops, such as target\/chaos-report.json.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false },
{ "name": "camel.chaos.reportOnShutdown", "required": false, "description": "Whether to log the chaos report when the CamelContext stops, if any rule was added.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true, "secret": false },
{ "name": "camel.chaos.rules", "required": false, "description": "Rules to add at startup, in the one-line text form of a rule, separated by semicolons.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.scenario", "required": false, "description": "A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as chaos\/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.scenario", "required": false, "description": "A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as test\/chaos\/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "string", "javaType": "java.lang.String", "secret": false, "security": "insecure:dev" },
{ "name": "camel.chaos.seed", "required": false, "description": "The seed of the random draws of the rules. Without it a seed is picked at startup, and shown in the report.", "sourceType": "org.apache.camel.main.ChaosConfigurationProperties", "type": "integer", "javaType": "java.lang.Long", "secret": false },
{ "name": "camel.cluster.consul.aclToken", "required": false, "description": "Sets the ACL token to be used with Consul", "sourceType": "org.apache.camel.component.consul.cluster.ConsulClusterService", "type": "string", "javaType": "java.lang.String", "secret": true, "security": "secret" },
{ "name": "camel.cluster.consul.blockSeconds", "required": false, "description": "The second to wait for a watch event, default 10 seconds", "sourceType": "org.apache.camel.component.consul.cluster.ConsulClusterService", "type": "integer", "javaType": "int", "defaultValue": 10, "secret": false },
Expand Down
2 changes: 1 addition & 1 deletion core/camel-main/src/main/docs/main.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ The camel.chaos supports 7 options, which are listed below.
| `camel.chaos.reportFile` | A file to write the chaos report to as JSON when the CamelContext stops, such as target/chaos-report.json. | | String
| `camel.chaos.reportOnShutdown` | Whether to log the chaos report when the CamelContext stops, if any rule was added. | true | boolean
| `camel.chaos.rules` | Rules to add at startup, in the one-line text form of a rule, separated by semicolons. | | String
| `camel.chaos.scenario` | A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set. | | String
| `camel.chaos.scenario` | A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as test/chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless the seed option is set. | | String
| `camel.chaos.seed` | The seed of the random draws of the rules. Without it a seed is picked at startup, and shown in the report. | | Long
|===

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public String getScenario() {

/**
* A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as
* chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless
* the seed option is set.
* test/chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used
* unless the seed option is set.
*/
public void setScenario(String scenario) {
this.scenario = scenario;
Expand Down Expand Up @@ -165,8 +165,8 @@ public ChaosConfigurationProperties withRules(String rules) {

/**
* A scenario to load at startup: a file with one rule per line, # comments and an optional seed= line (such as
* chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used unless
* the seed option is set.
* test/chaos/outage.chaos), or classpath:name. Its rules are added before the rules option, and its seed is used
* unless the seed option is set.
*/
public ChaosConfigurationProperties withScenario(String scenario) {
this.scenario = scenario;
Expand Down
Loading
Loading