jerryshao commented on code in PR #9559:
URL: https://github.com/apache/gravitino/pull/9559#discussion_r2647634648
##########
core/src/test/java/org/apache/gravitino/job/TestJobManager.java:
##########
@@ -114,23 +114,53 @@ public static void setUp() throws IllegalAccessException {
JobManager jm = new JobManager(config, entityStore, idGenerator,
jobExecutor);
jobManager = Mockito.spy(jm);
+ // Stop the background schedulers to prevent interference with tests
+ ScheduledExecutorService cleanUpExecutor =
+ (ScheduledExecutorService) FieldUtils.readField(jobManager,
"cleanUpExecutor", true);
+ if (cleanUpExecutor != null) {
+ cleanUpExecutor.shutdownNow();
+ }
+
+ cleanUpExecutor.shutdown();
+ try {
+ if (!cleanUpExecutor.awaitTermination(100, TimeUnit.MILLISECONDS)) {
+ cleanUpExecutor.shutdownNow();
+ }
+ } catch (InterruptedException e) {
+ cleanUpExecutor.shutdownNow();
+ Thread.currentThread().interrupt();
+ }
+
+ ScheduledExecutorService statusPullExecutor =
+ (ScheduledExecutorService) FieldUtils.readField(jobManager,
"statusPullExecutor", true);
+ if (statusPullExecutor != null) {
+ statusPullExecutor.shutdown();
+ try {
+ if (!statusPullExecutor.awaitTermination(100, TimeUnit.MILLISECONDS)) {
+ statusPullExecutor.shutdownNow();
+ }
+ } catch (InterruptedException e) {
+ statusPullExecutor.shutdownNow();
+ Thread.currentThread().interrupt();
+ }
+ }
Review Comment:
Why do you shutdown the executor before each test, not after? This doesn't
logically make sense. Also, the job manager is closed in `AfterEach`, do you
need to do this here using reflection?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]