use of org.apache.drill.exec.proto.UserBitShared.Registry in project drill by apache.
the class TestDynamicUDFSupport method testExceedRetryAttemptsDuringUnregistration.
@Test
public void testExceedRetryAttemptsDuringUnregistration() throws Exception {
RemoteFunctionRegistry remoteFunctionRegistry = spyRemoteFunctionRegistry();
Path registryPath = hadoopToJavaPath(remoteFunctionRegistry.getRegistryArea());
copyDefaultJarsToStagingArea();
test("create function using jar '%s'", defaultBinaryJar);
reset(remoteFunctionRegistry);
doThrow(new VersionMismatchException("Version mismatch detected", 1)).when(remoteFunctionRegistry).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
String summary = "Failed to update remote function registry. Exceeded retry attempts limit.";
testBuilder().sqlQuery("drop function using jar '%s'", defaultBinaryJar).unOrdered().baselineColumns("ok", "summary").baselineValues(false, summary).go();
verify(remoteFunctionRegistry, times(remoteFunctionRegistry.getRetryAttempts() + 1)).updateRegistry(any(Registry.class), any(DataChangeVersion.class));
assertTrue("Binary should be present in registry area", registryPath.resolve(defaultBinaryJar).toFile().exists());
assertTrue("Source should be present in registry area", registryPath.resolve(defaultSourceJar).toFile().exists());
Registry registry = remoteFunctionRegistry.getRegistry(new DataChangeVersion());
assertEquals("Registry should contain one jar", registry.getJarList().size(), 1);
assertEquals(registry.getJar(0).getName(), defaultBinaryJar);
}
use of org.apache.drill.exec.proto.UserBitShared.Registry in project drill by apache.
the class TestDynamicUDFSupport method testSuccessfulRegistration.
@Test
public void testSuccessfulRegistration() throws Exception {
copyDefaultJarsToStagingArea();
String summary = "The following UDFs in jar %s have been registered:\n" + "[custom_lower(VARCHAR-REQUIRED)]";
testBuilder().sqlQuery("create function using jar '%s'", defaultBinaryJar).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format(summary, defaultBinaryJar)).go();
RemoteFunctionRegistry remoteFunctionRegistry = getDrillbitContext().getRemoteFunctionRegistry();
FileSystem fs = remoteFunctionRegistry.getFs();
assertFalse("Staging area should be empty", fs.listFiles(remoteFunctionRegistry.getStagingArea(), false).hasNext());
assertFalse("Temporary area should be empty", fs.listFiles(remoteFunctionRegistry.getTmpArea(), false).hasNext());
Path path = hadoopToJavaPath(remoteFunctionRegistry.getRegistryArea());
assertTrue("Binary should be present in registry area", path.resolve(defaultBinaryJar).toFile().exists());
assertTrue("Source should be present in registry area", path.resolve(defaultBinaryJar).toFile().exists());
Registry registry = remoteFunctionRegistry.getRegistry(new DataChangeVersion());
assertEquals("Registry should contain one jar", registry.getJarList().size(), 1);
assertEquals(registry.getJar(0).getName(), defaultBinaryJar);
}
Aggregations