From 6d881b640e83a8d4d593ca4928ffb3e885eebb3a Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 18 Feb 2025 08:59:56 +0900 Subject: [PATCH] Use S3FileSystemFactory in Iceberg test HiveS3Config is deprecated. --- ...TestTrinoHiveCatalogWithHiveMetastore.java | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/hms/TestTrinoHiveCatalogWithHiveMetastore.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/hms/TestTrinoHiveCatalogWithHiveMetastore.java index 5ddc3a043b56..de52cfe07e6f 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/hms/TestTrinoHiveCatalogWithHiveMetastore.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/hms/TestTrinoHiveCatalogWithHiveMetastore.java @@ -15,21 +15,15 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import io.airlift.log.Logger; import io.airlift.units.Duration; +import io.opentelemetry.api.OpenTelemetry; import io.trino.filesystem.Location; import io.trino.filesystem.TrinoFileSystem; import io.trino.filesystem.TrinoFileSystemFactory; -import io.trino.filesystem.hdfs.HdfsFileSystemFactory; -import io.trino.hdfs.DynamicHdfsConfiguration; -import io.trino.hdfs.HdfsConfig; -import io.trino.hdfs.HdfsConfigurationInitializer; -import io.trino.hdfs.HdfsEnvironment; -import io.trino.hdfs.TrinoHdfsFileSystemStats; -import io.trino.hdfs.authentication.NoHdfsAuthentication; -import io.trino.hdfs.s3.HiveS3Config; -import io.trino.hdfs.s3.TrinoS3ConfigurationInitializer; +import io.trino.filesystem.s3.S3FileSystemConfig; +import io.trino.filesystem.s3.S3FileSystemFactory; +import io.trino.filesystem.s3.S3FileSystemStats; import io.trino.metastore.Table; import io.trino.metastore.TableInfo; import io.trino.metastore.cache.CachingHiveMetastore; @@ -66,7 +60,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import static com.google.common.base.Verify.verify; import static com.google.common.util.concurrent.MoreExecutors.directExecutor; @@ -81,6 +74,7 @@ import static io.trino.testing.TestingConnectorSession.SESSION; import static io.trino.testing.TestingNames.randomNameSuffix; import static io.trino.testing.containers.Minio.MINIO_ACCESS_KEY; +import static io.trino.testing.containers.Minio.MINIO_REGION; import static io.trino.testing.containers.Minio.MINIO_SECRET_KEY; import static java.util.Locale.ENGLISH; import static java.util.concurrent.TimeUnit.MINUTES; @@ -128,20 +122,15 @@ public void tearDown() @Override protected TrinoCatalog createTrinoCatalog(boolean useUniqueTableLocations) { - TrinoFileSystemFactory fileSystemFactory = new HdfsFileSystemFactory(new HdfsEnvironment( - new DynamicHdfsConfiguration( - new HdfsConfigurationInitializer( - new HdfsConfig(), - Set.of(new TrinoS3ConfigurationInitializer(new HiveS3Config() - .setS3Endpoint(dataLake.getMinio().getMinioAddress()) - .setS3SslEnabled(false) - .setS3AwsAccessKey(MINIO_ACCESS_KEY) - .setS3AwsSecretKey(MINIO_SECRET_KEY) - .setS3PathStyleAccess(true)))), - ImmutableSet.of()), - new HdfsConfig(), - new NoHdfsAuthentication()), - new TrinoHdfsFileSystemStats()); + TrinoFileSystemFactory fileSystemFactory = new S3FileSystemFactory( + OpenTelemetry.noop(), + new S3FileSystemConfig() + .setEndpoint(dataLake.getMinio().getMinioAddress()) + .setAwsAccessKey(MINIO_ACCESS_KEY) + .setAwsSecretKey(MINIO_SECRET_KEY) + .setRegion(MINIO_REGION) + .setPathStyleAccess(true), + new S3FileSystemStats()); ThriftMetastore thriftMetastore = testingThriftHiveMetastoreBuilder() .thriftMetastoreConfig(new ThriftMetastoreConfig() // Read timed out sometimes happens with the default timeout @@ -227,13 +216,13 @@ public void testCreateMaterializedView() storageTableName = storageTable.get().getSchemaTableName().getTableName(); } Location dataLocation = Location.of(getNamespaceLocation(namespace) + "/" + storageTableName); - assertThat(fileSystem.newInputFile(dataLocation).exists()) + assertThat(fileSystem.directoryExists(dataLocation).orElseThrow()) .describedAs("The directory corresponding to the table data for materialized view must exist") .isTrue(); catalog.dropMaterializedView(SESSION, new SchemaTableName(namespace, materializedViewName)); - assertThat(fileSystem.newInputFile(dataLocation).exists()) + assertThat(fileSystem.directoryExists(dataLocation)) .describedAs("The materialized view drop should also delete the data files associated with it") - .isFalse(); + .isEmpty(); } finally { try {