huaxingao commented on code in PR #14773:
URL: https://github.com/apache/iceberg/pull/14773#discussion_r2608647979


##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -3345,6 +3470,73 @@ public <T extends RESTResponse> T execute(
     return local;
   }
 
+  private IdempotentCreateEnv prepareIdempotentCreateEnv(
+      String namespaceName, String tableName, String idempotencyKey) {
+    Namespace ns = Namespace.of(namespaceName);
+    TableIdentifier ident = TableIdentifier.of(ns, tableName);
+    Schema schema = new Schema(Types.NestedField.required(1, "id", 
Types.IntegerType.get()));
+
+    restCatalog.createNamespace(ns, ImmutableMap.of());
+
+    Map<String, String> headers =
+        ImmutableMap.of(
+            RESTUtil.IDEMPOTENCY_KEY_HEADER,
+            idempotencyKey,
+            "Authorization",
+            "Bearer client-credentials-token:sub=user",
+            "test-header",
+            "test-value");
+
+    Map<String, String> conf =
+        ImmutableMap.of(
+            CatalogProperties.URI,
+            httpServer.getURI().toString(),
+            HTTPClient.REST_SOCKET_TIMEOUT_MS,
+            "600000",
+            HTTPClient.REST_CONNECTION_TIMEOUT_MS,
+            "600000",
+            "header.test-header",
+            "test-value");
+    RESTClient httpBase =
+        HTTPClient.builder(conf)
+            .uri(conf.get(CatalogProperties.URI))
+            .withHeaders(RESTUtil.configHeaders(conf))
+            .build();
+    AuthManager am = AuthManagers.loadAuthManager("test", conf);
+    AuthSession httpSession = am.initSession(httpBase, conf);
+    RESTClient http = httpBase.withAuthSession(httpSession);
+
+    CreateTableRequest req =

Review Comment:
   I’ve added a reusable verify helper and now assert the request shape 
(method/path/headers, including Idempotency‑Key) after the POSTs. I’m keeping a 
real CreateTableRequest in the E2E tests because it’s needed to exercise 
serialization and replay.



##########
core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java:
##########
@@ -3345,6 +3470,73 @@ public <T extends RESTResponse> T execute(
     return local;
   }
 
+  private IdempotentCreateEnv prepareIdempotentCreateEnv(
+      String namespaceName, String tableName, String idempotencyKey) {
+    Namespace ns = Namespace.of(namespaceName);
+    TableIdentifier ident = TableIdentifier.of(ns, tableName);
+    Schema schema = new Schema(Types.NestedField.required(1, "id", 
Types.IntegerType.get()));
+
+    restCatalog.createNamespace(ns, ImmutableMap.of());
+
+    Map<String, String> headers =
+        ImmutableMap.of(
+            RESTUtil.IDEMPOTENCY_KEY_HEADER,
+            idempotencyKey,
+            "Authorization",
+            "Bearer client-credentials-token:sub=user",
+            "test-header",
+            "test-value");
+
+    Map<String, String> conf =
+        ImmutableMap.of(
+            CatalogProperties.URI,
+            httpServer.getURI().toString(),
+            HTTPClient.REST_SOCKET_TIMEOUT_MS,
+            "600000",
+            HTTPClient.REST_CONNECTION_TIMEOUT_MS,
+            "600000",
+            "header.test-header",
+            "test-value");
+    RESTClient httpBase =
+        HTTPClient.builder(conf)
+            .uri(conf.get(CatalogProperties.URI))
+            .withHeaders(RESTUtil.configHeaders(conf))
+            .build();
+    AuthManager am = AuthManagers.loadAuthManager("test", conf);
+    AuthSession httpSession = am.initSession(httpBase, conf);
+    RESTClient http = httpBase.withAuthSession(httpSession);
+
+    CreateTableRequest req =
+        CreateTableRequest.builder()
+            .withName(ident.name())
+            .withSchema(schema)
+            .withPartitionSpec(PartitionSpec.unpartitioned())
+            .build();
+
+    return new IdempotentCreateEnv(ns, ident, headers, http, req);
+  }
+
+  private static class IdempotentCreateEnv {

Review Comment:
   I removed this wrapped class



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to