Added a few simple seda tests to stress the core
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerToSedaTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerToSedaTest.java
new file mode 100644
index 0000000..420c93d
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerToSedaTest.java
@@ -0,0 +1,80 @@
+package org.apache.camel.itest.jmh;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class BlockingProducerToSedaTest {
+
+ @Test
+ public void launchBenchmark() throws Exception {
+ Options opt = new OptionsBuilder()
+ // Specify which benchmarks to run.
+ // You can be more specific if you'd like to run only one benchmark per test.
+ .include(this.getClass().getName() + ".*")
+ // Set the following options as needed
+ .measurementIterations(10)
+ .warmupIterations(5)
+ .forks(1)
+ .build();
+
+ new Runner(opt).run();
+ }
+
+ // The JMH samples are the best documentation for how to use it
+ // http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
+ @State(Scope.Benchmark)
+ public static class BenchmarkState {
+
+ CamelContext context;
+ ProducerTemplate producerTemplate;
+
+ @Setup(Level.Trial)
+ public void initialize() throws Exception {
+ context = new DefaultCamelContext();
+
+ producerTemplate = context.createProducerTemplate();
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ onException(IllegalStateException.class)
+ .process(e -> System.out.println("The SEDA queue is likely full and the system may be unable to catch to the load. Fix the test parameters"));
+
+ fromF("seda:test").to("log: ${body}");
+
+ }
+ });
+
+ context.start();
+ }
+ }
+
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SingleShotTime})
+ @Benchmark
+ public void sendBlocking(BlockingProducerToSedaTest.BenchmarkState state, Blackhole bh) {
+ state.producerTemplate.sendBody("seda:test?blockWhenFull=true&offerTimeout=1000", "test");
+ }
+
+
+
+
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerWithArrayBlockingQueueToSedaTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerWithArrayBlockingQueueToSedaTest.java
new file mode 100644
index 0000000..3779771
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/BlockingProducerWithArrayBlockingQueueToSedaTest.java
@@ -0,0 +1,102 @@
+package org.apache.camel.itest.jmh;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.seda.ArrayBlockingQueueFactory;
+import org.apache.camel.component.seda.SedaComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.results.format.ResultFormatType;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class BlockingProducerWithArrayBlockingQueueToSedaTest {
+
+ @Test
+ public void launchBenchmark() throws Exception {
+ Options opt = new OptionsBuilder()
+ // Specify which benchmarks to run.
+ // You can be more specific if you'd like to run only one benchmark per test.
+ .include(this.getClass().getName() + ".*")
+ // Set the following options as needed
+ .measurementIterations(10)
+ .warmupIterations(5)
+ .forks(1)
+ .resultFormat(ResultFormatType.JSON)
+ .result(this.getClass().getSimpleName() + ".jmh.json")
+ .build();
+
+ new Runner(opt).run();
+ }
+
+ // The JMH samples are the best documentation for how to use it
+ // http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
+ @State(Scope.Benchmark)
+ public static class BenchmarkState {
+
+ CamelContext context;
+ ProducerTemplate producerTemplate;
+ Endpoint endpoint;
+
+ File sampleFile = new File("some-file");
+ Integer someInt = Integer.valueOf(1);
+ Long someLong = Long.valueOf(2);
+
+ @Setup(Level.Trial)
+ public void initialize() throws Exception {
+ context = new DefaultCamelContext();
+
+ producerTemplate = context.createProducerTemplate();
+ context.getComponent("seda", SedaComponent.class).setDefaultQueueFactory(new ArrayBlockingQueueFactory());
+ endpoint = context.getEndpoint("seda:test?blockWhenFull=true&offerTimeout=1000");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ onException(IllegalStateException.class)
+ .process(e -> System.out.println("The SEDA queue is likely full and the system may be unable to catch to the load. Fix the test parameters"));
+
+ fromF("seda:test").to("log:?level=OFF");
+
+ }
+ });
+
+ context.start();
+ }
+ }
+
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SingleShotTime})
+ @Benchmark
+ public void sendBlocking(BlockingProducerWithArrayBlockingQueueToSedaTest.BenchmarkState state, Blackhole bh) {
+ state.producerTemplate.sendBody(state.endpoint, "test");
+ }
+
+
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SingleShotTime})
+ @Benchmark
+ public void sendBlockingWithMultipleTypes(BlockingProducerWithArrayBlockingQueueToSedaTest.BenchmarkState state, Blackhole bh) {
+ state.producerTemplate.sendBody(state.endpoint, "test");
+ state.producerTemplate.sendBody(state.endpoint, state.someInt);
+ state.producerTemplate.sendBody(state.endpoint, state.someLong);
+ state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
+ }
+
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContextStartStopTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContextStartStopTest.java
new file mode 100644
index 0000000..a1cbc2d
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContextStartStopTest.java
@@ -0,0 +1,67 @@
+package org.apache.camel.itest.jmh;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.engine.PrototypeExchangeFactory;
+import org.apache.camel.model.ModelCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class ContextStartStopTest {
+
+ @Test
+ public void launchBenchmark() throws Exception {
+ Options opt = new OptionsBuilder()
+ // Specify which benchmarks to run.
+ // You can be more specific if you'd like to run only one benchmark per test.
+ .include(this.getClass().getName() + ".*")
+ // Set the following options as needed
+ .mode(Mode.Throughput)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .measurementIterations(10)
+ .warmupIterations(5)
+ .forks(1)
+ .build();
+
+ new Runner(opt).run();
+ }
+
+ // The JMH samples are the best documentation for how to use it
+ // http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
+ @State(Scope.Benchmark)
+ public static class BenchmarkState {
+
+ CamelContext context;
+ PrototypeExchangeFactory factory;
+ ExtendedCamelContext extendedCamelContext;
+ ModelCamelContext modelCamelContext;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ context = new DefaultCamelContext();
+ }
+ }
+
+
+ @Benchmark
+ public void contextCycle(ContextStartStopTest.BenchmarkState state, Blackhole bh) {
+ state.context.start();
+ state.context.stop();
+
+ bh.consume(state.context);
+ }
+
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SedaRoundTripTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SedaRoundTripTest.java
new file mode 100644
index 0000000..0e945ac
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SedaRoundTripTest.java
@@ -0,0 +1,73 @@
+package org.apache.camel.itest.jmh;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ConsumerTemplate;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class SedaRoundTripTest {
+
+ @Test
+ public void launchBenchmark() throws Exception {
+ Options opt = new OptionsBuilder()
+ // Specify which benchmarks to run.
+ // You can be more specific if you'd like to run only one benchmark per test.
+ .include(this.getClass().getName() + ".*")
+ // Set the following options as needed
+ .measurementIterations(10)
+ .warmupIterations(5)
+ .forks(1)
+ .build();
+
+ new Runner(opt).run();
+ }
+
+ // The JMH samples are the best documentation for how to use it
+ // http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
+ @State(Scope.Benchmark)
+ public static class BenchmarkState {
+
+ CamelContext context;
+ ProducerTemplate producerTemplate;
+ ConsumerTemplate consumerTemplate;
+
+ @Setup(Level.Trial)
+ public void initialize() throws Exception {
+ context = new DefaultCamelContext();
+
+ producerTemplate = context.createProducerTemplate();
+ consumerTemplate = context.createConsumerTemplate();
+
+ context.start();
+ }
+ }
+
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SingleShotTime})
+ @Benchmark
+ public void sendBlocking(SedaRoundTripTest.BenchmarkState state, Blackhole bh) {
+ state.producerTemplate.sendBody("seda:test?blockWhenFull=true&offerTimeout=1000", "test");
+ bh.consume(state.consumerTemplate.receive("seda:test"));
+ }
+
+
+
+
+
+}