-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caddf66
commit cda0fe6
Showing
5 changed files
with
33 additions
and
55 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
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
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 |
---|---|---|
|
@@ -14,38 +14,48 @@ | |
package io.trino.tests.product.ranger; | ||
|
||
import io.trino.tempto.ProductTest; | ||
import io.trino.tempto.query.QueryExecutionException; | ||
import io.trino.tempto.query.QueryExecutor; | ||
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.APACHE_RANGER; | ||
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS; | ||
import static io.trino.tests.product.utils.QueryExecutors.onTrino; | ||
import static io.trino.tests.product.utils.QueryExecutors.connectToTrino; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
public class TestApacheRanger | ||
extends ProductTest | ||
{ | ||
@Test(groups = {APACHE_RANGER, PROFILE_SPECIFIC_TESTS}) | ||
public void testCreateTableAsSelect() | ||
{ | ||
String tableName = "memory.default.nation_" + randomNameSuffix(); | ||
final String tableName = "memory.default.nation_" + randomNameSuffix(); | ||
|
||
try (QueryExecutor trino = onTrino()) { | ||
// config 'presto' is mapped to user hive. Ranger plugin is configured with hive as a superuser, so all queries from hive should succeed. | ||
try (QueryExecutor userPresto = connectToTrino("presto")) { | ||
Check failure on line 38 in testing/trino-product-tests/src/main/java/io/trino/tests/product/ranger/TestApacheRanger.java GitHub Actions / pt (default, suite-apache-ranger, )TestApacheRanger > testCreateTableAsSelect [groups: profile_specific_tests, apache-ranger]
|
||
try { | ||
trino.executeQuery("DROP TABLE IF EXISTS " + tableName); | ||
assertThat(trino.executeQuery("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation")).updatedRowsCountIsEqualTo(25); | ||
assertThat(trino.executeQuery("SELECT COUNT(*) FROM " + tableName)).containsOnly(row(25)); | ||
assertThat(trino.executeQuery("TRUNCATE TABLE " + tableName)).updatedRowsCountIsEqualTo(0); | ||
assertThat(trino.executeQuery("INSERT INTO " + tableName + " SELECT * FROM tpch.tiny.nation")).updatedRowsCountIsEqualTo(25); | ||
userPresto.executeQuery("DROP TABLE IF EXISTS " + tableName); | ||
assertThat(userPresto.executeQuery("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation")).updatedRowsCountIsEqualTo(25); | ||
assertThat(userPresto.executeQuery("SELECT COUNT(*) FROM " + tableName)).containsOnly(row(25)); | ||
assertThat(userPresto.executeQuery("TRUNCATE TABLE " + tableName)).updatedRowsCountIsEqualTo(0); | ||
assertThat(userPresto.executeQuery("INSERT INTO " + tableName + " SELECT * FROM tpch.tiny.nation")).updatedRowsCountIsEqualTo(25); | ||
/* memory catalog does not support UPDATE and DELETE | ||
assertThat(trino.executeQuery("UPDATE " + tableName + " SET comment = name")).updatedRowsCountIsEqualTo(25); | ||
assertThat(trino.executeQuery("DELETE FROM " + tableName)).updatedRowsCountIsEqualTo(25); | ||
assertThat(userPresto.executeQuery("UPDATE " + tableName + " SET comment = name")).updatedRowsCountIsEqualTo(25); | ||
assertThat(userPresto.executeQuery("DELETE FROM " + tableName)).updatedRowsCountIsEqualTo(25); | ||
*/ | ||
|
||
// config 'alice@presto' is mapped to user alice. This user doesn't have any permissions in Ranger, so all queries should fail. | ||
try (QueryExecutor userAlice = connectToTrino("alice@presto")) { | ||
assertThatThrownBy(() -> userAlice.executeQuery("SELECT COUNT(*) FROM " + tableName)).isInstanceOf(QueryExecutionException.class); | ||
assertThatThrownBy(() -> userAlice.executeQuery("TRUNCATE TABLE " + tableName)).isInstanceOf(QueryExecutionException.class); | ||
assertThatThrownBy(() -> userAlice.executeQuery("INSERT INTO " + tableName + " SELECT * FROM tpch.tiny.nation")).isInstanceOf(QueryExecutionException.class); | ||
} | ||
} | ||
finally { | ||
trino.executeQuery("DROP TABLE " + tableName); | ||
userPresto.executeQuery("DROP TABLE IF EXISTS " + tableName); | ||
} | ||
} | ||
} | ||
|