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();
}
}
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();
}
}
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);
}
}
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();
}
}
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");
}
}
Aggregations