Skip to content

Commit

Permalink
add production tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xiacongling committed Aug 12, 2022
1 parent 3cf99d9 commit 55e9583
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private void configureCompatibilityTestContainer(Environment.Builder builder, Co
.withCopyFileToContainer(forHostPath(dockerFiles.getDockerFilesHostPath("conf/presto/etc/jvm.config")), containerConfigDir + "jvm.config")
.withCopyFileToContainer(forHostPath(configDir.getPath(getConfigFileFor(dockerImage))), containerConfigDir + "config.properties")
.withCopyFileToContainer(forHostPath(configDir.getPath("hive.properties")), containerConfigDir + "catalog/hive.properties")
.withCopyFileToContainer(forHostPath(configDir.getPath("iceberg.properties")), containerConfigDir + "catalog/iceberg.properties")
.withCopyFileToContainer(forHostPath(dockerFiles.getDockerFilesHostPath()), "/docker/presto-product-tests")
.withStartupCheckStrategy(new IsRunningStartupCheckStrategy())
.waitingForAll(forLogMessage(".*======== SERVER STARTED ========.*", 1), forHealthcheck())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ public List<SuiteTestRun> getTestRuns(EnvironmentConfig config)
.withGroups("configured_features", "hive_view_compatibility")
.build())
.collect(toImmutableList());
ImmutableList<SuiteTestRun> trinoIcebergCompatibilityTestRuns = testedPrestoDockerImages().stream()
.map(image -> testOnEnvironment(EnvSinglenodeCompatibility.class, ImmutableMap.of("compatibility.testDockerImage", image))
.withGroups("configured_features", "iceberg_format_version_compatibility")
.build())
.collect(toImmutableList());

return ImmutableList.<SuiteTestRun>builder()
.addAll(trinoCompatibilityTestRuns)
.addAll(prestoCompatibilityTestRuns)
.addAll(trinoIcebergCompatibilityTestRuns)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connector.name=iceberg
hive.metastore.uri=thrift://hadoop-master:9083
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public final class TestGroups
public static final String KAFKA = "kafka";
public static final String TWO_HIVES = "two_hives";
public static final String ICEBERG = "iceberg";
public static final String ICEBERG_FORMAT_VERSION_COMPATIBILITY = "iceberg_format_version_compatibility";
public static final String AVRO = "avro";
public static final String PHOENIX = "phoenix";
public static final String CLICKHOUSE = "clickhouse";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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 io.trino.tempto.ProductTest;
import io.trino.tempto.assertions.QueryAssert;
import org.testng.annotations.Test;

import java.util.List;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.tempto.assertions.QueryAssert.assertThat;
import static io.trino.tests.product.TestGroups.ICEBERG_FORMAT_VERSION_COMPATIBILITY;
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.trino.tests.product.hive.util.TemporaryHiveTable.randomTableSuffix;
import static io.trino.tests.product.utils.QueryExecutors.onCompatibilityTestServer;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
import static org.testng.Assert.assertEquals;

public class TestIcebergFormatVersionCompatibility
extends ProductTest
{
private static final String TRINO_CATALOG = "iceberg";
private static final String TEST_SCHEMA_NAME = "default";

@Test(groups = {ICEBERG_FORMAT_VERSION_COMPATIBILITY, PROFILE_SPECIFIC_TESTS})
public void testTrinoTimeTravelReadTableCreatedByEarlyVersionTrino()
{
String baseTableName = "test_trino_reading_primitive_types_" + randomTableSuffix();
String tableName = trinoTableName(baseTableName);

onCompatibilityTestServer().executeQuery(format("CREATE TABLE %s (c VARCHAR)", tableName));
onCompatibilityTestServer().executeQuery(format("INSERT INTO %s VALUES ('a'), ('b'), ('c');", tableName));

long latestSnapshotId = (long) onCompatibilityTestServer()
.executeQuery(format("SELECT snapshot_id FROM %s ORDER BY committed_at DESC FETCH FIRST 1 ROW WITH TIES", trinoTableName("\"" + baseTableName + "$snapshots\"")))
.row(0).get(0);
assertThat(onTrino().executeQuery(format("SELECT snapshot_id FROM %s ORDER BY committed_at DESC FETCH FIRST 1 ROW WITH TIES", trinoTableName("\"" + baseTableName + "$snapshots\""))))
.containsOnly(row(latestSnapshotId));

List<QueryAssert.Row> expected = onCompatibilityTestServer().executeQuery(format("SELECT * FROM %s", tableName)).rows().stream()
.map(row -> row(row.toArray()))
.collect(toImmutableList());
assertEquals(expected.size(), 3);
assertThat(onTrino().executeQuery(format("SELECT * FROM %s FOR VERSION AS OF %d", tableName, latestSnapshotId))).containsOnly(expected);

onCompatibilityTestServer().executeQuery(format("DROP TABLE %s", tableName));
}

private static String trinoTableName(String tableName)
{
return format("%s.%s.%s", TRINO_CATALOG, TEST_SCHEMA_NAME, tableName);
}
}

0 comments on commit 55e9583

Please sign in to comment.