nastra commented on code in PR #14773:
URL: https://github.com/apache/iceberg/pull/14773#discussion_r2606815069
##########
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:
seems a bit weird to create the request here. Can we not mock stuff as we do
in a bunch of other tests and verify that the correct requests were sent?
##########
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:
do we really need this wrapper 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]