Skip to content

Add JUnit @Category-based smoke test suite as proof of concept - #1146

Open
vgosain-psg wants to merge 3 commits into
apache:mainfrom
vgosain-psg:jws-4412-junit-categories
Open

vgosain-psg wants to merge 3 commits into
apache:mainfrom
vgosain-psg:jws-4412-junit-categories

Conversation

@vgosain-psg

@vgosain-psg vgosain-psg commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary

  • Introduces SmokeTest category marker interface and SmokeSuite as a compile-checked alternative to the property file-based smoke profile
  • Annotates all 57 smoke test classes with @Category(SmokeTest.class) so the tag lives next to the code rather than in a separate properties file
  • Adds ant test-smoke-category target to run the suite via JUnit's Categories runner
  • Updates test-profiles.properties.default to replace the deleted TestHostConfigAutomaticDeploymentA/B/C with their refactored successors (Dir, War, Xml)
  • Updates BUILDING.txt with profile usage instructions and an explanation of the category-based approach

The existing property-based smoke profile is left intact — this is a proof of concept running alongside it, not a replacement. The intent is to gather feedback before deciding whether to extend categories to other profiles and retire the properties file mechanism.

Addresses: JWS-4412

Test plan

  • ant test-compile passes cleanly (verified locally — 0 errors)
  • ant test -Dtest.profile=smoke still works as before (existing mechanism unchanged)
  • ant test-smoke-category runs the new category-based suite and produces equivalent results
  • Renaming or deleting an annotated class causes a compile error in SmokeSuite.java (the key safety property)

🤖 Generated with Claude Code

@dsoumis
dsoumis self-requested a review November 6, 2026 12:25

@csutherl csutherl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the change is pretty straightforward, but I have some concerns about duplicated items (the smoke test list is in multiple places and duplicated macro config in the build.xml). Also we should drop the POC references from the doc and changelog entries. Specific comments are in line.

Comment thread test-profiles.properties.default Resolved
Comment thread BUILDING.txt Resolved
Comment thread build.xml Resolved
Comment thread webapps/docs/changelog.xml Resolved

@dsoumis dsoumis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good initial effort, but a few things need to be revisited.
First, you need to run ant -Dexecute.validate=true validate to fix any checkstyle errors on every contribution.

A change of design is needed:

  1. SmokeSuite and the test-smoke-category target should be removed.
  2. The annotation alone should decide what runs.
  3. Make sure each test class still gets its own JVM, because the proposed approach runs all in one JVM.

You can create a helper class in the test/ directory, which can be used by a new "-test-categories" target that scans the compiled classes for the requested category by the @Category annotation. It writes the matching file list into test.name, and behaves like the smoke profile.

@vgosain-psg
vgosain-psg force-pushed the jws-4412-junit-categories branch from cb5717f to c305b66 Compare November 9, 2026 16:31
Comment thread build.xml Resolved
@dsoumis

dsoumis commented Nov 9, 2026

Copy link
Copy Markdown
Member

ant test -Dtest.profile=smoke fails on a fresh checkout.
The profile step sets switches that test-compile needs, and now it also scans the compiled classes, which has to happen after compiling. As suggested before, please move the scan into its own -test-categories target that runs after test-compile and scans for the requested category

@vgosain-psg
vgosain-psg force-pushed the jws-4412-junit-categories branch 2 times, most recently from 2d9aad6 to 44580c5 Compare November 9, 2026 21:11
Comment thread build.xml Resolved
Comment thread build.xml Resolved
Comment thread BUILDING.txt Resolved
Comment thread BUILDING.txt Resolved
@vgosain-psg
vgosain-psg force-pushed the jws-4412-junit-categories branch 2 times, most recently from bc2fa0c to 631510c Compare November 12, 2026 15:58
@dsoumis

dsoumis commented Nov 16, 2026

Copy link
Copy Markdown
Member

@vgosain-psg lgtm now. Can you add the rest of the categories so we can remove the default profiles file as well as the section in build.xml? (In a separate commit, don't force push :) )

@vgosain-psg

Copy link
Copy Markdown
Author

Thank you both for the thorough review. All feedback has been addressed — summary below.

From @csutherl:

  • The TestHostConfigAutomaticDeploymentA/B/C fix has been split into its own first commit.
  • "Proof of concept" language removed from both BUILDING.txt and changelog.xml.
  • test-smoke-category target and its duplicated <junit> config removed entirely.
  • SmokeSuite.java removed. The annotation is now the single source of truth — CategoryScanner discovers annotated classes at build time and feeds the result into test.name so the existing batchtest / runtests macro handles execution unchanged.

From @dsoumis (round 2):

  • fork="true" added to the <java> task.
  • System.exit replaced with throw new IllegalArgumentException.
  • Load failures in scanDir now throw RuntimeException instead of being swallowed.

From @dsoumis (round 3):

  • depends="test-compile" removed from -test-categories; the target is now listed after test-compile in both test-nio and test-only-nio, so ant test-only -Dtest.profile=smoke works correctly against already-compiled classes.
  • logError="true" added to prevent forked JVM stderr from bleeding into test.name.
  • Scanner throws IllegalStateException on empty results to prevent Ant falling back to **/Test*.java.
  • Scanner now filters to concrete Test* classes only: excludes Tester* by name, excludes abstract classes via Modifier.isAbstract(), and skips stale .class files whose .java source no longer exists (source dir passed as a third argument).
  • BUILDING.txt corrected: performance tests are not excluded by default; the properties-file claim updated to note the smoke profile is annotation-driven.

Vanshita-Gosain and others added 3 commits November 16, 2026 17:35
TestHostConfigAutomaticDeploymentA/B/C were refactored into
per-scenario test classes in a prior commit. Update the smoke
profile to reference the replacement classes: Dir, War, and Xml.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Replace the smoke profile file list in test-profiles.properties.default
with @category(SmokeTest.class) annotations on each smoke test class.
CategoryScanner discovers annotated tests at build time by scanning
compiled classes and feeds the result into the existing batchtest
fileset, preserving per-test JVM isolation.

Changes:
- Add SmokeTest category marker interface
- Add CategoryScanner utility to scan compiled classes for a given
  @category annotation and output matching .java paths
- Annotate all 57 smoke test classes with @category(SmokeTest.class)
- Remove the smoke file list from test-profiles.properties.default;
  the annotation is now the single source of truth
- Reorder test-nio dependencies so test-compile runs before
  -test-name-default, ensuring compiled classes are available when
  the scanner runs during profile initialisation
- Update BUILDING.txt with instructions for the annotation-based approach
- Update changelog.xml

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…s file

Annotate all test classes in the catalina, coyote, performance, tribes,
buildutil, and integration profiles with their corresponding @category
marker. CategoryScanner discovers annotated classes at build time so no
file list needs to be maintained anywhere.

Remove test-profiles.properties.default: all profiles are now
annotation-driven and the properties file has no remaining entries.

Remove the property file load statements from build.xml and update the
set-profile-pattern macro to map each profile name to its category class.
The special build-time flags (test.includeBuildutil, test.includeTribes,
test.includeIntegration, test.excludePerformance) are still set by
-test-profile-init so the existing batchtest exclusions continue to work.

Update BUILDING.txt with per-profile annotation instructions.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@vgosain-psg
vgosain-psg force-pushed the jws-4412-junit-categories branch from 0503f9d to 0d5e8f3 Compare November 16, 2026 22:36
@dsoumis

dsoumis commented Nov 17, 2026

Copy link
Copy Markdown
Member

The rest of the categories should be handled in build.xml rather than annotating each file. We should keep the annotation only for hand-picked sets (smoke now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants