You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "RocMarshal (via GitHub)" <gi...@apache.org> on 2026/04/02 06:55:14 UTC
[PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
RocMarshal opened a new pull request, #27884:
URL: https://github.com/apache/flink/pull/27884
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## 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
## 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)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on PR #27884:
URL: https://github.com/apache/flink/pull/27884#issuecomment-4181812661
Hi, masters @reswqa @1996fanrui Could you help take a look ? thanks a lot
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3031890813
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/RuntimeOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.util.Utils;
+import org.apache.flink.runtime.rest.util.DocumentingDispatcherRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RuntimeRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.apache.flink.docs.rest.RuntimeOpenApiSpecGenerator.RUNTIME_OPEN_API_TITLE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Verifies that generated Runtime REST and Open API docs (HTML + OpenAPI yml) match committed
+ * files.
+ *
+ * <p>This acts as a freshness check to ensure the documentation stays in sync with the code.
+ */
+class RuntimeOpenRestAPIDocsCompletenessITCase {
+
+ @Test
+ void testRuntimeRestApiDocsUpToDate(@TempDir Path tempDir) throws Exception {
+ final DocumentingDispatcherRestEndpoint endpoint = new DocumentingDispatcherRestEndpoint();
+ for (final RuntimeRestAPIVersion apiVersion : RuntimeRestAPIVersion.values()) {
+ if (apiVersion == RuntimeRestAPIVersion.V0) {
+ continue;
+ }
+ final String version = apiVersion.getURLVersionPrefix();
+ String targetHtmlName = String.format("rest_%s_dispatcher.html", version);
+ final Path pathOfGeneratedHtml = tempDir.resolve(targetHtmlName);
+ RestAPIDocGenerator.createHtmlFile(endpoint, apiVersion, pathOfGeneratedHtml);
+ assertFilesEqual(
+ pathOfGeneratedHtml, getPathOfCommittedHtml(targetHtmlName), targetHtmlName);
+
+ String targetYmlName = String.format("rest_%s_dispatcher.yml", version);
+ final Path pathOfGeneratedYaml = tempDir.resolve(targetYmlName);
+ OpenApiSpecGenerator.createDocumentationFile(
+ RUNTIME_OPEN_API_TITLE, endpoint, apiVersion, pathOfGeneratedYaml);
+ assertFilesEqual(
+ pathOfGeneratedYaml, getPathOfCommittedYaml(targetYmlName), targetYmlName);
+ }
+ }
+
+ static void assertFilesEqual(
+ Path pathOfGeneratedFile, Path pathOfCommittedFile, String description)
+ throws Exception {
+ assertThat(pathOfCommittedFile)
+ .as("Missing committed %s file: %s", description, pathOfCommittedFile)
+ .exists();
+ final String generatedContent = readNormalized(pathOfGeneratedFile);
+ final String committedContent = readNormalized(pathOfCommittedFile);
+ assertThat(generatedContent)
+ .as(
+ "Committed `%s` file is out of date. Please regenerate docs under `flink-docs` module based on `README.md`.",
+ description)
+ .isEqualTo(committedContent);
+ }
+
+ static String readNormalized(Path file) throws Exception {
+ return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n");
Review Comment:
do we really need this?
Asking since we have `.editoconfig` telling that https://github.com/apache/flink/blob/463330c76606d4dc6b4531a8fb3cff971050b8e1/.editorconfig#L5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27884:
URL: https://github.com/apache/flink/pull/27884#issuecomment-4175123026
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "c14c9cf45c9c3c11697dc5b643eb0ced161c7a27",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "c14c9cf45c9c3c11697dc5b643eb0ced161c7a27",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* c14c9cf45c9c3c11697dc5b643eb0ced161c7a27 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3026763376
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/SqlGatewayOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.table.gateway.rest.util.DocumentingSqlGatewayRestEndpoint;
+import org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.file.Path;
+
+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;
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal merged PR #27884:
URL: https://github.com/apache/flink/pull/27884
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3032760651
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/RuntimeOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.util.Utils;
+import org.apache.flink.runtime.rest.util.DocumentingDispatcherRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RuntimeRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.apache.flink.docs.rest.RuntimeOpenApiSpecGenerator.RUNTIME_OPEN_API_TITLE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Verifies that generated Runtime REST and Open API docs (HTML + OpenAPI yml) match committed
+ * files.
+ *
+ * <p>This acts as a freshness check to ensure the documentation stays in sync with the code.
+ */
+class RuntimeOpenRestAPIDocsCompletenessITCase {
+
+ @Test
+ void testRuntimeRestApiDocsUpToDate(@TempDir Path tempDir) throws Exception {
+ final DocumentingDispatcherRestEndpoint endpoint = new DocumentingDispatcherRestEndpoint();
+ for (final RuntimeRestAPIVersion apiVersion : RuntimeRestAPIVersion.values()) {
+ if (apiVersion == RuntimeRestAPIVersion.V0) {
+ continue;
+ }
+ final String version = apiVersion.getURLVersionPrefix();
+ String targetHtmlName = String.format("rest_%s_dispatcher.html", version);
+ final Path pathOfGeneratedHtml = tempDir.resolve(targetHtmlName);
+ RestAPIDocGenerator.createHtmlFile(endpoint, apiVersion, pathOfGeneratedHtml);
+ assertFilesEqual(
+ pathOfGeneratedHtml, getPathOfCommittedHtml(targetHtmlName), targetHtmlName);
+
+ String targetYmlName = String.format("rest_%s_dispatcher.yml", version);
+ final Path pathOfGeneratedYaml = tempDir.resolve(targetYmlName);
+ OpenApiSpecGenerator.createDocumentationFile(
+ RUNTIME_OPEN_API_TITLE, endpoint, apiVersion, pathOfGeneratedYaml);
+ assertFilesEqual(
+ pathOfGeneratedYaml, getPathOfCommittedYaml(targetYmlName), targetYmlName);
+ }
+ }
+
+ static void assertFilesEqual(
+ Path pathOfGeneratedFile, Path pathOfCommittedFile, String description)
+ throws Exception {
+ assertThat(pathOfCommittedFile)
+ .as("Missing committed %s file: %s", description, pathOfCommittedFile)
+ .exists();
+ final String generatedContent = readNormalized(pathOfGeneratedFile);
+ final String committedContent = readNormalized(pathOfCommittedFile);
+ assertThat(generatedContent)
+ .as(
+ "Committed `%s` file is out of date. Please regenerate docs under `flink-docs` module based on `README.md`.",
+ description)
+ .isEqualTo(committedContent);
+ }
+
+ static String readNormalized(Path file) throws Exception {
+ return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n");
Review Comment:
Thanks @snuyanzin for the reminder.
You're right.
Updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "RocMarshal (via GitHub)" <gi...@apache.org>.
RocMarshal commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3027409340
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/SqlGatewayOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.table.gateway.rest.util.DocumentingSqlGatewayRestEndpoint;
+import org.apache.flink.table.gateway.rest.util.SqlGatewayRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.file.Path;
+
+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;
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3031896462
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/RuntimeOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.util.Utils;
+import org.apache.flink.runtime.rest.util.DocumentingDispatcherRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RuntimeRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.apache.flink.docs.rest.RuntimeOpenApiSpecGenerator.RUNTIME_OPEN_API_TITLE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Verifies that generated Runtime REST and Open API docs (HTML + OpenAPI yml) match committed
+ * files.
+ *
+ * <p>This acts as a freshness check to ensure the documentation stays in sync with the code.
+ */
+class RuntimeOpenRestAPIDocsCompletenessITCase {
+
+ @Test
+ void testRuntimeRestApiDocsUpToDate(@TempDir Path tempDir) throws Exception {
+ final DocumentingDispatcherRestEndpoint endpoint = new DocumentingDispatcherRestEndpoint();
+ for (final RuntimeRestAPIVersion apiVersion : RuntimeRestAPIVersion.values()) {
+ if (apiVersion == RuntimeRestAPIVersion.V0) {
+ continue;
+ }
+ final String version = apiVersion.getURLVersionPrefix();
+ String targetHtmlName = String.format("rest_%s_dispatcher.html", version);
+ final Path pathOfGeneratedHtml = tempDir.resolve(targetHtmlName);
+ RestAPIDocGenerator.createHtmlFile(endpoint, apiVersion, pathOfGeneratedHtml);
+ assertFilesEqual(
+ pathOfGeneratedHtml, getPathOfCommittedHtml(targetHtmlName), targetHtmlName);
+
+ String targetYmlName = String.format("rest_%s_dispatcher.yml", version);
+ final Path pathOfGeneratedYaml = tempDir.resolve(targetYmlName);
+ OpenApiSpecGenerator.createDocumentationFile(
+ RUNTIME_OPEN_API_TITLE, endpoint, apiVersion, pathOfGeneratedYaml);
+ assertFilesEqual(
+ pathOfGeneratedYaml, getPathOfCommittedYaml(targetYmlName), targetYmlName);
+ }
+ }
+
+ static void assertFilesEqual(
+ Path pathOfGeneratedFile, Path pathOfCommittedFile, String description)
+ throws Exception {
+ assertThat(pathOfCommittedFile)
+ .as("Missing committed %s file: %s", description, pathOfCommittedFile)
+ .exists();
+ final String generatedContent = readNormalized(pathOfGeneratedFile);
+ final String committedContent = readNormalized(pathOfCommittedFile);
+ assertThat(generatedContent)
+ .as(
+ "Committed `%s` file is out of date. Please regenerate docs under `flink-docs` module based on `README.md`.",
+ description)
+ .isEqualTo(committedContent);
+ }
+
+ static String readNormalized(Path file) throws Exception {
+ return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n");
Review Comment:
and if not
then probably can just use `assertJ` functionality like
```java
assertThat(pathOfGeneratedHtml.toFile())
.hasSameTextualContentAs(getPathOfCommittedHtml(targetHtmlName).toFile());
```
and no need for `assertFilesEqual` at all
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39359][docs] Introduce integration test cases to ensure that the generated REST-API related documentation stays consistent with the code. [flink]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #27884:
URL: https://github.com/apache/flink/pull/27884#discussion_r3031890813
##########
flink-docs/src/test/java/org/apache/flink/docs/rest/RuntimeOpenRestAPIDocsCompletenessITCase.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.docs.util.Utils;
+import org.apache.flink.runtime.rest.util.DocumentingDispatcherRestEndpoint;
+import org.apache.flink.runtime.rest.versioning.RuntimeRestAPIVersion;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.apache.flink.docs.rest.RuntimeOpenApiSpecGenerator.RUNTIME_OPEN_API_TITLE;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Verifies that generated Runtime REST and Open API docs (HTML + OpenAPI yml) match committed
+ * files.
+ *
+ * <p>This acts as a freshness check to ensure the documentation stays in sync with the code.
+ */
+class RuntimeOpenRestAPIDocsCompletenessITCase {
+
+ @Test
+ void testRuntimeRestApiDocsUpToDate(@TempDir Path tempDir) throws Exception {
+ final DocumentingDispatcherRestEndpoint endpoint = new DocumentingDispatcherRestEndpoint();
+ for (final RuntimeRestAPIVersion apiVersion : RuntimeRestAPIVersion.values()) {
+ if (apiVersion == RuntimeRestAPIVersion.V0) {
+ continue;
+ }
+ final String version = apiVersion.getURLVersionPrefix();
+ String targetHtmlName = String.format("rest_%s_dispatcher.html", version);
+ final Path pathOfGeneratedHtml = tempDir.resolve(targetHtmlName);
+ RestAPIDocGenerator.createHtmlFile(endpoint, apiVersion, pathOfGeneratedHtml);
+ assertFilesEqual(
+ pathOfGeneratedHtml, getPathOfCommittedHtml(targetHtmlName), targetHtmlName);
+
+ String targetYmlName = String.format("rest_%s_dispatcher.yml", version);
+ final Path pathOfGeneratedYaml = tempDir.resolve(targetYmlName);
+ OpenApiSpecGenerator.createDocumentationFile(
+ RUNTIME_OPEN_API_TITLE, endpoint, apiVersion, pathOfGeneratedYaml);
+ assertFilesEqual(
+ pathOfGeneratedYaml, getPathOfCommittedYaml(targetYmlName), targetYmlName);
+ }
+ }
+
+ static void assertFilesEqual(
+ Path pathOfGeneratedFile, Path pathOfCommittedFile, String description)
+ throws Exception {
+ assertThat(pathOfCommittedFile)
+ .as("Missing committed %s file: %s", description, pathOfCommittedFile)
+ .exists();
+ final String generatedContent = readNormalized(pathOfGeneratedFile);
+ final String committedContent = readNormalized(pathOfCommittedFile);
+ assertThat(generatedContent)
+ .as(
+ "Committed `%s` file is out of date. Please regenerate docs under `flink-docs` module based on `README.md`.",
+ description)
+ .isEqualTo(committedContent);
+ }
+
+ static String readNormalized(Path file) throws Exception {
+ return Files.readString(file, StandardCharsets.UTF_8).replace("\r\n", "\n");
Review Comment:
do we really need this?
Asking since we have `.editorconfig` telling that https://github.com/apache/flink/blob/463330c76606d4dc6b4531a8fb3cff971050b8e1/.editorconfig#L5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org