-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extensions): observability services unit and integration tests
- Loading branch information
Showing
14 changed files
with
639 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...mel/quarkus/component/observabilityservices/deployment/MicroProfileHealthEnabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.observabilityservices.deployment; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import jakarta.inject.Inject; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.health.HealthCheckRegistry; | ||
import org.apache.camel.impl.health.ConsumersHealthCheckRepository; | ||
import org.apache.camel.impl.health.ContextHealthCheck; | ||
import org.apache.camel.impl.health.RoutesHealthCheckRepository; | ||
import org.apache.camel.microprofile.health.CamelMicroProfileHealthCheckRegistry; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
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.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class MicroProfileHealthEnabledTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Inject | ||
CamelContext context; | ||
|
||
@Test | ||
public void healthCheckRegistryNotNull() { | ||
HealthCheckRegistry registry = HealthCheckRegistry.get(context); | ||
assertNotNull(registry); | ||
assertTrue(registry instanceof CamelMicroProfileHealthCheckRegistry); | ||
assertEquals("camel-microprofile-health", registry.getId()); | ||
} | ||
|
||
@Test | ||
public void contextHealthCheckNotNull() { | ||
ContextHealthCheck contextHealthCheck = context.getRegistry().lookupByNameAndType("context", ContextHealthCheck.class); | ||
assertNotNull(contextHealthCheck); | ||
} | ||
|
||
@Test | ||
public void routesHealthCheckNotNull() { | ||
RoutesHealthCheckRepository routesRepository = context.getRegistry().lookupByNameAndType("routes", | ||
RoutesHealthCheckRepository.class); | ||
assertNotNull(routesRepository); | ||
} | ||
|
||
@Test | ||
public void consumersHealthCheckNotNull() { | ||
ConsumersHealthCheckRepository consumersRepository = context.getRegistry().lookupByNameAndType("consumers", | ||
ConsumersHealthCheckRepository.class); | ||
assertNotNull(consumersRepository); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
...arkus/component/observabilityservices/deployment/MicrometerMetricsConfigDefaultsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* 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.observabilityservices.deployment; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import jakarta.inject.Inject; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier; | ||
import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifierNamingStrategy; | ||
import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier; | ||
import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifierNamingStrategy; | ||
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyConfiguration; | ||
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory; | ||
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyNamingStrategy; | ||
import org.apache.camel.component.micrometer.spi.InstrumentedThreadPoolFactory; | ||
import org.apache.camel.impl.engine.DefaultMessageHistoryFactory; | ||
import org.apache.camel.spi.EventNotifier; | ||
import org.apache.camel.spi.MessageHistoryFactory; | ||
import org.apache.camel.spi.RoutePolicyFactory; | ||
import org.apache.camel.spi.ThreadPoolFactory; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
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.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class MicrometerMetricsConfigDefaultsTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Inject | ||
CamelContext context; | ||
|
||
@Test | ||
public void testMicrometerMetricsConfiguration() { | ||
List<RoutePolicyFactory> routePolicyFactories = context.getRoutePolicyFactories(); | ||
assertEquals(1, routePolicyFactories.size()); | ||
RoutePolicyFactory routePolicyFactory = routePolicyFactories.get(0); | ||
assertInstanceOf(MicrometerRoutePolicyFactory.class, routePolicyFactory); | ||
MicrometerRoutePolicyFactory micrometerRoutePolicyFactory = (MicrometerRoutePolicyFactory) routePolicyFactory; | ||
assertEquals(MicrometerRoutePolicyNamingStrategy.DEFAULT, micrometerRoutePolicyFactory.getNamingStrategy()); | ||
|
||
MicrometerRoutePolicyConfiguration policyConfiguration = micrometerRoutePolicyFactory.getPolicyConfiguration(); | ||
assertTrue(policyConfiguration.isContextEnabled()); | ||
assertTrue(policyConfiguration.isRouteEnabled()); | ||
assertNull(policyConfiguration.getExcludePattern()); | ||
|
||
MessageHistoryFactory messageHistoryFactory = context.getMessageHistoryFactory(); | ||
assertNotNull(messageHistoryFactory); | ||
assertInstanceOf(DefaultMessageHistoryFactory.class, messageHistoryFactory); | ||
|
||
List<EventNotifier> eventNotifiers = context.getManagementStrategy() | ||
.getEventNotifiers() | ||
.stream() | ||
.filter(eventNotifier -> !eventNotifier.getClass().getName().contains("BaseMainSupport")) | ||
.toList(); | ||
assertEquals(3, eventNotifiers.size()); | ||
|
||
Optional<EventNotifier> optionalExchangeEventNotifier = context.getManagementStrategy() | ||
.getEventNotifiers() | ||
.stream() | ||
.filter(eventNotifier -> eventNotifier.getClass().equals(MicrometerExchangeEventNotifier.class)) | ||
.findFirst(); | ||
assertTrue(optionalExchangeEventNotifier.isPresent()); | ||
|
||
MicrometerExchangeEventNotifier micrometerExchangeEventNotifier = (MicrometerExchangeEventNotifier) optionalExchangeEventNotifier | ||
.get(); | ||
assertEquals(MicrometerExchangeEventNotifierNamingStrategy.DEFAULT, | ||
micrometerExchangeEventNotifier.getNamingStrategy()); | ||
|
||
Optional<EventNotifier> optionalRouteEventNotifier = context.getManagementStrategy() | ||
.getEventNotifiers() | ||
.stream() | ||
.filter(eventNotifier -> eventNotifier.getClass().equals(MicrometerRouteEventNotifier.class)) | ||
.findFirst(); | ||
assertTrue(optionalRouteEventNotifier.isPresent()); | ||
|
||
MicrometerRouteEventNotifier micrometerRouteEventNotifier = (MicrometerRouteEventNotifier) optionalRouteEventNotifier | ||
.get(); | ||
assertEquals(MicrometerRouteEventNotifierNamingStrategy.DEFAULT, micrometerRouteEventNotifier.getNamingStrategy()); | ||
|
||
ThreadPoolFactory threadPoolFactory = context.getExecutorServiceManager().getThreadPoolFactory(); | ||
assertNotNull(threadPoolFactory); | ||
assertFalse(threadPoolFactory instanceof InstrumentedThreadPoolFactory); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...he/camel/quarkus/component/observabilityservices/deployment/OpenTelemetryEnabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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.observabilityservices.deployment; | ||
|
||
import java.util.Set; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import jakarta.inject.Inject; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.opentelemetry.CamelQuarkusOpenTelemetryTracer; | ||
import org.apache.camel.opentelemetry.OpenTelemetryTracer; | ||
import org.apache.camel.opentelemetry.OpenTelemetryTracingStrategy; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
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.assertInstanceOf; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class OpenTelemetryEnabledTest { | ||
|
||
private static final String EXCLUDE_PATTERNS = "platform-http:*,platform-http:/prefix/.*"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest() | ||
.overrideConfigKey("quarkus.otel.sdk.disabled", "false") | ||
.overrideConfigKey("quarkus.camel.opentelemetry.encoding", "true") | ||
.overrideConfigKey("quarkus.camel.opentelemetry.exclude-patterns", EXCLUDE_PATTERNS) | ||
.overrideConfigKey("quarkus.camel.opentelemetry.trace-processors", "true") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)); | ||
|
||
@Inject | ||
CamelContext context; | ||
|
||
@Test | ||
public void camelOpenTelemetryTracerRegistryBeanNotNull() { | ||
Set<OpenTelemetryTracer> tracers = context.getRegistry().findByType(OpenTelemetryTracer.class); | ||
assertEquals(1, tracers.size()); | ||
|
||
OpenTelemetryTracer tracer = tracers.iterator().next(); | ||
assertInstanceOf(CamelQuarkusOpenTelemetryTracer.class, tracer); | ||
assertInstanceOf(OpenTelemetryTracingStrategy.class, tracer.getTracingStrategy()); | ||
assertTrue(tracer.isEncoding()); | ||
assertEquals(EXCLUDE_PATTERNS, tracer.getExcludePatterns()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.