Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce presto product tests suite
Patch introduces bunch of product tests based on tempto testing framework.
- Loading branch information
Showing
495 changed files
with
26,816 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ benchmark_outputs | |
*.pyc | ||
*.class | ||
.checkstyle | ||
*-local.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Presto product tests | ||
|
||
## Test configuration | ||
|
||
Test assume that you have hadoop and presto cluster running. For setting up development environment we | ||
recommend presto-docker-devenv project. This presto-docker-devenv contains tools for building and running | ||
docker images to be used on local developer machine for easy setup of presto instance together with dependencies | ||
like hadoop. You can also start presto on your machine locally from IDE (please check main presto README). | ||
|
||
To make it work you need either: | ||
- define environment variables for hadoop ${HADOOP_MASTER} and presto ${PRESTO_MASTER} with their IP numbers, | ||
and ${PRESTO_PRODUCT_TESTS_ROOT} with path to the presto product test directory | ||
- create test-configuration-local.yaml with following (example content): | ||
|
||
``` | ||
databases: | ||
hive: | ||
host: 172.16.2.10 | ||
presto: | ||
host: 192.168.205.1 | ||
``` | ||
|
||
## Running tests | ||
|
||
Product tests are not run by default. To start them use run following command: | ||
|
||
``` | ||
java -jar target/presto-product-tests-*-executable.jar --config-local file://`pwd`/tempto-configuration-local.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>presto-root</artifactId> | ||
<groupId>com.facebook.presto</groupId> | ||
<version>0.126-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>presto-product-tests</artifactId> | ||
<name>presto-product-tests</name> | ||
|
||
<properties> | ||
<air.main.basedir>${project.parent.basedir}</air.main.basedir> | ||
<main-class>com.facebook.presto.tests.TemptoProductTestRunner</main-class> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.facebook.presto</groupId> | ||
<artifactId>presto-jdbc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.facebook.presto</groupId> | ||
<artifactId>presto-main</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.teradata.tempto</groupId> | ||
<artifactId>tempto-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.teradata.tempto</groupId> | ||
<artifactId>tempto-runner</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.facebook.presto</groupId> | ||
<artifactId>presto-cli</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>units</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>json</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>http-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.facebook.presto.hive</groupId> | ||
<artifactId>hive-apache-jdbc</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<shadedArtifactAttached>true</shadedArtifactAttached> | ||
<shadedClassifierName>executable</shadedClassifierName> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<manifestEntries> | ||
<Main-Class>${main-class}</Main-Class> | ||
</manifestEntries> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
52 changes: 52 additions & 0 deletions
52
presto-product-tests/src/main/java/com/facebook/presto/tests/AlterTableTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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.tests; | ||
|
||
import com.facebook.presto.tests.ImmutableTpchTablesRequirements.ImmutableNationTable; | ||
import com.facebook.presto.tests.utils.PrestoDDLUtils.Table; | ||
import com.teradata.tempto.ProductTest; | ||
import com.teradata.tempto.Requires; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.facebook.presto.tests.TestGroups.ALTER_TABLE; | ||
import static com.facebook.presto.tests.TestGroups.SMOKE; | ||
import static com.facebook.presto.tests.utils.PrestoDDLUtils.createPrestoTable; | ||
import static com.teradata.tempto.assertions.QueryAssert.assertThat; | ||
import static com.teradata.tempto.query.QueryExecutor.query; | ||
import static com.teradata.tempto.query.QueryType.UPDATE; | ||
import static java.lang.String.format; | ||
|
||
@Requires(ImmutableNationTable.class) | ||
public class AlterTableTests | ||
extends ProductTest | ||
{ | ||
@Test(groups = {ALTER_TABLE, SMOKE}) | ||
public void renameTable() | ||
throws IOException | ||
{ | ||
String tableName = "to_be_renamed_table_name"; | ||
String renamedTableName = "renamed_table_name"; | ||
try (Table table = createPrestoTable(tableName, "CREATE TABLE %s AS SELECT * FROM nation")) { | ||
assertThat(query(format("ALTER TABLE %s RENAME TO %s", table.getNameInDatabase(), renamedTableName), UPDATE)) | ||
.hasRowsCount(1); | ||
assertThat(query(format("SELECT * FROM %s", renamedTableName))) | ||
.hasRowsCount(25); | ||
// rename back to original name | ||
assertThat(query(format("ALTER TABLE %s RENAME TO %s", renamedTableName, table.getNameInDatabase()), UPDATE)) | ||
.hasRowsCount(1); | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
presto-product-tests/src/main/java/com/facebook/presto/tests/CreateDropViewTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* 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.tests; | ||
|
||
import com.facebook.presto.tests.ImmutableTpchTablesRequirements.ImmutableNationTable; | ||
import com.teradata.tempto.ProductTest; | ||
import com.teradata.tempto.Requires; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static com.facebook.presto.tests.TestGroups.CREATE_DROP_VIEW; | ||
import static com.facebook.presto.tests.TestGroups.SMOKE; | ||
import static com.teradata.tempto.assertions.QueryAssert.assertThat; | ||
import static com.teradata.tempto.context.ContextDsl.executeWith; | ||
import static com.teradata.tempto.query.QueryExecutor.query; | ||
import static com.teradata.tempto.query.QueryType.UPDATE; | ||
import static com.teradata.tempto.sql.SqlContexts.createViewAs; | ||
import static java.lang.String.format; | ||
|
||
@Requires(ImmutableNationTable.class) | ||
public class CreateDropViewTests | ||
extends ProductTest | ||
{ | ||
@Test(groups = CREATE_DROP_VIEW) | ||
public void createSimpleView() | ||
throws IOException | ||
{ | ||
executeWith(createViewAs("SELECT * FROM nation"), view -> { | ||
assertThat(query(format("SELECT * FROM %s", view.getName()))) | ||
.hasRowsCount(25); | ||
}); | ||
} | ||
|
||
@Test(groups = CREATE_DROP_VIEW) | ||
public void createViewWithAggregate() | ||
throws IOException | ||
{ | ||
executeWith(createViewAs("SELECT n_regionkey, count(*) countries FROM nation GROUP BY n_regionkey ORDER BY n_regionkey"), view -> { | ||
assertThat(query(format("SELECT * FROM %s", view.getName()))) | ||
.hasRowsCount(5); | ||
}); | ||
} | ||
|
||
@Test(groups = {CREATE_DROP_VIEW, SMOKE}) | ||
public void createOrReplaceSimpleView() | ||
throws IOException | ||
{ | ||
executeWith(createViewAs("SELECT * FROM nation"), view -> { | ||
assertThat(query(format("CREATE OR REPLACE VIEW %s AS SELECT * FROM nation", view.getName()), UPDATE)) | ||
.hasRowsCount(1); | ||
assertThat(query(format("SELECT * FROM %s", view.getName()))) | ||
.hasRowsCount(25); | ||
}); | ||
} | ||
|
||
@Test(groups = CREATE_DROP_VIEW) | ||
public void createSimpleViewTwiceShouldFail() | ||
throws IOException | ||
{ | ||
executeWith(createViewAs("SELECT * FROM nation"), view -> { | ||
assertThat(() -> query(format("CREATE VIEW %s AS SELECT * FROM nation", view.getName()), UPDATE)) | ||
.failsWithMessage("View already exists"); | ||
assertThat(query(format("SELECT * FROM %s", view.getName()))) | ||
.hasRowsCount(25); | ||
}); | ||
} | ||
|
||
@Test(groups = {CREATE_DROP_VIEW, SMOKE}) | ||
public void dropViewTest() | ||
throws IOException | ||
{ | ||
executeWith(createViewAs("SELECT * FROM nation"), view -> { | ||
assertThat(query(format("SELECT * FROM %s", view.getName()))) | ||
.hasRowsCount(25); | ||
assertThat(query(format("DROP VIEW %s", view.getName()), UPDATE)) | ||
.hasRowsCount(1); | ||
assertThat(() -> query(format("SELECT * FROM %s", view.getName()))) | ||
.failsWithMessage("does not exist"); | ||
}); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
presto-product-tests/src/main/java/com/facebook/presto/tests/CreateTableTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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.tests; | ||
|
||
import com.facebook.presto.tests.ImmutableTpchTablesRequirements.ImmutableNationTable; | ||
import com.facebook.presto.tests.utils.PrestoDDLUtils.Table; | ||
import com.teradata.tempto.ProductTest; | ||
import com.teradata.tempto.Requires; | ||
import org.testng.annotations.Test; | ||
|
||
import static com.facebook.presto.tests.TestGroups.CREATE_TABLE; | ||
import static com.facebook.presto.tests.utils.PrestoDDLUtils.createPrestoTable; | ||
import static com.teradata.tempto.assertions.QueryAssert.assertThat; | ||
import static com.teradata.tempto.query.QueryExecutor.query; | ||
import static java.lang.String.format; | ||
|
||
@Requires(ImmutableNationTable.class) | ||
public class CreateTableTests | ||
extends ProductTest | ||
{ | ||
@Test(groups = CREATE_TABLE) | ||
public void shouldCreateTableAsSelect() | ||
throws Exception | ||
{ | ||
String tableName = "create_table_as_select"; | ||
try (Table table = createPrestoTable(tableName, "CREATE TABLE %s AS SELECT * FROM nation")) { | ||
assertThat(query(format("SELECT * FROM %s", table.getNameInDatabase()))).hasRowsCount(25); | ||
} | ||
} | ||
|
||
@Test(groups = CREATE_TABLE) | ||
public void shouldCreateTableAsEmptySelect() | ||
throws Exception | ||
{ | ||
String tableName = "create_table_as_empty_select"; | ||
try (Table table = createPrestoTable(tableName, "CREATE TABLE %s AS SELECT * FROM nation WHERE 0 is NULL")) { | ||
assertThat(query(format("SELECT * FROM %s", table.getNameInDatabase()))).hasRowsCount(0); | ||
} | ||
} | ||
} |
Oops, something went wrong.