diff --git a/pom.xml b/pom.xml index e5c7d9ac17751..f78c7ff24b38a 100644 --- a/pom.xml +++ b/pom.xml @@ -169,6 +169,7 @@ presto-common presto-thrift-testing-udf-server presto-thrift-spec + testing/presto-testng-services @@ -654,6 +655,12 @@ ${project.version} + + com.facebook.presto + presto-testng-services + ${project.version} + + com.facebook.hive hive-dwrf diff --git a/presto-accumulo/pom.xml b/presto-accumulo/pom.xml index 20a443252aa2f..f1b1d23b60511 100644 --- a/presto-accumulo/pom.xml +++ b/presto-accumulo/pom.xml @@ -300,6 +300,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-array/pom.xml b/presto-array/pom.xml index 64d0e3020df11..7bd2cd27d77de 100644 --- a/presto-array/pom.xml +++ b/presto-array/pom.xml @@ -37,6 +37,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-atop/pom.xml b/presto-atop/pom.xml index 7f9d73a9053f5..6e8995fc440bb 100644 --- a/presto-atop/pom.xml +++ b/presto-atop/pom.xml @@ -123,6 +123,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-tests diff --git a/presto-base-jdbc/pom.xml b/presto-base-jdbc/pom.xml index 01377e5ab6b61..dad98c29062fd 100644 --- a/presto-base-jdbc/pom.xml +++ b/presto-base-jdbc/pom.xml @@ -106,6 +106,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-benchmark-driver/pom.xml b/presto-benchmark-driver/pom.xml index 137e24f9b900f..52eaaa58de90d 100644 --- a/presto-benchmark-driver/pom.xml +++ b/presto-benchmark-driver/pom.xml @@ -78,6 +78,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-benchmark/pom.xml b/presto-benchmark/pom.xml index d046b2ccf9e8c..40e4a9fcc3f15 100644 --- a/presto-benchmark/pom.xml +++ b/presto-benchmark/pom.xml @@ -107,6 +107,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.openjdk.jmh jmh-core diff --git a/presto-benchto-benchmarks/pom.xml b/presto-benchto-benchmarks/pom.xml index f3b686f2213ab..202ea4813e02c 100644 --- a/presto-benchto-benchmarks/pom.xml +++ b/presto-benchto-benchmarks/pom.xml @@ -28,6 +28,12 @@ 0.4 + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-bigquery/pom.xml b/presto-bigquery/pom.xml index 21758e43bc0b6..3db80a26a36f6 100644 --- a/presto-bigquery/pom.xml +++ b/presto-bigquery/pom.xml @@ -244,6 +244,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-blackhole/pom.xml b/presto-blackhole/pom.xml index 270b55ea47e0d..eb84a675af7aa 100644 --- a/presto-blackhole/pom.xml +++ b/presto-blackhole/pom.xml @@ -72,6 +72,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-tests diff --git a/presto-bytecode/pom.xml b/presto-bytecode/pom.xml index 50b4797396439..7c65c50d187e6 100644 --- a/presto-bytecode/pom.xml +++ b/presto-bytecode/pom.xml @@ -50,6 +50,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-cache/pom.xml b/presto-cache/pom.xml index 0d3ae65e29ab9..93818a5ccb224 100644 --- a/presto-cache/pom.xml +++ b/presto-cache/pom.xml @@ -127,6 +127,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-cassandra/pom.xml b/presto-cassandra/pom.xml index 0985df0006235..53e6e1fc9dc60 100644 --- a/presto-cassandra/pom.xml +++ b/presto-cassandra/pom.xml @@ -125,6 +125,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-client/pom.xml b/presto-client/pom.xml index c2230e834a01f..063a5f6f61de8 100644 --- a/presto-client/pom.xml +++ b/presto-client/pom.xml @@ -87,6 +87,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-common/pom.xml b/presto-common/pom.xml index 2f9a653b92b16..6cca83d683ecb 100644 --- a/presto-common/pom.xml +++ b/presto-common/pom.xml @@ -43,6 +43,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-druid/pom.xml b/presto-druid/pom.xml index b6e76448c4585..7ae8edbb01057 100644 --- a/presto-druid/pom.xml +++ b/presto-druid/pom.xml @@ -292,6 +292,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-example-http/pom.xml b/presto-example-http/pom.xml index b88fd57cc7dd7..104df652374cb 100644 --- a/presto-example-http/pom.xml +++ b/presto-example-http/pom.xml @@ -99,6 +99,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-function-namespace-managers/pom.xml b/presto-function-namespace-managers/pom.xml index b8156336432dc..8c317171222c9 100644 --- a/presto-function-namespace-managers/pom.xml +++ b/presto-function-namespace-managers/pom.xml @@ -136,6 +136,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.airlift testing diff --git a/presto-geospatial-toolkit/pom.xml b/presto-geospatial-toolkit/pom.xml index 2df0f4021acc5..2b7168dd989e0 100644 --- a/presto-geospatial-toolkit/pom.xml +++ b/presto-geospatial-toolkit/pom.xml @@ -61,6 +61,12 @@ true + + com.facebook.presto + presto-testng-services + test + + org.openjdk.jmh jmh-core diff --git a/presto-geospatial/pom.xml b/presto-geospatial/pom.xml index 835c939a77d46..b36ec6a9696a3 100644 --- a/presto-geospatial/pom.xml +++ b/presto-geospatial/pom.xml @@ -89,6 +89,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto.hadoop hadoop-apache2 diff --git a/presto-hive-hadoop2/pom.xml b/presto-hive-hadoop2/pom.xml index 730f594c63d42..d14acb70a238b 100644 --- a/presto-hive-hadoop2/pom.xml +++ b/presto-hive-hadoop2/pom.xml @@ -88,6 +88,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-hive-metastore/pom.xml b/presto-hive-metastore/pom.xml index 2d865a882eb95..800a15e513d3f 100644 --- a/presto-hive-metastore/pom.xml +++ b/presto-hive-metastore/pom.xml @@ -166,6 +166,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.openjdk.jmh jmh-core diff --git a/presto-hive/pom.xml b/presto-hive/pom.xml index febb620d8419e..b42fab5c6b80b 100644 --- a/presto-hive/pom.xml +++ b/presto-hive/pom.xml @@ -280,6 +280,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-spi diff --git a/presto-i18n-functions/pom.xml b/presto-i18n-functions/pom.xml index 0715ee41109ed..21bf95c8c99d0 100644 --- a/presto-i18n-functions/pom.xml +++ b/presto-i18n-functions/pom.xml @@ -58,6 +58,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-jdbc/pom.xml b/presto-jdbc/pom.xml index 6b47a934965d4..e7022fcae8c24 100644 --- a/presto-jdbc/pom.xml +++ b/presto-jdbc/pom.xml @@ -87,6 +87,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-jmx/pom.xml b/presto-jmx/pom.xml index 494461606ec74..5e1a36960bf9f 100644 --- a/presto-jmx/pom.xml +++ b/presto-jmx/pom.xml @@ -110,6 +110,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-kafka/pom.xml b/presto-kafka/pom.xml index d92d1e6a4572f..dff21e623c66a 100644 --- a/presto-kafka/pom.xml +++ b/presto-kafka/pom.xml @@ -170,6 +170,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-kudu/pom.xml b/presto-kudu/pom.xml index e54421c0e473a..34f16e92f302a 100644 --- a/presto-kudu/pom.xml +++ b/presto-kudu/pom.xml @@ -135,6 +135,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-local-file/pom.xml b/presto-local-file/pom.xml index 6850ddb8f10dc..29cbfd8954b6e 100644 --- a/presto-local-file/pom.xml +++ b/presto-local-file/pom.xml @@ -95,6 +95,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-main/pom.xml b/presto-main/pom.xml index 2a2f60a3698ba..b9b22848b7fd9 100644 --- a/presto-main/pom.xml +++ b/presto-main/pom.xml @@ -445,6 +445,12 @@ com.facebook.presto presto-plugin-toolkit + + + com.facebook.presto + presto-testng-services + test + diff --git a/presto-main/src/test/java/com/facebook/presto/execution/TestThriftTaskStatus.java b/presto-main/src/test/java/com/facebook/presto/execution/TestThriftTaskStatus.java index 88429a1347479..691bee29d7e11 100644 --- a/presto-main/src/test/java/com/facebook/presto/execution/TestThriftTaskStatus.java +++ b/presto-main/src/test/java/com/facebook/presto/execution/TestThriftTaskStatus.java @@ -47,6 +47,7 @@ import static com.facebook.presto.spi.StandardErrorCode.TOO_MANY_REQUESTS_FAILED; import static org.testng.Assert.assertEquals; +@Test(singleThreaded = true) public class TestThriftTaskStatus { private static final ThriftCodecManager COMPILER_READ_CODEC_MANAGER = new ThriftCodecManager(new CompilerThriftCodecFactory(false)); diff --git a/presto-main/src/test/resources/META-INF/services/org.testng.ITestNGListener b/presto-main/src/test/resources/META-INF/services/org.testng.ITestNGListener deleted file mode 100644 index ed81df7bba0bb..0000000000000 --- a/presto-main/src/test/resources/META-INF/services/org.testng.ITestNGListener +++ /dev/null @@ -1 +0,0 @@ -com.facebook.presto.tests.LogTestDurationListener diff --git a/presto-matching/pom.xml b/presto-matching/pom.xml index 966e113f6186d..d3576ec48f304 100644 --- a/presto-matching/pom.xml +++ b/presto-matching/pom.xml @@ -35,6 +35,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-memory-context/pom.xml b/presto-memory-context/pom.xml index 8d443e2e7c9df..270ca6ee1f1c2 100644 --- a/presto-memory-context/pom.xml +++ b/presto-memory-context/pom.xml @@ -29,6 +29,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.airlift testing diff --git a/presto-memory/pom.xml b/presto-memory/pom.xml index aec5a861ecf6f..b34530c381308 100644 --- a/presto-memory/pom.xml +++ b/presto-memory/pom.xml @@ -109,6 +109,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-tests diff --git a/presto-ml/pom.xml b/presto-ml/pom.xml index 93ce8e1f0aa33..430d7d278e4a6 100644 --- a/presto-ml/pom.xml +++ b/presto-ml/pom.xml @@ -100,6 +100,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-mongodb/pom.xml b/presto-mongodb/pom.xml index af5e85eab6857..cf2a08822e8c9 100644 --- a/presto-mongodb/pom.xml +++ b/presto-mongodb/pom.xml @@ -118,6 +118,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-tests diff --git a/presto-mysql/pom.xml b/presto-mysql/pom.xml index 81defe296a488..5d2d2bf066704 100644 --- a/presto-mysql/pom.xml +++ b/presto-mysql/pom.xml @@ -90,6 +90,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.assertj assertj-core diff --git a/presto-oracle/pom.xml b/presto-oracle/pom.xml index c5b37485d4b6d..5e7183d87b665 100644 --- a/presto-oracle/pom.xml +++ b/presto-oracle/pom.xml @@ -110,6 +110,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-orc/pom.xml b/presto-orc/pom.xml index 168f01947db09..8f84867335766 100644 --- a/presto-orc/pom.xml +++ b/presto-orc/pom.xml @@ -106,6 +106,12 @@ test + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-spi @@ -145,7 +151,6 @@ org.testng testng - 6.9.6 test diff --git a/presto-orc/src/test/java/com/facebook/presto/orc/TestStorageOrcFileTailSource.java b/presto-orc/src/test/java/com/facebook/presto/orc/TestStorageOrcFileTailSource.java index bd06f47c35edb..3e503d9408def 100644 --- a/presto-orc/src/test/java/com/facebook/presto/orc/TestStorageOrcFileTailSource.java +++ b/presto-orc/src/test/java/com/facebook/presto/orc/TestStorageOrcFileTailSource.java @@ -41,6 +41,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +@Test(singleThreaded = true) public class TestStorageOrcFileTailSource { private static final DataSize DEFAULT_SIZE = new DataSize(1, MEGABYTE); diff --git a/presto-parquet/pom.xml b/presto-parquet/pom.xml index 49422d4a793b5..19813c3dc6b20 100644 --- a/presto-parquet/pom.xml +++ b/presto-parquet/pom.xml @@ -91,6 +91,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-parser/pom.xml b/presto-parser/pom.xml index 9dd7bb19abe4c..ec898830bb2f3 100644 --- a/presto-parser/pom.xml +++ b/presto-parser/pom.xml @@ -48,6 +48,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-password-authenticators/pom.xml b/presto-password-authenticators/pom.xml index 46a2194d18e0c..54613cbab2c66 100644 --- a/presto-password-authenticators/pom.xml +++ b/presto-password-authenticators/pom.xml @@ -107,6 +107,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-pinot-toolkit/pom.xml b/presto-pinot-toolkit/pom.xml index 83628ac8d73bd..407be4df3fdf8 100644 --- a/presto-pinot-toolkit/pom.xml +++ b/presto-pinot-toolkit/pom.xml @@ -148,6 +148,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-main diff --git a/presto-plugin-toolkit/pom.xml b/presto-plugin-toolkit/pom.xml index 405309dcdbdb8..55b52789ee672 100644 --- a/presto-plugin-toolkit/pom.xml +++ b/presto-plugin-toolkit/pom.xml @@ -79,6 +79,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-postgresql/pom.xml b/presto-postgresql/pom.xml index 19eb541812d8a..83ccf302cbea4 100644 --- a/presto-postgresql/pom.xml +++ b/presto-postgresql/pom.xml @@ -85,6 +85,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-proxy/pom.xml b/presto-proxy/pom.xml index e744c10faac2d..6f1407a13759d 100644 --- a/presto-proxy/pom.xml +++ b/presto-proxy/pom.xml @@ -155,6 +155,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-raptor/pom.xml b/presto-raptor/pom.xml index 01a3e2929c932..d085c81811958 100644 --- a/presto-raptor/pom.xml +++ b/presto-raptor/pom.xml @@ -214,6 +214,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-rcfile/pom.xml b/presto-rcfile/pom.xml index 0428a66cba8b5..fa6ccb15b6e6c 100644 --- a/presto-rcfile/pom.xml +++ b/presto-rcfile/pom.xml @@ -78,6 +78,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-record-decoder/pom.xml b/presto-record-decoder/pom.xml index 9bcbf464495f9..4e09e5694b001 100644 --- a/presto-record-decoder/pom.xml +++ b/presto-record-decoder/pom.xml @@ -86,6 +86,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-redis/pom.xml b/presto-redis/pom.xml index 689ae7dc9c777..3895d6a0730ab 100644 --- a/presto-redis/pom.xml +++ b/presto-redis/pom.xml @@ -119,6 +119,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-redshift/pom.xml b/presto-redshift/pom.xml index 532c13190edf4..bfe96c97cca9d 100644 --- a/presto-redshift/pom.xml +++ b/presto-redshift/pom.xml @@ -87,6 +87,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-resource-group-managers/pom.xml b/presto-resource-group-managers/pom.xml index b8814f747d60f..32e0d92cbdb1a 100644 --- a/presto-resource-group-managers/pom.xml +++ b/presto-resource-group-managers/pom.xml @@ -146,6 +146,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-session-property-managers/pom.xml b/presto-session-property-managers/pom.xml index d05cc84077968..551654bfbd13a 100644 --- a/presto-session-property-managers/pom.xml +++ b/presto-session-property-managers/pom.xml @@ -88,6 +88,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-spark-base/pom.xml b/presto-spark-base/pom.xml index f9105cef97069..1a198fad13d9f 100644 --- a/presto-spark-base/pom.xml +++ b/presto-spark-base/pom.xml @@ -171,6 +171,12 @@ fastutil + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-spark-testing/pom.xml b/presto-spark-testing/pom.xml index 57009057f7ac4..f8953b4e1fb9f 100644 --- a/presto-spark-testing/pom.xml +++ b/presto-spark-testing/pom.xml @@ -31,6 +31,12 @@ guava + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-spi/pom.xml b/presto-spi/pom.xml index 0e657a7661463..af2973de81575 100644 --- a/presto-spi/pom.xml +++ b/presto-spi/pom.xml @@ -54,6 +54,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-common diff --git a/presto-sqlserver/pom.xml b/presto-sqlserver/pom.xml index 10bb28ae00619..72654cb409d89 100644 --- a/presto-sqlserver/pom.xml +++ b/presto-sqlserver/pom.xml @@ -83,6 +83,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-teradata-functions/pom.xml b/presto-teradata-functions/pom.xml index bfe5b76b4b45f..11df9b16fb0ef 100644 --- a/presto-teradata-functions/pom.xml +++ b/presto-teradata-functions/pom.xml @@ -68,6 +68,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-tests/pom.xml b/presto-tests/pom.xml index 793d3cce1bc0f..3fcd5c36469f7 100644 --- a/presto-tests/pom.xml +++ b/presto-tests/pom.xml @@ -222,6 +222,12 @@ + + com.facebook.presto + presto-testng-services + test + + com.facebook.presto presto-resource-group-managers diff --git a/presto-thrift-api/pom.xml b/presto-thrift-api/pom.xml index c3a17f872bd38..f90413d9ec437 100644 --- a/presto-thrift-api/pom.xml +++ b/presto-thrift-api/pom.xml @@ -54,6 +54,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-thrift-connector/pom.xml b/presto-thrift-connector/pom.xml index 63e506020bd7c..7d5b323312729 100644 --- a/presto-thrift-connector/pom.xml +++ b/presto-thrift-connector/pom.xml @@ -149,6 +149,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-thrift-testing-server/pom.xml b/presto-thrift-testing-server/pom.xml index cc91ff0575fea..232d3977d21c0 100644 --- a/presto-thrift-testing-server/pom.xml +++ b/presto-thrift-testing-server/pom.xml @@ -120,5 +120,11 @@ org.testng testng + + + com.facebook.presto + presto-testng-services + test + diff --git a/presto-tpcds/pom.xml b/presto-tpcds/pom.xml index 49d3bb457bfec..db9a85ba4248a 100644 --- a/presto-tpcds/pom.xml +++ b/presto-tpcds/pom.xml @@ -80,20 +80,19 @@ com.facebook.presto - presto-tests + presto-testng-services test com.facebook.presto - presto-main + presto-tests test com.facebook.presto presto-main - test-jar test diff --git a/presto-tpch/pom.xml b/presto-tpch/pom.xml index 00d5d035f0bf2..bb833b17ab4a9 100644 --- a/presto-tpch/pom.xml +++ b/presto-tpch/pom.xml @@ -68,6 +68,12 @@ + + com.facebook.presto + presto-testng-services + test + + org.testng testng diff --git a/presto-verifier/pom.xml b/presto-verifier/pom.xml index 3c06730ad3dc7..1482d9ddab70e 100644 --- a/presto-verifier/pom.xml +++ b/presto-verifier/pom.xml @@ -259,6 +259,12 @@ test + + com.facebook.presto + presto-testng-services + test + + com.facebook.airlift diff --git a/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestQueryConfiguration.java b/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestQueryConfiguration.java index b1fa7b5450cfb..36ba98f943877 100644 --- a/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestQueryConfiguration.java +++ b/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestQueryConfiguration.java @@ -25,6 +25,7 @@ import static com.facebook.presto.verifier.framework.QueryConfigurationOverrides.SessionPropertiesOverrideStrategy.OVERRIDE; import static com.facebook.presto.verifier.framework.QueryConfigurationOverrides.SessionPropertiesOverrideStrategy.SUBSTITUTE; +@Test(singleThreaded = true) public class TestQueryConfiguration { private static final String CATALOG = "catalog"; diff --git a/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestVerificationManager.java b/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestVerificationManager.java index 30d1fdffac28a..89fdccbb10058 100644 --- a/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestVerificationManager.java +++ b/presto-verifier/src/test/java/com/facebook/presto/verifier/framework/TestVerificationManager.java @@ -55,6 +55,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static org.testng.Assert.assertEquals; +@Test(singleThreaded = true) public class TestVerificationManager { private static class MockPrestoAction diff --git a/testing/presto-testng-services/pom.xml b/testing/presto-testng-services/pom.xml new file mode 100644 index 0000000000000..a4b48a3776bda --- /dev/null +++ b/testing/presto-testng-services/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + + com.facebook.presto + presto-root + 0.255-SNAPSHOT + ../../pom.xml + + + presto-testng-services + presto-testng-services + + + ${project.parent.basedir} + + + + + org.testng + testng + + + + com.google.guava + guava + + + + org.assertj + assertj-core + test + + + + com.facebook.airlift + log + + + + io.airlift + units + + + + com.facebook.airlift + concurrent + + + + com.google.code.findbugs + jsr305 + + + diff --git a/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/Listeners.java b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/Listeners.java new file mode 100644 index 0000000000000..ec3a29bb8c7c8 --- /dev/null +++ b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/Listeners.java @@ -0,0 +1,38 @@ +/* + * 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 com.facebook.presto.testng.services; + +import org.testng.ITestNGListener; + +import static java.lang.String.format; + +final class Listeners +{ + private Listeners() {} + + /** + * Print error to standard error and exit JVM. + * + * @apiNote A TestNG listener cannot throw an exception, as this are not currently properly handlded by TestNG. + */ + public static void reportListenerFailure(Class listenerClass, String format, Object... args) + { + System.err.println(format("FATAL: %s: ", listenerClass.getName()) + format(format, args)); + System.err.println("JVM will be terminated"); + + // TestNG may or may not propagate listener's exception as test execution exception. + // Therefore, instead of throwing, we terminate the JVM. + System.exit(1); + } +} diff --git a/presto-main/src/test/java/com/facebook/presto/tests/LogTestDurationListener.java b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/LogTestDurationListener.java similarity index 97% rename from presto-main/src/test/java/com/facebook/presto/tests/LogTestDurationListener.java rename to testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/LogTestDurationListener.java index b7c0c076d4774..0d0d6c6a0fa3d 100644 --- a/presto-main/src/test/java/com/facebook/presto/tests/LogTestDurationListener.java +++ b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/LogTestDurationListener.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.facebook.presto.tests; +package com.facebook.presto.testng.services; import com.facebook.airlift.log.Logger; import com.google.common.collect.ImmutableMap; @@ -103,7 +103,7 @@ private void checkForTestHang() Map runningTests = ImmutableMap.copyOf(started); if (!runningTests.isEmpty()) { String testDetails = runningTests.entrySet().stream() - .map(entry -> String.format("%s running for %s", entry.getKey(), nanosSince(entry.getValue()))) + .map(entry -> format("%s running for %s", entry.getKey(), nanosSince(entry.getValue()))) .collect(joining("\n\t", "\n\t", "")); dumpAllThreads(format("No test started or completed in %s. Running tests:%s.", GLOBAL_IDLE_LOGGING_THRESHOLD, testDetails)); } diff --git a/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/ReportMultiThreadedBeforeOrAfterMethod.java b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/ReportMultiThreadedBeforeOrAfterMethod.java new file mode 100644 index 0000000000000..4a746c610faa3 --- /dev/null +++ b/testing/presto-testng-services/src/main/java/com/facebook/presto/testng/services/ReportMultiThreadedBeforeOrAfterMethod.java @@ -0,0 +1,84 @@ +/* + * 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 com.facebook.presto.testng.services; + +import com.google.common.annotations.VisibleForTesting; +import org.testng.IClassListener; +import org.testng.ITestClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.testng.xml.XmlSuite.ParallelMode; +import org.testng.xml.XmlTest; + +import java.lang.reflect.Method; + +import static com.facebook.presto.testng.services.Listeners.reportListenerFailure; +import static com.google.common.base.Throwables.getStackTraceAsString; +import static java.lang.String.format; + +public class ReportMultiThreadedBeforeOrAfterMethod + implements IClassListener +{ + @Override + public void onBeforeClass(ITestClass testClass) + { + try { + if (!isParallel(testClass.getXmlTest())) { + return; + } + + reportMultiThreadedBeforeOrAfterMethod(testClass.getRealClass()); + } + catch (RuntimeException | Error e) { + reportListenerFailure( + ReportMultiThreadedBeforeOrAfterMethod.class, + "Failed to process %s: \n%s", + testClass, + getStackTraceAsString(e)); + } + } + + private boolean isParallel(XmlTest xmlTest) + { + if (xmlTest.getThreadCount() == 1) { + return false; + } + + ParallelMode parallel = xmlTest.getParallel(); + return parallel.isParallel(); + } + + @VisibleForTesting + static void reportMultiThreadedBeforeOrAfterMethod(Class testClass) + { + Test testAnnotation = testClass.getAnnotation(Test.class); + if (testAnnotation != null && testAnnotation.singleThreaded()) { + return; + } + + Method[] methods = testClass.getMethods(); + for (Method method : methods) { + if (method.getAnnotation(BeforeMethod.class) != null || method.getAnnotation(AfterMethod.class) != null) { + throw new RuntimeException(format( + "Test class %s should be annotated as @Test(singleThreaded=true), if it contains mutable state as indicated by %s", + testClass.getName(), + method)); + } + } + } + + @Override + public void onAfterClass(ITestClass iTestClass) {} +} diff --git a/testing/presto-testng-services/src/main/resources/META-INF/services/org.testng.ITestNGListener b/testing/presto-testng-services/src/main/resources/META-INF/services/org.testng.ITestNGListener new file mode 100644 index 0000000000000..dd8388ac52c94 --- /dev/null +++ b/testing/presto-testng-services/src/main/resources/META-INF/services/org.testng.ITestNGListener @@ -0,0 +1,2 @@ +com.facebook.presto.testng.services.LogTestDurationListener +com.facebook.presto.testng.services.ReportMultiThreadedBeforeOrAfterMethod diff --git a/testing/presto-testng-services/src/test/java/com/facebook/presto/testng/services/TestReportMultiThreadedBeforeOrAfterMethod.java b/testing/presto-testng-services/src/test/java/com/facebook/presto/testng/services/TestReportMultiThreadedBeforeOrAfterMethod.java new file mode 100644 index 0000000000000..6e5a8f38e6794 --- /dev/null +++ b/testing/presto-testng-services/src/test/java/com/facebook/presto/testng/services/TestReportMultiThreadedBeforeOrAfterMethod.java @@ -0,0 +1,69 @@ +/* + * 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 com.facebook.presto.testng.services; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static com.facebook.presto.testng.services.ReportMultiThreadedBeforeOrAfterMethod.reportMultiThreadedBeforeOrAfterMethod; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class TestReportMultiThreadedBeforeOrAfterMethod +{ + @Test + public void test() + { + // no @BeforeMethod + reportMultiThreadedBeforeOrAfterMethod(ClassWithoutBeforeMethod.class); + + // @BeforeMethod but not @Test(singleThreaded) + assertThatThrownBy(() -> reportMultiThreadedBeforeOrAfterMethod(ClassWithBeforeMethod.class)) + .hasMessageMatching("Test class \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$ClassWithBeforeMethod should be annotated as @Test(singleThreaded=true)\\E, " + + "if it contains mutable state as indicated by public void \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$ClassWithBeforeMethod.someBeforeMethod()"); + + // @BeforeMethod and @Test(singleThreaded) + reportMultiThreadedBeforeOrAfterMethod(SingleThreadedClassWithBeforeMethod.class); + + // inherited @BeforeMethod but not @Test(singleThreaded) + assertThatThrownBy(() -> reportMultiThreadedBeforeOrAfterMethod(ClassWithInheritedBeforeMethod.class)) + .hasMessageMatching("Test class \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$ClassWithInheritedBeforeMethod should be annotated as @Test(singleThreaded=true)\\E, " + + "if it contains mutable state as indicated by public void \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$ClassWithBeforeMethod.someBeforeMethod()"); + + // inherited @BeforeMethod and "inherited" @Test(singleThreaded) (this does not get propagated to child class yet, see https://github.com/cbeust/testng/issues/144) + assertThatThrownBy(() -> reportMultiThreadedBeforeOrAfterMethod(ClassExtendingSingleThreadedClassWithBeforeMethod.class)) + .hasMessageMatching("Test class \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$ClassExtendingSingleThreadedClassWithBeforeMethod should be annotated as @Test(singleThreaded=true)\\E, " + + "if it contains mutable state as indicated by public void \\S*\\Q.TestReportMultiThreadedBeforeOrAfterMethod$SingleThreadedClassWithBeforeMethod.someBeforeMethod()"); + } + + public static class ClassWithoutBeforeMethod {} + + public static class ClassWithBeforeMethod + { + @BeforeMethod + public void someBeforeMethod() {} + } + + @Test(singleThreaded = true) + public static class SingleThreadedClassWithBeforeMethod + { + @BeforeMethod + public void someBeforeMethod() {} + } + + public static class ClassWithInheritedBeforeMethod + extends ClassWithBeforeMethod {} + + public static class ClassExtendingSingleThreadedClassWithBeforeMethod + extends SingleThreadedClassWithBeforeMethod {} +}