use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class UriCacheGeneratorTest method testWeirdSchemaOnExactURI.
@Test
public void testWeirdSchemaOnExactURI() throws Exception {
final UriExtractionNamespace extractionNamespace = new UriExtractionNamespace(new URI(FAKE_SCHEME, namespace.getUri().getUserInfo(), namespace.getUri().getHost(), namespace.getUri().getPort(), namespace.getUri().getPath(), namespace.getUri().getQuery(), namespace.getUri().getFragment()), null, null, namespace.getNamespaceParseSpec(), Period.millis((int) namespace.getPollMs()), null, null);
Assert.assertNotNull(generator.generateCache(extractionNamespace, null, null, scheduler));
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class UriCacheGeneratorTest method testMissing.
@Test(expected = FileNotFoundException.class)
public void testMissing() throws Exception {
UriExtractionNamespace badNamespace = new UriExtractionNamespace(namespace.getUri(), null, null, namespace.getNamespaceParseSpec(), Period.millis((int) namespace.getPollMs()), null, null);
Assert.assertTrue(new File(namespace.getUri()).delete());
generator.generateCache(badNamespace, null, null, scheduler);
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class UriCacheGeneratorTest method simplePileONamespacesTest.
@Test
public void simplePileONamespacesTest() throws InterruptedException {
final int size = 128;
List<CacheScheduler.Entry> entries = new ArrayList<>(size);
for (int i = 0; i < size; ++i) {
UriExtractionNamespace namespace = new UriExtractionNamespace(tmpFile.toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new ObjectMapper())), new Period(0), null, null);
CacheScheduler.Entry entry = scheduler.schedule(namespace);
entries.add(entry);
CacheSchedulerTest.waitFor(entry);
}
for (CacheScheduler.Entry entry : entries) {
final Map<String, String> map = entry.getCache();
Assert.assertEquals("bar", map.get("foo"));
Assert.assertEquals(null, map.get("baz"));
entry.close();
}
Assert.assertEquals(0, scheduler.getActiveEntries());
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class UriCacheGeneratorTest method testMissingRegex.
@Test(expected = FileNotFoundException.class)
public void testMissingRegex() throws Exception {
UriExtractionNamespace badNamespace = new UriExtractionNamespace(null, Paths.get(namespace.getUri()).getParent().toUri(), Pattern.quote(Paths.get(namespace.getUri()).getFileName().toString()), namespace.getNamespaceParseSpec(), Period.millis((int) namespace.getPollMs()), null, null);
Assert.assertTrue(new File(namespace.getUri()).delete());
generator.generateCache(badNamespace, null, null, scheduler);
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class CacheSchedulerTest method testRunCount.
@Test(timeout = 60_000L)
public void testRunCount() throws InterruptedException {
final int numWaits = 5;
try {
final UriExtractionNamespace namespace = getUriExtractionNamespace((long) 5);
try (CacheScheduler.Entry entry = scheduler.schedule(namespace)) {
final Future<?> future = entry.getUpdaterFuture();
entry.awaitNextUpdates(numWaits);
Assert.assertFalse(future.isDone());
}
} finally {
lifecycle.stop();
}
while (!cacheManager.waitForServiceToEnd(1_000, TimeUnit.MILLISECONDS)) {
// keep waiting
}
Assert.assertTrue(scheduler.updatesStarted() >= numWaits);
checkNoMoreRunning();
}
Aggregations