Boyi Dai created ZOOKEEPER-5132:
-----------------------------------

             Summary: Recipe tests that extend ClientBase are silently skipped
                 Key: ZOOKEEPER-5132
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5132
             Project: ZooKeeper
          Issue Type: Bug
          Components: recipes, tests
    Affects Versions: 3.9.7, 3.9.0
            Reporter: Boyi Dai


The recipe test classes that extend {{ClientBase}} 
({{LeaderElectionSupportTest}}, {{WriteLockTest}} and {{DistributedQueueTest}}) 
are silently skipped by Maven. The build passes with 0 tests in 
{{zookeeper-recipes-election}} and {{zookeeper-recipes-queue}}, and only 
{{ZNodeNameTest}} in {{zookeeper-recipes-lock}}. The {{full-build-java-tests}} 
CI job on master shows the same counts, for example [this 
run|https://github.com/apache/zookeeper/actions/runs/42666755686/job/129332359967].

{{ZKTestCase}} uses hamcrest since ZOOKEEPER-4655 (3.9.0), but hamcrest is not 
on the test classpath of the recipe modules, so JUnit fails to resolve every 
class that extends {{ClientBase}} during discovery. Surefire 2.22.1 uses its 
default JUnit Platform launcher (1.3.1), which ignores discovery failures, so 
the build doesn't fail.

*Steps to reproduce:*
# Run {{mvn install -DskipTests}} so the {{zookeeper}} jar and test jar are 
available.
# Run {{mvn test -pl 
zookeeper-recipes/zookeeper-recipes-election,zookeeper-recipes/zookeeper-recipes-lock,zookeeper-recipes/zookeeper-recipes-queue}}.
# The election and queue modules report {{Tests run: 0}}, and the lock module 
reports 6 (all from {{ZNodeNameTest}}).
# Add {{junit-platform-launcher}} 1.6.2 as a test dependency and run it again. 
The build now fails with {{ClassSelector \[className = 
'org.apache.zookeeper.recipes.leader.LeaderElectionSupportTest'\] resolution 
failed: org/hamcrest/Description}}, and the same happens for the other two 
classes.

*Expected:* all recipe tests run, and a test class that can't be resolved fails 
the build.

*Proposed fix:* add {{hamcrest-library}} as a test dependency of 
{{zookeeper-recipes}}, and {{junit-platform-launcher}} (managed at 
{{junit-platform.version}} in the root pom) so discovery failures are reported. 
With both, all 27 recipe tests run and pass.

I have a patch and will open a PR.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to