Fix OpenAPI spec generation compiler plugin tests#2612
Conversation
- Add AfterMethod cleanup so failed verifySpecContent does not leave stale target/openapi and break testSpecGenerationWithoutFlag. - Update sample_package_42: valid @http:CallerInfo http:Caller signature and remove invalid callerErr resources that no longer compile. - Refresh complex_openapi.yaml golden to match generated OpenAPI. Made-with: Cursor
|
There was a problem hiding this comment.
Pull request overview
Updates the HTTP compiler-plugin OpenAPI spec generation tests and their associated golden resources to eliminate CI flakiness caused by leftover build artifacts and to align sample sources/spec output with current http:Caller / @http:CallerInfo behavior.
Changes:
- Added per-test cleanup to remove
target/(and generatedDependencies.toml) for OpenAPI sample packages after each test. - Updated
sample_package_42to use a valid@http:CallerInfo http:Callerresource and removed invalid CallerInfo cases from that sample. - Regenerated
complex_openapi.yamlto match current OpenAPI output for the updated sample.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| compiler-plugin-tests/src/test/java/io/ballerina/stdlib/http/compiler/OpenAPISpecGenerationTest.java | Adds @AfterMethod cleanup and fixes an assertion message to reduce test flakiness from stale build artifacts. |
| compiler-plugin-tests/src/test/resources/ballerina_sources/sample_package_42/service.bal | Aligns the sample service’s CallerInfo usage with current HTTP module rules used by the OpenAPI generator. |
| compiler-plugin-tests/src/test/resources/yaml_files/complex_openapi.yaml | Updates the golden OpenAPI YAML to reflect the new sample behavior and current generated output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @AfterMethod(alwaysRun = true) | ||
| public void cleanOpenApiSampleTargets() throws IOException { | ||
| for (String pkg : OPENAPI_SAMPLE_PACKAGES) { | ||
| deleteDirectories(RESOURCE_DIRECTORY.resolve(pkg)); | ||
| } | ||
| } |
There was a problem hiding this comment.
The cleanup is only done in @AfterMethod. If a developer runs a single test method (or the suite is re-run in a workspace that already has stale target/openapi from a previous run), tests that assert the spec is not generated (e.g., testSpecGenerationWithoutFlag, testSpecGenerationWithCompilationErrors) can still fail because the old OpenAPI artifacts exist before the test executes. Consider also cleaning the relevant package(s) in a @BeforeMethod(alwaysRun = true) (or cleaning at the start of each test) so each test is hermetic regardless of prior filesystem state.
|
Hi @Viranya2006! |



Summary
Fixes flaky and failing \OpenAPISpecGenerationTest\ cases seen in CI (stdlib level builds).
Changes
Notes
Made with Cursor