From e1b8dbe909b0f8c181dcb5ee0e7e072f27f82cbb Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Sun, 27 Oct 2024 18:52:18 +0100 Subject: [PATCH] NUTCH-2771 Tests in nightly builds: skip long runners - introduce target "test-full" which executes all unit tests, even slow ones - slow unit tests are only run if the system property "test.include.slow" is true (it is set to true by the target "test-full") --- build.xml | 7 +++++++ .../nutch/segment/TestSegmentMerger.java | 7 +++++++ .../segment/TestSegmentMergerCrawlDatums.java | 21 ++++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/build.xml b/build.xml index 845bdfce89..ed48be46b2 100644 --- a/build.xml +++ b/build.xml @@ -469,6 +469,12 @@ + + + + + + @@ -496,6 +502,7 @@ errorProperty="tests.failed" failureProperty="tests.failed" maxmemory="1000m"> + diff --git a/src/test/org/apache/nutch/segment/TestSegmentMerger.java b/src/test/org/apache/nutch/segment/TestSegmentMerger.java index b4dcf1291c..e705188738 100644 --- a/src/test/org/apache/nutch/segment/TestSegmentMerger.java +++ b/src/test/org/apache/nutch/segment/TestSegmentMerger.java @@ -31,7 +31,9 @@ import org.apache.nutch.util.NutchConfiguration; import org.junit.After; import org.junit.Assert; +import org.junit.Assume; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; public class TestSegmentMerger { @@ -43,6 +45,11 @@ public class TestSegmentMerger { Path out; int countSeg1, countSeg2; + @BeforeClass + public static void checkConditions() throws Exception { + Assume.assumeTrue(Boolean.getBoolean("test.include.slow")); + } + @Before public void setUp() throws Exception { conf = NutchConfiguration.create(); diff --git a/src/test/org/apache/nutch/segment/TestSegmentMergerCrawlDatums.java b/src/test/org/apache/nutch/segment/TestSegmentMergerCrawlDatums.java index db7c067b25..ae6d6f81f5 100644 --- a/src/test/org/apache/nutch/segment/TestSegmentMergerCrawlDatums.java +++ b/src/test/org/apache/nutch/segment/TestSegmentMergerCrawlDatums.java @@ -32,7 +32,9 @@ import org.apache.nutch.crawl.CrawlDatum; import org.apache.nutch.util.NutchConfiguration; import org.junit.Assert; +import org.junit.Assume; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,13 +46,13 @@ * merging where we're looking for an expected status. A second test is able to * randomly inject redirects in segment, likely causing the segment merger to * fail resulting in a bad merged segment. - * + * * See also: - * + * * https://issues.apache.org/jira/browse/NUTCH-1113 * https://issues.apache.org/jira/browse/NUTCH-1616 * https://issues.apache.org/jira/browse/NUTCH-1520 - * + * * Cheers! */ public class TestSegmentMergerCrawlDatums { @@ -61,6 +63,11 @@ public class TestSegmentMergerCrawlDatums { private static final Logger LOG = LoggerFactory .getLogger(MethodHandles.lookup().lookupClass()); + @BeforeClass + public static void checkConditions() throws Exception { + Assume.assumeTrue(Boolean.getBoolean("test.include.slow")); + } + @Before public void setUp() throws Exception { conf = NutchConfiguration.create(); @@ -222,7 +229,7 @@ public void testEndsWithRedirect() throws Exception { /** * Execute a sequence of creating segments, merging them and checking the * final output - * + * * @param status * to start with * @param status @@ -281,7 +288,7 @@ protected byte executeSequence(byte firstStatus, byte lastStatus, int rounds, /** * Checks the merged segment and removes the stuff again. - * + * * @param the * test directory * @param the @@ -326,7 +333,7 @@ protected byte checkMergedSegment(Path testDir, Path mergedSegment) /** * Merge some segments! - * + * * @param the * test directory * @param the @@ -349,7 +356,7 @@ protected Path merge(Path testDir, Path[] segments) throws Exception { /** * Create a segment with the specified status. - * + * * @param the * segment's paths * @param the