From 9be344cca0c6c3e704861bdca17c87ac335081ba Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Wed, 22 Jul 2020 10:39:44 +0200 Subject: [PATCH] Move testCreateExternalTableWithInaccessibleSchemaLocation to TestExternalHiveTable --- .../tests/hive/TestExternalHiveTable.java | 24 +++++++++ .../hive/TestHiveCreateExternalTable.java | 51 ------------------- 2 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveCreateExternalTable.java diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestExternalHiveTable.java b/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestExternalHiveTable.java index cc065ca6ad94f..7f4b33513e97e 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestExternalHiveTable.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestExternalHiveTable.java @@ -13,11 +13,13 @@ */ package io.prestosql.tests.hive; +import com.google.inject.Inject; import io.prestosql.tempto.ProductTest; import io.prestosql.tempto.Requirement; import io.prestosql.tempto.RequirementsProvider; import io.prestosql.tempto.configuration.Configuration; import io.prestosql.tempto.fulfillment.table.TableInstance; +import io.prestosql.tempto.hadoop.hdfs.HdfsClient; import org.testng.annotations.Test; import static io.prestosql.tempto.Requirements.compose; @@ -27,17 +29,24 @@ import static io.prestosql.tempto.fulfillment.table.TableRequirements.mutableTable; import static io.prestosql.tempto.fulfillment.table.hive.tpch.TpchTableDefinitions.NATION; import static io.prestosql.tempto.query.QueryExecutor.query; +import static io.prestosql.tests.TestGroups.HIVE_WITH_EXTERNAL_WRITES; +import static io.prestosql.tests.TestGroups.PROFILE_SPECIFIC_TESTS; import static io.prestosql.tests.hive.HiveTableDefinitions.NATION_PARTITIONED_BY_BIGINT_REGIONKEY; import static io.prestosql.tests.hive.HiveTableDefinitions.NATION_PARTITIONED_BY_REGIONKEY_NUMBER_OF_LINES_PER_SPLIT; import static io.prestosql.tests.utils.QueryExecutors.onHive; import static io.prestosql.tests.utils.QueryExecutors.onPresto; +import static java.lang.String.format; public class TestExternalHiveTable extends ProductTest implements RequirementsProvider { + private static final String HIVE_CATALOG_WITH_EXTERNAL_WRITES = "hive_with_external_writes"; private static final String EXTERNAL_TABLE_NAME = "target_table"; + @Inject + private HdfsClient hdfsClient; + @Override public Requirement getRequirements(Configuration configuration) { @@ -127,6 +136,21 @@ public void testDeleteFromExternalPartitionedTableTable() assertThat(onPresto().executeQuery("SELECT * FROM " + EXTERNAL_TABLE_NAME)).hasRowsCount(0); } + @Test(groups = {HIVE_WITH_EXTERNAL_WRITES, PROFILE_SPECIFIC_TESTS}) + public void testCreateExternalTableWithInaccessibleSchemaLocation() + { + String schema = "schema_without_location"; + String schemaLocation = "/tmp/" + schema; + hdfsClient.createDirectory(schemaLocation); + query(format("CREATE SCHEMA %s.%s WITH (location='%s')", HIVE_CATALOG_WITH_EXTERNAL_WRITES, schema, schemaLocation)); + + hdfsClient.delete(schemaLocation); + + String table = "test_create_external"; + String tableLocation = "/tmp/" + table; + query(format("CREATE TABLE %s.%s.%s WITH (external_location = '%s') AS SELECT * FROM tpch.tiny.nation", HIVE_CATALOG_WITH_EXTERNAL_WRITES, schema, table, tableLocation)); + } + private void insertNationPartition(TableInstance nation, int partition) { onHive().executeQuery( diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveCreateExternalTable.java b/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveCreateExternalTable.java deleted file mode 100644 index 583423fd66fc6..0000000000000 --- a/presto-product-tests/src/main/java/io/prestosql/tests/hive/TestHiveCreateExternalTable.java +++ /dev/null @@ -1,51 +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.prestosql.tests.hive; - -import com.google.inject.Inject; -import io.prestosql.tempto.ProductTest; -import io.prestosql.tempto.hadoop.hdfs.HdfsClient; -import org.testng.annotations.Test; - -import static io.prestosql.tempto.query.QueryExecutor.query; -import static io.prestosql.tests.TestGroups.HIVE_WITH_EXTERNAL_WRITES; -import static io.prestosql.tests.TestGroups.PROFILE_SPECIFIC_TESTS; -import static java.lang.String.format; - -public class TestHiveCreateExternalTable - extends ProductTest -{ - private static final String HIVE_CATALOG_NAME = "hive_with_external_writes"; - - @Inject - private HdfsClient hdfsClient; - - @Test(groups = {HIVE_WITH_EXTERNAL_WRITES, PROFILE_SPECIFIC_TESTS}) - public void testCreateExternalTableWithInaccessibleSchemaLocation() - { - String schema = "schema_without_location"; - String schemaLocation = "/tmp/" + schema; - hdfsClient.createDirectory(schemaLocation); - query(format("CREATE SCHEMA %s.%s WITH (location='%s')", - HIVE_CATALOG_NAME, schema, schemaLocation)); - - hdfsClient.delete(schemaLocation); - - String table = "test_create_external"; - String tableLocation = "/tmp/" + table; - query(format("CREATE TABLE %s.%s.%s WITH (external_location = '%s') AS " + - "SELECT * FROM tpch.tiny.nation", - HIVE_CATALOG_NAME, schema, table, tableLocation)); - } -}