mirror of
https://github.com/valitydev/proxy-mocketbank.git
synced 2024-11-06 10:05:16 +00:00
Add woody with deadlines (#35)
This commit is contained in:
parent
f4d18b0369
commit
fe9b71f013
4
pom.xml
4
pom.xml
@ -12,7 +12,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>proxy-mocketbank</artifactId>
|
<artifactId>proxy-mocketbank</artifactId>
|
||||||
<version>1.0.5-SNAPSHOT</version>
|
<version>1.0.6-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>proxy-mocketbank</name>
|
<name>proxy-mocketbank</name>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rbkmoney.woody</groupId>
|
<groupId>com.rbkmoney.woody</groupId>
|
||||||
<artifactId>woody-thrift</artifactId>
|
<artifactId>woody-thrift</artifactId>
|
||||||
<version>1.1.13</version>
|
<version>1.1.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.rbkmoney.geck</groupId>
|
<groupId>com.rbkmoney.geck</groupId>
|
||||||
|
@ -1,32 +1,39 @@
|
|||||||
package com.rbkmoney.proxy.mocketbank.configuration;
|
package com.rbkmoney.proxy.mocketbank.configuration;
|
||||||
|
|
||||||
|
import com.rbkmoney.woody.api.trace.ContextUtils;
|
||||||
|
import com.rbkmoney.woody.api.trace.context.TraceContext;
|
||||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.context.annotation.RequestScope;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.UnrecoverableKeyException;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class RestTemplateConfiguration {
|
public class RestTemplateConfiguration {
|
||||||
|
|
||||||
|
@Value("${restTemplate.networkTimeout}")
|
||||||
|
private int networkTimeout;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
SSLContext sslContext() throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException {
|
public SSLContext sslContext() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
|
||||||
return new SSLContextBuilder()
|
return new SSLContextBuilder()
|
||||||
.loadTrustMaterial((x509Certificates, s) -> true)
|
.loadTrustMaterial((x509Certificates, s) -> true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
CloseableHttpClient httpClient(SSLContext sslContext) {
|
public CloseableHttpClient httpClient(SSLContext sslContext) {
|
||||||
return HttpClients.custom()
|
return HttpClients.custom()
|
||||||
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
|
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
|
||||||
.setSSLContext(sslContext)
|
.setSSLContext(sslContext)
|
||||||
@ -34,15 +41,21 @@ public class RestTemplateConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
HttpComponentsClientHttpRequestFactory requestFactory(CloseableHttpClient httpClient) {
|
public HttpComponentsClientHttpRequestFactory requestFactory(CloseableHttpClient httpClient) {
|
||||||
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
requestFactory.setHttpClient(httpClient);
|
requestFactory.setHttpClient(httpClient);
|
||||||
return requestFactory;
|
return requestFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
RestTemplate restTemplate(HttpComponentsClientHttpRequestFactory requestFactory) {
|
@RequestScope
|
||||||
return new RestTemplate(requestFactory);
|
public RestTemplate restTemplate(HttpComponentsClientHttpRequestFactory requestFactory) {
|
||||||
|
int executionTimeout = ContextUtils.getExecutionTimeout(TraceContext.getCurrentTraceData().getServiceSpan(), networkTimeout);
|
||||||
|
return new RestTemplateBuilder()
|
||||||
|
.requestFactory(requestFactory)
|
||||||
|
.setConnectTimeout(executionTimeout)
|
||||||
|
.setReadTimeout(executionTimeout)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,19 +22,7 @@ public class CdsStorageApi {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CdsStorageApi.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CdsStorageApi.class);
|
||||||
|
|
||||||
private StorageSrv.Iface storageSrv;
|
private final StorageSrv.Iface storageSrv;
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Constructors
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@link CdsStorageApi CdsApi} instance.
|
|
||||||
*/
|
|
||||||
public CdsStorageApi() {
|
|
||||||
// Constructs default a new {@link CdsApi CdsApi} instance.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@link CdsStorageApi CdsApi} instance with the given
|
* Constructs a new {@link CdsStorageApi CdsApi} instance with the given
|
||||||
@ -63,7 +51,7 @@ public class CdsStorageApi {
|
|||||||
LOGGER.info("getCardData: token: {}", token);
|
LOGGER.info("getCardData: token: {}", token);
|
||||||
try {
|
try {
|
||||||
CardData cardData = storageSrv.getCardData(token);
|
CardData cardData = storageSrv.getCardData(token);
|
||||||
LOGGER.info("getCardData: response, token: {}");
|
LOGGER.info("getCardData: response, token: {}", token);
|
||||||
return cardData;
|
return cardData;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new CdsException(String.format("Exception in getCardData with token: %s", token), ex);
|
throw new CdsException(String.format("Exception in getCardData with token: %s", token), ex);
|
||||||
|
@ -40,6 +40,9 @@ timer:
|
|||||||
fixture:
|
fixture:
|
||||||
cards: classpath:fixture/cards.csv
|
cards: classpath:fixture/cards.csv
|
||||||
---
|
---
|
||||||
|
restTemplate:
|
||||||
|
networkTimeout: 5000
|
||||||
|
---
|
||||||
error-mapping:
|
error-mapping:
|
||||||
file: classpath:fixture/errors.json
|
file: classpath:fixture/errors.json
|
||||||
patternReason: "'%s' - '%s'" # 'code' - 'description'
|
patternReason: "'%s' - '%s'" # 'code' - 'description'
|
||||||
|
@ -6,6 +6,8 @@ import com.palantir.docker.compose.execution.DockerComposeExecArgument;
|
|||||||
import com.palantir.docker.compose.execution.DockerComposeExecOption;
|
import com.palantir.docker.compose.execution.DockerComposeExecOption;
|
||||||
import org.junit.rules.ExternalResource;
|
import org.junit.rules.ExternalResource;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class IntegrationBaseRule extends ExternalResource {
|
public class IntegrationBaseRule extends ExternalResource {
|
||||||
|
|
||||||
private static final String CDS = "cds";
|
private static final String CDS = "cds";
|
||||||
@ -19,25 +21,23 @@ public class IntegrationBaseRule extends ExternalResource {
|
|||||||
.waitingForService(PROXY_MOCKETBANK_MPI, HealthChecks.toHaveAllPortsOpen())
|
.waitingForService(PROXY_MOCKETBANK_MPI, HealthChecks.toHaveAllPortsOpen())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void before() throws Throwable {
|
protected void before() throws Throwable {
|
||||||
docker.before();
|
docker.before();
|
||||||
executeHolmesScripts();
|
executeHolmesScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void after() {
|
protected void after() {
|
||||||
docker.after();
|
docker.after();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeHolmesScripts() {
|
private void executeHolmesScripts() throws IOException, InterruptedException {
|
||||||
try {
|
docker.dockerCompose().exec(
|
||||||
docker.dockerCompose().exec(
|
DockerComposeExecOption.options("-T"),
|
||||||
DockerComposeExecOption.noOptions(),
|
HOLMES,
|
||||||
HOLMES,
|
DockerComposeExecArgument.arguments("/opt/holmes/scripts/cds/init-keyring.sh")
|
||||||
DockerComposeExecArgument.arguments("/opt/holmes/scripts/cds/init-keyring.sh")
|
);
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user