Skip to content

Add generic, component-agnostic test-run REST endpoint - #1699

Merged
ashishvijaywargiya merged 3 commits into
apache:trunkfrom
ashishvijaywargiya:rest-api-test-improvement
Aug 22, 2026
Merged

Add generic, component-agnostic test-run REST endpoint#1699
ashishvijaywargiya merged 3 commits into
apache:trunkfrom
ashishvijaywargiya:rest-api-test-improvement

Conversation

@ashishvijaywargiya

Copy link
Copy Markdown
Contributor

Title: Add generic, component-agnostic test-run REST endpoint

Adds a single REST endpoint, in framework/testtools, that can trigger and poll a testdef
test-suite run for any component:

POST /rest/testtools/testruns/{componentName}
GET /rest/testtools/testruns/{runId}

componentName is supplied as a URL path parameter and bound into the service context by the
REST framework's existing path-parameter mechanism - the same mechanism the GET operation's
{runId} already used. The endpoint wires directly to the runTestSuite/getTestRunStatus services
that already existed, unscoped, in framework/testtools/servicedef/services.xml.

Why

This replaces a per-component pattern (see the companion ofbiz-plugins pull request (apache/ofbiz-plugins#374)) that
required copy-pasting a groovy wrapper class, two duplicated definitions, and a
component-owned *.rest.xml into every adopting component, purely to hard-code that one
component's name. The generic endpoint needs zero new files for any current or future component
that already has a real test-suite.

TestRunServices.runScopedTestSuite/getScopedTestRunStatus - the helper methods that existed only
to support the old per-component wrapper - are removed, along with their tests.

Security fix included

The endpoint's componentName normally comes from the URL path, but REST attribute binding merges
body/path/query/header values onto the same context map, so a caller could previously send an
empty componentName (e.g. an empty query parameter) and bypass the per-component
test.api.enabled. toggle entirely, falling back to an unscoped sweep across every
component's tests. runTestSuite now rejects a blank componentName outright, restoring the
fail-closed behavior the old per-component wrapper always had.

Testing

  • Unit tests for TestRunServices: 9/9 passing.
  • Manual verification against a running server: triggered several components' suites through the
    new endpoint, confirmed PASSED status with the correct componentName reported; confirmed a
    deliberately wrong testParams override produces the expected different failure, proving the
    override reaches the underlying assertion; confirmed the old per-component URL naming pattern
    is not a real route.
  • Full testIntegration run across the whole codebase: 658/658 tests passing, zero regressions.

Dependency on the companion pull request

This should merge together with, or after, the companion ofbiz-plugins pull request (apache/ofbiz-plugins#374). That PR
deletes the wrapper scripts that call runScopedTestSuite/getScopedTestRunStatus - merging this
PR first while those scripts are still present would leave them calling methods that no longer
exist.

…ror messages

The runTestSuite service returned the raw test.api.enabled property name and
value directly in the error response sent to REST callers when the test
execution API was disabled, either globally or for a specific component.
This exposed internal configuration details unnecessarily. Both messages now
return generic text without the property name or value, while server-side
logging still captures full detail for diagnostics.
…er-component gating

The generic testruns.rest.xml endpoint supplies componentName as a URL path
parameter, but REST attribute binding merges body/path/query/header sources
onto the same context map, so a caller could still send an empty value (e.g.
an empty query parameter) and reach an unscoped code path that used to only
exist for internal callers. An empty componentName resolved to
ComponentConfig.matchingComponentName as null, which matches every
component - silently turning a per-component request into an unscoped sweep
across every component's tests and bypassing the per-component
test.api.enabled.<componentName> gate entirely. This is exactly the failure
mode the now-deleted runScopedTestSuite wrapper used to fail closed against,
but the guard was not carried over when the wrapper was replaced by the
generic endpoint.

runTestSuite now rejects a blank componentName outright, both javadoc/
service-description text reworded to describe what the URL path parameter
actually guarantees (a non-blank value) versus what it doesn't (that the
value can't be overridden to a different real component - which was never a
concern this design needed to prevent, since the endpoint is deliberately
generic).
ashishvijaywargiya added a commit to apache/ofbiz-plugins that referenced this pull request Aug 22, 2026
…c testtools endpoint (#374)

Deletes the per-component test-run REST wrapper pattern from example, ecommerce, assetmaint,
lucene, and scrum:

- the groovy wrapper class in each component (e.g. ExampleTestRunServices.groovy)
- the two duplicated <service> definitions each wrapper needed, in each component's
  servicedef/services.xml
- each component's own test-run *.rest.xml (for example, this is the TestRunResource block
  removed from its shared rest.xml, since that file also carries example's own business-service
  REST resource; for the other four it is the entire file, since they had nothing else in it)

ecommerce's servicedef/services.xml and its ofbiz-component.xml service-resource entry are
removed entirely - that file existed solely to declare the two now-deleted services.

Why

Superseded by a new, generic, framework-owned REST endpoint added in the companion
ofbiz-framework pull request, which takes componentName as a URL path parameter and needs no
per-component files at all. All five components' tests remain reachable, now via

  POST /rest/testtools/testruns/{componentName}
  GET  /rest/testtools/testruns/{runId}

instead of each component's own separately-branded URL.

No changes to any component's actual test suites, Jupiter test classes, or testdef files - this
is REST/service wiring only.

Testing

- gradlew classes testClasses passes after each component's change.
- Full sweep against a running server: all five old branded URLs (example-rest, ecommerce-rest,
  assetmaint-rest, lucene-rest, scrum-rest) confirmed gone (404); all five components' real test
  suites confirmed passing end-to-end through the new generic endpoint.
- Full testIntegration run across the whole codebase: 658/658 tests passing, zero regressions.

Dependency on the companion pull request

This should merge together with, or before, the companion ofbiz-framework pull request (apache/ofbiz-framework#1699). This PR
removes the last callers of TestRunServices.runScopedTestSuite/getScopedTestRunStatus, which the
framework PR deletes. Merging the framework PR first while these wrapper scripts are still
present would leave them calling methods that no longer exist.
@ashishvijaywargiya
ashishvijaywargiya merged commit a5cc17f into apache:trunk Aug 22, 2026
7 checks passed
@ashishvijaywargiya
ashishvijaywargiya deleted the rest-api-test-improvement branch August 22, 2026 11:49
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