Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Security and Compliance
entitlements
Commits
c85ef178
Commit
c85ef178
authored
Apr 29, 2021
by
Rostislav Vatolin [SLB]
☕
Browse files
Merge branch 'create_bean_on_startup' into 'master'
Create redis spring bean beforehand See merge request
!70
parents
18f3ca3a
e88aa6b7
Pipeline
#37839
passed with stages
in 17 minutes and 8 seconds
Changes
13
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
provider/entitlements-v2-azure/src/main/java/org/opengroup/osdu/entitlements/v2/azure/config/CacheConfig.java
View file @
c85ef178
...
...
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Lazy
;
@Configuration
public
class
CacheConfig
{
...
...
@@ -30,7 +31,12 @@ public class CacheConfig {
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
/**
* To make sure a connection to redis is created beforehand,
* we need to create this spring bean on application startup
*/
@Bean
@Lazy
(
false
)
public
RedisCache
<
String
,
ParentReferences
>
groupCacheRedis
()
{
return
new
RedisCache
<>(
getRedisHostname
(),
redisPort
,
getRedisPassword
(),
redisTtlSeconds
,
redisDatabase
,
String
.
class
,
ParentReferences
.
class
);
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/service/GraphTraversalSourceUtilServiceTest.java
View file @
c85ef178
...
...
@@ -9,6 +9,7 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.model.NodeVertex
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.EdgePropertyNames
;
...
...
@@ -18,6 +19,7 @@ import org.opengroup.osdu.entitlements.v2.model.NodeType;
import
org.opengroup.osdu.entitlements.v2.model.Role
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.Arrays
;
...
...
@@ -34,6 +36,8 @@ public class GraphTraversalSourceUtilServiceTest {
private
GremlinConnector
gremlinConnector
;
@Autowired
private
GraphTraversalSourceUtilService
graphTraversalSourceUtilService
;
@MockBean
private
CacheConfig
cacheConfig
;
@After
public
void
cleanup
()
{
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/service/GroupCacheServiceAzureTest.java
View file @
c85ef178
...
...
@@ -13,6 +13,7 @@ import org.mockito.stubbing.Answer;
import
org.opengroup.osdu.core.common.cache.RedisCache
;
import
org.opengroup.osdu.core.common.logging.JaxRsDpsLog
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.service.metrics.hitsnmisses.HitsNMissesMetricService
;
import
org.opengroup.osdu.entitlements.v2.model.EntityNode
;
import
org.opengroup.osdu.entitlements.v2.model.ParentReference
;
...
...
@@ -87,6 +88,8 @@ public class GroupCacheServiceAzureTest {
@MockBean
private
JaxRsDpsLog
log
;
@MockBean
private
CacheConfig
cacheConfig
;
@MockBean
private
PartitionCacheTtlService
partitionCacheTtlService
;
@Mock
private
ParentTreeDto
parentTreeDto
;
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/service/HealthServiceAzureTest.java
View file @
c85ef178
...
...
@@ -8,10 +8,12 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.cache.ICache
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.model.ParentReferences
;
import
org.opengroup.osdu.entitlements.v2.service.HealthService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.boot.test.mock.mockito.SpyBean
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
redis.embedded.RedisServer
;
...
...
@@ -23,6 +25,9 @@ public class HealthServiceAzureTest {
@Autowired
private
HealthService
healthService
;
@MockBean
private
CacheConfig
cacheConfig
;
@SpyBean
private
ICache
<
String
,
ParentReferences
>
redisGroupCache
;
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/addmember/AddMemberRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -9,6 +9,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.EdgePropertyNames
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.VertexPropertyNames
;
...
...
@@ -38,6 +39,9 @@ public class AddMemberRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@After
public
void
cleanup
()
{
gremlinConnector
.
getGraphTraversalSource
().
V
().
drop
().
iterate
();
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/creategroup/CreateGroupRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -8,6 +8,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.VertexPropertyNames
;
import
org.opengroup.osdu.entitlements.v2.logging.AuditLogger
;
...
...
@@ -36,6 +37,9 @@ public class CreateGroupRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@Autowired
private
CreateGroupRepo
createGroupRepo
;
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/deletegroup/DeleteGroupRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -6,6 +6,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.addmember.AddMemberRepoGremlin
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.VertexPropertyNames
;
...
...
@@ -36,6 +37,9 @@ public class DeleteGroupRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@After
public
void
cleanup
()
{
gremlinConnector
.
getGraphTraversalSource
().
V
().
drop
().
iterate
();
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/listmember/ListMemberRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -5,6 +5,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.addmember.AddMemberRepoGremlin
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.EdgePropertyNames
;
...
...
@@ -40,6 +41,9 @@ public class ListMemberRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@Test
public
void
shouldLoadDirectChildrenSuccessfully
()
{
GraphTraversalSource
graphTraversalSource
=
gremlinConnector
.
getGraphTraversalSource
();
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/removemember/RemoveMemberRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -7,6 +7,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.addmember.AddMemberRepoGremlin
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.constant.VertexPropertyNames
;
...
...
@@ -42,6 +43,9 @@ public class RemoveMemberRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@After
public
void
cleanup
()
{
GraphTraversalSource
graphTraversalSource
=
gremlinConnector
.
getGraphTraversalSource
();
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/renamegroup/RenameGroupRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -10,6 +10,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.service.AddEdgeDto
;
import
org.opengroup.osdu.entitlements.v2.azure.service.GraphTraversalSourceUtilService
;
import
org.opengroup.osdu.entitlements.v2.azure.service.VertexUtilService
;
...
...
@@ -42,6 +43,8 @@ public class RenameGroupRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@Autowired
private
RenameGroupRepo
renameGroupRepo
;
@Autowired
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/retrievegroup/RetrieveGroupRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -7,6 +7,7 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.service.GraphTraversalSourceUtilService
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.addmember.AddMemberRepoGremlin
;
import
org.opengroup.osdu.entitlements.v2.azure.spi.gremlin.connection.GremlinConnector
;
...
...
@@ -54,6 +55,8 @@ public class RetrieveGroupRepoGremlinTest {
private
AddMemberRepoGremlin
addMemberRepoGremlin
;
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@After
public
void
cleanup
()
{
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/spi/gremlin/updateappids/UpdateAppIdsRepoGremlinTest.java
View file @
c85ef178
...
...
@@ -10,6 +10,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.opengroup.osdu.core.common.logging.audit.AuditStatus
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.service.AddEdgeDto
;
import
org.opengroup.osdu.entitlements.v2.azure.service.GraphTraversalSourceUtilService
;
import
org.opengroup.osdu.entitlements.v2.azure.service.VertexUtilService
;
...
...
@@ -43,6 +44,8 @@ public class UpdateAppIdsRepoGremlinTest {
@MockBean
private
AuditLogger
auditLogger
;
@MockBean
private
CacheConfig
cacheConfig
;
@Autowired
private
UpdateAppIdsRepo
updateAppIdsRepo
;
@Autowired
...
...
provider/entitlements-v2-azure/src/test/java/org/opengroup/osdu/entitlements/v2/azure/workflow/CreateMembershipsWorkflowSinglePartitionTest.java
View file @
c85ef178
...
...
@@ -21,6 +21,7 @@ import org.opengroup.osdu.entitlements.v2.api.DeleteGroupApi;
import
org.opengroup.osdu.entitlements.v2.api.DeleteMemberApi
;
import
org.opengroup.osdu.entitlements.v2.auth.AuthorizationService
;
import
org.opengroup.osdu.entitlements.v2.azure.AzureAppProperties
;
import
org.opengroup.osdu.entitlements.v2.azure.config.CacheConfig
;
import
org.opengroup.osdu.entitlements.v2.azure.service.PartitionCacheTtlService
;
import
org.opengroup.osdu.entitlements.v2.logging.AuditLogger
;
import
org.opengroup.osdu.entitlements.v2.model.GroupType
;
...
...
@@ -95,6 +96,8 @@ public class CreateMembershipsWorkflowSinglePartitionTest {
@MockBean
private
RedisCache
<
String
,
ParentReferences
>
redisGroupCache
;
@MockBean
private
CacheConfig
cacheConfig
;
@MockBean
private
RedissonClient
redissonClient
;
@Mock
private
RLock
cacheLock
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment