Search in sources :

Example 96 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testDropPublicAliasWithNonAdminUser.

@Test
public void testDropPublicAliasWithNonAdminUser() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        String sql = "DROP PUBLIC ALIAS abc for storage";
        client.queryBuilder().sql(sql).run();
        fail();
    } catch (UserRemoteException e) {
        MatcherAssert.assertThat(e.getVerboseMessage(), containsString("PERMISSION ERROR: Not authorized to perform operations on public aliases."));
    } finally {
        storageAliasesRegistry.deletePublicAliases();
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 97 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testDropAllTableUserAliases.

@Test
public void testDropAllTableUserAliases() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        tableAliasesRegistry.createUserAliases(TEST_USER_2);
        tableAliasesRegistry.getUserAliases(TEST_USER_2).put("`tpch_lineitem`", "`cp`.`default`.`tpch/lineitem.parquet`", true);
        String sql = "DROP ALL ALIASES FOR TABLE";
        client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("ok", "summary").baselineValues(true, "Table aliases dropped successfully").go();
        tableAliasesRegistry.getUserAliases(TEST_USER_2).getAllAliases().forEachRemaining(entry -> fail());
    } finally {
        tableAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 98 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testCreateStorageUserAlias.

@Test
public void testCreateStorageUserAlias() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        String sql = "CREATE ALIAS abc for storage dfs";
        client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("ok", "summary").baselineValues(true, "Storage alias '`abc`' for '`dfs`' created successfully").go();
        List<String> expectedAliases = Collections.singletonList("`abc`");
        List<String> expectedValues = Collections.singletonList("`dfs`");
        List<String> actualAliases = new ArrayList<>();
        List<String> actualValues = new ArrayList<>();
        storageAliasesRegistry.getUserAliases(TEST_USER_2).getAllAliases().forEachRemaining(entry -> {
            actualAliases.add(entry.getKey());
            actualValues.add(entry.getValue());
        });
        assertEquals(expectedAliases, actualAliases);
        assertEquals(expectedValues, actualValues);
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 99 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestAliasCommands method testCreateTableUserAlias.

@Test
public void testCreateTableUserAlias() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        String sql = "CREATE ALIAS tpch_lineitem for table cp.`tpch/lineitem.parquet`";
        client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("ok", "summary").baselineValues(true, "Table alias '`tpch_lineitem`' for '`cp`.`default`.`tpch/lineitem.parquet`' created successfully").go();
        List<String> expectedAliases = Collections.singletonList("`tpch_lineitem`");
        List<String> expectedValues = Collections.singletonList("`cp`.`default`.`tpch/lineitem.parquet`");
        List<String> actualAliases = new ArrayList<>();
        List<String> actualValues = new ArrayList<>();
        tableAliasesRegistry.getUserAliases(TEST_USER_2).getAllAliases().forEachRemaining(entry -> {
            actualAliases.add(entry.getKey());
            actualValues.add(entry.getValue());
        });
        assertEquals(expectedAliases, actualAliases);
        assertEquals(expectedValues, actualValues);
    } finally {
        tableAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 100 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TopNBatchTest method sortOneKeyAscending.

/**
 * End to end test of the TopN operator.
 * @throws Throwable
 */
@Test
public void sortOneKeyAscending() throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        TestBuilder testBuilder = new TestBuilder(new ClusterFixture.FixtureTestServices(client));
        testBuilder.ordered().physicalPlanFromFile("topN/one_key_sort.json").baselineColumns("blue").go();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) TestBuilder(org.apache.drill.test.TestBuilder) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2