PavithranRick commented on code in PR #18073:
URL: https://github.com/apache/hudi/pull/18073#discussion_r2761219578


##########
hudi-timeline-service/src/test/java/org/apache/hudi/timeline/service/TestRequestHandler.java:
##########
@@ -120,6 +122,87 @@ void testCreateMarkerAPIWithDifferentSchemes() throws 
IOException {
     assertMarkerCreation(tempDir.resolve("base-path-2").toUri().toString(), 
"test2:/");
   }
 
+  @Test
+  void testMarkerIdempotency() throws IOException, InterruptedException {
+    String basePath = 
tempDir.resolve("base-path-idempotency").toUri().toString();
+    HoodieTableMetaClient metaClient = HoodieTestUtils.init(basePath, 
getTableType());
+    String markerDir = metaClient.getMarkerFolderPath("102");
+    String markerName = "partition1/file1.parquet.marker.CREATE";
+    String requestId1 = java.util.UUID.randomUUID().toString();
+    String requestId2 = java.util.UUID.randomUUID().toString();
+
+    Map<String, String> queryParameters = new HashMap<>();
+    queryParameters.put(BASEPATH_PARAM, basePath);
+    queryParameters.put(MARKER_DIR_PATH_PARAM, markerDir);
+    queryParameters.put(MARKER_NAME_PARAM, markerName);
+    queryParameters.put(MARKER_REQUEST_ID_PARAM, requestId1);
+
+    // First request
+    boolean result1 = timelineServiceClient.makeRequest(
+            TimelineServiceClient.Request.newBuilder(POST, CREATE_MARKER_URL)
+                .addQueryParams(queryParameters)
+                .build())
+        .getDecodedContent(new TypeReference<Boolean>() {});
+    assertTrue(result1, "First marker creation should succeed");
+
+    // Give server time to process
+    Thread.sleep(500);
+
+    // Retry with same requestId (simulating timeout + retry) should succeed 
(idempotent)
+    boolean result2 = timelineServiceClient.makeRequest(
+            TimelineServiceClient.Request.newBuilder(POST, CREATE_MARKER_URL)
+                .addQueryParams(queryParameters)
+                .build())
+        .getDecodedContent(new TypeReference<Boolean>() {});
+    assertTrue(result2, "Retry with same requestId should succeed 
(idempotent)");
+
+    // Retry with different requestId (distinct logical request) should fail
+    queryParameters.put(MARKER_REQUEST_ID_PARAM, requestId2);
+    boolean result3 = timelineServiceClient.makeRequest(
+            TimelineServiceClient.Request.newBuilder(POST, CREATE_MARKER_URL)
+                .addQueryParams(queryParameters)
+                .build())
+        .getDecodedContent(new TypeReference<Boolean>() {});
+    assertFalse(result3, "Retry with different requestId should fail");
+  }
+
+  @Test
+  void testMarkerBackwardCompatibilityNullExistingRequestId() throws 
IOException, InterruptedException {

Review Comment:
   changed the test.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to