From d6d0d942db9458b754900c073c280ec0a7f6bc75 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 27 Oct 2021 13:30:23 -0400 Subject: [PATCH 1/2] intra test case fix --- .../sleuthkit/autopsy/testutils/IngestJobRunner.java | 12 +++++++++--- .../IngestedWithHashAndFileTypeIntraCaseTest.java | 7 ------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java b/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java index c424e057c2..14b7c21091 100755 --- a/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java +++ b/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java @@ -53,7 +53,7 @@ public final class IngestJobRunner { */ public static List runIngestJob(Collection dataSources, IngestJobSettings settings) throws InterruptedException { Object ingestMonitor = new Object(); - IngestJobCompletiontListener completiontListener = new IngestJobCompletiontListener(ingestMonitor); + IngestJobCompletiontListener completiontListener = new IngestJobCompletiontListener(ingestMonitor, dataSources.size()); IngestManager ingestManager = IngestManager.getInstance(); ingestManager.addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, completiontListener); try { @@ -84,6 +84,7 @@ public final class IngestJobRunner { private static final class IngestJobCompletiontListener implements PropertyChangeListener { private final Object ingestMonitor; + private int remainingJobsCount; /** * Constructs an ingest job event listener that allows @@ -92,9 +93,11 @@ public final class IngestJobRunner { * * @param ingestMonitor A Java object to notify when the ingest job is * omcpleted. + * @param jobsCount The number of jobs to listen for before notifying monitor. */ - IngestJobCompletiontListener(Object ingestMonitor) { + IngestJobCompletiontListener(Object ingestMonitor, int jobsCount) { this.ingestMonitor = ingestMonitor; + this.remainingJobsCount = jobsCount; } /** @@ -109,7 +112,10 @@ public final class IngestJobRunner { String eventType = event.getPropertyName(); if (eventType.equals(IngestManager.IngestJobEvent.COMPLETED.toString()) || eventType.equals(IngestManager.IngestJobEvent.CANCELLED.toString())) { synchronized (ingestMonitor) { - ingestMonitor.notify(); + this.remainingJobsCount--; + if (this.remainingJobsCount <= 0) { + ingestMonitor.notify(); + } } } } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java index 3cef4d1320..f5807509d0 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonpropertiessearch/IngestedWithHashAndFileTypeIntraCaseTest.java @@ -82,13 +82,6 @@ public class IngestedWithHashAndFileTypeIntraCaseTest extends NbTestCase { Exceptions.printStackTrace(ex); Assert.fail(ex.getMessage()); } - - // wait 10 seconds for all processes to finish before beginning tests - try { - Thread.sleep(10_000); - } catch (InterruptedException ex) { - Exceptions.printStackTrace(ex); - } } @Override From 0d5e7d8dd4a84dd04127970fbf401b87930acb65 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 27 Oct 2021 13:45:37 -0400 Subject: [PATCH 2/2] class rename --- .../org/sleuthkit/autopsy/testutils/IngestJobRunner.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java b/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java index 14b7c21091..59c05dd603 100755 --- a/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java +++ b/Core/src/org/sleuthkit/autopsy/testutils/IngestJobRunner.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Set; +import javax.annotation.concurrent.GuardedBy; import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobStartResult; @@ -53,7 +54,7 @@ public final class IngestJobRunner { */ public static List runIngestJob(Collection dataSources, IngestJobSettings settings) throws InterruptedException { Object ingestMonitor = new Object(); - IngestJobCompletiontListener completiontListener = new IngestJobCompletiontListener(ingestMonitor, dataSources.size()); + IngestJobCompletionListener completiontListener = new IngestJobCompletionListener(ingestMonitor, dataSources.size()); IngestManager ingestManager = IngestManager.getInstance(); ingestManager.addIngestJobEventListener(INGEST_JOB_EVENTS_OF_INTEREST, completiontListener); try { @@ -81,9 +82,11 @@ public final class IngestJobRunner { * An ingest job event listener that allows IngestRunner.runIngestJob to * block until the specified ingest job is completed. */ - private static final class IngestJobCompletiontListener implements PropertyChangeListener { + private static final class IngestJobCompletionListener implements PropertyChangeListener { private final Object ingestMonitor; + + @GuardedBy("ingestMonitor") private int remainingJobsCount; /** @@ -95,7 +98,7 @@ public final class IngestJobRunner { * omcpleted. * @param jobsCount The number of jobs to listen for before notifying monitor. */ - IngestJobCompletiontListener(Object ingestMonitor, int jobsCount) { + IngestJobCompletionListener(Object ingestMonitor, int jobsCount) { this.ingestMonitor = ingestMonitor; this.remainingJobsCount = jobsCount; }