You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Nathan McDonald (Jira)" <ji...@apache.org> on 2022/03/02 09:48:00 UTC

[jira] [Created] (SUREFIRE-2029) Parallel execution but surefire.forkNumber is the same

Nathan McDonald created SUREFIRE-2029:
-----------------------------------------

             Summary: Parallel execution but surefire.forkNumber is the same
                 Key: SUREFIRE-2029
                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2029
             Project: Maven Surefire
          Issue Type: Bug
          Components: Maven Failsafe Plugin
    Affects Versions: 2.22.2
            Reporter: Nathan McDonald


We have a multi module maven project, and due to our legacy architecture different modules are using the same underlying database.

We are using the one db per fork strategy mentioned, and each test clears the database before running its test.

 

This seems to work fine. But when running the full build on azure with
 -T 1C

We occasionally see one long running test fail, and have traced it to being that another test is running in parallel and clearing the database before that test fails.  This would only seem to happen if parallel threads running but same surefire.forkNumber being set for multiple threads.

Outputting logs of when tests start and end, with log outputting "Thread#$threadId\{$forkNumber}, e.g. Thread#7\{3} for thread with id 7, where  surefire.forkNumber is 3 

Looking at logs we can see test starts on thread/fork 1, clears db as expected, and 30 seconds later logs that it completes (with error that is shown later).

But we can see just moments later, another test starts up and also clears the database, but is using same thread/fork:


2022-03-01T16:30:59.5953417Z 2022-03-01 16:30:59.585 [main] INFO  e.t.b.h.w.c.AbstractIT:556 - Thread#1\{1} - Clearing the database before test
2022-03-01T16:30:59.7150510Z 2022-03-01 16:30:59.711 [main] INFO  e.t.b.a.w.c.AnalysisJobDownloadControllerTest:78 - Thread#1\{1} - running setup for AnalysisJobDownloadControllerTest#downloadTransactionsAfterAppendingDuplicateRecords
….
2022-03-01T16:31:01.1305751Z 2022-03-01 16:31:01.128 [main] INFO  e.t.b.h.w.c.AbstractIT:556 - Thread#1\{1} - Clearing the database before test
2022-03-01T16:31:01.6123984Z [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 24.715 s - in e.t.b.h.w.c.FinancialStatementReportItemRestControllerIT
2022-03-01T16:31:01.6124965Z [INFO] Running e.t.b.h.w.c.KeyInformationRestControllerIT
…
2022-03-01T16:31:29.1656587Z 2022-03-01 16:31:29.164 [main] INFO  e.t.b.a.w.c.AnalysisJobDownloadControllerTest:94 - Thread#1\{1} - complete test AnalysisJobDownloadControllerTest#downloadTransactionsAfterAppendingDuplicateRecords

This isn't consistent though. Can see other cases where this works, but is running on separate fork:
Thread#1\{3} 

Obviously there are separate threads/forks running here, so seems like somewhere between maven multi module and  -T 1C, there is not always assigning unique forkNumber to each fork.

I figure best practice is probably having separate modules not use same db, so possibly this issue is existing but not being hit by people as would only cause issue if same fork number used for separate modules on different databases.

Still looking into issue our side will update if find workaround or more detailed information



--
This message was sent by Atlassian Jira
(v8.20.1#820001)