Skip to content

Add test that all @Action classes are routed - #3282

Open
CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:test-all-actions-routed
Open

CydeWeys wants to merge 1 commit into
google:masterfrom
CydeWeys:test-all-actions-routed

Conversation

@CydeWeys

@CydeWeys CydeWeys commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Why

RequestComponentTest.testRoutingMap only checks the routes that are already
declared in RequestComponent against the routing.txt golden file. It never
catches an @Action class that is missing from RequestComponent. Such a
class compiles and has unit tests, but no request can ever reach it. That is
how CheckBulkComplianceAction has stayed unrouted and unscheduled since it
was added in 2022.

What

This adds RequestComponentTest.testAllProductionActionsAreRouted, which:

  • Uses Guava ClassPath to scan google.registry.* (nested classes included,
    e.g. ReadinessProbeAction.ReadinessProbeActionPubApi) for every concrete
    @Action class. It keeps only classes whose CodeSource matches
    RequestComponent's, so test-only @Action classes are excluded without
    relying on class-name heuristics.
  • Collects the @Action classes that RequestComponent exposes. It uses the
    same rule Router uses to build routes: zero-arg factory methods that return
    a Runnable annotated with @Action.
  • Checks the unrouted production actions against a KNOWN_UNROUTED_ACTIONS
    allowlist in both directions:
    • A new @Action that isn't wired up fails with: register it in
      RequestComponent (and update routing.txt).
    • An allowlist entry that is now routed or deleted fails with: remove it
      from KNOWN_UNROUTED_ACTIONS.
  • Includes sanity checks so the classpath scan can't pass vacuously. Known
    actions must be found, and every routed action must be one of the
    discovered production actions.

CheckBulkComplianceAction is currently the only unrouted production
@Action. It is allowlisted with a TODO for b/261763205.

Testing

  • Mutation-tested both directions. Removing CheckBulkComplianceAction from
    the allowlist fails with the "not wired" message. Adding a routed action to
    the allowlist fails with the "stale entry" message.
  • ./gradlew :core:standardTest passes. The new test runs in about 2 seconds.
  • runPresubmits, spotlessCheck, and javaIncrementalFormatCheck pass.

BUG= http://b/587437992


This change is Reviewable

Add RequestComponentTest.testAllProductionActionsAreRouted, which scans the
classpath with Guava ClassPath for every concrete @action class compiled
from the same production code source as RequestComponent (excluding @action
classes defined in tests), and compares it against the @action classes
exposed by RequestComponent's zero-argument Runnable factory methods (the
same methods Router turns into routes).

Any unrouted production action must be listed in KNOWN_UNROUTED_ACTIONS.
The test fails in both directions with actionable messages: a new @action
that is not registered in RequestComponent (and routing.txt), or a stale
allowlist entry for an action that has since been wired up or deleted.
Sanity checks ensure the scan finds known actions and that every routed
action is a discovered production action.

CheckBulkComplianceAction is currently the only unrouted production
@action; it is allowlisted with a TODO pointing at its tracking bug.

BUG= http://b/587437992
@CydeWeys
CydeWeys requested a review from sharma1210 November 19, 2026 20:34
@CydeWeys
CydeWeys enabled auto-merge November 19, 2026 20:34

This branch has not been deployed

No deployments
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.

1 participant