New Instance type: Batch Manager

This commit is contained in:
taskain7
2022-06-28 15:32:17 +02:00
committed by Arnold Gálovics
parent 67850e3889
commit ffb9147770
16 changed files with 62 additions and 57 deletions
@@ -60,7 +60,7 @@ public class InstanceModeIntegrationTest {
jobId = schedulerJobHelper.getSchedulerJobIdByName(jobName);
}
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testGetHeadOfficeWorks_WhenInstanceModeIsReadOnly() {
// given
@@ -70,7 +70,7 @@ public class InstanceModeIntegrationTest {
assertNotNull(result);
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testGetHeadOfficeWorks_WhenInstanceModeIsWriteOnly() {
// given
@@ -80,7 +80,7 @@ public class InstanceModeIntegrationTest {
assertNotNull(result);
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchEnabled = true)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = true, batchManagerEnabled = true)
@Test
public void testGetHeadOfficeDoesntWork_WhenInstanceModeIsBatchOnly() {
// given
@@ -89,7 +89,7 @@ public class InstanceModeIntegrationTest {
// then no exception is thrown
}
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testCreateClientDoesntWork_WhenReadOnly() {
// given
@@ -99,7 +99,7 @@ public class InstanceModeIntegrationTest {
// then no exception thrown
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testCreateClientWorks_WhenWriteOnly() {
// given
@@ -110,7 +110,7 @@ public class InstanceModeIntegrationTest {
assertNotNull(result);
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchEnabled = true)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = true, batchManagerEnabled = true)
@Test
public void testCreateClientDoesntWork_WhenBatchOnly() {
// given
@@ -120,7 +120,7 @@ public class InstanceModeIntegrationTest {
// then no exception thrown
}
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = true, writeEnabled = false, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testRunSchedulerJobDoesntWork_WhenReadOnly() {
// given
@@ -129,7 +129,7 @@ public class InstanceModeIntegrationTest {
// then no exception thrown
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchEnabled = false)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = true, batchWorkerEnabled = false, batchManagerEnabled = false)
@Test
public void testRunSchedulerJobDoesntWork_WhenWriteOnly() {
// given
@@ -138,7 +138,7 @@ public class InstanceModeIntegrationTest {
// then no exception thrown
}
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchEnabled = true)
@ConfigureInstanceMode(readEnabled = false, writeEnabled = false, batchWorkerEnabled = true, batchManagerEnabled = true)
@Test
public void testRunSchedulerJobWorks_WhenBatchOnly() {
// given
@@ -32,5 +32,7 @@ public @interface ConfigureInstanceMode {
boolean writeEnabled();
boolean batchEnabled();
boolean batchWorkerEnabled();
boolean batchManagerEnabled();
}
@@ -31,9 +31,9 @@ public class InstanceModeHelper {
private static final Gson GSON = new JSON().getGson();
public static void changeMode(RequestSpecification requestSpec, ResponseSpecification responseSpec, boolean readEnabled,
boolean writeEnabled, boolean batchEnabled) {
boolean writeEnabled, boolean batchWorkerEnabled, boolean batchManagerEnabled) {
ChangeInstanceModeRequest request = new ChangeInstanceModeRequest().readEnabled(readEnabled).writeEnabled(writeEnabled)
.batchEnabled(batchEnabled);
.batchWorkerEnabled(batchWorkerEnabled).batchManagerEnabled(batchManagerEnabled);
String requestStr = GSON.toJson(request);
Utils.performServerPut(requestSpec, responseSpec, "/fineract-provider/api/v1/instance-mode?" + Utils.TENANT_IDENTIFIER, requestStr);
}
@@ -42,8 +42,9 @@ public class InstanceModeSupportExtension implements BeforeTestExecutionCallback
if (annotation != null) {
boolean readEnabled = annotation.readEnabled();
boolean writeEnabled = annotation.writeEnabled();
boolean batchEnabled = annotation.batchEnabled();
changeInstanceMode(context, readEnabled, writeEnabled, batchEnabled);
boolean batchWorkerEnabled = annotation.batchWorkerEnabled();
boolean batchManagerEnabled = annotation.batchWorkerEnabled();
changeInstanceMode(context, readEnabled, writeEnabled, batchWorkerEnabled, batchManagerEnabled);
}
});
}
@@ -53,12 +54,13 @@ public class InstanceModeSupportExtension implements BeforeTestExecutionCallback
context.getTestMethod().ifPresent(m -> {
ConfigureInstanceMode annotation = m.getAnnotation(ConfigureInstanceMode.class);
if (annotation != null) {
changeInstanceMode(context, true, true, true);
changeInstanceMode(context, true, true, true, true);
}
});
}
private void changeInstanceMode(ExtensionContext extensionContext, boolean readEnabled, boolean writeEnabled, boolean batchEnabled) {
private void changeInstanceMode(ExtensionContext extensionContext, boolean readEnabled, boolean writeEnabled,
boolean batchWorkerEnabled, boolean batchManagerEnabled) {
Store store = extensionContext.getStore(INSTANCE_MODE_NAMESPACE);
String authKey = store.getOrComputeIfAbsent(AUTH_KEY, k -> Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey(),
String.class);
@@ -66,6 +68,6 @@ public class InstanceModeSupportExtension implements BeforeTestExecutionCallback
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
requestSpec.header("Authorization", "Basic " + authKey);
InstanceModeHelper.changeMode(requestSpec, responseSpec, readEnabled, writeEnabled, batchEnabled);
InstanceModeHelper.changeMode(requestSpec, responseSpec, readEnabled, writeEnabled, batchWorkerEnabled, batchManagerEnabled);
}
}