mirror of https://github.com/dapr/java-sdk.git
Supporting placement and scheduler custom images (#1450)
* supporting placement and scheduler custom images Signed-off-by: salaboy <Salaboy@gmail.com> * Bump org.apache.commons:commons-lang3 from 3.9 to 3.18.0 (#1446) Bumps org.apache.commons:commons-lang3 from 3.9 to 3.18.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-version: 3.18.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: artur-ciocanu <artur.ciocanu@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com> * Update dapr docs for Hugo upgrade (#1443) Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com> * Adds note about workflow start time (#1444) Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Co-authored-by: artur-ciocanu <artur.ciocanu@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com> * adding test to validate canonical names with substitutes Signed-off-by: salaboy <Salaboy@gmail.com> * Migrate PubSub removing flaky test (#1407) * Migrate PubSub removing flaky test Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> * Adjust assertion Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> * Change assert Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> * Apply pull request suggestions Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> * Use custom ObjectSerializer Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> --------- Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> Co-authored-by: artur-ciocanu <artur.ciocanu@gmail.com> Signed-off-by: salaboy <Salaboy@gmail.com> * adding tests for coverage Signed-off-by: salaboy <Salaboy@gmail.com> --------- Signed-off-by: salaboy <Salaboy@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> Signed-off-by: joshvanl <me@joshvanl.dev> Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: artur-ciocanu <artur.ciocanu@gmail.com> Co-authored-by: Marc Duiker <marcduiker@users.noreply.github.com> Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com> Co-authored-by: Josh van Leeuwen <me@joshvanl.dev> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Co-authored-by: Matheus Cruz <56329339+mcruzdev@users.noreply.github.com> Signed-off-by: sirivarma <siri.varma@outlook.com>
This commit is contained in:
parent
3c9bee7546
commit
8a6f839ed7
|
|
@ -56,10 +56,10 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
private static final YamlConverter<Subscription> SUBSCRIPTION_CONVERTER = new SubscriptionYamlConverter(YAML_MAPPER);
|
||||
private static final YamlConverter<HttpEndpoint> HTTPENDPOINT_CONVERTER = new HttpEndpointYamlConverter(YAML_MAPPER);
|
||||
private static final YamlConverter<Configuration> CONFIGURATION_CONVERTER = new ConfigurationYamlConverter(
|
||||
YAML_MAPPER);
|
||||
YAML_MAPPER);
|
||||
private static final WaitStrategy WAIT_STRATEGY = Wait.forHttp("/v1.0/healthz/outbound")
|
||||
.forPort(DAPRD_DEFAULT_HTTP_PORT)
|
||||
.forStatusCodeMatching(statusCode -> statusCode >= 200 && statusCode <= 399);
|
||||
.forPort(DAPRD_DEFAULT_HTTP_PORT)
|
||||
.forStatusCodeMatching(statusCode -> statusCode >= 200 && statusCode <= 399);
|
||||
|
||||
private final Set<Component> components = new HashSet<>();
|
||||
private final Set<Subscription> subscriptions = new HashSet<>();
|
||||
|
|
@ -68,8 +68,8 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
private String appChannelAddress = "localhost";
|
||||
private String placementService = "placement";
|
||||
private String schedulerService = "scheduler";
|
||||
private String placementDockerImageName = DAPR_PLACEMENT_IMAGE_TAG;
|
||||
private String schedulerDockerImageName = DAPR_SCHEDULER_IMAGE_TAG;
|
||||
private DockerImageName placementDockerImageName = DockerImageName.parse(DAPR_PLACEMENT_IMAGE_TAG);
|
||||
private DockerImageName schedulerDockerImageName = DockerImageName.parse(DAPR_SCHEDULER_IMAGE_TAG);
|
||||
|
||||
private Configuration configuration;
|
||||
private DaprPlacementContainer placementContainer;
|
||||
|
|
@ -82,6 +82,7 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
|
||||
/**
|
||||
* Creates a new Dapr container.
|
||||
*
|
||||
* @param dockerImageName Docker image name.
|
||||
*/
|
||||
public DaprContainer(DockerImageName dockerImageName) {
|
||||
|
|
@ -94,6 +95,7 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
|
||||
/**
|
||||
* Creates a new Dapr container.
|
||||
*
|
||||
* @param image Docker image name.
|
||||
*/
|
||||
public DaprContainer(String image) {
|
||||
|
|
@ -166,16 +168,26 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public DaprContainer withPlacementImage(String placementDockerImageName) {
|
||||
public DaprContainer withPlacementImage(DockerImageName placementDockerImageName) {
|
||||
this.placementDockerImageName = placementDockerImageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DaprContainer withSchedulerImage(String schedulerDockerImageName) {
|
||||
public DaprContainer withPlacementImage(String placementDockerImageName) {
|
||||
this.placementDockerImageName = DockerImageName.parse(placementDockerImageName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DaprContainer withSchedulerImage(DockerImageName schedulerDockerImageName) {
|
||||
this.schedulerDockerImageName = schedulerDockerImageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DaprContainer withSchedulerImage(String schedulerDockerImageName) {
|
||||
this.schedulerDockerImageName = DockerImageName.parse(schedulerDockerImageName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DaprContainer withReusablePlacement(boolean shouldReusePlacement) {
|
||||
this.shouldReusePlacement = shouldReusePlacement;
|
||||
return this;
|
||||
|
|
@ -203,6 +215,7 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
|
||||
/**
|
||||
* Adds a Dapr component from a YAML file.
|
||||
*
|
||||
* @param path Path to the YAML file.
|
||||
* @return This container.
|
||||
*/
|
||||
|
|
@ -217,7 +230,7 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
String type = (String) spec.get("type");
|
||||
String version = (String) spec.get("version");
|
||||
List<Map<String, String>> specMetadata =
|
||||
(List<Map<String, String>>) spec.getOrDefault("metadata", Collections.emptyList());
|
||||
(List<Map<String, String>>) spec.getOrDefault("metadata", Collections.emptyList());
|
||||
|
||||
ArrayList<MetadataEntry> metadataEntries = new ArrayList<>();
|
||||
|
||||
|
|
@ -258,17 +271,17 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
|
||||
if (this.placementContainer == null) {
|
||||
this.placementContainer = new DaprPlacementContainer(this.placementDockerImageName)
|
||||
.withNetwork(getNetwork())
|
||||
.withNetworkAliases(placementService)
|
||||
.withReuse(this.shouldReusePlacement);
|
||||
.withNetwork(getNetwork())
|
||||
.withNetworkAliases(placementService)
|
||||
.withReuse(this.shouldReusePlacement);
|
||||
this.placementContainer.start();
|
||||
}
|
||||
|
||||
if (this.schedulerContainer == null) {
|
||||
this.schedulerContainer = new DaprSchedulerContainer(this.schedulerDockerImageName)
|
||||
.withNetwork(getNetwork())
|
||||
.withNetworkAliases(schedulerService)
|
||||
.withReuse(this.shouldReuseScheduler);
|
||||
.withNetwork(getNetwork())
|
||||
.withNetworkAliases(schedulerService)
|
||||
.withReuse(this.shouldReuseScheduler);
|
||||
this.schedulerContainer.start();
|
||||
}
|
||||
|
||||
|
|
@ -384,6 +397,14 @@ public class DaprContainer extends GenericContainer<DaprContainer> {
|
|||
return DEFAULT_IMAGE_NAME;
|
||||
}
|
||||
|
||||
public DockerImageName getPlacementDockerImageName() {
|
||||
return placementDockerImageName;
|
||||
}
|
||||
|
||||
public DockerImageName getSchedulerDockerImageName() {
|
||||
return schedulerDockerImageName;
|
||||
}
|
||||
|
||||
// Required by spotbugs plugin
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package io.dapr.testcontainers;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
|
||||
import static io.dapr.testcontainers.DaprContainerConstants.DAPR_RUNTIME_IMAGE_TAG;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class DaprContainerTest {
|
||||
|
||||
@Test
|
||||
public void schedulerAndPlacementCustomImagesTest() {
|
||||
|
||||
DaprContainer dapr = new DaprContainer(DAPR_RUNTIME_IMAGE_TAG)
|
||||
.withAppName("dapr-app")
|
||||
.withSchedulerImage(DockerImageName.parse("custom/scheduler:1.15.4")
|
||||
.asCompatibleSubstituteFor("daprio/scheduler:1.15.4"))
|
||||
.withPlacementImage(DockerImageName.parse("custom/placement:1.15.4")
|
||||
.asCompatibleSubstituteFor("daprio/placement:1.15.4"))
|
||||
.withAppPort(8081)
|
||||
.withDaprLogLevel(DaprLogLevel.DEBUG)
|
||||
.withAppChannelAddress("host.testcontainers.internal");
|
||||
|
||||
|
||||
assertEquals("custom/placement:1.15.4", dapr.getPlacementDockerImageName().asCanonicalNameString());
|
||||
assertEquals("custom/scheduler:1.15.4", dapr.getSchedulerDockerImageName().asCanonicalNameString());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schedulerAndPlacementCustomImagesStringTest() {
|
||||
|
||||
DaprContainer dapr = new DaprContainer(DAPR_RUNTIME_IMAGE_TAG)
|
||||
.withAppName("dapr-app")
|
||||
.withSchedulerImage("daprio/scheduler:1.15.4")
|
||||
.withPlacementImage("daprio/placement:1.15.4")
|
||||
.withAppPort(8081)
|
||||
.withDaprLogLevel(DaprLogLevel.DEBUG)
|
||||
.withAppChannelAddress("host.testcontainers.internal");
|
||||
|
||||
|
||||
assertEquals("daprio/placement:1.15.4", dapr.getPlacementDockerImageName().asCanonicalNameString());
|
||||
assertEquals("daprio/scheduler:1.15.4", dapr.getSchedulerDockerImageName().asCanonicalNameString());
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue