Skip to content

Commit

Permalink
NUTCH-2771 Tests in nightly builds: skip long runners
Browse files Browse the repository at this point in the history
- 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")
  • Loading branch information
sebastian-nagel committed Oct 29, 2024
1 parent 5961e26 commit e1b8dbe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@
<!-- ================================================================== -->
<target name="test" depends="test-core, test-plugins" description="--> run JUnit tests"/>

<target name="test-full" description="--> run all JUnit tests, including slow ones">
<antcall target="test">
<param name="test.include.slow" value="true" />
</antcall>
</target>

<target name="test-core" depends="compile-core-test, job" description="--> run core JUnit tests only">

<delete dir="${test.build.data}"/>
Expand Down Expand Up @@ -496,6 +502,7 @@
errorProperty="tests.failed" failureProperty="tests.failed" maxmemory="1000m">
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="test.src.dir" value="${test.src.dir}"/>
<sysproperty key="test.include.slow" value="${test.include.slow}"/>
<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
Expand Down
7 changes: 7 additions & 0 deletions src/test/org/apache/nutch/segment/TestSegmentMerger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -326,7 +333,7 @@ protected byte checkMergedSegment(Path testDir, Path mergedSegment)

/**
* Merge some segments!
*
*
* @param the
* test directory
* @param the
Expand All @@ -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
Expand Down

0 comments on commit e1b8dbe

Please sign in to comment.