Skip to content

Commit

Permalink
add devservice
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrebert committed Oct 7, 2024
1 parent ec0e781 commit ba09cee
Show file tree
Hide file tree
Showing 53 changed files with 1,293 additions and 138 deletions.
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/includes/quarkus-temporal.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ a| [[quarkus-temporal_quarkus-temporal-connection-target]]`link:#quarkus-tempora

[.description]
--
Sets a target string, which can be either a valid `NameResolver`-compliant URI, or an authority string. See `ManagedChannelBuilder++#++forTarget(String)` for more information about parameter format. Default is 127.0.0.1:7233
Sets a target string, which can be either a valid `NameResolver`-compliant URI, or an authority string. See `ManagedChannelBuilder++#++forTarget(String)` for more information about parameter format.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_TEMPORAL_CONNECTION_TARGET+++[]
Expand All @@ -726,7 +726,7 @@ ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_TEMPORAL_CONNECTION_TARGET+++`
endif::add-copy-button-to-env-var[]
--|string
|`127.0.0.1:7233`
|required icon:exclamation-circle[title=Configuration property is required]


a| [[quarkus-temporal_quarkus-temporal-connection-enable-https]]`link:#quarkus-temporal_quarkus-temporal-connection-enable-https[quarkus.temporal.connection.enable-https]`
Expand Down
16 changes: 13 additions & 3 deletions extension/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,25 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-common-deployment</artifactId>
<artifactId>quarkus-grpc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-grpc-deployment</artifactId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health-spi</artifactId>
<artifactId>quarkus-devservices-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.temporal</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkiverse.temporal.deployment.devui;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

// import io.quarkus.devservices.common.ConfigureUtil;

public class TemporalContainer extends GenericContainer<TemporalContainer> {

private static final Integer SERVER_EXPOSED_PORT = 7233;
private static final Integer UI_EXPOSED_PORT = 8233;

private final TemporalDevserviceConfig config;
private String serviceName;
// private String hostname;

public TemporalContainer(DockerImageName dockerImageName, TemporalDevserviceConfig config) {
super(dockerImageName);
this.config = config;
this.serviceName = "temporal";
}

@Override
protected void configure() {
super.configure();

withCreateContainerCmdModifier(cmd -> {
cmd.withEntrypoint("/usr/local/bin/temporal");
cmd.withCmd("server", "start-dev", "--ip", "0.0.0.0");
});

withExposedPorts(SERVER_EXPOSED_PORT, UI_EXPOSED_PORT);

withLabel("quarkus-devservice-temporal", serviceName);

withReuse(config.reuse());

// hostname = ConfigureUtil.configureSharedNetwork(this, "temporal-" + serviceName);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.quarkiverse.temporal.deployment.devui;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

@ConfigMapping(prefix = "quarkus.temporal.devservice")
@ConfigRoot(phase = ConfigPhase.BUILD_TIME)
public interface TemporalDevserviceConfig {

/**
* Enable the Temporal Devservice.
*/
@WithDefault("true")
Boolean enabled();

/**
* The image to use for the Temporal Devservice.
*/
// @WithDefault("temporalio/auto-setup")
@WithDefault("temporaliotest/auto-setup")
String image();

/**
* The version of the image to use for the Temporal Devservice.
*/
@WithDefault("latest")
String version();

/**
* Whether to reuse the Temporal Devservice.
*/
@WithDefault("true")
Boolean reuse();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.quarkiverse.temporal.deployment.devui;

import java.util.Map;

import org.testcontainers.utility.DockerImageName;

import io.quarkus.deployment.IsNormal;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.builditem.DevServicesResultBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devservices.common.ContainerLocator;

@BuildSteps(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class })
public class TemporalDevserviceProcessor {

private static final Integer SERVER_EXPOSED_PORT = 7233;
private static final Integer UI_EXPOSED_PORT = 8233;
private static final String DEV_SERVICE_LABEL = "quarkus-devservice-temporal";
private static final ContainerLocator containerLocator = new ContainerLocator(DEV_SERVICE_LABEL, SERVER_EXPOSED_PORT);

@BuildStep
public void build(TemporalDevserviceConfig config, BuildProducer<DevServicesResultBuildItem> devServiceProducer) {
if (Boolean.FALSE.equals(config.enabled())) {
return;
}

var imageStr = config.image() + ":" + config.version();
var image = DockerImageName.parse(imageStr)
.asCompatibleSubstituteFor(imageStr);

var serverContainer = new TemporalContainer(image, config);
serverContainer.start();

var serverPort = serverContainer.getMappedPort(SERVER_EXPOSED_PORT);
devServiceProducer.produce(new DevServicesResultBuildItem("temporal", serverContainer.getContainerId(), Map.of(
"quarkus.temporal.connection.target", "localhost:" + serverPort)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ public class HealthCheckEnabledTest {
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(
new StringAsset(
"quarkus.temporal.start-workers: false\n" + "quarkus.temporal.health.enabled: true\n"),
"quarkus.temporal.start-workers: false\n" +
"quarkus.temporal.health.enabled: true\n"),
"application.properties"));

@Test
public void testDataSourceHealthCheckExclusion() {
public void testDataSourceHealthCheck() {
RestAssured.when().get("/q/health/ready")
.then()
.body("status", equalTo("DOWN")) // Verifies that the status at the root level is "DOWN"
.body("status", equalTo("UP")) // Verifies that the status at the root level is "DOWN"
.body("checks", hasSize(1)) // Verifies that there is exactly one check in the "checks" array
.body("checks[0].name", equalTo("Temporal")) // Verifies that the name of the first check is "Temporal"
.body("checks[0].status", equalTo("DOWN")) // Verifies that the status of the first check is "DOWN"
.body("checks[0].data.'127.0.0.1:7233'", equalTo("DOWN"));
.body("checks[0].status", equalTo("UP")) // Verifies that the status of the first check is "DOWN"
;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ public interface ConnectionRuntimeConfig {
/**
* Sets a target string, which can be either a valid {@link NameResolver}-compliant URI, or an
* authority string. See {@link ManagedChannelBuilder#forTarget(String)} for more information
* about parameter format. Default is 127.0.0.1:7233
* about parameter format.
*/
@WithDefault("127.0.0.1:7233")
String target();

/**
Expand Down
140 changes: 140 additions & 0 deletions integration-tests/devservice/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.temporal</groupId>
<artifactId>quarkus-temporal-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>integration-tests-devservice</artifactId>
<name>Temporal - Integration Tests - Devservice</name>
<properties>
<skipITs>true</skipITs>
</properties>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.temporal</groupId>
<artifactId>quarkus-temporal</artifactId>
<version>${project.version}</version>
</dependency>
<!-- <dependency>
<groupId>io.quarkiverse.temporal</groupId>
<artifactId>quarkus-temporal-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency> -->
<!-- <dependency>
<groupId>io.quarkiverse.temporal</groupId>
<artifactId>quarkus-temporal-test-deployment</artifactId>
<version>${project.version}</version>
</dependency> -->
<dependency>
<groupId>io.quarkiverse.temporal</groupId>
<artifactId>quarkus-temporal-deployment</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<!-- <version>3.0</version> -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${native.surefire.skip}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<skipITs>false</skipITs>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
</profile>
</profiles>
</project>
Empty file.
Loading

0 comments on commit ba09cee

Please sign in to comment.