steveloughran commented on code in PR #15304: URL: https://github.com/apache/iceberg/pull/15304#discussion_r2799197893
########## aws/src/test/java/org/apache/iceberg/aws/s3/TestDefaultS3FileIOAwsClientFactory.java: ########## @@ -0,0 +1,167 @@ +/* + * 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.iceberg.aws.s3; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.SetSystemProperty; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.AwsCredentials; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; +import software.amazon.awssdk.metrics.MetricCollection; +import software.amazon.awssdk.metrics.MetricPublisher; + +// disable loading (unexpected) profiles +@SetSystemProperty(key = "aws.sharedCredentialsFile", value = "target/missing/ignore") +@SetSystemProperty(key = "aws.configFile", value = "target/missing/ignore") +class TestDefaultS3FileIOAwsClientFactory { + @Test + void metricsPublisherCreateSync() { + final var factory = new DefaultS3FileIOAwsClientFactory(); + factory.initialize( + Map.of( + "client.credentials-provider", TestCredentialProvider.class.getName(), + "client.metrics-publisher", NoArgPublisher.class.getName(), + "client.region", "us-east-1")); + try (var s3 = factory.s3()) { + assertThat(NoArgPublisher.INSTANCE.get()).isNotNull(); + } finally { + NoArgPublisher.INSTANCE.remove(); + } + } + + @Test + void metricsPublisherCreateMapSync() { + final var factory = new DefaultS3FileIOAwsClientFactory(); + factory.initialize( + Map.of( + "client.credentials-provider", + TestCredentialProvider.class.getName(), + "client.metrics-publisher", + MapArgPublisher.class.getName(), + "client.metrics-publisher.test", + "ok", + "client.region", + "us-east-1")); + try (var s3 = factory.s3()) { + assertThat(MapArgPublisher.INSTANCE.get().args.get("test")).isEqualTo("ok"); + } finally { + NoArgPublisher.INSTANCE.remove(); + } + } + + @Test + void metricsPublisherCreateASync() { + final var factory = new DefaultS3FileIOAwsClientFactory(); + factory.initialize( + Map.of( + // CRT impl is still not equivalent to the default java one + "s3.crt.enabled", + "false", + "client.credentials-provider", + TestCredentialProvider.class.getName(), + "client.metrics-publisher", + NoArgPublisher.class.getName(), + "client.region", + "us-east-1")); + try (var s3 = factory.s3Async()) { + assertThat(NoArgPublisher.INSTANCE.get()).isNotNull(); + } finally { + NoArgPublisher.INSTANCE.remove(); + } + } + + @Test + void metricsPublisherCreateMapASync() { + final var factory = new DefaultS3FileIOAwsClientFactory(); + factory.initialize( + Map.of( + // CRT impl is still not equivalent to the default java one + "s3.crt.enabled", "false", Review Comment: just a source of a different stack traces... -- 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]
