[FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code.#27884
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds integration tests to the flink-docs module to ensure that generated REST API documentation (HTML + OpenAPI YAML) remains consistent with the committed generated docs, preventing silent drift between code and documentation.
Changes:
- Added two REST/OpenAPI docs “completeness” integration tests for Runtime (JobManager/Dispatcher) and SQL Gateway endpoints.
- Centralized project-root resolution (
rootDir) intoorg.apache.flink.docs.util.Utilsand updated existing tests to use it. - Introduced reusable title constants in the REST OpenAPI generator entrypoints.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| flink-docs/src/test/java/org/apache/flink/docs/rest/SqlGatewayOpenRestAPIDocsCompletenessITCase.java | New ITCase that generates SQL Gateway REST HTML/YAML and compares against committed generated docs. |
| flink-docs/src/test/java/org/apache/flink/docs/rest/RuntimeOpenRestAPIDocsCompletenessITCase.java | New ITCase that generates Runtime REST HTML/YAML and compares against committed generated docs; provides shared comparison/path helpers. |
| flink-docs/src/test/java/org/apache/flink/docs/configuration/ConfigOptionsYamlSpecTest.java | Switched project-root lookup to shared Utils.getProjectRootDir(). |
| flink-docs/src/test/java/org/apache/flink/docs/configuration/ConfigOptionsDocsCompletenessITCase.java | Switched project-root lookup to shared Utils.getProjectRootDir(). |
| flink-docs/src/test/java/org/apache/flink/docs/configuration/ConfigOptionsDocGeneratorTest.java | Removed local getProjectRootDir() helper now that it lives in Utils. |
| flink-docs/src/main/java/org/apache/flink/docs/util/Utils.java | Added getProjectRootDir() utility (supports -DrootDir and IDE fallback). |
| flink-docs/src/main/java/org/apache/flink/docs/rest/SqlGatewayOpenApiSpecGenerator.java | Added SQL_GATEWAY_OPEN_API_TITLE constant and reused it. |
| flink-docs/src/main/java/org/apache/flink/docs/rest/RuntimeOpenApiSpecGenerator.java | Added RUNTIME_OPEN_API_TITLE constant and reused it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import static org.apache.flink.docs.rest.RuntimeOpenRestAPIDocsCompletenessITCase.assertFilesEqual; | ||
| import static org.apache.flink.docs.rest.RuntimeOpenRestAPIDocsCompletenessITCase.getPathOfCommittedHtml; | ||
| import static org.apache.flink.docs.rest.RuntimeOpenRestAPIDocsCompletenessITCase.getPathOfCommittedYaml; |
There was a problem hiding this comment.
SqlGatewayOpenRestAPIDocsCompletenessITCase depends on helper methods from RuntimeOpenRestAPIDocsCompletenessITCase via static imports. This couples the two ITCases and makes future refactors (renames/moves) harder. Consider extracting these helpers (assertFilesEqual/getPathOfCommittedHtml/getPathOfCommittedYaml) into a dedicated package-private test utility class in org.apache.flink.docs.rest and importing from there in both ITCases.
There was a problem hiding this comment.
ForAI:
- There will be no high-frequency or large-scale changes here, so the ROI for reuse is quite low.
- Introducing new files to store these methods will increase the number of class files.
- If placed in the existing Utils, some constant values related to document directories need to be passed frequently; placing test-case-related constants in Utils may not be effective.
|
Hi, masters @reswqa @1996fanrui Could you help take a look ? thanks a lot |
1996fanrui
left a comment
There was a problem hiding this comment.
thanks for the improvement to ensure the consistency, lgtm
| } | ||
|
|
||
| static String readNormalized(Path file) throws Exception { | ||
| return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n"); |
There was a problem hiding this comment.
do we really need this?
Asking since we have .editorconfig telling that
Line 5 in 463330c
There was a problem hiding this comment.
and if not
then probably can just use assertJ functionality like
assertThat(pathOfGeneratedHtml.toFile())
.hasSameTextualContentAs(getPathOfCommittedHtml(targetHtmlName).toFile());and no need for assertFilesEqual at all
There was a problem hiding this comment.
Thanks @snuyanzin for the reminder.
You're right.
Updated.
…he generated REST-API related documentation stays consistent with the code. Co-authored-by: 1996fanrui <1996fanrui@gmail.com> Co-authored-by: Sergey Nuyanzin <snuyanzin@gmail.com>
snuyanzin
left a comment
There was a problem hiding this comment.
LGTM
thanks for addressing feedback
RocMarshal
left a comment
There was a problem hiding this comment.
Thanks all reviewers.
Merging...
What is the purpose of the change
[FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code.
Brief change log
Introduced :
RuntimeOpenRestAPIDocsCompletenessITCase
SqlGatewayOpenRestAPIDocsCompletenessITCase
Why introduce two cases classes for this issue?
Given the static nature and shared context of OpenApiSpecGenerator#modelConverterContext, placing all test methods in a single class would lead to unnecessary pollution of the generated files. Therefore, splitting them into two separate files to isolate the static scope of OpenApiSpecGenerator#modelConverterContext is a clean implementation approach.
Verifying this change
This change is already covered by existing tests, such as (please describe tests).
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation