Commit 424ffc31 authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

config connection timeout in the application.properties

parent cf0f053a
Pipeline #39181 failed with stages
in 4 minutes and 46 seconds
......@@ -16,7 +16,7 @@
<properties>
<osdu.partition-core.version>0.9.0-SNAPSHOT</osdu.partition-core.version>
<osdu.corelibazure.version>0.9.0-SNAPSHOT-partition</osdu.corelibazure.version>
<osdu.corelibazure.version>v0.9.0-rc2</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.9.0-rc6</osdu.oscorecommon.version>
<azure.version>2.3.5</azure.version>
<junit.version>4.12</junit.version>
......
......@@ -43,10 +43,13 @@ public class RedisConfig {
@Value("${redis.database}")
private int database;
@Value("${redis.connection.timeout}")
private long timeout;
@Bean
public RedisCache<String, PartitionInfo> partitionServiceCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.socketOptions(SocketOptions.builder().connectTimeout(timeout, TimeUnit.SECONDS).build())
.build();
return new RedisCache<>(host, port, password, expiration, database, clientOptions, String.class, PartitionInfo.class);
}
......@@ -54,7 +57,7 @@ public class RedisConfig {
@Bean
public RedisCache<String, List<String>> partitionListCache(@Named("REDIS_HOST") String host, @Named("REDIS_PASSWORD") String password) {
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.socketOptions(SocketOptions.builder().connectTimeout(timeout, TimeUnit.SECONDS).build())
.build();
return new RedisCache(host, port, password, expiration, database, clientOptions, String.class, List.class);
}
......@@ -74,10 +77,13 @@ public class RedisConfig {
@Value("${redis.database}")
private int database;
@Value("${redis.connection.timeout}")
private long timeout;
@Bean
public RedisCache<String, PartitionInfo> partitionServiceCache(@Named("REDIS_HOST") String host) {
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.socketOptions(SocketOptions.builder().connectTimeout(timeout, TimeUnit.SECONDS).build())
.build();
return new RedisCache<>(host, port, expiration, database, clientOptions, String.class, PartitionInfo.class);
}
......@@ -85,7 +91,7 @@ public class RedisConfig {
@Bean
public RedisCache<String, List<String>> partitionListCache(@Named("REDIS_HOST") String host) {
ClientOptions clientOptions = ClientOptions.builder()
.socketOptions(SocketOptions.builder().connectTimeout(15, TimeUnit.SECONDS).build())
.socketOptions(SocketOptions.builder().connectTimeout(timeout, TimeUnit.SECONDS).build())
.build();
return new RedisCache(host, port, expiration, database, clientOptions, String.class, List.class);
}
......
......@@ -33,8 +33,9 @@ cache.maxSize=1000
redis.port=6380
redis.expiration=3600
redis.ssl.enabled=true
redis.connection.timeout=15
redis.database=${REDIS_DATABASE}
service.cryptography.enabled=false
service.eventgrid.topic.enabled=false
service.eventgrid.manager.enabled=false
azure.cryptography.enabled=false
azure.eventgrid.topic.enabled=false
azure.eventgrid.manager.enabled=false
......@@ -9,7 +9,6 @@ import org.opengroup.osdu.partition.util.BaseTestTemplate;
import org.springframework.http.HttpStatus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public abstract class UpdatePartitionTest extends BaseTestTemplate {
......@@ -71,8 +70,7 @@ public abstract class UpdatePartitionTest extends BaseTestTemplate {
deleteResource();
assertEquals(response.getStatus(), HttpStatus.NO_CONTENT.value());
assertEquals("GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH", response.getHeaders().getFirst("Access-Control-Allow-Methods"));
assertTrue("origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey".equals(response.getHeaders().getFirst("Access-Control-Allow-Headers")) ||
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey".equals(response.getHeaders().getFirst("Access-Control-Allow-Headers")));
assertEquals("origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey", response.getHeaders().getFirst("Access-Control-Allow-Headers"));
assertEquals("*", response.getHeaders().getFirst("Access-Control-Allow-Origin"));
assertEquals("true", response.getHeaders().getFirst("Access-Control-Allow-Credentials"));
assertEquals("default-src 'self'", response.getHeaders().getFirst("Content-Security-Policy"));
......
......@@ -20,7 +20,6 @@ import com.sun.jersey.api.client.ClientResponse;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public abstract class BaseTestTemplate extends TestBase {
......@@ -70,8 +69,7 @@ public abstract class BaseTestTemplate extends TestBase {
deleteResource();
assertEquals(error(response.getStatus() == 204 ? "" : response.getEntity(String.class)), expectedOkResponseCode(), response.getStatus());
assertEquals("GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH", response.getHeaders().getFirst("Access-Control-Allow-Methods"));
assertTrue("origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey".equals(response.getHeaders().getFirst("Access-Control-Allow-Headers")) ||
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey".equals(response.getHeaders().getFirst("Access-Control-Allow-Headers")));
assertEquals("origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey", response.getHeaders().getFirst("Access-Control-Allow-Headers"));
assertEquals("*", response.getHeaders().getFirst("Access-Control-Allow-Origin"));
assertEquals("true", response.getHeaders().getFirst("Access-Control-Allow-Credentials"));
assertEquals("default-src 'self'", response.getHeaders().getFirst("Content-Security-Policy"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment