modify riak extension

This commit is contained in:
ggmaleva 2021-09-29 17:34:34 +03:00
parent 05d501db7e
commit a5a823b16f
No known key found for this signature in database
GPG Key ID: 0E412B78565B108F
4 changed files with 11 additions and 25 deletions

View File

@ -15,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
@ -41,11 +39,6 @@ public class RiakTest {
@Autowired
private RiakClient client;
@DynamicPropertySource
static void connectionConfigs(DynamicPropertyRegistry registry) {
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
}
@Test
void riakTest() throws ExecutionException, InterruptedException {
sleep(10000);

View File

@ -16,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import java.net.URI;
import java.net.URISyntaxException;
@ -62,11 +60,6 @@ public class WbListManagerApplicationTest {
private WbListServiceSrv.Iface handler;
@DynamicPropertySource
static void connectionConfigs(DynamicPropertyRegistry registry) {
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
}
@BeforeEach
void setUp() throws URISyntaxException {
THClientBuilder clientBuilder = new THClientBuilder()

View File

@ -14,8 +14,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.TestPropertySource;
import static org.mockito.ArgumentMatchers.any;
@ -36,11 +34,6 @@ public class WbListSafetyApplicationTest {
@MockBean
private ListRepository listRepository;
@DynamicPropertySource
static void connectionConfigs(DynamicPropertyRegistry registry) {
registry.add("riak.port", () -> RiakContainerExtension.RIAK.getMappedPort(8087));
}
@Test
void kafkaRowTestException() throws Exception {
doThrow(new RiakExecutionException(),

View File

@ -1,5 +1,6 @@
package com.rbkmoney.wb.list.manager.extension;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.testcontainers.containers.GenericContainer;
@ -7,18 +8,24 @@ import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import java.time.Duration;
public class RiakContainerExtension implements BeforeAllCallback {
public class RiakContainerExtension implements BeforeAllCallback, AfterAllCallback {
public static GenericContainer RIAK;
public static GenericContainer riak;
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
RIAK = new GenericContainer("basho/riak-kv")
riak = new GenericContainer("basho/riak-kv")
.withExposedPorts(8098, 8087)
.withPrivilegedMode(true)
.waitingFor(new WaitAllStrategy()
.withStartupTimeout(Duration.ofMinutes(2)));
RIAK.start();
riak.start();
System.setProperty("riak.port", String.valueOf(riak.getMappedPort(8087)));
}
@Override
public void afterAll(ExtensionContext extensionContext) throws Exception {
riak.stop();
}
}