From 48441d399af4d56205ed832663ccc38a070a3f4d Mon Sep 17 00:00:00 2001 From: praveenkrishna Date: Wed, 12 Oct 2022 21:32:02 +0200 Subject: [PATCH] Revert "Test setting S3 region explicitly" This reverts commit 8e4153dd951638a5066e02da69ff3a544f53d980. --- .../hive/containers/HiveMinioDataLake.java | 11 +---- .../hive/s3/TestS3WrongRegionPicked.java | 42 ------------------- 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3WrongRegionPicked.java diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java index 6b6e4575b8da..fbfb5aeb3cc3 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/containers/HiveMinioDataLake.java @@ -34,12 +34,6 @@ public class HiveMinioDataLake public static final String MINIO_ACCESS_KEY = Minio.MINIO_ACCESS_KEY; @Deprecated public static final String MINIO_SECRET_KEY = Minio.MINIO_SECRET_KEY; - /** - * In S3 this region is implicitly the default one. In Minio, however, - * if we set an empty region, it will accept any. - * So setting it by default to `us-east-1` simulates S3 better - */ - public static final String MINIO_DEFAULT_REGION = "us-east-1"; private final String bucketName; private final Minio minio; @@ -70,7 +64,6 @@ public HiveMinioDataLake(String bucketName, Map hiveHadoopFilesT .withEnvVars(ImmutableMap.builder() .put("MINIO_ACCESS_KEY", MINIO_ACCESS_KEY) .put("MINIO_SECRET_KEY", MINIO_SECRET_KEY) - .put("MINIO_REGION", MINIO_DEFAULT_REGION) .buildOrThrow()) .build()); @@ -81,7 +74,7 @@ public HiveMinioDataLake(String bucketName, Map hiveHadoopFilesT this.hiveHadoop = closer.register(hiveHadoopBuilder.build()); } - public HiveMinioDataLake start() + public void start() { checkState(state == State.INITIAL, "Already started: %s", state); state = State.STARTING; @@ -90,8 +83,6 @@ public HiveMinioDataLake start() minioClient = closer.register(minio.createMinioClient()); minio.createBucket(bucketName); state = State.STARTED; - - return this; } public void stop() diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3WrongRegionPicked.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3WrongRegionPicked.java deleted file mode 100644 index 2d8608c6942c..000000000000 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/s3/TestS3WrongRegionPicked.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed 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 io.trino.plugin.hive.s3; - -import com.google.common.collect.ImmutableMap; -import io.trino.plugin.hive.containers.HiveMinioDataLake; -import io.trino.testing.QueryRunner; -import org.testng.annotations.Test; - -import static io.trino.testing.sql.TestTable.randomTableSuffix; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class TestS3WrongRegionPicked -{ - @Test - public void testS3WrongRegionSelection() - throws Exception - { - try (HiveMinioDataLake dataLake = new HiveMinioDataLake("test-bucket").start(); - QueryRunner queryRunner = S3HiveQueryRunner.builder(dataLake) - .setHiveProperties(ImmutableMap.of("hive.s3.region", "eu-central-1")) // Different than the default one - .build()) { - String tableName = "s3_region_test_" + randomTableSuffix(); - queryRunner.execute("CREATE TABLE default." + tableName + " (a int) WITH (external_location = 's3://test-bucket/" + tableName + "')"); - assertThatThrownBy(() -> queryRunner.execute("SELECT * FROM default." + tableName)) - .getRootCause() - .hasMessageContaining("Status Code: 400") - .hasMessageContaining("Error Code: AuthorizationHeaderMalformed"); // That is how Minio reacts to bad region - } - } -}