New Instance type: Batch Manager
This commit is contained in:
committed by
Arnold Gálovics
parent
67850e3889
commit
ffb9147770
+3
-10
@@ -55,18 +55,11 @@ public class FineractProperties {
|
||||
|
||||
private boolean readEnabled;
|
||||
private boolean writeEnabled;
|
||||
private boolean batchEnabled;
|
||||
private boolean batchWorkerEnabled;
|
||||
private boolean batchManagerEnabled;
|
||||
|
||||
public boolean isReadOnlyMode() {
|
||||
return readEnabled && !writeEnabled && !batchEnabled;
|
||||
}
|
||||
|
||||
public boolean isWriteOnlyMode() {
|
||||
return !readEnabled && writeEnabled && !batchEnabled;
|
||||
}
|
||||
|
||||
public boolean isBatchOnlyMode() {
|
||||
return !readEnabled && !writeEnabled && batchEnabled;
|
||||
return readEnabled && !writeEnabled && !batchWorkerEnabled && !batchManagerEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -71,7 +71,8 @@ public class InstanceModeApiResource implements InitializingBean {
|
||||
log.warn("------------------------------------------------------------");
|
||||
fineractProperties.getMode().setReadEnabled(request.isReadEnabled());
|
||||
fineractProperties.getMode().setWriteEnabled(request.isWriteEnabled());
|
||||
fineractProperties.getMode().setBatchEnabled(request.isBatchEnabled());
|
||||
fineractProperties.getMode().setBatchWorkerEnabled(request.isBatchWorkerEnabled());
|
||||
fineractProperties.getMode().setBatchManagerEnabled(request.isBatchManagerEnabled());
|
||||
return Response.ok().build();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -34,6 +34,8 @@ public class InstanceModeApiResourceSwagger {
|
||||
@Schema(required = true, example = "true")
|
||||
public boolean writeEnabled;
|
||||
@Schema(required = true, example = "true")
|
||||
public boolean batchEnabled;
|
||||
public boolean batchWorkerEnabled;
|
||||
@Schema(required = true, example = "true")
|
||||
public boolean batchManagerEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
|
||||
public class FineractInstanceModeApiFilter extends OncePerRequestFilter {
|
||||
|
||||
private static final List<ExceptionListItem> EXCEPTION_LIST = List.of(
|
||||
item(FineractProperties.FineractModeProperties::isBatchEnabled, pi -> pi.startsWith("/jobs")),
|
||||
item(FineractProperties.FineractModeProperties::isBatchManagerEnabled, pi -> pi.startsWith("/jobs")),
|
||||
item(p -> true, pi -> pi.startsWith("/instance-mode")));
|
||||
|
||||
private final FineractProperties fineractProperties;
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public class SchedulerJobApiResource {
|
||||
@QueryParam(SchedulerJobApiConstants.COMMAND) @Parameter(description = "command") final String commandParam) {
|
||||
// check the logged in user have permissions to execute scheduler jobs
|
||||
Response response;
|
||||
if (fineractProperties.getMode().isBatchEnabled()) {
|
||||
if (fineractProperties.getMode().isBatchManagerEnabled()) {
|
||||
final boolean hasNotPermission = this.context.authenticatedUser().hasNotPermissionForAnyOf("ALL_FUNCTIONS",
|
||||
"EXECUTEJOB_SCHEDULER");
|
||||
if (hasNotPermission) {
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class JobRegisterServiceImpl implements JobRegisterService, ApplicationLi
|
||||
@PostConstruct
|
||||
public void loadAllJobs() {
|
||||
// If the instance is not Batch Enabled will not load the Jobs
|
||||
if (!fineractProperties.getMode().isBatchEnabled()) {
|
||||
if (!fineractProperties.getMode().isBatchManagerEnabled()) {
|
||||
return;
|
||||
}
|
||||
final List<FineractPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
|
||||
@@ -37,7 +37,8 @@ fineract.tenant.description=${FINERACT_DEFAULT_TENANTDB_DESCRIPTION:Default Demo
|
||||
|
||||
fineract.mode.read-enabled=${FINERACT_MODE_READ_ENABLED:true}
|
||||
fineract.mode.write-enabled=${FINERACT_MODE_WRITE_ENABLED:true}
|
||||
fineract.mode.batch-enabled=${FINERACT_MODE_BATCH_ENABLED:true}
|
||||
fineract.mode.batch-worker-enabled=${FINERACT_MODE_BATCH_WORKER_ENABLED:true}
|
||||
fineract.mode.batch-manager-enabled=${FINERACT_MODE_BATCH_MANAGER_ENABLED:true}
|
||||
|
||||
management.health.jms.enabled=false
|
||||
|
||||
|
||||
+7
-5
@@ -147,7 +147,7 @@ public class DataSourcePerTenantServiceFactoryTest {
|
||||
void testCreateNewDataSourceFor_ShouldUseNormalConfiguration_WhenInAllMode() {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = createModeProps(MASTER_DB_AUTO_COMMIT_ENABLED,
|
||||
MASTER_DB_AUTO_COMMIT_ENABLED, MASTER_DB_AUTO_COMMIT_ENABLED);
|
||||
MASTER_DB_AUTO_COMMIT_ENABLED, MASTER_DB_AUTO_COMMIT_ENABLED, MASTER_DB_AUTO_COMMIT_ENABLED);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
|
||||
// when
|
||||
@@ -173,7 +173,7 @@ public class DataSourcePerTenantServiceFactoryTest {
|
||||
@Test
|
||||
void testCreateNewDataSourceFor_ShouldUseReadOnlyConfiguration_WhenInReadOnlyMode() {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = createModeProps(true, false, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = createModeProps(true, false, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
|
||||
// when
|
||||
@@ -199,7 +199,7 @@ public class DataSourcePerTenantServiceFactoryTest {
|
||||
@Test
|
||||
void testCreateNewDataSourceFor_ShouldUseNormalConfiguration_WhenInBatchOnlyMode() {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = createModeProps(false, false, true);
|
||||
FineractProperties.FineractModeProperties modeProperties = createModeProps(false, false, true, true);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
|
||||
// when
|
||||
@@ -222,11 +222,13 @@ public class DataSourcePerTenantServiceFactoryTest {
|
||||
assertEquals(MASTER_DB_AUTO_COMMIT_ENABLED, hikariConfig.isAutoCommit());
|
||||
}
|
||||
|
||||
private FineractProperties.FineractModeProperties createModeProps(boolean readEnabled, boolean writeEnabled, boolean batchEnabled) {
|
||||
private FineractProperties.FineractModeProperties createModeProps(boolean readEnabled, boolean writeEnabled, boolean batchWorkerEnabled,
|
||||
boolean batchManagerEnabled) {
|
||||
FineractProperties.FineractModeProperties modeProperties = new FineractProperties.FineractModeProperties();
|
||||
modeProperties.setReadEnabled(readEnabled);
|
||||
modeProperties.setWriteEnabled(writeEnabled);
|
||||
modeProperties.setBatchEnabled(batchEnabled);
|
||||
modeProperties.setBatchWorkerEnabled(batchWorkerEnabled);
|
||||
modeProperties.setBatchManagerEnabled(batchManagerEnabled);
|
||||
return modeProperties;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -31,7 +31,8 @@ public class InstanceTypeStepDefinitions implements En {
|
||||
Given("Set every Fineract instance type to false", () -> {
|
||||
fineractProperties.getMode().setWriteEnabled(false);
|
||||
fineractProperties.getMode().setReadEnabled(false);
|
||||
fineractProperties.getMode().setBatchEnabled(false);
|
||||
fineractProperties.getMode().setBatchWorkerEnabled(false);
|
||||
fineractProperties.getMode().setBatchManagerEnabled(false);
|
||||
});
|
||||
Given("Fineract instance is a write instance", () -> {
|
||||
fineractProperties.getMode().setWriteEnabled(true);
|
||||
@@ -39,8 +40,8 @@ public class InstanceTypeStepDefinitions implements En {
|
||||
Given("Fineract instance is a read instance", () -> {
|
||||
fineractProperties.getMode().setReadEnabled(true);
|
||||
});
|
||||
Given("Fineract instance is a batch instance", () -> {
|
||||
fineractProperties.getMode().setBatchEnabled(true);
|
||||
Given("Fineract instance is a batch manager instance", () -> {
|
||||
fineractProperties.getMode().setBatchManagerEnabled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -27,11 +27,12 @@ public final class InstanceModeMock {
|
||||
}
|
||||
|
||||
public static FineractProperties.FineractModeProperties createModeProps(boolean readEnabled, boolean writeEnabled,
|
||||
boolean batchEnabled) {
|
||||
boolean batchWorkerEnabled, boolean batchManagerEnabled) {
|
||||
FineractProperties.FineractModeProperties modeProperties = new FineractProperties.FineractModeProperties();
|
||||
modeProperties.setReadEnabled(readEnabled);
|
||||
modeProperties.setWriteEnabled(writeEnabled);
|
||||
modeProperties.setBatchEnabled(batchEnabled);
|
||||
modeProperties.setBatchWorkerEnabled(batchWorkerEnabled);
|
||||
modeProperties.setBatchManagerEnabled(batchManagerEnabled);
|
||||
return modeProperties;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -71,7 +71,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInAllModeAndIsGetApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, true, true);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, true, true, true);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getPathInfo()).willReturn("/loans");
|
||||
@@ -84,7 +84,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInReadOnlyModeAndIsGetApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getPathInfo()).willReturn("/loans");
|
||||
@@ -98,7 +98,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
void testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInReadOnlyModeAndIsHealthApi()
|
||||
throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getServletPath()).willReturn("/actuator/health");
|
||||
@@ -112,7 +112,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldNotLetWriteApisThrough_WhenFineractIsInReadOnlyModeAndIsPostApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.POST.name());
|
||||
given(request.getPathInfo()).willReturn("/loans");
|
||||
@@ -126,7 +126,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldNotLetBatchApisThrough_WhenFineractIsInReadOnlyModeAndIsJobsApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(true, false, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.POST.name());
|
||||
given(request.getPathInfo()).willReturn("/jobs/1");
|
||||
@@ -140,7 +140,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetReadApisThrough_WhenFineractIsInWriteModeAndIsGetApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getPathInfo()).willReturn("/loans");
|
||||
@@ -153,7 +153,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetWriteApisThrough_WhenFineractIsInWriteModeAndIsPostApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.POST.name());
|
||||
given(request.getPathInfo()).willReturn("/loans");
|
||||
@@ -166,7 +166,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetWriteApisThrough_WhenFineractIsInWriteModeAndIsPutApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.PUT.name());
|
||||
given(request.getPathInfo()).willReturn("/loans/1");
|
||||
@@ -179,7 +179,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInWriteModeAndIsHelathApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getServletPath()).willReturn("/actuator/health");
|
||||
@@ -193,7 +193,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldNotLetBatchApisThrough_WhenFineractIsInWriteModeAndIsJobsApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, true, false, false);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.POST.name());
|
||||
given(request.getPathInfo()).willReturn("/jobs/1");
|
||||
@@ -207,7 +207,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetBatchApisThrough_WhenFineractIsInBatchModeAndIsJobsApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true, true);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.POST.name());
|
||||
given(request.getPathInfo()).willReturn("/jobs/1");
|
||||
@@ -221,7 +221,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
void testDoFilterInternal_ShouldLetBatchApisThrough_WhenFineractIsInBatchModeAndIsListingJobsApi()
|
||||
throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true, true);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getPathInfo()).willReturn("/jobs");
|
||||
@@ -234,7 +234,7 @@ class FineractInstanceModeApiFilterTest {
|
||||
@Test
|
||||
void testDoFilterInternal_ShouldLetActuatorApisThrough_WhenFineractIsInBatchModeAndIsHealthApi() throws ServletException, IOException {
|
||||
// given
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true);
|
||||
FineractProperties.FineractModeProperties modeProperties = InstanceModeMock.createModeProps(false, false, true, true);
|
||||
given(fineractProperties.getMode()).willReturn(modeProperties);
|
||||
given(request.getMethod()).willReturn(HttpMethod.GET.name());
|
||||
given(request.getServletPath()).willReturn("/actuator/health");
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ Feature: Core Infrastructure
|
||||
@infrastructure
|
||||
Scenario: Verify that schema migration is not executed when the Fineract instance is a batch instance
|
||||
Given Set every Fineract instance type to false
|
||||
Given Fineract instance is a batch instance
|
||||
Given Fineract instance is a batch manager instance
|
||||
Given Liquibase is enabled with a default tenant
|
||||
When The database migration process is executed
|
||||
Then The database migration did not do anything, because it is not a write instance
|
||||
|
||||
Reference in New Issue
Block a user