RED-8702: Explore document databases to store entityLog
This commit is contained in:
parent
ff3fb59c39
commit
6ffffd75d9
@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package com.iqser.red.service.peristence.v1.server.integration.utils;
|
package com.iqser.red.service.peristence.v1.server.integration.utils;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_DATABASE;
|
||||||
|
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_PASSWORD;
|
||||||
|
import static com.iqser.red.service.peristence.v1.server.integration.utils.MongoDBTestContainer.MONGO_USERNAME;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -104,6 +107,8 @@ import com.iqser.red.storage.commons.utils.FileSystemBackedStorageService;
|
|||||||
import com.knecon.fforesight.databasetenantcommons.providers.TenantCreatedListener;
|
import com.knecon.fforesight.databasetenantcommons.providers.TenantCreatedListener;
|
||||||
import com.knecon.fforesight.databasetenantcommons.providers.events.TenantCreatedEvent;
|
import com.knecon.fforesight.databasetenantcommons.providers.events.TenantCreatedEvent;
|
||||||
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
import com.knecon.fforesight.databasetenantcommons.providers.utils.MagicConverter;
|
||||||
|
import com.knecon.fforesight.mongo.database.commons.liquibase.MongoTenantCreatedEvent;
|
||||||
|
import com.knecon.fforesight.mongo.database.commons.liquibase.MongoTenantCreatedListener;
|
||||||
import com.knecon.fforesight.tenantcommons.EncryptionDecryptionService;
|
import com.knecon.fforesight.tenantcommons.EncryptionDecryptionService;
|
||||||
import com.knecon.fforesight.tenantcommons.TenantContext;
|
import com.knecon.fforesight.tenantcommons.TenantContext;
|
||||||
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
||||||
@ -233,6 +238,8 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
private EncryptionDecryptionService encryptionDecryptionService;
|
private EncryptionDecryptionService encryptionDecryptionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantCreatedListener tenantCreatedListener;
|
private TenantCreatedListener tenantCreatedListener;
|
||||||
|
@Autowired
|
||||||
|
private MongoTenantCreatedListener mongoTenantCreatedListener;
|
||||||
|
|
||||||
|
|
||||||
private static String[] getAllRoles() {
|
private static String[] getAllRoles() {
|
||||||
@ -360,9 +367,9 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
redactionTenant.setMongoDBConnection(MongoDBConnection.builder()
|
redactionTenant.setMongoDBConnection(MongoDBConnection.builder()
|
||||||
.host(mongoDbContainer.getHost())
|
.host(mongoDbContainer.getHost())
|
||||||
.port(String.valueOf(mongoDbContainer.getFirstMappedPort()))
|
.port(String.valueOf(mongoDbContainer.getFirstMappedPort()))
|
||||||
.username(MongoDBTestContainer.MONGO_USERNAME)
|
.username(MONGO_USERNAME)
|
||||||
.password(encryptionDecryptionService.encrypt(MongoDBTestContainer.MONGO_PASSWORD))
|
.password(encryptionDecryptionService.encrypt(MONGO_PASSWORD))
|
||||||
.database(MongoDBTestContainer.MONGO_DATABASE)
|
.database(MONGO_DATABASE)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
when(tenantsClient.getTenant("redaction")).thenReturn(redactionTenant);
|
when(tenantsClient.getTenant("redaction")).thenReturn(redactionTenant);
|
||||||
@ -370,6 +377,7 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
tenantCreatedListener.createTenant(new TenantCreatedEvent("redaction"));
|
tenantCreatedListener.createTenant(new TenantCreatedEvent("redaction"));
|
||||||
|
mongoTenantCreatedListener.createTenant(new MongoTenantCreatedEvent("redaction"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -393,8 +401,6 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void cleanupStorage() {
|
public void cleanupStorage() {
|
||||||
|
|
||||||
@ -477,8 +483,8 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
"REDIS_HOST=" + redisContainer.getHost(),
|
"REDIS_HOST=" + redisContainer.getHost(),
|
||||||
"MONGODB_HOST=" + mongoInstance.getHost(),
|
"MONGODB_HOST=" + mongoInstance.getHost(),
|
||||||
"MONGODB_PORT=" + mongoInstance.getFirstMappedPort(),
|
"MONGODB_PORT=" + mongoInstance.getFirstMappedPort(),
|
||||||
"MONGODB_USER=" + MongoDBTestContainer.MONGO_USERNAME,
|
"MONGODB_USER=" + MONGO_USERNAME,
|
||||||
"MONGODB_PASSWORD=" + MongoDBTestContainer.MONGO_PASSWORD,
|
"MONGODB_PASSWORD=" + MONGO_PASSWORD,
|
||||||
"fforesight.jobs.enabled=false",
|
"fforesight.jobs.enabled=false",
|
||||||
"fforesight.keycloak.enabled=false").applyTo(configurableApplicationContext.getEnvironment());
|
"fforesight.keycloak.enabled=false").applyTo(configurableApplicationContext.getEnvironment());
|
||||||
|
|
||||||
@ -490,23 +496,23 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
private static void createMongoDBDatabase(MongoDBTestContainer mongoDBTestContainer) {
|
private static void createMongoDBDatabase(MongoDBTestContainer mongoDBTestContainer) {
|
||||||
|
|
||||||
try (MongoClient mongoClient = MongoClients.create(String.format("mongodb://%s:%s@%s:%s/",
|
try (MongoClient mongoClient = MongoClients.create(String.format("mongodb://%s:%s@%s:%s/",
|
||||||
MongoDBTestContainer.MONGO_USERNAME,
|
MONGO_USERNAME,
|
||||||
MongoDBTestContainer.MONGO_PASSWORD,
|
MONGO_PASSWORD,
|
||||||
mongoDBTestContainer.getHost(),
|
mongoDBTestContainer.getHost(),
|
||||||
mongoDBTestContainer.getFirstMappedPort()))) {
|
mongoDBTestContainer.getFirstMappedPort()))) {
|
||||||
MongoDatabase database = mongoClient.getDatabase(MongoDBTestContainer.MONGO_DATABASE);
|
MongoDatabase database = mongoClient.getDatabase(MONGO_DATABASE);
|
||||||
BsonDocument createUserCommand = new BsonDocument();
|
BsonDocument createUserCommand = new BsonDocument();
|
||||||
createUserCommand.append("createUser", new BsonString(MongoDBTestContainer.MONGO_USERNAME));
|
createUserCommand.append("createUser", new BsonString(MONGO_USERNAME));
|
||||||
createUserCommand.append("pwd", new BsonString(MongoDBTestContainer.MONGO_PASSWORD));
|
createUserCommand.append("pwd", new BsonString(MONGO_PASSWORD));
|
||||||
BsonArray roles = new BsonArray();
|
BsonArray roles = new BsonArray();
|
||||||
roles.add(new BsonString("readWrite"));
|
roles.add(new BsonDocument("role", new BsonString("dbOwner")).append("db", new BsonString(MONGO_DATABASE)));
|
||||||
createUserCommand.append("roles", roles);
|
createUserCommand.append("roles", roles);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
database.runCommand(createUserCommand);
|
database.runCommand(createUserCommand);
|
||||||
} catch (MongoCommandException mongoCommandException) {
|
} catch (MongoCommandException mongoCommandException) {
|
||||||
// ignore user already exists
|
// ignore user already exists
|
||||||
if(mongoCommandException.getErrorCode() != 51003) {
|
if (mongoCommandException.getErrorCode() != 51003) {
|
||||||
throw mongoCommandException;
|
throw mongoCommandException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,11 +521,12 @@ public abstract class AbstractPersistenceServerServiceTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@EnableMethodSecurity
|
@EnableMethodSecurity
|
||||||
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
||||||
@ComponentScan(basePackages = {"com.iqser.red.service.persistence" })
|
@ComponentScan("com.iqser.red.service.persistence")
|
||||||
public static class TestConfiguration {
|
public static class TestConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user