1919
2020package io .temporal .internal .sync ;
2121
22- import static io .temporal .internal .sync .DeterministicRunner .DEFAULT_DEADLOCK_DETECTION_TIMEOUT ;
22+ import static io .temporal .internal .sync .DeterministicRunner .getDeadlockDetectionTimeout ;
2323import static junit .framework .TestCase .*;
2424import static org .junit .Assert .assertFalse ;
2525import static org .mockito .Mockito .*;
@@ -108,17 +108,17 @@ public void testYield() throws Throwable {
108108 status = "done" ;
109109 });
110110 assertEquals ("initial" , status );
111- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
111+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
112112 assertEquals ("started" , status );
113113 assertFalse (d .isDone ());
114114 unblock1 = true ;
115- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
115+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
116116 assertEquals ("after1" , status );
117117 // Just check that running again doesn't make any progress.
118- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
118+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
119119 assertEquals ("after1" , status );
120120 unblock2 = true ;
121- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
121+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
122122 assertEquals ("done" , status );
123123 assertTrue (d .isDone ());
124124 }
@@ -158,7 +158,7 @@ public void testRetry() throws Throwable {
158158 });
159159 try {
160160 for (int i = 0 ; i < Duration .ofSeconds (400 ).toMillis (); i += 10 ) {
161- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
161+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
162162 }
163163 fail ("failure expected" );
164164 } catch (IllegalThreadStateException e ) {
@@ -189,12 +189,12 @@ public void testRootFailure() throws Throwable {
189189 throw new RuntimeException ("simulated" );
190190 });
191191 assertEquals ("initial" , status );
192- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
192+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
193193 assertEquals ("started" , status );
194194 assertFalse (d .isDone ());
195195 unblock1 = true ;
196196 try {
197- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
197+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
198198 fail ("exception expected" );
199199 } catch (Exception ignored ) {
200200 }
@@ -218,11 +218,11 @@ public void testDispatcherStop() throws Throwable {
218218 status = "done" ;
219219 });
220220 assertEquals ("initial" , status );
221- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
221+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
222222 assertEquals ("started" , status );
223223 assertFalse (d .isDone ());
224224 unblock1 = true ;
225- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
225+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
226226 assertEquals ("after1" , status );
227227 d .close ();
228228 assertTrue (d .isDone ());
@@ -255,10 +255,10 @@ public void testDispatcherExit() throws Throwable {
255255 thread2 .get ();
256256 trace .add ("root done" );
257257 });
258- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
258+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
259259 assertFalse (d .isDone ());
260260 unblock2 = true ;
261- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
261+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
262262 assertTrue (d .isDone ());
263263 assertEquals ("exitValue" , d .getExitValue ());
264264 String [] expected =
@@ -282,10 +282,10 @@ public void testRootCancellation() throws Throwable {
282282 "reason1" , () -> CancellationScope .current ().isCancelRequested ());
283283 trace .add ("root done" );
284284 });
285- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
285+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
286286 assertFalse (d .isDone ());
287287 d .cancel ("I just feel like it" );
288- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
288+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
289289 assertTrue (d .isDone ());
290290 String [] expected =
291291 new String [] {
@@ -320,7 +320,7 @@ public void testExplicitScopeCancellation() throws Throwable {
320320 }
321321 trace .add ("root done" );
322322 });
323- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
323+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
324324 assertTrue (trace .toString (), d .isDone ());
325325 String [] expected =
326326 new String [] {
@@ -362,7 +362,7 @@ public void testExplicitDetachedScopeCancellation() throws Throwable {
362362 }
363363 trace .add ("root done" );
364364 });
365- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
365+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
366366 assertTrue (trace .toString (), d .isDone ());
367367 String [] expected =
368368 new String [] {
@@ -420,7 +420,7 @@ public void testExplicitThreadCancellation() throws Throwable {
420420 trace .add ("root done" );
421421 });
422422
423- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
423+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
424424 assertTrue (d .stackTrace (), d .isDone ());
425425 String [] expected =
426426 new String [] {
@@ -476,7 +476,7 @@ public void testExplicitCancellationOnFailure() throws Throwable {
476476 trace .add ("root done" );
477477 });
478478
479- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
479+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
480480 assertTrue (d .stackTrace (), d .isDone ());
481481 String [] expected =
482482 new String [] {
@@ -525,10 +525,10 @@ public void testDetachedCancellation() throws Throwable {
525525 }
526526 trace .add ("root done" );
527527 });
528- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
528+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
529529 assertFalse (trace .toString (), d .isDone ());
530530 d .cancel ("I just feel like it" );
531- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
531+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
532532 assertFalse (d .isDone ());
533533 String [] expected =
534534 new String [] {
@@ -537,7 +537,7 @@ public void testDetachedCancellation() throws Throwable {
537537 trace .setExpected (expected );
538538 trace .assertExpected ();
539539 unblock1 = true ;
540- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
540+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
541541 assertTrue (d .stackTrace (), d .isDone ());
542542 expected =
543543 new String [] {
@@ -563,17 +563,17 @@ public void testChild() throws Throwable {
563563 async .get ();
564564 });
565565 assertEquals ("initial" , status );
566- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
566+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
567567 assertEquals ("started" , status );
568568 assertFalse (d .isDone ());
569569 unblock1 = true ;
570- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
570+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
571571 assertEquals ("after1" , status );
572572 // Just check that running again doesn't make any progress.
573- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
573+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
574574 assertEquals ("after1" , status );
575575 unblock2 = true ;
576- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
576+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
577577 assertEquals ("done" , status );
578578 assertTrue (d .isDone ());
579579 }
@@ -605,9 +605,9 @@ public void apply() {
605605 @ Test
606606 public void testChildTree () throws Throwable {
607607 DeterministicRunner d = new DeterministicRunnerImpl (new TestChildTreeRunnable (0 )::apply );
608- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
608+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
609609 unblock1 = true ;
610- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
610+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
611611 assertTrue (d .isDone ());
612612 List <String > expected = new ArrayList <>();
613613 for (int i = 0 ; i <= CHILDREN ; i ++) {
@@ -668,7 +668,7 @@ public void workflowThreadsWillEvictCacheWhenMaxThreadCountIsHit() throws Throwa
668668
669669 cache .getOrCreate (response , new com .uber .m3 .tally .NoopScope (), () -> workflowRunTaskHandler );
670670 cache .addToCache (response .getWorkflowExecution ().getRunId (), workflowRunTaskHandler );
671- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
671+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
672672 assertEquals (2 , threadPool .getActiveCount ());
673673 assertEquals (1 , cache .size ());
674674
@@ -689,7 +689,7 @@ public void workflowThreadsWillEvictCacheWhenMaxThreadCountIsHit() throws Throwa
689689 },
690690 cache );
691691 // Act: This should kick out threads consumed by 'd'
692- d2 .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
692+ d2 .runUntilAllBlocked (getDeadlockDetectionTimeout () );
693693
694694 // Assert: Cache is evicted and only threads consumed by d2 remain.
695695 assertEquals (2 , threadPool .getActiveCount ());
@@ -730,7 +730,7 @@ public void workflowThreadsWillNotEvictCacheWhenMaxThreadCountIsHit() throws Thr
730730
731731 cache .getOrCreate (response , new com .uber .m3 .tally .NoopScope (), () -> workflowRunTaskHandler );
732732 cache .addToCache (response .getWorkflowExecution ().getRunId (), workflowRunTaskHandler );
733- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
733+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
734734 assertEquals (2 , threadPool .getActiveCount ());
735735 assertEquals (1 , cache .size ());
736736
@@ -751,7 +751,7 @@ public void workflowThreadsWillNotEvictCacheWhenMaxThreadCountIsHit() throws Thr
751751 cache );
752752
753753 // Act: This should not kick out threads consumed by 'd' since there's enough capacity
754- d2 .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
754+ d2 .runUntilAllBlocked (getDeadlockDetectionTimeout () );
755755
756756 // Assert: Cache is not evicted and all threads remain.
757757 assertEquals (4 , threadPool .getActiveCount ());
@@ -801,7 +801,7 @@ public void testRejectedExecutionError() {
801801 assertEquals ("initial" , status );
802802
803803 try {
804- d .runUntilAllBlocked (DEFAULT_DEADLOCK_DETECTION_TIMEOUT );
804+ d .runUntilAllBlocked (getDeadlockDetectionTimeout () );
805805 } catch (Throwable t ) {
806806 assertTrue (t instanceof WorkflowRejectedExecutionError );
807807 }
0 commit comments