Skip to content

Commit

Permalink
Merge pull request wildfly#17610 from rhusar/WFLY-18080
Browse files Browse the repository at this point in the history
WFLY-18080 Fix FaultToleranceMicrometerIntegrationTestCase to check for Docker being available which is a requirement of the MicrometerSetupTask
  • Loading branch information
pferraro committed Feb 9, 2024
2 parents 65c5ecc + 3d4a347 commit 6713749
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
Expand Up @@ -26,10 +26,12 @@
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.integration.common.HttpRequest;
import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.integration.microprofile.faulttolerance.micrometer.deployment.FaultTolerantApplication;
Expand Down Expand Up @@ -65,6 +67,14 @@ public static Archive<?> deploy() {
@Inject
private MeterRegistry meterRegistry;

// The @ServerSetup(MicrometerSetupTask.class) requires Docker to be available.
// Otherwise the org.wildfly.extension.micrometer.registry.NoOpRegistry is installed which will result in 0 counters,
// and cause the test fail seemingly intermittently on machines with broken Docker setup.
@BeforeClass
public static void checkForDocker() {
AssumeTestGroupUtil.assumeDockerAvailable();
}

@Test
@InSequence(1)
public void clearInjectedRegistry() {
Expand Down
Expand Up @@ -13,13 +13,16 @@
import org.jboss.as.controller.client.Operation;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.dmr.ModelNode;
import org.testcontainers.utility.MountableFile;

import java.io.File;
import java.io.IOException;

/**
* Sets up a functioning Micrometer subsystem configuration. Requires functioning Docker environment! Tests using this
* are expected to call AssumeTestGroupUtil.assumeDockerAvailable(); in a @BeforeClass.
*/
public class MicrometerSetupTask implements ServerSetupTask {
static OpenTelemetryCollectorContainer otelCollector;

Expand Down Expand Up @@ -81,18 +84,16 @@ public void tearDown(final ManagementClient managementClient, String containerId
}

private void startOpenTelemetryCollector() {
if ( AssumeTestGroupUtil.isDockerAvailable()) {
String otelCollectorConfigFile = getClass().getPackage().getName().replaceAll("\\.", File.separator) +
File.separator + "otel-collector-config.yaml";
otelCollector = new OpenTelemetryCollectorContainer()
.withCopyFileToContainer(MountableFile.forClasspathResource(otelCollectorConfigFile),
OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
.withCommand("--config " + OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
;

otelCollector.start();
containerStarted = true;
}
String otelCollectorConfigFile = getClass().getPackage().getName().replaceAll("\\.", File.separator) +
File.separator + "otel-collector-config.yaml";
otelCollector = new OpenTelemetryCollectorContainer()
.withCopyFileToContainer(MountableFile.forClasspathResource(otelCollectorConfigFile),
OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
.withCommand("--config " + OpenTelemetryCollectorContainer.OTEL_COLLECTOR_CONFIG_YAML)
;

otelCollector.start();
containerStarted = true;
}

private ModelNode enableStatistics(boolean enabled) {
Expand Down

0 comments on commit 6713749

Please sign in to comment.