This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 043fbeaa335 Fixes #9459. Add camel-quarkus-chaos JVM-only extension
043fbeaa335 is described below
commit 043fbeaa3359cef75802ebf32c61ce8826c53171
Author: James Netherton <[email protected]>
AuthorDate: Thu Dec 3 16:46:38 2026 +0000
Fixes #9459. Add camel-quarkus-chaos JVM-only extension
Includes a Dev UI page, available in dev mode only, to view and change
the chaos rules and to see their report.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
catalog/pom.xml | 13 ++
docs/modules/ROOT/examples/others/chaos.yml | 13 ++
docs/modules/ROOT/nav.adoc | 1 +
.../ROOT/pages/reference/extensions/chaos.adoc | 88 ++++++++
extensions-jvm/chaos/deployment/pom.xml | 84 +++++++
.../component/chaos/deployment/ChaosProcessor.java | 46 ++++
.../deployment/devui/ChaosDevUIProcessor.java | 45 ++++
.../src/main/resources/dev-ui/qwc-camel-chaos.js | 248 +++++++++++++++++++++
.../chaos/deployment/ChaosDefaultTest.java | 40 ++++
.../chaos/deployment/ChaosDevModeTest.java | 55 +++++
.../chaos/deployment/ChaosDevProfileTest.java | 41 ++++
.../chaos/deployment/ChaosEnabledTest.java | 41 ++++
.../chaos/deployment/ChaosProdProfileTest.java | 42 ++++
.../deployment/devui/ChaosDevUIConsoleTest.java | 50 +++++
.../chaos/deployment/devui/ChaosDevUITest.java | 90 ++++++++
extensions-jvm/chaos/pom.xml | 39 ++++
extensions-jvm/chaos/runtime/pom.xml | 100 +++++++++
.../chaos/runtime/src/main/doc/usage.adoc | 41 ++++
.../component/chaos/CamelChaosDevUIService.java | 120 ++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 37 +++
extensions-jvm/pom.xml | 1 +
integration-tests-jvm/chaos/pom.xml | 118 ++++++++++
.../quarkus/component/chaos/it/ChaosResource.java | 69 ++++++
.../quarkus/component/chaos/it/ChaosRoutes.java | 30 +++
.../src/main/resources/application.properties | 18 ++
.../quarkus/component/chaos/it/ChaosTest.java | 69 ++++++
integration-tests-jvm/pom.xml | 1 +
poms/bom/pom.xml | 15 ++
poms/bom/src/main/generated/flattened-full-pom.xml | 15 ++
.../src/main/generated/flattened-reduced-pom.xml | 15 ++
.../generated/flattened-reduced-verbose-pom.xml | 15 ++
31 files changed, 1600 insertions(+)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index 0521e725cc1..3539fc95148 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -812,6 +812,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-chatscript</artifactId>
diff --git a/docs/modules/ROOT/examples/others/chaos.yml
b/docs/modules/ROOT/examples/others/chaos.yml
new file mode 100644
index 00000000000..6ee9ef7f196
--- /dev/null
+++ b/docs/modules/ROOT/examples/others/chaos.yml
@@ -0,0 +1,13 @@
+# Do not edit directly!
+# This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+cqArtifactId: camel-quarkus-chaos
+cqArtifactIdBase: chaos
+cqNativeSupported: false
+cqStatus: Preview
+cqDeprecated: false
+cqJvmSince: 4.0.0
+cqNativeSince: n/a
+cqCamelPartName: chaos
+cqCamelPartTitle: Chaos
+cqCamelPartDescription: Turn on faults in a running Camel application during
development, and report how the routes cope
+cqExtensionPageTitle: Chaos
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 77706370044..0d69d03b216 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -98,6 +98,7 @@
*** xref:reference/extensions/cxf-soap.adoc[CXF]
*** xref:reference/extensions/caffeine.adoc[Caffeine Cache]
*** xref:reference/extensions/cassandraql.adoc[Cassandra CQL]
+*** xref:reference/extensions/chaos.adoc[Chaos]
*** xref:reference/extensions/chatscript.adoc[ChatScript]
*** xref:reference/extensions/chunk.adoc[Chunk]
*** xref:reference/extensions/cloudevents.adoc[Cloudevents]
diff --git a/docs/modules/ROOT/pages/reference/extensions/chaos.adoc
b/docs/modules/ROOT/pages/reference/extensions/chaos.adoc
new file mode 100644
index 00000000000..968d3070d4c
--- /dev/null
+++ b/docs/modules/ROOT/pages/reference/extensions/chaos.adoc
@@ -0,0 +1,88 @@
+// Do not edit directly!
+// This file was generated by
camel-quarkus-maven-plugin:update-extension-doc-page
+[id="extensions-chaos"]
+= Chaos
+:linkattrs:
+:cq-artifact-id: camel-quarkus-chaos
+:cq-native-supported: false
+:cq-status: Preview
+:cq-status-deprecation: Preview
+:cq-description: Turn on faults in a running Camel application during
development, and report how the routes cope
+:cq-deprecated: false
+:cq-jvm-since: 4.0.0
+:cq-native-since: n/a
+
+ifeval::[{doc-show-badges} == true]
+[.badges]
+[.badge-key]##JVM since##[.badge-supported]##4.0.0##
[.badge-key]##Native##[.badge-unsupported]##unsupported##
+endif::[]
+
+Turn on faults in a running Camel application during development, and report
how the routes cope
+
+[id="extensions-chaos-whats-inside"]
+== What's inside
+
+* xref:{cq-camel-components}:others:chaos.adoc[Chaos]
+
+Please refer to the above link for usage and configuration details.
+
+[id="extensions-chaos-maven-coordinates"]
+== Maven coordinates
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+</dependency>
+----
+ifeval::[{doc-show-user-guide-link} == true]
+Check the xref:user-guide/index.adoc[User guide] for more information about
writing Camel Quarkus applications.
+endif::[]
+
+[id="extensions-chaos-usage"]
+== Usage
+[id="extensions-chaos-usage-switching-chaos-on"]
+=== Switching chaos on
+
+Chaos is intended for development only.
+
+In Quarkus dev mode, chaos is switched on with no extra configuration, because
Camel Quarkus sets the Camel profile to `dev`.
+Nothing happens to your routes until a rule is added.
+
+Outside of dev mode, chaos is off by default. Use `camel.chaos.enabled` to
switch it on or off, with a Quarkus profile to limit
+where it applies:
+
+[source,properties]
+----
+# Switch chaos on in tests
+%test.camel.chaos.enabled = true
+
+# Keep chaos off in dev mode
+%dev.camel.chaos.enabled = false
+----
+
+[WARNING]
+====
+Without a profile prefix, `camel.chaos.enabled=true` also applies to a
packaged application. A warning is logged at startup
+whenever chaos is switched on.
+====
+
+[id="extensions-chaos-usage-managing-the-chaos-rules"]
+=== Managing the chaos rules
+
+In dev mode, open the Quarkus Dev UI and choose the Chaos page of the Camel
Chaos extension. It shows the rules and the report, and lets
+you add and remove rules while the application runs. The page is not available
outside of dev mode.
+
+Rules added on this page, and the report, are lost when the application
reloads. To add rules again after each reload, set
+`camel.chaos.rules`.
+
+Adding or removing rules does not reset the report. To start a new experiment,
use `Clear rules and reset report`.
+
+The rules and the report can also be read over HTTP. Add the
xref:reference/extensions/console.adoc[Console] extension, set
+`quarkus.camel.console.enabled=true`, and open `/q/camel/dev-console/chaos`.
By default, this is available in dev and test
+mode only. See the Console extension for how to expose it in prod mode, and
for the security implications.
+
+To control chaos with the Camel CLI (`camel cmd chaos-add`, `camel get
chaos`), add the
+xref:reference/extensions/cli-connector.adoc[CLI Connector] extension.
+
diff --git a/extensions-jvm/chaos/deployment/pom.xml
b/extensions-jvm/chaos/deployment/pom.xml
new file mode 100644
index 00000000000..9e7b0e27407
--- /dev/null
+++ b/extensions-jvm/chaos/deployment/pom.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <name>Camel Quarkus :: Chaos :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit-internal</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-devui-test-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-vertx-http-deployment</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProcessor.java
b/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProcessor.java
new file mode 100644
index 00000000000..aa5fe5534ad
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProcessor.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
+import org.apache.camel.quarkus.core.JvmOnlyRecorder;
+import org.jboss.logging.Logger;
+
+class ChaosProcessor {
+
+ private static final Logger LOG = Logger.getLogger(ChaosProcessor.class);
+ private static final String FEATURE = "camel-chaos";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ /**
+ * Remove this once this extension starts supporting the native mode.
+ */
+ @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
+ @Record(value = ExecutionTime.RUNTIME_INIT)
+ void warnJvmInNative(JvmOnlyRecorder recorder) {
+ JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
+ recorder.warnJvmInNative(FEATURE); // warn at runtime
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIProcessor.java
b/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIProcessor.java
new file mode 100644
index 00000000000..982e296486b
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/main/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIProcessor.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment.devui;
+
+import io.quarkus.deployment.IsDevelopment;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.BuildSteps;
+import io.quarkus.devjsonrpc.spi.JsonRPCProvidersBuildItem;
+import io.quarkus.devui.spi.page.CardPageBuildItem;
+import io.quarkus.devui.spi.page.Page;
+import org.apache.camel.quarkus.component.chaos.CamelChaosDevUIService;
+import org.apache.camel.quarkus.core.deployment.devui.CamelDevUIConstants;
+
+@BuildSteps(onlyIf = IsDevelopment.class)
+class ChaosDevUIProcessor {
+ @BuildStep
+ CardPageBuildItem createDevUICard() {
+ CardPageBuildItem card = new CardPageBuildItem();
+ card.addPage(Page.webComponentPageBuilder()
+ .title("Chaos")
+ .icon("font-awesome-solid:burst")
+ .componentLink("qwc-camel-chaos.js")
+ .metadata(CamelDevUIConstants.CONSOLE_ID_METADATA_KEY,
"chaos"));
+ return card;
+ }
+
+ @BuildStep
+ JsonRPCProvidersBuildItem createJsonRPCService() {
+ return new JsonRPCProvidersBuildItem(CamelChaosDevUIService.class);
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/main/resources/dev-ui/qwc-camel-chaos.js
b/extensions-jvm/chaos/deployment/src/main/resources/dev-ui/qwc-camel-chaos.js
new file mode 100644
index 00000000000..3151a6376c8
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/main/resources/dev-ui/qwc-camel-chaos.js
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {css, html, nothing} from 'lit';
+import {JsonRpc} from 'jsonrpc';
+import {notifier} from 'notifier';
+import {QwcCamelCore} from '../camel-quarkus-core/qwc-camel-core.js';
+import {columnBodyRenderer} from '@vaadin/grid/lit.js';
+import '@vaadin/button';
+import '@vaadin/grid';
+import '@vaadin/text-field';
+import '@qomponent/qui-badge';
+
+export class QwcCamelChaos extends QwcCamelCore {
+ static styles = [QwcCamelCore.styles, css`
+ :host {
+ gap: var(--lumo-space-s);
+ padding: var(--lumo-space-m);
+ box-sizing: border-box;
+ overflow: auto;
+ }
+
+ .toolbar {
+ display: flex;
+ gap: var(--lumo-space-s);
+ align-items: baseline;
+ }
+
+ .toolbar vaadin-text-field {
+ flex: 1;
+ }
+
+ .error {
+ color: var(--lumo-error-text-color);
+ }
+
+ .warning {
+ color: var(--lumo-warning-text-color);
+ }
+ `];
+
+ static properties = {
+ _rule: {state: true},
+ _error: {state: true},
+ _warnings: {state: true},
+ _busy: {state: true},
+ _seed: {state: true},
+ };
+
+ constructor() {
+ super('chaos', {});
+ this._rule = '';
+ this._error = '';
+ this._warnings = [];
+ this._busy = false;
+ this._seed = '';
+ // The inherited jsonRpc reads the dev console from camel-quarkus-core
+ this._chaosRpc = new JsonRpc(this);
+ this._chaosRpc._setExtensionName('camel-quarkus-chaos');
+ }
+
+ hotReload() {
+ // A request cut off by a reload never gets its reply
+ this._busy = false;
+ super.hotReload();
+ }
+
+ updated(changedProperties) {
+ super.updated?.(changedProperties);
+ // The seed is a 64-bit number, which JSON.parse rounds. The rounded
value only tells when to fetch the exact one
+ const rounded = this._consoleData?.report?.seed;
+ if (rounded !== undefined && rounded !== this._roundedSeed) {
+ this._roundedSeed = rounded;
+ this._chaosRpc.getSeed().then(response => {
+ const result = JSON.parse(response.result);
+ if (result.error) {
+ throw new Error(result.error);
+ }
+ this._seed = result.seed;
+ }).catch(() => {
+ this._seed = '';
+ // Try again at the next update, unless a newer seed is
already being fetched
+ if (this._roundedSeed === rounded) {
+ this._roundedSeed = undefined;
+ }
+ });
+ }
+ }
+
+ render() {
+ const data = this._consoleData;
+ if (!data) {
+ return html`<p>Loading...</p>`;
+ }
+ if (data.enabled === false) {
+ return html`<p>${data.reason ?? 'Chaos is off'}</p>`;
+ }
+ if (data.enabled !== true) {
+ return html`<p>The chaos dev console is not available, so this
page cannot tell whether chaos is on.</p>`;
+ }
+ const rules = data.rules ?? [];
+ const report = data.report ?? {};
+ // The report also has the rules that were removed or replaced, which
still count towards the verdict
+ const current = new Set(rules.map(rule => this._ruleKey(rule)));
+ const pastRules = (report.rules ?? []).filter(rule =>
!current.has(this._ruleKey(rule)));
+ return html`
+ <div class="toolbar">
+ <vaadin-text-field
+ label="Chaos rule"
+ placeholder="endpoint=direct:orders error rate=0.5
until=1m"
+ .value="${this._rule}"
+ @value-changed="${e => this._rule = e.detail.value}"
+ @keydown="${e => e.key === 'Enter' && this._add()}">
+ </vaadin-text-field>
+ <vaadin-button theme="primary" ?disabled="${this._busy ||
!this._rule.trim()}" @click="${this._add}">Add</vaadin-button>
+ <vaadin-button theme="error" ?disabled="${this._busy ||
rules.length === 0}" @click="${this._clear}">Clear all</vaadin-button>
+ </div>
+ ${this._error ? html`<div class="error">${this._error}</div>` :
nothing}
+ ${this._warnings.map(warning => html`<div
class="warning">${warning}</div>`)}
+ <h4>Rules</h4>
+ <vaadin-grid .items="${rules}" theme="no-border row-stripes
wrap-cell-content" all-rows-visible>
+ <vaadin-grid-column path="id" header="ID" width="6em"
flex-grow="0"></vaadin-grid-column>
+ <vaadin-grid-column header="Rule" ${columnBodyRenderer(rule =>
html`
+ <div>${rule.description}</div>
+ ${this.codeStyleRenderer(rule.rule)}`,
[])}></vaadin-grid-column>
+ <vaadin-grid-column path="state" header="State" auto-width
flex-grow="0"></vaadin-grid-column>
+ <vaadin-grid-column path="matches" header="Matches" auto-width
flex-grow="0"></vaadin-grid-column>
+ <vaadin-grid-column header="Faults" auto-width flex-grow="0"
+ ${columnBodyRenderer(rule => this._faults(rule),
[])}></vaadin-grid-column>
+ <vaadin-grid-column path="expectation.outcome"
header="Expectation" auto-width flex-grow="0"></vaadin-grid-column>
+ <vaadin-grid-column header="" auto-width flex-grow="0"
${columnBodyRenderer(rule => html`
+ <vaadin-button theme="small error"
?disabled="${this._busy}" @click="${() =>
this._remove(rule.id)}">Remove</vaadin-button>`, [this._busy])}>
+ </vaadin-grid-column>
+ <span slot="empty-state">No rules</span>
+ </vaadin-grid>
+ <div class="toolbar">
+ <h4>Report</h4>
+ <vaadin-button theme="small error" ?disabled="${this._busy}"
@click="${this._reset}">Clear rules and reset report</vaadin-button>
+ </div>
+ <div>
+ Verdict: <qui-badge
small><span>${report.verdict}</span></qui-badge>
+ | Messages lost: ${report.lost} | Seed:
${this.codeStyleRenderer(this._seed)}
+ </div>
+ ${(report.reasons ?? []).map(reason => html`<div
class="error">${reason}</div>`)}
+ <vaadin-grid .items="${report.routes ?? []}" theme="no-border
row-stripes" all-rows-visible>
+ <vaadin-grid-column path="route"
header="Route"></vaadin-grid-column>
+ <vaadin-grid-column path="completed"
header="Completed"></vaadin-grid-column>
+ <vaadin-grid-column path="failed"
header="Failed"></vaadin-grid-column>
+ <vaadin-grid-column path="handled"
header="Handled"></vaadin-grid-column>
+ <vaadin-grid-column path="redeliveries"
header="Redeliveries"></vaadin-grid-column>
+ <span slot="empty-state">No data available</span>
+ </vaadin-grid>
+ ${pastRules.length > 0 ? this._renderPastRules(pastRules) :
nothing}
+ `;
+ }
+
+ _renderPastRules(pastRules) {
+ return html`
+ <h4>Past rules</h4>
+ <vaadin-grid .items="${pastRules}" theme="no-border row-stripes
wrap-cell-content" all-rows-visible>
+ <vaadin-grid-column header="ID" width="6em" flex-grow="0"
+ ${columnBodyRenderer(rule => rule.version > 1 ?
`${rule.id} v${rule.version}` : rule.id, [])}></vaadin-grid-column>
+ <vaadin-grid-column header="Rule" ${columnBodyRenderer(rule =>
html`
+ <div>${rule.description}</div>
+ ${this.codeStyleRenderer(rule.rule)}`,
[])}></vaadin-grid-column>
+ <vaadin-grid-column path="state" header="State" auto-width
flex-grow="0"></vaadin-grid-column>
+ <vaadin-grid-column header="Faults" auto-width flex-grow="0"
+ ${columnBodyRenderer(rule => this._faults(rule),
[])}></vaadin-grid-column>
+ <vaadin-grid-column path="expectation.outcome"
header="Expectation" auto-width flex-grow="0"></vaadin-grid-column>
+ </vaadin-grid>
+ `;
+ }
+
+ _ruleKey(rule) {
+ return `${rule.id}:${rule.version}`;
+ }
+
+ _faults(rule) {
+ return Object.values(rule.fired ?? {}).reduce((total, count) => total
+ count, 0);
+ }
+
+ _add() {
+ if (!this._rule.trim()) {
+ return;
+ }
+ const rules = this._rule;
+ this._call(() => this._chaosRpc.addRules({'rules': rules}), result => {
+ // Keep a rule that was typed while waiting for the reply
+ if (this._rule === rules) {
+ this._rule = '';
+ }
+ this._warnings = result.warnings;
+ notifier.showInfoMessage(`Added ${result.ids.join(', ')}`);
+ });
+ }
+
+ _remove(id) {
+ this._call(() => this._chaosRpc.removeRule({'id': id}), result => {
+ notifier.showInfoMessage(result.removed ? `Removed ${id}` : `${id}
was already removed`);
+ });
+ }
+
+ _clear() {
+ this._call(() => this._chaosRpc.clearRules());
+ }
+
+ _reset() {
+ this._call(() => this._chaosRpc.reset());
+ }
+
+ _call(request, onSuccess) {
+ if (this._busy) {
+ return;
+ }
+ this._busy = true;
+ this._error = '';
+ this._warnings = [];
+ request().then(response => {
+ const result = JSON.parse(response.result);
+ if (result.error) {
+ this._error = result.error;
+ return;
+ }
+ onSuccess?.(result);
+ // Show the change now instead of at the next update
+ this.hotReload();
+ }).catch(error => {
+ this._error = error?.error?.message ?? 'The request failed';
+ }).finally(() => {
+ this._busy = false;
+ });
+ }
+}
+
+customElements.define('qwc-camel-chaos', QwcCamelChaos);
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDefaultTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDefaultTest.java
new file mode 100644
index 00000000000..7348076f15d
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDefaultTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.test.QuarkusExtensionTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class ChaosDefaultTest {
+ @RegisterExtension
+ static final QuarkusExtensionTest CONFIG = new QuarkusExtensionTest()
+ .withEmptyApplication();
+
+ @Inject
+ CamelContext context;
+
+ @Test
+ void chaosSwitchedOff() {
+ assertNull(ChaosManager.get(context));
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevModeTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevModeTest.java
new file mode 100644
index 00000000000..fc205dc411f
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevModeTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.test.QuarkusDevModeTest;
+import io.restassured.RestAssured;
+import io.vertx.ext.web.Router;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.event.Observes;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.hamcrest.Matchers.is;
+
+class ChaosDevModeTest {
+ @RegisterExtension
+ static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
+ .withApplicationRoot(archive ->
archive.addClass(ChaosStatus.class));
+
+ @Test
+ void chaosSwitchedOn() {
+ RestAssured.get("/chaos/enabled")
+ .then()
+ .statusCode(200)
+ .body(is("true"));
+ }
+
+ @ApplicationScoped
+ public static class ChaosStatus {
+ @Inject
+ CamelContext context;
+
+ void routes(@Observes Router router) {
+ router.get("/chaos/enabled")
+ .handler(rc ->
rc.end(String.valueOf(ChaosManager.get(context) != null)));
+ }
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevProfileTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevProfileTest.java
new file mode 100644
index 00000000000..942ec7d6187
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosDevProfileTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.test.QuarkusExtensionTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class ChaosDevProfileTest {
+ @RegisterExtension
+ static final QuarkusExtensionTest CONFIG = new QuarkusExtensionTest()
+ .withEmptyApplication()
+ .overrideConfigKey("camel.main.profile", "dev");
+
+ @Inject
+ CamelContext context;
+
+ @Test
+ void chaosSwitchedOn() {
+ assertNotNull(ChaosManager.get(context));
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosEnabledTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosEnabledTest.java
new file mode 100644
index 00000000000..67d1ae7adaf
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosEnabledTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.test.QuarkusExtensionTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class ChaosEnabledTest {
+ @RegisterExtension
+ static final QuarkusExtensionTest CONFIG = new QuarkusExtensionTest()
+ .withEmptyApplication()
+ .overrideConfigKey("camel.chaos.enabled", "true");
+
+ @Inject
+ CamelContext context;
+
+ @Test
+ void chaosSwitchedOn() {
+ assertNotNull(ChaosManager.get(context));
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProdProfileTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProdProfileTest.java
new file mode 100644
index 00000000000..3f48170998b
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/ChaosProdProfileTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment;
+
+import io.quarkus.test.QuarkusExtensionTest;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class ChaosProdProfileTest {
+ @RegisterExtension
+ static final QuarkusExtensionTest CONFIG = new QuarkusExtensionTest()
+ .withEmptyApplication()
+ .overrideConfigKey("camel.main.profile", "prod")
+ .overrideConfigKey("camel.chaos.enabled", "true");
+
+ @Inject
+ CamelContext context;
+
+ @Test
+ void chaosSwitchedOff() {
+ assertNull(ChaosManager.get(context));
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIConsoleTest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIConsoleTest.java
new file mode 100644
index 00000000000..ca601889b30
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUIConsoleTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment.devui;
+
+import java.util.Map;
+
+import io.quarkus.devui.tests.DevUIJsonRPCTest;
+import io.quarkus.test.QuarkusDevModeTest;
+import io.vertx.core.json.JsonObject;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class ChaosDevUIConsoleTest extends DevUIJsonRPCTest {
+ @RegisterExtension
+ static final QuarkusDevModeTest CONFIG = new QuarkusDevModeTest()
+ .withApplicationRoot(archive -> archive.addAsResource(
+ new StringAsset("camel.chaos.rules=endpoint=direct:none
error\n"), "application.properties"));
+
+ ChaosDevUIConsoleTest() {
+ super("org.apache.camel.quarkus.camel-quarkus-core");
+ }
+
+ @Test
+ void chaosConsole() throws Exception {
+ JsonObject console = new JsonObject(executeJsonRPCMethod(String.class,
"getConsoleJSON",
+ Map.of("id", "chaos", "options", Map.of())));
+ assertTrue(console.getBoolean("enabled"), console::encode);
+ assertEquals("endpoint=direct:none error",
+
console.getJsonArray("rules").getJsonObject(0).getString("rule"),
console::encode);
+ assertTrue(console.getJsonObject("report").containsKey("verdict"),
console::encode);
+ }
+}
diff --git
a/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUITest.java
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUITest.java
new file mode 100644
index 00000000000..35bb6b552a4
--- /dev/null
+++
b/extensions-jvm/chaos/deployment/src/test/java/org/apache/camel/quarkus/component/chaos/deployment/devui/ChaosDevUITest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.deployment.devui;
+
+import java.util.Map;
+
+import io.quarkus.devui.tests.DevUIJsonRPCTest;
+import io.quarkus.test.QuarkusDevModeTest;
+import io.vertx.core.json.JsonObject;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class ChaosDevUITest extends DevUIJsonRPCTest {
+ // JavaScript rounds this number
+ static final String SEED = "9007199254740993";
+
+ @RegisterExtension
+ static final QuarkusDevModeTest CONFIG = new QuarkusDevModeTest()
+ .withApplicationRoot(archive -> archive.addAsResource(
+ new StringAsset("camel.chaos.seed=" + SEED + "\n"),
"application.properties"));
+
+ ChaosDevUITest() {
+ super("org.apache.camel.quarkus.camel-quarkus-chaos");
+ }
+
+ @AfterEach
+ void clear() throws Exception {
+ call("clearRules", Map.of());
+ }
+
+ @Test
+ void addAndRemoveRule() throws Exception {
+ JsonObject added = call("addRules", Map.of("rules",
"endpoint=direct:none error"));
+ assertFalse(added.containsKey("error"), added::encode);
+ // No endpoint matches the rule
+ assertFalse(added.getJsonArray("warnings").isEmpty(), added::encode);
+ String id = added.getJsonArray("ids").getString(0);
+
+ assertTrue(call("removeRule", Map.of("id", id)).getBoolean("removed"));
+ assertFalse(call("removeRule", Map.of("id",
id)).getBoolean("removed"));
+ }
+
+ @Test
+ void clearRules() throws Exception {
+ call("addRules", Map.of("rules", "endpoint=direct:a error;
endpoint=direct:b error"));
+ assertEquals(2, call("clearRules", Map.of()).getInteger("removed"));
+ }
+
+ @Test
+ void seedIsText() throws Exception {
+ assertEquals(SEED, call("getSeed", Map.of()).getValue("seed"));
+ }
+
+ @Test
+ void reset() throws Exception {
+ call("addRules", Map.of("rules", "endpoint=direct:a error"));
+ assertEquals(1, call("reset", Map.of()).getInteger("removed"));
+ assertEquals(0, call("reset", Map.of()).getInteger("removed"));
+ }
+
+ @Test
+ void invalidRuleIsRejected() throws Exception {
+ JsonObject result = call("addRules", Map.of("rules",
"endpoint=direct:a error exception=com.example.Missing"));
+ assertTrue(result.getString("error").contains("com.example.Missing"),
result::encode);
+ }
+
+ private JsonObject call(String method, Map<String, Object> params) throws
Exception {
+ return new JsonObject(executeJsonRPCMethod(String.class, method,
params));
+ }
+}
diff --git a/extensions-jvm/chaos/pom.xml b/extensions-jvm/chaos/pom.xml
new file mode 100644
index 00000000000..60014629b7d
--- /dev/null
+++ b/extensions-jvm/chaos/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-extensions-jvm</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-chaos-parent</artifactId>
+ <name>Camel Quarkus :: Chaos</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions-jvm/chaos/runtime/pom.xml
b/extensions-jvm/chaos/runtime/pom.xml
new file mode 100644
index 00000000000..b2894b3f96e
--- /dev/null
+++ b/extensions-jvm/chaos/runtime/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <name>Camel Quarkus :: Chaos :: Runtime</name>
+ <description>Turn on faults in a running Camel application during
development, and report how the routes cope</description>
+
+ <properties>
+ <camel.quarkus.jvmSince>4.0.0</camel.quarkus.jvmSince>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-chaos</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+
<artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <property>
+ <name>!quickly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-extension-doc-page</id>
+ <goals>
+ <goal>update-extension-doc-page</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/extensions-jvm/chaos/runtime/src/main/doc/usage.adoc
b/extensions-jvm/chaos/runtime/src/main/doc/usage.adoc
new file mode 100644
index 00000000000..69997577b45
--- /dev/null
+++ b/extensions-jvm/chaos/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,41 @@
+=== Switching chaos on
+
+Chaos is intended for development only.
+
+In Quarkus dev mode, chaos is switched on with no extra configuration, because
Camel Quarkus sets the Camel profile to `dev`.
+Nothing happens to your routes until a rule is added.
+
+Outside of dev mode, chaos is off by default. Use `camel.chaos.enabled` to
switch it on or off, with a Quarkus profile to limit
+where it applies:
+
+[source,properties]
+----
+# Switch chaos on in tests
+%test.camel.chaos.enabled = true
+
+# Keep chaos off in dev mode
+%dev.camel.chaos.enabled = false
+----
+
+[WARNING]
+====
+Without a profile prefix, `camel.chaos.enabled=true` also applies to a
packaged application. A warning is logged at startup
+whenever chaos is switched on.
+====
+
+=== Managing the chaos rules
+
+In dev mode, open the Quarkus Dev UI and choose the Chaos page of the Camel
Chaos extension. It shows the rules and the report, and lets
+you add and remove rules while the application runs. The page is not available
outside of dev mode.
+
+Rules added on this page, and the report, are lost when the application
reloads. To add rules again after each reload, set
+`camel.chaos.rules`.
+
+Adding or removing rules does not reset the report. To start a new experiment,
use `Clear rules and reset report`.
+
+The rules and the report can also be read over HTTP. Add the
xref:reference/extensions/console.adoc[Console] extension, set
+`quarkus.camel.console.enabled=true`, and open `/q/camel/dev-console/chaos`.
By default, this is available in dev and test
+mode only. See the Console extension for how to expose it in prod mode, and
for the security implications.
+
+To control chaos with the Camel CLI (`camel cmd chaos-add`, `camel get
chaos`), add the
+xref:reference/extensions/cli-connector.adoc[CLI Connector] extension.
diff --git
a/extensions-jvm/chaos/runtime/src/main/java/org/apache/camel/quarkus/component/chaos/CamelChaosDevUIService.java
b/extensions-jvm/chaos/runtime/src/main/java/org/apache/camel/quarkus/component/chaos/CamelChaosDevUIService.java
new file mode 100644
index 00000000000..8eecb58001d
--- /dev/null
+++
b/extensions-jvm/chaos/runtime/src/main/java/org/apache/camel/quarkus/component/chaos/CamelChaosDevUIService.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos;
+
+import java.util.List;
+import java.util.function.BiConsumer;
+
+import io.quarkus.arc.Arc;
+import io.quarkus.arc.ArcContainer;
+import io.smallrye.common.annotation.Blocking;
+import jakarta.enterprise.context.ApplicationScoped;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.chaos.ChaosManager;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * Dev UI service to change the chaos rules. It is registered only in dev
mode. The rules and their report are read from
+ * the Camel {@code chaos} dev console.
+ */
+@ApplicationScoped
+public class CamelChaosDevUIService {
+ /**
+ * Adds rules separated by {@code ;}. Either all of them are added, or
none when one is not valid.
+ *
+ * @param rules The rules in their text form
+ * @return JSON String with the keys {@code ids} and {@code
warnings}, or {@code error}
+ */
+ @Blocking
+ public String addRules(String rules) {
+ return withManager((manager, response) -> {
+ List<String> ids = manager.addRules(rules);
+ JsonArray warnings = new JsonArray();
+ response.put("ids", new JsonArray(ids));
+ response.put("warnings", warnings);
+ for (String id : ids) {
+ try {
+ warnings.addAll(manager.checkRule(id));
+ } catch (Exception e) {
+ // The rule is active, so this must not be reported as a
failure to add it
+ warnings.add("Rule " + id + " was added, but could not be
checked: " + e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * Gets the seed of the rules as text, as JavaScript cannot represent
every 64-bit number.
+ *
+ * @return JSON String with the key {@code seed}, or {@code error}
+ */
+ @Blocking
+ public String getSeed() {
+ return withManager((manager, response) -> response.put("seed",
String.valueOf(manager.report().getSeed())));
+ }
+
+ /**
+ * Removes a rule.
+ *
+ * @param id The id of the rule
+ * @return JSON String with the key {@code removed}, or {@code error}
+ */
+ @Blocking
+ public String removeRule(String id) {
+ return withManager((manager, response) -> response.put("removed",
manager.removeRule(id)));
+ }
+
+ /**
+ * Removes all rules. They stay in the report.
+ *
+ * @return JSON String with the key {@code removed}, or {@code error}
+ */
+ @Blocking
+ public String clearRules() {
+ return withManager((manager, response) -> response.put("removed",
manager.clearRules()));
+ }
+
+ /**
+ * Removes all rules and starts a new report.
+ *
+ * @return JSON String with the key {@code removed}, or {@code error}
+ */
+ @Blocking
+ public String reset() {
+ return withManager((manager, response) -> response.put("removed",
manager.reset()));
+ }
+
+ private static String withManager(BiConsumer<ChaosManager, JsonObject>
action) {
+ JsonObject response = new JsonObject();
+ try {
+ // The container can be unavailable while a dev mode reload is in
progress
+ ArcContainer container = Arc.container();
+ CamelContext context = container == null ? null :
container.select(CamelContext.class).get();
+ ChaosManager manager = context == null ? null :
ChaosManager.get(context);
+ if (manager == null) {
+ boolean started = context != null && context.isStarted();
+ response.put("error", started ? "Chaos is off" : "Chaos is not
available, the application may be reloading");
+ } else {
+ action.accept(manager, response);
+ }
+ } catch (Exception e) {
+ response.put("error", e.getMessage() != null ? e.getMessage() :
e.getClass().getName());
+ }
+ return response.toJson();
+ }
+}
diff --git
a/extensions-jvm/chaos/runtime/src/main/resources/META-INF/quarkus-extension.yaml
b/extensions-jvm/chaos/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 00000000000..ce5bd2b5295
--- /dev/null
+++
b/extensions-jvm/chaos/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel Chaos"
+description: "Turn on faults in a running Camel application during
development, and report how the routes cope"
+metadata:
+ icon-url:
"https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
+ sponsor: "Apache Software Foundation"
+ unlisted: true
+ guide:
"https://camel.apache.org/camel-quarkus/latest/reference/extensions/chaos.html"
+ categories:
+ - "integration"
+ status: "preview"
+ integrates:
+ - name: "Camel"
+ artifact: "org.apache.camel:camel-base"
+ version: "${camel.version}"
\ No newline at end of file
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index bd821438bec..c1262733f51 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -41,6 +41,7 @@
<module>azure-files</module>
<module>barcode</module>
<module>bonita</module>
+ <module>chaos</module>
<module>chatscript</module>
<module>chunk</module>
<module>cli-connector</module>
diff --git a/integration-tests-jvm/chaos/pom.xml
b/integration-tests-jvm/chaos/pom.xml
new file mode 100644
index 00000000000..13532ca9d6f
--- /dev/null
+++ b/integration-tests-jvm/chaos/pom.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent-it/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-chaos</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Chaos</name>
+ <description>Integration tests for Camel Quarkus Chaos
extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>virtualDependencies</id>
+ <activation>
+ <property>
+ <name>!noVirtualDependencies</name>
+ </property>
+ </activation>
+ <dependencies>
+ <!-- The following dependencies guarantee that this module is
built after them. You can update them by running `mvn process-resources
-Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-console-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
diff --git
a/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosResource.java
b/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosResource.java
new file mode 100644
index 00000000000..6a6fc7f05c0
--- /dev/null
+++
b/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosResource.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.it;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.chaos.ChaosManager;
+
+@Path("/chaos")
+@ApplicationScoped
+public class ChaosResource {
+ @Inject
+ CamelContext context;
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/rules")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String addRule(String rule) {
+ return ChaosManager.get(context).addRule(rule);
+ }
+
+ @Path("/rules/{id}")
+ @DELETE
+ public void removeRule(@PathParam("id") String id) {
+ ChaosManager.get(context).removeRule(id);
+ }
+
+ @Path("/send")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response send() {
+ try {
+ return Response.ok(producerTemplate.requestBody("direct:start",
"test", String.class)).build();
+ } catch (CamelExecutionException e) {
+ Throwable cause = e.getCause();
+ return Response.serverError().entity(cause.getClass().getName() +
": " + cause.getMessage()).build();
+ }
+ }
+}
diff --git
a/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosRoutes.java
b/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosRoutes.java
new file mode 100644
index 00000000000..4106fbd0147
--- /dev/null
+++
b/integration-tests-jvm/chaos/src/main/java/org/apache/camel/quarkus/component/chaos/it/ChaosRoutes.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.it;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class ChaosRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ from("direct:start").routeId("start")
+ .to("direct:target");
+
+ from("direct:target").routeId("target")
+ .setBody(constant("OK"));
+ }
+}
diff --git
a/integration-tests-jvm/chaos/src/main/resources/application.properties
b/integration-tests-jvm/chaos/src/main/resources/application.properties
new file mode 100644
index 00000000000..6c7111dde4a
--- /dev/null
+++ b/integration-tests-jvm/chaos/src/main/resources/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+%test.camel.chaos.enabled=true
+quarkus.camel.console.enabled=true
diff --git
a/integration-tests-jvm/chaos/src/test/java/org/apache/camel/quarkus/component/chaos/it/ChaosTest.java
b/integration-tests-jvm/chaos/src/test/java/org/apache/camel/quarkus/component/chaos/it/ChaosTest.java
new file mode 100644
index 00000000000..60eb5daaa0b
--- /dev/null
+++
b/integration-tests-jvm/chaos/src/test/java/org/apache/camel/quarkus/component/chaos/it/ChaosTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.chaos.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+class ChaosTest {
+
+ @Test
+ void ruleLifecycle() {
+ assertSendSucceeds();
+
+ String id = RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body("endpoint=direct:target error
exception=java.net.ConnectException message=\"target down\"")
+ .post("/chaos/rules")
+ .then()
+ .statusCode(200)
+ .extract().asString();
+ try {
+ RestAssured.get("/chaos/send")
+ .then()
+ .statusCode(500)
+ .body(is("java.net.ConnectException: target down"));
+
+ RestAssured.given()
+ .accept(ContentType.JSON)
+ .get("/q/camel/dev-console/chaos")
+ .then()
+ .statusCode(200)
+ .body("chaos.enabled", is(true),
+ "chaos.rules.id", hasItem(id));
+ } finally {
+ RestAssured.delete("/chaos/rules/" + id)
+ .then()
+ .statusCode(204);
+ }
+
+ assertSendSucceeds();
+ }
+
+ private static void assertSendSucceeds() {
+ RestAssured.get("/chaos/send")
+ .then()
+ .statusCode(200)
+ .body(is("OK"));
+ }
+}
diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml
index a81c42f1375..a34b2265495 100644
--- a/integration-tests-jvm/pom.xml
+++ b/integration-tests-jvm/pom.xml
@@ -39,6 +39,7 @@
<module>azure-files</module>
<module>barcode</module>
<module>bonita</module>
+ <module>chaos</module>
<module>chatscript</module>
<module>chunk</module>
<module>cli-connector</module>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index fc4b96e2602..6f5073631bf 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -826,6 +826,11 @@
<artifactId>camel-cbor</artifactId>
<version>${camel.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-chaos</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-chatscript</artifactId>
@@ -4037,6 +4042,16 @@
<artifactId>camel-quarkus-cbor-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-chatscript</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml
b/poms/bom/src/main/generated/flattened-full-pom.xml
index 7daa11b822c..eee836331c6 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -749,6 +749,11 @@
<artifactId>camel-cbor</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-chaos</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-chatscript</artifactId>
@@ -3958,6 +3963,16 @@
<artifactId>camel-quarkus-cbor-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-chatscript</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index d2b38970dfc..65f7b9f0276 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -2191,6 +2191,11 @@
<artifactId>camel-cbor</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-chaos</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-chatscript</artifactId>
@@ -5405,6 +5410,16 @@
<artifactId>camel-quarkus-cbor-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-chatscript</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
index 503659e92e0..3659c23d8ec 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -2191,6 +2191,11 @@
<artifactId>camel-cbor</artifactId>
<version>4.24.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-chaos</artifactId>
+ <version>4.24.0</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-chatscript</artifactId>
@@ -5405,6 +5410,16 @@
<artifactId>camel-quarkus-cbor-deployment</artifactId>
<version>4.0.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-chaos-deployment</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-chatscript</artifactId>