3939import java .util .Collections ;
4040import java .util .Set ;
4141import java .util .concurrent .ConcurrentHashMap ;
42- import java .util .concurrent .ConcurrentLinkedDeque ;
4342import java .util .concurrent .Executor ;
4443import java .util .concurrent .Executors ;
4544import java .util .concurrent .LinkedBlockingDeque ;
5049
5150import org .apache .logging .log4j .LogManager ;
5251import org .apache .logging .log4j .Logger ;
52+ import org .awaitility .Awaitility ;
5353import org .junit .jupiter .api .AfterEach ;
54+ import org .junit .jupiter .api .BeforeAll ;
5455import org .junit .jupiter .api .BeforeEach ;
5556import org .junit .jupiter .api .RepeatedTest ;
5657import org .junit .jupiter .api .Test ;
5758import org .junit .jupiter .api .condition .EnabledIfEnvironmentVariable ;
5859
59- import engineering .swat .watch .WatchEvent .Kind ;
60-
6160class TortureTests {
6261
6362 private final Logger logger = LogManager .getLogger ();
6463
6564 private TestDirectory testDir ;
6665
66+ @ BeforeAll
67+ static void setupEverything () {
68+ Awaitility .setDefaultTimeout (TestHelper .LONG_WAIT .getSeconds (), TimeUnit .SECONDS );
69+ }
70+
6771 @ BeforeEach
6872 void setup () throws IOException {
6973 testDir = new TestDirectory ();
7074 }
7175
7276 @ AfterEach
73- void cleanup () throws IOException {
77+ void cleanup () {
7478 if (testDir != null ) {
7579 testDir .close ();
7680 }
@@ -90,7 +94,7 @@ private final class IOGenerator {
9094 }
9195 }
9296
93- private final static int BURST_SIZE = 1000 ;
97+ private static final int BURST_SIZE = 1000 ;
9498
9599 private void startJob (final Path root , Random r , Executor exec ) {
96100 exec .execute (() -> {
@@ -239,7 +243,6 @@ void manyRegistrationsForSamePath() throws InterruptedException, IOException {
239243 done .acquire (TORTURE_REGISTRATION_THREADS - 1 );
240244 assertTrue (seen .isEmpty (), "No events should have been sent" );
241245 var target = testDir .getTestDirectory ().resolve ("test124.txt" );
242- //logger.info("Writing: {}", target);
243246 Files .writeString (target , "Hello World" );
244247 var expected = Collections .singleton (target );
245248 await ("We should see only one event" )
@@ -324,8 +327,6 @@ void manyRegisterAndUnregisterSameTime() throws InterruptedException, IOExceptio
324327
325328 }
326329
327-
328-
329330 @ Test
330331 //Deletes can race the filesystem, so you might miss a few files in a dir, if that dir is already deleted
331332 @ EnabledIfEnvironmentVariable (named ="TORTURE_DELETE" , matches ="true" )
@@ -363,7 +364,7 @@ void pressureOnFSShouldNotMissDeletes() throws InterruptedException, IOException
363364 });
364365
365366 try (var activeWatch = watchConfig .start () ) {
366- logger .info ("Deleting files now" , THREADS );
367+ logger .info ("Deleting files now ({} threads) " , THREADS );
367368 testDir .deleteAllFiles ();
368369 logger .info ("Waiting for the events processing to stabilize" );
369370 waitForStable (events , happened );
0 commit comments