Skip to content

[FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code.#27884

Merged
RocMarshal merged 1 commit intoapache:masterfrom
RocMarshal:FLINK-39359
Apr 4, 2026

Conversation

@RocMarshal
Copy link
Copy Markdown
Contributor

@RocMarshal RocMarshal commented Apr 2, 2026

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:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Apr 2, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) into org.apache.flink.docs.util.Utils and 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.

Comment on lines +29 to +31
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;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Apr 2, 2026
@RocMarshal
Copy link
Copy Markdown
Contributor Author

Hi, masters @reswqa @1996fanrui Could you help take a look ? thanks a lot

Copy link
Copy Markdown
Member

@1996fanrui 1996fanrui left a comment

Choose a reason for hiding this comment

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

thanks for the improvement to ensure the consistency, lgtm

Copy link
Copy Markdown
Member

@reswqa reswqa left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

}

static String readNormalized(Path file) throws Exception {
return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n");
Copy link
Copy Markdown
Contributor

@snuyanzin snuyanzin Apr 3, 2026

Choose a reason for hiding this comment

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

do we really need this?
Asking since we have .editorconfig telling that

end_of_line = lf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Contributor

@snuyanzin snuyanzin left a comment

Choose a reason for hiding this comment

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

LGTM
thanks for addressing feedback

Copy link
Copy Markdown
Contributor Author

@RocMarshal RocMarshal left a comment

Choose a reason for hiding this comment

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

Thanks all reviewers.
Merging...

@RocMarshal RocMarshal merged commit 9b3037b into apache:master Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants