Merge branch '3.1.x'

This commit is contained in:
spencergibb
2023-03-09 14:33:36 -05:00
9 changed files with 16 additions and 19 deletions

View File

@@ -153,7 +153,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>

View File

@@ -75,7 +75,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -84,7 +84,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -100,7 +100,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -21,9 +21,8 @@ import java.util.HashMap;
import com.ecwid.consul.v1.ConsulClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.consul.ConsulContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.springframework.cloud.consul.ConsulProperties;
import org.springframework.context.ApplicationContextInitializer;
@@ -43,18 +42,16 @@ public class ConsulTestcontainers implements ApplicationContextInitializer<Confi
/**
* Shared consul container.
*/
public static GenericContainer<?> consul = createConsulContainer();
public static ConsulContainer consul = createConsulContainer();
public static GenericContainer<?> createConsulContainer() {
public static ConsulContainer createConsulContainer() {
return createConsulContainer("1.7");
}
public static GenericContainer<?> createConsulContainer(String consulVersion) {
public static ConsulContainer createConsulContainer(String consulVersion) {
String dockerImageName = "consul:" + consulVersion;
return new GenericContainer<>(dockerImageName)
.withLogConsumer(new Slf4jLogConsumer(logger).withSeparateOutputStreams())
.waitingFor(Wait.forHttp("/v1/status/leader")).withExposedPorts(DEFAULT_PORT)
.withCommand("agent", "-dev", "-server", "-bootstrap", "-client", "0.0.0.0", "-log-level", "trace");
return new ConsulContainer(dockerImageName)
.withLogConsumer(new Slf4jLogConsumer(logger).withSeparateOutputStreams());
}
@Override

View File

@@ -131,7 +131,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -21,7 +21,7 @@ import java.util.List;
import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.agent.model.NewService;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.consul.ConsulContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@@ -54,11 +54,11 @@ public class ConsulDiscoveryClientNoPortTests {
// 1.10 introduces different data for port
@Container
static GenericContainer<?> consul = ConsulTestcontainers.createConsulContainer("1.10");
static ConsulContainer consul = ConsulTestcontainers.createConsulContainer("1.10");
@DynamicPropertySource
static void consulProperties(DynamicPropertyRegistry registry) {
registry.add(ConsulProperties.PREFIX + ".host", consul::getContainerIpAddress);
registry.add(ConsulProperties.PREFIX + ".host", consul::getHost);
registry.add(ConsulProperties.PREFIX + ".port", () -> consul.getMappedPort(ConsulTestcontainers.DEFAULT_PORT));
}

View File

@@ -69,7 +69,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<artifactId>consul</artifactId>
<scope>test</scope>
</dependency>
<dependency>