Skip to content

Commit 57c290e

Browse files
Merge pull request #913 from lewismc/NUTCH-3175
NUTCH-3175 Implement integration testing framework for Nutch Protocol plugins using Testcontainers
2 parents 2009e0e + cbb1d09 commit 57c290e

21 files changed

Lines changed: 869 additions & 10 deletions

File tree

.codespellrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[codespell]
2+
# JUnit 5 annotations incorrectly flagged as spelling errors
3+
ignore-words-list = AfterAll,BeforeAll
4+
# CHANGES.md is a historical changelog not maintained by this branch
5+
skip = CHANGES.md

.github/workflows/master-build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ jobs:
224224
- 'src/plugin/**'
225225
indexer_plugins:
226226
- 'src/plugin/indexer-*/**'
227+
protocol_plugins:
228+
- 'src/plugin/protocol-*/**'
227229
buildconf:
228230
- 'build.xml'
229231
- 'ivy/ivy.xml'
@@ -244,6 +246,10 @@ jobs:
244246
- name: test indexer integration
245247
if: ${{ steps.filter.outputs.indexer_plugins == 'true' && matrix.os == 'ubuntu-latest' }}
246248
run: ant clean test-indexer-integration -buildfile build.xml
249+
# run protocol integration tests when protocol plugin files change (Docker required, ubuntu-latest only)
250+
- name: test protocol integration
251+
if: ${{ steps.filter.outputs.protocol_plugins == 'true' && matrix.os == 'ubuntu-latest' }}
252+
run: ant clean test-protocol-integration -buildfile build.xml
247253
- name: Check for test results
248254
id: check_tests
249255
if: always() && matrix.os == 'ubuntu-latest'

.yetus/blanks-eol.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Ignore trailing blanks in Yetus-generated patch/diff and logs (not source files).
22
# See --blanks-eol-ignore-file in the blanks plugin.
33
^out/
4+
CHANGES.md

.yetus/blanks-tabs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Ignore tabs in Yetus-generated patch dir (not source files).
22
# See --blanks-tabs-ignore-file in the blanks plugin.
33
^out/
4+
CHANGES.md

build.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
</target>
100100

101101
<target name="dependencytests" depends="resolve-test" description="Show unit tests dependency tree">
102-
<ivy:dependencytree />
102+
<ivy:dependencytree />
103103
</target>
104104

105105
<!-- ====================================================== -->
@@ -528,6 +528,10 @@
528528
<ant dir="src/plugin" target="test-indexer-integration" inheritAll="false"/>
529529
</target>
530530

531+
<target name="test-protocol-integration" depends="resolve-test, compile, compile-core-test, job" description="--> run protocol plugin integration tests (Testcontainers)">
532+
<ant dir="src/plugin" target="test-protocol-integration" inheritAll="false"/>
533+
</target>
534+
531535
<target name="nightly" depends="test, tar-src, zip-src" description="--> run the nightly target build">
532536
</target>
533537

@@ -1079,7 +1083,7 @@
10791083
projectName="Apache Nutch Spotbugs Analysis"
10801084
stylesheet="fancy-hist.xsl" >
10811085
<auxClasspath>
1082-
<!-- depency jars required for analysis but not analyzed (not our bugs) -->
1086+
<!-- dependency jars required for analysis but not analyzed (not our bugs) -->
10831087
<pathelement path="${basedir}/${build.dir}/lib"/>
10841088
<fileset dir="${basedir}/${build.dir}/plugins">
10851089
<include name="**/*.jar"/>

conf/log4j2.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
<!-- default values that can be overridden by system properties:
2020
Note: the script bin/nutch sets these properties from the environment variables
2121
NUTCH_LOG_DIR and NUTCH_LOGFILE -->
22-
<Property name="hadoop.log.dir">${sys:hadoop.log.dir:-./logs}</Property>
23-
<Property name="hadoop.log.file">${sys:hadoop.log.file:-hadoop.log}</Property>
22+
<Property name="nutch.log.dir">${sys:hadoop.log.dir:-./logs}</Property>
23+
<Property name="nutch.log.file">${sys:hadoop.log.file:-hadoop.log}</Property>
2424
</Properties>
2525
<Appenders>
26-
<RollingFile name="RollingFile" fileName="${hadoop.log.dir}/${hadoop.log.file}"
27-
filePattern="${hadoop.log.dir}/$${date:yyyy-MM}/nutch-%d{yyyy-MM-dd}.log.gz">
26+
<RollingFile name="RollingFile" fileName="${nutch.log.dir}/${nutch.log.file}"
27+
filePattern="${nutch.log.dir}/$${date:yyyy-MM}/nutch-%d{yyyy-MM-dd}.log.gz">
2828
<PatternLayout pattern="%d %p %c{1.} [%t] %m%n" />
2929
<CronTriggeringPolicy schedule="0 0 0 * * ?" evaluateOnStartup="true" />
3030
<DefaultRolloverStrategy>
31-
<Delete basePath="${hadoop.log.dir}" maxDepth="2">
31+
<Delete basePath="${nutch.log.dir}" maxDepth="2">
3232
<IfFileName glob="*/nutch-*.log.gz" />
3333
<IfLastModified age="60d" />
3434
</Delete>

ivy/ivy.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,13 @@
122122
<dependency org="org.mockito" name="mockito-core" rev="5.18.0" conf="test->default"/>
123123
<dependency org="org.mockito" name="mockito-junit-jupiter" rev="5.18.0" conf="test->default"/>
124124

125-
<!-- Testcontainers for indexer plugin integration tests -->
125+
<!-- Testcontainers for indexer and protocol plugin integration tests -->
126126
<dependency org="org.testcontainers" name="testcontainers" rev="2.0.3" conf="test->default"/>
127127
<dependency org="org.testcontainers" name="junit-jupiter" rev="1.21.4" conf="test->default"/>
128+
<!-- WireMock for HTTP mock server in protocol-httpclient integration tests -->
129+
<dependency org="com.github.tomakehurst" name="wiremock-standalone" rev="3.0.1" conf="test->default"/>
130+
<!-- MockFtpServer for in-process FTP server in protocol-ftp integration tests -->
131+
<dependency org="org.mockftpserver" name="MockFtpServer" rev="3.1.0" conf="test->default"/>
128132

129133
<!-- MockServer (https://www.mock-server.com/) for static HTTP content in unit tests. -->
130134
<dependency org="org.mock-server" name="mockserver-netty" rev="5.15.0" conf="test->default">

src/plugin/build-plugin.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<include name="hamcrest*.jar" />
8888
<include name="junit*.jar" />
8989
<include name="opentest4j*.jar" />
90+
<include name="testcontainers*.jar" />
9091
</fileset>
9192
<path refid="classpath"/>
9293
</path>
@@ -277,6 +278,33 @@
277278
<fail if="integration.tests.failed">Indexer integration tests failed!</fail>
278279
</target>
279280

281+
<!-- ================================================================== -->
282+
<!-- Run protocol plugin integration tests (Testcontainers) -->
283+
<!-- ================================================================== -->
284+
<target name="test-protocol-integration" depends="compile-test, deploy" if="test.available">
285+
<echo message="Running protocol integration tests for plugin: ${name}"/>
286+
<junitlauncher printSummary="true" haltOnFailure="false" failureProperty="protocol.integration.tests.failed">
287+
<classpath refid="test.classpath"/>
288+
<testclasses outputDir="${build.test}">
289+
<listener type="legacy-plain" sendSysOut="true" sendSysErr="true"/>
290+
<listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>
291+
<fork forkMode="perTestClass">
292+
<jvmarg value="-Xmx2000m"/>
293+
<sysproperty key="test.data" value="${build.test}/data"/>
294+
<sysproperty key="test.input" value="${root}/data"/>
295+
<sysproperty key="testcontainers.reuse.enable" value="true"/>
296+
<sysproperty key="javax.xml.parsers.DocumentBuilderFactory" value="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
297+
</fork>
298+
<fileset dir="${build.test}">
299+
<include name="**/IT*.class"/>
300+
<include name="**/*IT.class"/>
301+
<include name="**/*IntegrationTest.class"/>
302+
</fileset>
303+
</testclasses>
304+
</junitlauncher>
305+
<fail if="protocol.integration.tests.failed">Protocol integration tests failed!</fail>
306+
</target>
307+
280308
<!-- target: resolve ================================================= -->
281309
<target name="resolve-default" depends="clean-lib" description="resolve and retrieve dependencies with ivy">
282310
<ivy:resolve file="ivy.xml" conf="default" log="download-only"/>

src/plugin/build.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@
183183
<ant dir="indexer-solr" target="test-indexer-integration"/>
184184
</target>
185185

186+
<!-- ====================================================== -->
187+
<!-- Protocol plugin integration tests (Testcontainers) -->
188+
<!-- Run sequentially to avoid container resource contention-->
189+
<!-- ====================================================== -->
190+
<target name="test-protocol-integration">
191+
<ant dir="protocol-ftp" target="test-protocol-integration"/>
192+
<ant dir="protocol-http" target="test-protocol-integration"/>
193+
<ant dir="protocol-httpclient" target="test-protocol-integration"/>
194+
<ant dir="protocol-htmlunit" target="test-protocol-integration"/>
195+
<ant dir="protocol-okhttp" target="test-protocol-integration"/>
196+
<ant dir="protocol-selenium" target="test-protocol-integration"/>
197+
</target>
198+
186199
<!-- ====================================================== -->
187200
<!-- Clean all of the plugins. -->
188201
<!-- ====================================================== -->

src/plugin/protocol-ftp/ivy.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
</publications>
3838

3939
<dependencies>
40-
<dependency org="commons-net" name="commons-net" rev="1.2.2" conf="*->master"/>
40+
<dependency org="commons-net" name="commons-net" rev="3.9.0" conf="*->master"/>
41+
<dependency org="org.mockftpserver" name="MockFtpServer" rev="3.1.0" conf="test->default"/>
4142
</dependencies>
4243

4344
</ivy-module>

0 commit comments

Comments
 (0)