@@ -88,11 +88,6 @@ public class FlowDurabilityTest {
8888 @ Rule
8989 public TimedRepeatRule repeater = new TimedRepeatRule ();
9090
91- @ Rule
92- public LoggerRule logging = new LoggerRule ();
93-
94- private Logger log = Logger .getLogger (FlowDurabilityTest .class .getName ());
95-
9691 // Used in Race-condition/persistence fuzzing where we need to run repeatedly
9792 static class TimedRepeatRule implements TestRule {
9893
@@ -575,7 +570,6 @@ public void evaluate() throws Throwable {
575570 */
576571 @ Test
577572 public void testDurableAgainstCleanRestartFailsWithDirtyShutdown () throws Exception {
578- logging .record ( hudson .model .RunMap .class , Level .WARNING ).capture (200 );
579573 final String [] logStart = new String [1 ];
580574 story .addStepWithDirtyShutdown (new Statement () {
581575 @ Override
@@ -589,36 +583,9 @@ public void evaluate() throws Throwable {
589583 story .addStep (new Statement () {
590584 @ Override
591585 public void evaluate () throws Throwable {
592- if (logging .getMessages ().stream ().anyMatch (msg -> msg .contains ("could not load" ) && msg .contains ("jobs/durableAgainstClean/builds/1" ))){
593- log .warning ("Found a message in LoggerRule - trying to log the build.xml" );
594- File buildXml = new File (story .j .jenkins .getRootDir () + "/jobs/durableAgainstClean/builds/1/build.xml" );
595- BufferedReader in = new BufferedReader (new FileReader (buildXml ));
596- String line = in .readLine ();
597- while (line != null )
598- {
599- log .warning (line );
600- line = in .readLine ();
601- }
602- in .close ();
603- log .warning ("Done logging the build.xml" );
604- }
605586 WorkflowRun run = story .j .jenkins .getItemByFullName ("durableAgainstClean" , WorkflowJob .class ).getLastBuild ();
606- try {
607- verifyFailedCleanly (story .j .jenkins , run );
608- } catch (NullPointerException e ) {
609- log .warning ("Caught NPE - trying to log the build.xml" );
610- File buildXml = new File (story .j .jenkins .getRootDir () + "/jobs/durableAgainstClean/builds/1/build.xml" );
611- BufferedReader in = new BufferedReader (new FileReader (buildXml ));
612- String line = in .readLine ();
613- while (line != null )
614- {
615- log .warning (line );
616- line = in .readLine ();
617- }
618- in .close ();
619- log .warning ("Done logging the build.xml" );
620- throw e ;
621- }
587+ if (run == null ) { return ; } //there is a small chance due to non atomic write that build.xml will be empty and the run won't load at all
588+ verifyFailedCleanly (story .j .jenkins , run );
622589 story .j .assertLogContains (logStart [0 ], run );
623590 }
624591 });
0 commit comments