use of org.apache.pulsar.functions.worker.WorkerUtils in project pulsar by apache.
the class SinkApiV3ResourceTest method testDeregisterSinkBKPackageCleanup.
@Test
public void testDeregisterSinkBKPackageCleanup() throws IOException {
mockInstanceUtils();
try (final MockedStatic<WorkerUtils> ctx = Mockito.mockStatic(WorkerUtils.class)) {
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);
String packagePath = "public/default/test/591541f0-c7c5-40c0-983b-610c722f90b0-pulsar-io-batch-data-generator-2.7.0.nar";
when(mockedManager.getFunctionMetaData(eq(tenant), eq(namespace), eq(sink))).thenReturn(FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath(packagePath).build()).build());
deregisterDefaultSink();
ctx.verify(() -> {
WorkerUtils.deleteFromBookkeeper(any(), eq(packagePath));
}, times(1));
}
}
use of org.apache.pulsar.functions.worker.WorkerUtils in project pulsar by apache.
the class SourceApiV3ResourceTest method testDeregisterFileSourceBKPackageCleanup.
@Test
public void testDeregisterFileSourceBKPackageCleanup() throws IOException {
String packagePath = "file://foo/connector.jar";
try (final MockedStatic<WorkerUtils> ctx = Mockito.mockStatic(WorkerUtils.class)) {
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(source))).thenReturn(true);
when(mockedManager.getFunctionMetaData(eq(tenant), eq(namespace), eq(source))).thenReturn(FunctionMetaData.newBuilder().setPackageLocation(PackageLocationMetaData.newBuilder().setPackagePath(packagePath).build()).build());
deregisterDefaultSource();
// if the source has a file url, we shouldn't try to clean it up
ctx.verify(() -> {
WorkerUtils.deleteFromBookkeeper(any(), eq(packagePath));
}, times(0));
}
}
use of org.apache.pulsar.functions.worker.WorkerUtils in project pulsar by apache.
the class SinkApiV3ResourceTest method testDeregisterBuiltinSinkBKPackageCleanup.
@Test
public void testDeregisterBuiltinSinkBKPackageCleanup() {
mockInstanceUtils();
try (final MockedStatic<WorkerUtils> ctx = Mockito.mockStatic(WorkerUtils.class)) {
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);
String packagePath = String.format("%s://data-generator", Utils.BUILTIN);
when(mockedManager.getFunctionMetaData(eq(tenant), eq(namespace), eq(sink))).thenReturn(FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath(packagePath).build()).build());
deregisterDefaultSink();
// if the sink is a builtin sink we shouldn't try to clean it up
ctx.verify(() -> {
WorkerUtils.deleteFromBookkeeper(any(), eq(packagePath));
}, times(0));
}
}
use of org.apache.pulsar.functions.worker.WorkerUtils in project pulsar by yahoo.
the class SinkApiV3ResourceTest method testDeregisterBuiltinSinkBKPackageCleanup.
@Test
public void testDeregisterBuiltinSinkBKPackageCleanup() {
mockInstanceUtils();
try (final MockedStatic<WorkerUtils> ctx = Mockito.mockStatic(WorkerUtils.class)) {
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);
String packagePath = String.format("%s://data-generator", Utils.BUILTIN);
when(mockedManager.getFunctionMetaData(eq(tenant), eq(namespace), eq(sink))).thenReturn(FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath(packagePath).build()).build());
deregisterDefaultSink();
// if the sink is a builtin sink we shouldn't try to clean it up
ctx.verify(() -> {
WorkerUtils.deleteFromBookkeeper(any(), eq(packagePath));
}, times(0));
}
}
use of org.apache.pulsar.functions.worker.WorkerUtils in project pulsar by yahoo.
the class SinkApiV3ResourceTest method testDeregisterSinkBKPackageCleanup.
@Test
public void testDeregisterSinkBKPackageCleanup() throws IOException {
mockInstanceUtils();
try (final MockedStatic<WorkerUtils> ctx = Mockito.mockStatic(WorkerUtils.class)) {
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(sink))).thenReturn(true);
String packagePath = "public/default/test/591541f0-c7c5-40c0-983b-610c722f90b0-pulsar-io-batch-data-generator-2.7.0.nar";
when(mockedManager.getFunctionMetaData(eq(tenant), eq(namespace), eq(sink))).thenReturn(FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath(packagePath).build()).build());
deregisterDefaultSink();
ctx.verify(() -> {
WorkerUtils.deleteFromBookkeeper(any(), eq(packagePath));
}, times(1));
}
}
Aggregations