Search in sources :

Example 1 with TempFile

use of com.facebook.airlift.testing.TempFile in project presto by prestodb.

the class TestDynamicPruning method testDynamicBucketPruning.

@Test
public void testDynamicBucketPruning() {
    HiveClientConfig config = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HiveTransactionHandle transaction = new HiveTransactionHandle();
    try (TempFile tempFile = new TempFile()) {
        ConnectorPageSource emptyPageSource = createTestingPageSource(transaction, config, new SplitContext(false, getToSkipTupleDomainForPartition()), metastoreClientConfig, tempFile.file());
        assertEquals(emptyPageSource.getClass(), HiveEmptySplitPageSource.class);
        ConnectorPageSource nonEmptyPageSource = createTestingPageSource(transaction, config, new SplitContext(false, getToKeepTupleDomainForPartition()), metastoreClientConfig, tempFile.file());
        assertEquals(nonEmptyPageSource.getClass(), HivePageSource.class);
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : TempFile(com.facebook.airlift.testing.TempFile) SplitContext(com.facebook.presto.spi.SplitContext) IOException(java.io.IOException) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) Test(org.testng.annotations.Test)

Example 2 with TempFile

use of com.facebook.airlift.testing.TempFile in project presto by prestodb.

the class TestDynamicPruning method testDynamicPartitionPruning.

@Test
public void testDynamicPartitionPruning() {
    HiveClientConfig config = new HiveClientConfig();
    MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig();
    HiveTransactionHandle transaction = new HiveTransactionHandle();
    try (TempFile tempFile = new TempFile()) {
        ConnectorPageSource emptyPageSource = createTestingPageSource(transaction, config, new SplitContext(false, getToSkipTupleDomain()), metastoreClientConfig, tempFile.file());
        assertEquals(emptyPageSource.getClass(), HiveEmptySplitPageSource.class);
        ConnectorPageSource nonEmptyPageSource = createTestingPageSource(transaction, config, new SplitContext(false, getToKeepTupleDomain()), metastoreClientConfig, tempFile.file());
        assertEquals(nonEmptyPageSource.getClass(), HivePageSource.class);
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
}
Also used : TempFile(com.facebook.airlift.testing.TempFile) SplitContext(com.facebook.presto.spi.SplitContext) IOException(java.io.IOException) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) Test(org.testng.annotations.Test)

Example 3 with TempFile

use of com.facebook.airlift.testing.TempFile in project presto by prestodb.

the class TestFileSessionPropertyManager method assertProperties.

private static void assertProperties(Map<String, String> defaultProperties, Map<String, String> overrideProperties, SessionMatchSpec... spec) throws IOException {
    try (TempFile tempFile = new TempFile()) {
        Path configurationFile = tempFile.path();
        Files.write(configurationFile, CODEC.toJsonBytes(Arrays.asList(spec)));
        SessionPropertyConfigurationManager manager = new FileSessionPropertyManager(new FileSessionPropertyManagerConfig().setConfigFile(configurationFile.toFile()));
        SystemSessionPropertyConfiguration propertyConfiguration = manager.getSystemSessionProperties(CONTEXT);
        assertEquals(propertyConfiguration.systemPropertyDefaults, defaultProperties);
        assertEquals(propertyConfiguration.systemPropertyOverrides, overrideProperties);
    }
}
Also used : Path(java.nio.file.Path) TempFile(com.facebook.airlift.testing.TempFile) SystemSessionPropertyConfiguration(com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration) SessionPropertyConfigurationManager(com.facebook.presto.spi.session.SessionPropertyConfigurationManager)

Example 4 with TempFile

use of com.facebook.airlift.testing.TempFile in project presto by prestodb.

the class PrestoCliTests method shouldRunQueryFromFile.

@Test(groups = CLI, timeOut = TIMEOUT)
public void shouldRunQueryFromFile() throws Exception {
    try (TempFile file = new TempFile()) {
        Files.write("select * from hive.default.nation;\n", file.file(), UTF_8);
        launchPrestoCliWithServerArgument("--file", file.file().getAbsolutePath());
        assertThat(trimLines(presto.readRemainingOutputLines())).containsAll(nationTableBatchLines);
        presto.waitForWithTimeoutAndKill();
    }
}
Also used : TempFile(com.facebook.airlift.testing.TempFile) Test(org.testng.annotations.Test)

Example 5 with TempFile

use of com.facebook.airlift.testing.TempFile in project presto by prestodb.

the class PrestoCliTests method shouldNotExitOnErrorFromFile.

@Test(groups = CLI, timeOut = TIMEOUT)
public void shouldNotExitOnErrorFromFile() throws IOException, InterruptedException {
    try (TempFile file = new TempFile()) {
        Files.write("select * from hive.default.nations;\nselect * from hive.default.nation;\n", file.file(), UTF_8);
        launchPrestoCliWithServerArgument("--file", file.file().getAbsolutePath(), "--ignore-errors");
        assertThat(trimLines(presto.readRemainingOutputLines())).containsAll(nationTableBatchLines);
        assertThatThrownBy(() -> presto.waitForWithTimeoutAndKill()).hasMessage("Child process exited with non-zero code: 1");
    }
}
Also used : TempFile(com.facebook.airlift.testing.TempFile) Test(org.testng.annotations.Test)

Aggregations

TempFile (com.facebook.airlift.testing.TempFile)6 Test (org.testng.annotations.Test)5 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)2 SplitContext (com.facebook.presto.spi.SplitContext)2 IOException (java.io.IOException)2 SessionPropertyConfigurationManager (com.facebook.presto.spi.session.SessionPropertyConfigurationManager)1 SystemSessionPropertyConfiguration (com.facebook.presto.spi.session.SessionPropertyConfigurationManager.SystemSessionPropertyConfiguration)1 Path (java.nio.file.Path)1