Skip to content

Commit 2e2001f

Browse files
FINERACT-2525 accept MariaDB snapshot isolation conflict responses in savings integration tests
1 parent 1cdc97a commit 2e2001f

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

integration-tests/src/test/java/org/apache/fineract/integrationtests/SavingsAccountTransactionTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,13 @@ public void run() {
381381
assertNotNull(responses, "Responses");
382382
if (enclosingTransaction) {
383383
Integer statusCode1 = responses.get(0).getStatusCode();
384+
String msg1 = Strings.nullToEmpty(responses.get(0).getBody());
384385
assertNotNull(statusCode1, "First enlosingTransaction response status code");
385-
assertTrue(SC_OK == statusCode1 || SC_CONFLICT == statusCode1, "Status code: " + statusCode1);
386+
assertTrue(
387+
SC_OK == statusCode1
388+
|| SC_CONFLICT == statusCode1
389+
|| (SC_FORBIDDEN == statusCode1 && msg1.contains("Record has changed since last read")),
390+
"Status code: " + statusCode1 + ", message: " + msg1);
386391
if (SC_OK == statusCode1) {
387392
assertEquals(4, responses.size(), "Response size for enlosingTransaction OK response");
388393
Integer statusCode4 = responses.get(3).getStatusCode();
@@ -394,16 +399,21 @@ public void run() {
394399
} else {
395400
assertEquals(4, responses.size(), "Response size for without-enlosingTransaction response");
396401
Integer statusCode1 = responses.get(0).getStatusCode();
402+
String msg1 = Strings.nullToEmpty(responses.get(0).getBody());
397403
assertNotNull(statusCode1, "First without-enlosingTransaction response status code");
398-
assertTrue(SC_OK == statusCode1 || SC_CONFLICT == statusCode1,
399-
"First without-enlosingTransaction response status code: " + statusCode1);
404+
assertTrue(
405+
SC_OK == statusCode1
406+
|| SC_CONFLICT == statusCode1
407+
|| (SC_FORBIDDEN == statusCode1 && msg1.contains("Record has changed since last read")),
408+
"First without-enlosingTransaction response status code: " + statusCode1 + ", message: " + msg1);
400409
Integer statusCode4 = responses.get(3).getStatusCode();
401410
assertNotNull(statusCode4, "Last without-enlosingTransaction response status code");
402411
assertTrue(
403412
SC_OK == statusCode1 ? (SC_OK == statusCode4 || SC_CONFLICT == statusCode4)
404413
: (SC_FORBIDDEN == statusCode4 || SC_CONFLICT == statusCode4),
405414
"Last without-enlosingTransaction response status code: " + statusCode4);
406415
}
416+
407417
} else {
408418
String json = transactionData.getJson();
409419
String response = (String) this.savingsHelper.depositToSavingsAccount(savingsId, json, null);
@@ -444,8 +454,11 @@ private void runDeadlockBatch(SavingsAccountHelper savingsHelper, Integer saving
444454
String msg = Strings.nullToEmpty(response1.getBody());
445455
assertNotNull(statusCode, "First response status code");
446456
assertTrue(
447-
SC_OK == statusCode || SC_CONFLICT == statusCode
448-
|| (SC_FORBIDDEN == statusCode && msg.contains("Cannot add or update a child row")),
457+
SC_OK == statusCode
458+
|| SC_CONFLICT == statusCode
459+
|| (SC_FORBIDDEN == statusCode
460+
&& (msg.contains("Cannot add or update a child row")
461+
|| msg.contains("Record has changed since last read"))),
449462
"Status code: " + statusCode + ", message: " + msg);
450463
if (SC_OK == statusCode) {
451464
assertEquals(4, responses.size(), "Response size for OK response");

0 commit comments

Comments
 (0)