Skip to content

Commit

Permalink
Remove unused product test groups
Browse files Browse the repository at this point in the history
Remove product test groups that are not used for defining test suites.
  • Loading branch information
findepi committed Jan 12, 2024
1 parent e0f7835 commit 0e0dfc8
Show file tree
Hide file tree
Showing 31 changed files with 265 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
package io.trino.tests.product;

import com.google.common.collect.ImmutableSet;

import java.lang.reflect.Field;
import java.util.IdentityHashMap;
import java.util.Set;
Expand All @@ -24,17 +26,9 @@

public final class TestGroups
{
public static final String CREATE_TABLE = "create_table";
public static final String CREATE_DROP_VIEW = "create_drop_view";
public static final String ALTER_TABLE = "alter_table";
public static final String COMMENT = "comment";
public static final String SIMPLE = "simple";
public static final String FUNCTIONS = "functions";
public static final String CLI = "cli";
public static final String SYSTEM = "system";
public static final String CONFIGURED_FEATURES = "configured_features";
public static final String JMX = "jmx";
public static final String BLACKHOLE = "blackhole";
public static final String TPCH = "tpch";
public static final String TPCDS = "tpcds";
public static final String JOIN = "join";
Expand All @@ -46,30 +40,23 @@ public final class TestGroups
public static final String OAUTH2_REFRESH = "oauth2_refresh";
public static final String MYSQL = "mysql";
public static final String TRINO_JDBC = "trino_jdbc";
public static final String QE = "qe"; // query engine
public static final String COMPARISON = "comparison";
public static final String LOGICAL = "logical";
public static final String JSON_FUNCTIONS = "json_functions";
public static final String STORAGE_FORMATS = "storage_formats";
public static final String STORAGE_FORMATS_DETAILED = "storage_formats_detailed";
public static final String HMS_ONLY = "hms_only";
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_PARTITIONING = "hive_partitioning";
public static final String HIVE_SPARK = "hive_spark";
public static final String HIVE_SPARK_NO_STATS_FALLBACK = "hive_spark_no_stats_fallback";
public static final String HIVE_COMPRESSION = "hive_compression";
public static final String HIVE_TRANSACTIONAL = "hive_transactional";
public static final String HIVE_VIEWS = "hive_views";
public static final String HIVE_VIEW_COMPATIBILITY = "hive_view_compatibility";
public static final String HIVE_CACHING = "hive_caching";
public static final String HIVE_ICEBERG_REDIRECTIONS = "hive_iceberg_redirections";
public static final String HIVE_HUDI_REDIRECTIONS = "hive_hudi_redirections";
public static final String HIVE_KERBEROS = "hive_kerberos";
public static final String HIVE_FILE_HEADER = "hive_file_header";
public static final String AUTHORIZATION = "authorization";
public static final String HIVE_COERCION = "hive_coercion";
public static final String AZURE = "azure";
public static final String CASSANDRA = "cassandra";
public static final String POSTGRESQL = "postgresql";
Expand All @@ -80,8 +67,6 @@ public final class TestGroups
public static final String LDAP_AND_FILE_CLI = "ldap_and_file_cli";
public static final String LDAP_MULTIPLE_BINDS = "ldap_multiple_binds";
public static final String TLS = "tls";
public static final String ROLES = "roles";
public static final String CANCEL_QUERY = "cancel_query";
public static final String LARGE_QUERY = "large_query";
public static final String KAFKA = "kafka";
public static final String KAFKA_CONFLUENT_LICENSE = "kafka_confluent_license";
Expand All @@ -91,7 +76,6 @@ public final class TestGroups
public static final String ICEBERG_REST = "iceberg_rest";
public static final String ICEBERG_JDBC = "iceberg_jdbc";
public static final String ICEBERG_NESSIE = "iceberg_nessie";
public static final String AVRO = "avro";
public static final String PHOENIX = "phoenix";
public static final String CLICKHOUSE = "clickhouse";
public static final String KUDU = "kudu";
Expand All @@ -116,23 +100,32 @@ public abstract static class Introspection
{
private Introspection() {}

private static final Set<String> ALL_GROUPS;
// Identity-based set
private static final Set<String> ALL_GROUPS_IDENTITIES;

static {
try {
ImmutableSet.Builder<String> groups = ImmutableSet.builder();
Set<String> groupIdentities = newSetFromMap(new IdentityHashMap<>());
for (Field field : TestGroups.class.getFields()) {
String group = (String) field.get(null);
groups.add(group);
groupIdentities.add(group);
}
ALL_GROUPS = groups.build();
ALL_GROUPS_IDENTITIES = unmodifiableSet(groupIdentities);
}
catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}

public static Set<String> getAllGroups()
{
return ALL_GROUPS;
}

public static void validateGroupIdentityReferences(Iterable<String> groupNames)
{
for (String groupName : groupNames) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.launcher.suite;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.inject.Injector;
import com.google.inject.Module;
import io.airlift.bootstrap.Bootstrap;
import io.trino.tests.product.TestGroups;
import io.trino.tests.product.launcher.env.configs.ConfigDefault;
import org.junit.jupiter.api.Test;

import java.util.Set;
import java.util.stream.Stream;

import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.inject.util.Modules.EMPTY_MODULE;
import static org.assertj.core.api.Assertions.assertThat;

public class TestAllGroupsUsed
{
@Test
public void testAllTestGroupsUsedInSuites()
{
Bootstrap app = new Bootstrap(
ImmutableList.<Module>builder()
.add(new SuiteModule(EMPTY_MODULE /* TODO support extensions */))
.build());

Injector injector = app
.initialize();

SuiteFactory suiteFactory = injector.getInstance(SuiteFactory.class);

Set<String> usedGroups = suiteFactory.listSuites().stream()
.map(suiteFactory::getSuite)
.flatMap(suite -> suite.getTestRuns(new ConfigDefault()).stream())
.flatMap(testRun -> Stream.concat(
testRun.getGroups().stream(),
testRun.getExcludedGroups().stream()))
.collect(toImmutableSet());

Set<String> definedGroups = TestGroups.Introspection.getAllGroups();

assertThat(Sets.difference(usedGroups, definedGroups)).as("Only groups defined by TestGroups should be used in test suites")
.isEmpty();

assertThat(Sets.difference(definedGroups, usedGroups)).as("All groups defined by TestGroups should be used in test suites")
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.tempto.assertions.QueryAssert.assertQueryFailure;
import static io.trino.tests.product.TestGroups.ALTER_TABLE;
import static io.trino.tests.product.TestGroups.SMOKE;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
Expand All @@ -43,7 +42,7 @@ public void dropTestTables()
onTrino().executeQuery(format("DROP TABLE IF EXISTS %s", RENAMED_TABLE_NAME));
}

@Test(groups = {ALTER_TABLE, SMOKE})
@Test(groups = SMOKE)
public void renameTable()
{
onTrino().executeQuery(format("CREATE TABLE %s AS SELECT * FROM nation", TABLE_NAME));
Expand All @@ -59,7 +58,7 @@ public void renameTable()
.hasRowsCount(1);
}

@Test(groups = {ALTER_TABLE, SMOKE})
@Test(groups = SMOKE)
public void renameColumn()
{
onTrino().executeQuery(format("CREATE TABLE %s AS SELECT * FROM nation", TABLE_NAME));
Expand All @@ -76,7 +75,7 @@ public void renameColumn()
onTrino().executeQuery(format("ALTER TABLE %s RENAME COLUMN nationkey TO n_nationkey", TABLE_NAME));
}

@Test(groups = {ALTER_TABLE, SMOKE})
@Test(groups = SMOKE)
public void addColumn()
{
onTrino().executeQuery(format("CREATE TABLE %s AS SELECT * FROM nation", TABLE_NAME));
Expand All @@ -91,7 +90,7 @@ public void addColumn()
.hasMessageContaining("Column 'n_naTioNkEy' already exists");
}

@Test(groups = {ALTER_TABLE, SMOKE})
@Test(groups = SMOKE)
public void dropColumn()
{
onTrino().executeQuery(format("CREATE TABLE %s AS SELECT n_nationkey, n_regionkey, n_name FROM nation", TABLE_NAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static io.trino.tempto.assertions.QueryAssert.assertQueryFailure;
import static io.trino.tempto.context.ContextDsl.executeWith;
import static io.trino.tempto.sql.SqlContexts.createViewAs;
import static io.trino.tests.product.TestGroups.CREATE_DROP_VIEW;
import static io.trino.tests.product.TestGroups.SMOKE;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
Expand All @@ -31,7 +30,7 @@
public class TestCreateDropView
extends ProductTest
{
@Test(groups = CREATE_DROP_VIEW)
@Test
public void createSimpleView()
{
executeWith(createViewAs("SELECT * FROM nation", onTrino()), view -> {
Expand All @@ -40,7 +39,7 @@ public void createSimpleView()
});
}

@Test(groups = CREATE_DROP_VIEW)
@Test
public void querySimpleViewQualified()
{
executeWith(createViewAs("SELECT * FROM nation", onTrino()), view -> {
Expand All @@ -49,7 +48,7 @@ public void querySimpleViewQualified()
});
}

@Test(groups = CREATE_DROP_VIEW)
@Test
public void createViewWithAggregate()
{
executeWith(createViewAs("SELECT n_regionkey, count(*) countries FROM nation GROUP BY n_regionkey ORDER BY n_regionkey", onTrino()), view -> {
Expand All @@ -58,7 +57,7 @@ public void createViewWithAggregate()
});
}

@Test(groups = {CREATE_DROP_VIEW, SMOKE})
@Test(groups = SMOKE)
public void createOrReplaceSimpleView()
{
executeWith(createViewAs("SELECT * FROM nation", onTrino()), view -> {
Expand All @@ -69,7 +68,7 @@ public void createOrReplaceSimpleView()
});
}

@Test(groups = CREATE_DROP_VIEW)
@Test
public void createSimpleViewTwiceShouldFail()
{
executeWith(createViewAs("SELECT * FROM nation", onTrino()), view -> {
Expand All @@ -80,7 +79,7 @@ public void createSimpleViewTwiceShouldFail()
});
}

@Test(groups = {CREATE_DROP_VIEW, SMOKE})
@Test(groups = SMOKE)
public void dropViewTest()
{
executeWith(createViewAs("SELECT * FROM nation", onTrino()), view -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static io.trino.tempto.assertions.QueryAssert.assertQueryFailure;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tests.product.TestGroups.CREATE_TABLE;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -29,7 +28,7 @@
public class TestCreateTable
extends ProductTest
{
@Test(groups = CREATE_TABLE)
@Test
public void shouldCreateTableAsSelect()
{
String tableName = "create_table_as_select";
Expand All @@ -38,7 +37,7 @@ public void shouldCreateTableAsSelect()
assertThat(onTrino().executeQuery(format("SELECT * FROM %s", tableName))).hasRowsCount(25);
}

@Test(groups = CREATE_TABLE)
@Test
public void shouldCreateTableAsEmptySelect()
{
String tableName = "create_table_as_empty_select";
Expand All @@ -50,7 +49,7 @@ public void shouldCreateTableAsEmptySelect()
/**
* {@code BaseConnectorTest.testCreateTableSchemaNotFound()} copy run against Thrift metastore.
*/
@Test(groups = CREATE_TABLE)
@Test
public void shouldNotCreateTableInNonExistentSchema()
{
String schemaName = "test_schema_" + randomNameSuffix();
Expand All @@ -63,7 +62,7 @@ public void shouldNotCreateTableInNonExistentSchema()
.hasMessageMatching("\\QQuery failed (#\\E\\S+\\Q): line 1:1: Schema '" + schemaName + "' does not exist");
}

@Test(groups = CREATE_TABLE)
@Test
public void shouldNotCreateExternalTableInNonExistentSchema()
{
String schemaName = "test_schema_" + randomNameSuffix();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.testng.annotations.Test;

import static io.trino.tests.product.TestGroups.JDBC;
import static io.trino.tests.product.TestGroups.JMX;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static java.sql.JDBCType.BIGINT;
import static java.sql.JDBCType.VARCHAR;
Expand All @@ -26,7 +25,7 @@
public class TestJmxConnector
extends ProductTest
{
@Test(groups = {JMX, JDBC})
@Test(groups = JDBC)
public void selectFromJavaRuntimeJmxMBean()
{
String sql = "SELECT node, vmname, vmversion FROM jmx.current.\"java.lang:type=runtime\"";
Expand All @@ -35,7 +34,7 @@ public void selectFromJavaRuntimeJmxMBean()
.hasAnyRows();
}

@Test(groups = JMX)
@Test
public void selectFromJavaOperatingSystemJmxMBean()
{
assertThat(onTrino().executeQuery("SELECT openfiledescriptorcount, maxfiledescriptorcount " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.tempto.context.ThreadLocalTestContextHolder.testContextIfSet;
import static io.trino.tempto.fulfillment.table.hive.tpch.TpchTableDefinitions.NATION;
import static io.trino.tests.product.TestGroups.SIMPLE;
import static io.trino.tests.product.TestGroups.SMOKE;
import static io.trino.tests.product.utils.QueryExecutors.onTrino;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -56,14 +55,14 @@ public void afterTest()
assertThat(testContextIfSet().isPresent()).isTrue();
}

@Test(groups = {SIMPLE, SMOKE})
@Test(groups = SMOKE)
@Requires(SimpleTestRequirements.class)
public void selectAllFromNation()
{
assertThat(onTrino().executeQuery("select * from nation")).hasRowsCount(25);
}

@Test(groups = {SIMPLE, SMOKE})
@Test(groups = SMOKE)
@Requires(SimpleTestRequirements.class)
public void selectCountFromNation()
{
Expand Down
Loading

0 comments on commit 0e0dfc8

Please sign in to comment.