Skip to content

Commit

Permalink
Add azure native-fs product tests for table formats
Browse files Browse the repository at this point in the history
  • Loading branch information
anusudarsan committed May 13, 2024
1 parent 7716347 commit c7a2a6a
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public final class TestGroups
public static final String PROFILE_SPECIFIC_TESTS = "profile_specific_tests";
public static final String HDFS_IMPERSONATION = "hdfs_impersonation";
public static final String HDFS_NO_IMPERSONATION = "hdfs_no_impersonation";
public static final String HIVE_AZURE = "hive_azure";
public static final String HIVE_GCS = "hive_gcs";
public static final String HIVE_SPARK = "hive_spark";
public static final String HIVE_SPARK_NO_STATS_FALLBACK = "hive_spark_no_stats_fallback";
Expand Down Expand Up @@ -76,6 +77,7 @@ public final class TestGroups
public static final String KAFKA_CONFLUENT_LICENSE = "kafka_confluent_license";
public static final String TWO_HIVES = "two_hives";
public static final String ICEBERG = "iceberg";
public static final String ICEBERG_AZURE = "iceberg_azure";
public static final String ICEBERG_GCS = "iceberg_gcs";
public static final String ICEBERG_ALLUXIO_CACHING = "iceberg_alluxio_caching";
public static final String ICEBERG_FORMAT_VERSION_COMPATIBILITY = "iceberg_format_version_compatibility";
Expand All @@ -90,6 +92,7 @@ public final class TestGroups
public static final String DELTA_LAKE_OSS = "delta-lake-oss";
public static final String DELTA_LAKE_HDFS = "delta-lake-hdfs";
public static final String DELTA_LAKE_MINIO = "delta-lake-minio";
public static final String DELTA_LAKE_AZURE = "delta-lake-azure";
public static final String DELTA_LAKE_GCS = "delta-lake-gcs";
public static final String DELTA_LAKE_DATABRICKS = "delta-lake-databricks";
public static final String DELTA_LAKE_DATABRICKS_104 = "delta-lake-databricks-104";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.WORKER;
import static io.trino.tests.product.launcher.env.common.Hadoop.CONTAINER_HADOOP_INIT_D;
import static io.trino.tests.product.launcher.env.common.Hadoop.CONTAINER_TRINO_HIVE_PROPERTIES;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_ETC;
import static java.nio.file.attribute.PosixFilePermissions.fromString;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.utility.MountableFile.forHostPath;
Expand Down Expand Up @@ -101,7 +103,9 @@ public void extendEnvironment(Environment.Builder builder)
.map(files -> files + "," + temptoConfig)
.orElse(temptoConfig)));

builder.addConnector("hive", forHostPath(configDir.getPath("hive.properties")));
builder.addConnector("hive", forHostPath(configDir.getPath("hive.properties")), CONTAINER_TRINO_HIVE_PROPERTIES);
builder.addConnector("delta_lake", forHostPath(configDir.getPath("delta.properties")), CONTAINER_TRINO_ETC + "/catalog/delta.properties");
builder.addConnector("iceberg", forHostPath(configDir.getPath("iceberg.properties")), CONTAINER_TRINO_ETC + "/catalog/iceberg.properties");
}

private Path getCoreSiteOverrideXml()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

import static io.trino.tests.product.TestGroups.AZURE;
import static io.trino.tests.product.TestGroups.CONFIGURED_FEATURES;
import static io.trino.tests.product.TestGroups.DELTA_LAKE_AZURE;
import static io.trino.tests.product.TestGroups.HIVE_AZURE;
import static io.trino.tests.product.TestGroups.ICEBERG_AZURE;
import static io.trino.tests.product.launcher.suite.SuiteTestRun.testOnEnvironment;

public class SuiteAzure
Expand All @@ -34,6 +37,15 @@ public List<SuiteTestRun> getTestRuns(EnvironmentConfig config)
return ImmutableList.of(
testOnEnvironment(EnvMultinodeAzure.class)
.withGroups(CONFIGURED_FEATURES, AZURE)
.build(),
testOnEnvironment(EnvMultinodeAzure.class)
.withGroups(DELTA_LAKE_AZURE, CONFIGURED_FEATURES)
.build(),
testOnEnvironment(EnvMultinodeAzure.class)
.withGroups(ICEBERG_AZURE, CONFIGURED_FEATURES)
.build(),
testOnEnvironment(EnvMultinodeAzure.class)
.withGroups(HIVE_AZURE, CONFIGURED_FEATURES)
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
connector.name=delta_lake
hive.metastore.uri=thrift://hadoop-master:9083
fs.hadoop.enabled=false
fs.native-azure.enabled=true
azure.auth-type=ACCESS_KEY
azure.access-key=${ENV:ABFS_ACCESS_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
connector.name=iceberg
hive.metastore.uri=thrift://hadoop-master:9083
iceberg.file-format=PARQUET
fs.hadoop.enabled=false
fs.native-azure.enabled=true
azure.auth-type=ACCESS_KEY
azure.access-key=${ENV:ABFS_ACCESS_KEY}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.tests.product.deltalake;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.trino.tempto.BeforeMethodWithContext;
import io.trino.tempto.ProductTest;
import org.testng.annotations.Test;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tests.product.TestGroups.DELTA_LAKE_AZURE;
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;

public class TestDeltaLakeAzure
extends ProductTest
{
@Inject
@Named("databases.presto.abfs_schema")
private String schema;
private String schemaLocation;

@BeforeMethodWithContext
public void setUp()
{
String container = requireNonNull(System.getenv("ABFS_CONTAINER"), "Environment variable not set: ABFS_CONTAINER");
String account = requireNonNull(System.getenv("ABFS_ACCOUNT"), "Environment variable not set: ABFS_ACCOUNT");
schemaLocation = format("abfs://%s@%s.dfs.core.windows.net/%s", container, account, schema);
}

@Test(groups = {DELTA_LAKE_AZURE, PROFILE_SPECIFIC_TESTS})
public void testCreateAndSelectNationTable()
{
String tableName = "nation_" + randomNameSuffix();
String tableLocation = schemaLocation + "/" + tableName;
onTrino().executeQuery(format(
"CREATE TABLE delta.default.%1$s WITH (location = '%2$s/%1$s') AS SELECT * FROM tpch.tiny.nation",
tableName,
tableLocation));

assertThat(onTrino().executeQuery("SELECT count(*) FROM delta.default." + tableName)).containsOnly(row(25));
onTrino().executeQuery("DROP TABLE delta.default." + tableName);
}

@Test(groups = {DELTA_LAKE_AZURE, PROFILE_SPECIFIC_TESTS})
public void testBasicWriteOperations()
{
String tableName = "table_write_operations_" + randomNameSuffix();
String tableLocation = schemaLocation + "/" + tableName;

onTrino().executeQuery(format(
"CREATE TABLE delta.default.%1$s (a_bigint bigint, a_varchar varchar) WITH (location = '%2$s/%1$s')",
tableName,
tableLocation));

onTrino().executeQuery(format("INSERT INTO delta.default.%s VALUES (1, 'hello world')".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName)).containsOnly(row(1L, "hello world"));

onTrino().executeQuery(format("UPDATE delta.default.%s SET a_varchar = 'hallo Welt' WHERE a_bigint = 1".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName)).containsOnly(row(1L, "hallo Welt"));

onTrino().executeQuery(format("DELETE FROM delta.default.%s WHERE a_bigint = 1".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName)).hasNoRows();
onTrino().executeQuery("DROP TABLE delta.default." + tableName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* 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.tests.product.hive;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.trino.tempto.AfterMethodWithContext;
import io.trino.tempto.BeforeMethodWithContext;
import io.trino.tempto.ProductTest;
import org.testng.annotations.Test;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tests.product.TestGroups.HIVE_AZURE;
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.trino.tests.product.utils.QueryExecutors.onHive;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;

public class TestHiveAzure
extends ProductTest
{
@Inject
@Named("databases.presto.abfs_schema")
private String schema;
private String schemaLocation;

@BeforeMethodWithContext
public void setUp()
{
String container = requireNonNull(System.getenv("ABFS_CONTAINER"), "Environment variable not set: ABFS_CONTAINER");
String account = requireNonNull(System.getenv("ABFS_ACCOUNT"), "Environment variable not set: ABFS_ACCOUNT");
schemaLocation = format("abfs://%s@%s.dfs.core.windows.net/%s", container, account, schema);

onHive().executeQuery("dfs -rm -f -r " + schemaLocation);
onHive().executeQuery("dfs -mkdir -p " + schemaLocation);
}

@AfterMethodWithContext
public void tearDown()
{
onHive().executeQuery("dfs -mkdir -p " + schemaLocation);
}

@Test(groups = {HIVE_AZURE, PROFILE_SPECIFIC_TESTS})
public void testCreateAndSelectNationTable()
{
String tableName = "nation_" + randomNameSuffix();

try {
onTrino().executeQuery(format("CREATE SCHEMA hive.az WITH (location = '%1$s')", schemaLocation));
onTrino().executeQuery(format("CREATE TABLE hive.az.%1$s AS SELECT * FROM tpch.tiny.nation", tableName));

assertThat(onTrino().executeQuery("SELECT count(*) FROM hive.az." + tableName)).containsOnly(row(25));
}
finally {
onTrino().executeQuery("DROP TABLE hive.az." + tableName);
onTrino().executeQuery("DROP SCHEMA hive.az");
}
}

@Test(groups = {HIVE_AZURE, PROFILE_SPECIFIC_TESTS})
public void testBasicWriteOperations()
{
String tableName = "table_write_operations_" + randomNameSuffix();
try {
onTrino().executeQuery(format("CREATE SCHEMA hive.az WITH (location = '%1$s')", schemaLocation));
onTrino().executeQuery(format("CREATE TABLE hive.az.%1$s (a_bigint bigint, a_varchar varchar)", tableName));

onTrino().executeQuery(format("INSERT INTO hive.az.%s VALUES (1, 'hello world')".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM hive.az." + tableName)).containsOnly(row(1L, "hello world"));
}
finally {
onTrino().executeQuery("DROP TABLE hive.az." + tableName);
onTrino().executeQuery("DROP SCHEMA hive.az");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.tests.product.iceberg;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.trino.tempto.BeforeMethodWithContext;
import io.trino.tempto.ProductTest;
import org.testng.annotations.Test;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tests.product.TestGroups.ICEBERG_AZURE;
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;

public class TestIcebergAzure
extends ProductTest
{
@Inject
@Named("databases.presto.abfs_schema")
private String schema;
private String schemaLocation;

@BeforeMethodWithContext
public void setUp()
{
String container = requireNonNull(System.getenv("ABFS_CONTAINER"), "Environment variable not set: ABFS_CONTAINER");
String account = requireNonNull(System.getenv("ABFS_ACCOUNT"), "Environment variable not set: ABFS_ACCOUNT");
schemaLocation = format("abfs://%s@%s.dfs.core.windows.net/%s", container, account, schema);
}

@Test(groups = {ICEBERG_AZURE, PROFILE_SPECIFIC_TESTS})
public void testCreateAndSelectNationTable()
{
String tableName = "nation_" + randomNameSuffix();
String tableLocation = schemaLocation + "/" + tableName;
onTrino().executeQuery(format(
"CREATE TABLE iceberg.default.%1$s WITH (location = '%2$s/%1$s') AS SELECT * FROM tpch.tiny.nation",
tableName,
tableLocation));

assertThat(onTrino().executeQuery("SELECT count(*) FROM iceberg.default." + tableName)).containsOnly(row(25));
onTrino().executeQuery("DROP TABLE iceberg.default." + tableName);
}

@Test(groups = {ICEBERG_AZURE, PROFILE_SPECIFIC_TESTS})
public void testBasicWriteOperations()
{
String tableName = "table_write_operations_" + randomNameSuffix();
String tableLocation = schemaLocation + "/" + tableName;

onTrino().executeQuery(format(
"CREATE TABLE iceberg.default.%1$s (a_bigint bigint, a_varchar varchar) WITH (location = '%2$s/%1$s')",
tableName,
tableLocation));

onTrino().executeQuery(format("INSERT INTO iceberg.default.%s VALUES (1, 'hello world')".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM iceberg.default." + tableName)).containsOnly(row(1L, "hello world"));

onTrino().executeQuery(format("UPDATE iceberg.default.%s SET a_varchar = 'hallo Welt' WHERE a_bigint = 1".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM iceberg.default." + tableName)).containsOnly(row(1L, "hallo Welt"));

onTrino().executeQuery(format("DELETE FROM iceberg.default.%s WHERE a_bigint = 1".formatted(tableName)));
assertThat(onTrino().executeQuery("SELECT * FROM iceberg.default." + tableName)).hasNoRows();
onTrino().executeQuery("DROP TABLE iceberg.default." + tableName);
}
}

0 comments on commit c7a2a6a

Please sign in to comment.