Search in sources :

Example 1 with KubernetesRuntimeFactoryConfig

use of org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig in project pulsar by yahoo.

the class FunctionRuntimeManagerTest method testExternallyManagedRuntimeUpdate.

@Test
public void testExternallyManagedRuntimeUpdate() throws Exception {
    WorkerConfig workerConfig = new WorkerConfig();
    workerConfig.setWorkerId("worker-1");
    workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
    workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(new KubernetesRuntimeFactoryConfig().setSubmittingInsidePod(false), Map.class));
    workerConfig.setPulsarServiceUrl(PULSAR_SERVICE_URL);
    workerConfig.setStateStorageServiceUrl("foo");
    workerConfig.setPulsarFunctionsCluster("cluster");
    PulsarClient pulsarClient = mock(PulsarClient.class);
    ReaderBuilder readerBuilder = mock(ReaderBuilder.class);
    doReturn(readerBuilder).when(pulsarClient).newReader();
    doReturn(readerBuilder).when(readerBuilder).topic(anyString());
    doReturn(readerBuilder).when(readerBuilder).startMessageId(any());
    doReturn(readerBuilder).when(readerBuilder).readCompacted(anyBoolean());
    doReturn(mock(Reader.class)).when(readerBuilder).create();
    PulsarWorkerService workerService = mock(PulsarWorkerService.class);
    doReturn(pulsarClient).when(workerService).getClient();
    doReturn(mock(PulsarAdmin.class)).when(workerService).getFunctionAdmin();
    KubernetesRuntimeFactory kubernetesRuntimeFactory = mock(KubernetesRuntimeFactory.class);
    doNothing().when(kubernetesRuntimeFactory).initialize(any(WorkerConfig.class), any(AuthenticationConfig.class), any(SecretsProviderConfigurator.class), any(), any(), any());
    doNothing().when(kubernetesRuntimeFactory).setupClient();
    doReturn(true).when(kubernetesRuntimeFactory).externallyManaged();
    KubernetesRuntime kubernetesRuntime = mock(KubernetesRuntime.class);
    doReturn(kubernetesRuntime).when(kubernetesRuntimeFactory).createContainer(any(), any(), any(), any());
    FunctionActioner functionActioner = spy(new FunctionActioner(workerConfig, kubernetesRuntimeFactory, null, null, null, null));
    try (final MockedStatic<RuntimeFactory> runtimeFactoryMockedStatic = Mockito.mockStatic(RuntimeFactory.class)) {
        runtimeFactoryMockedStatic.when(() -> RuntimeFactory.getFuntionRuntimeFactory(anyString())).thenAnswer(invocation -> kubernetesRuntimeFactory);
        // test new assignment update functions
        FunctionRuntimeManager functionRuntimeManager = new FunctionRuntimeManager(workerConfig, workerService, mock(Namespace.class), mock(MembershipManager.class), mock(ConnectorsManager.class), mock(FunctionsManager.class), mock(FunctionMetaDataManager.class), mock(WorkerStatsManager.class), mock(ErrorNotifier.class));
        functionRuntimeManager.setFunctionActioner(functionActioner);
        Function.FunctionMetaData function1 = Function.FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath("path").build()).setFunctionDetails(Function.FunctionDetails.newBuilder().setTenant("test-tenant").setNamespace("test-namespace").setName("func-1")).build();
        Function.Assignment assignment1 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        /**
         * Test transfer from me to other worker *
         */
        // add existing assignments
        functionRuntimeManager.setAssignment(assignment1);
        // new assignment with different worker
        Function.Assignment assignment2 = Function.Assignment.newBuilder().setWorkerId("worker-2").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        Function.Instance instance = Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build();
        FunctionRuntimeInfo functionRuntimeInfo = new FunctionRuntimeInfo().setFunctionInstance(instance).setRuntimeSpawner(functionActioner.getRuntimeSpawner(instance, function1.getPackageLocation().getPackagePath()));
        functionRuntimeManager.functionRuntimeInfos.put("test-tenant/test-namespace/func-1:0", functionRuntimeInfo);
        functionRuntimeManager.processAssignment(assignment2);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-2").get("test-tenant/test-namespace/func-1:0"), assignment2);
        assertNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0"));
        /**
         * Test transfer from other worker to me *
         */
        Function.Assignment assignment3 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        functionRuntimeManager.processAssignment(assignment3);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-1").get("test-tenant/test-namespace/func-1:0"), assignment3);
        assertNull(functionRuntimeManager.workerIdToAssignments.get("worker-2"));
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getFunctionInstance(), functionRuntimeInfo.getFunctionInstance());
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getFunctionDetails(), function1.getFunctionDetails());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getInstanceId(), instance.getInstanceId());
        assertTrue(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntimeFactory() instanceof KubernetesRuntimeFactory);
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntime());
        verify(kubernetesRuntime, times(1)).reinitialize();
    }
}
Also used : Reader(org.apache.pulsar.client.api.Reader) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) Function(org.apache.pulsar.functions.proto.Function) PulsarClient(org.apache.pulsar.client.api.PulsarClient) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) RuntimeFactory(org.apache.pulsar.functions.runtime.RuntimeFactory) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) ProcessRuntimeFactory(org.apache.pulsar.functions.runtime.process.ProcessRuntimeFactory) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) KubernetesRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig) Namespace(org.apache.distributedlog.api.namespace.Namespace) AuthenticationConfig(org.apache.pulsar.functions.instance.AuthenticationConfig) SecretsProviderConfigurator(org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator) KubernetesRuntime(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntime) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 2 with KubernetesRuntimeFactoryConfig

use of org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig in project incubator-pulsar by apache.

the class FunctionRuntimeManagerTest method testExternallyManagedRuntimeUpdate.

@Test
public void testExternallyManagedRuntimeUpdate() throws Exception {
    WorkerConfig workerConfig = new WorkerConfig();
    workerConfig.setWorkerId("worker-1");
    workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
    workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(new KubernetesRuntimeFactoryConfig().setSubmittingInsidePod(false), Map.class));
    workerConfig.setPulsarServiceUrl(PULSAR_SERVICE_URL);
    workerConfig.setStateStorageServiceUrl("foo");
    workerConfig.setPulsarFunctionsCluster("cluster");
    PulsarClient pulsarClient = mock(PulsarClient.class);
    ReaderBuilder readerBuilder = mock(ReaderBuilder.class);
    doReturn(readerBuilder).when(pulsarClient).newReader();
    doReturn(readerBuilder).when(readerBuilder).topic(anyString());
    doReturn(readerBuilder).when(readerBuilder).startMessageId(any());
    doReturn(readerBuilder).when(readerBuilder).readCompacted(anyBoolean());
    doReturn(mock(Reader.class)).when(readerBuilder).create();
    PulsarWorkerService workerService = mock(PulsarWorkerService.class);
    doReturn(pulsarClient).when(workerService).getClient();
    doReturn(mock(PulsarAdmin.class)).when(workerService).getFunctionAdmin();
    KubernetesRuntimeFactory kubernetesRuntimeFactory = mock(KubernetesRuntimeFactory.class);
    doNothing().when(kubernetesRuntimeFactory).initialize(any(WorkerConfig.class), any(AuthenticationConfig.class), any(SecretsProviderConfigurator.class), any(), any(), any());
    doNothing().when(kubernetesRuntimeFactory).setupClient();
    doReturn(true).when(kubernetesRuntimeFactory).externallyManaged();
    KubernetesRuntime kubernetesRuntime = mock(KubernetesRuntime.class);
    doReturn(kubernetesRuntime).when(kubernetesRuntimeFactory).createContainer(any(), any(), any(), any());
    FunctionActioner functionActioner = spy(new FunctionActioner(workerConfig, kubernetesRuntimeFactory, null, null, null, null));
    try (final MockedStatic<RuntimeFactory> runtimeFactoryMockedStatic = Mockito.mockStatic(RuntimeFactory.class)) {
        runtimeFactoryMockedStatic.when(() -> RuntimeFactory.getFuntionRuntimeFactory(anyString())).thenAnswer(invocation -> kubernetesRuntimeFactory);
        // test new assignment update functions
        FunctionRuntimeManager functionRuntimeManager = new FunctionRuntimeManager(workerConfig, workerService, mock(Namespace.class), mock(MembershipManager.class), mock(ConnectorsManager.class), mock(FunctionsManager.class), mock(FunctionMetaDataManager.class), mock(WorkerStatsManager.class), mock(ErrorNotifier.class));
        functionRuntimeManager.setFunctionActioner(functionActioner);
        Function.FunctionMetaData function1 = Function.FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath("path").build()).setFunctionDetails(Function.FunctionDetails.newBuilder().setTenant("test-tenant").setNamespace("test-namespace").setName("func-1")).build();
        Function.Assignment assignment1 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        /**
         * Test transfer from me to other worker *
         */
        // add existing assignments
        functionRuntimeManager.setAssignment(assignment1);
        // new assignment with different worker
        Function.Assignment assignment2 = Function.Assignment.newBuilder().setWorkerId("worker-2").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        Function.Instance instance = Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build();
        FunctionRuntimeInfo functionRuntimeInfo = new FunctionRuntimeInfo().setFunctionInstance(instance).setRuntimeSpawner(functionActioner.getRuntimeSpawner(instance, function1.getPackageLocation().getPackagePath()));
        functionRuntimeManager.functionRuntimeInfos.put("test-tenant/test-namespace/func-1:0", functionRuntimeInfo);
        functionRuntimeManager.processAssignment(assignment2);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-2").get("test-tenant/test-namespace/func-1:0"), assignment2);
        assertNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0"));
        /**
         * Test transfer from other worker to me *
         */
        Function.Assignment assignment3 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        functionRuntimeManager.processAssignment(assignment3);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-1").get("test-tenant/test-namespace/func-1:0"), assignment3);
        assertNull(functionRuntimeManager.workerIdToAssignments.get("worker-2"));
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getFunctionInstance(), functionRuntimeInfo.getFunctionInstance());
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getFunctionDetails(), function1.getFunctionDetails());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getInstanceId(), instance.getInstanceId());
        assertTrue(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntimeFactory() instanceof KubernetesRuntimeFactory);
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntime());
        verify(kubernetesRuntime, times(1)).reinitialize();
    }
}
Also used : Reader(org.apache.pulsar.client.api.Reader) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) Function(org.apache.pulsar.functions.proto.Function) PulsarClient(org.apache.pulsar.client.api.PulsarClient) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) RuntimeFactory(org.apache.pulsar.functions.runtime.RuntimeFactory) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) ProcessRuntimeFactory(org.apache.pulsar.functions.runtime.process.ProcessRuntimeFactory) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) KubernetesRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig) Namespace(org.apache.distributedlog.api.namespace.Namespace) AuthenticationConfig(org.apache.pulsar.functions.instance.AuthenticationConfig) SecretsProviderConfigurator(org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator) KubernetesRuntime(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntime) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 3 with KubernetesRuntimeFactoryConfig

use of org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig in project pulsar by apache.

the class FunctionRuntimeManagerTest method testExternallyManagedRuntimeUpdate.

@Test
public void testExternallyManagedRuntimeUpdate() throws Exception {
    WorkerConfig workerConfig = new WorkerConfig();
    workerConfig.setWorkerId("worker-1");
    workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
    workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(new KubernetesRuntimeFactoryConfig().setSubmittingInsidePod(false), Map.class));
    workerConfig.setPulsarServiceUrl(PULSAR_SERVICE_URL);
    workerConfig.setStateStorageServiceUrl("foo");
    workerConfig.setPulsarFunctionsCluster("cluster");
    PulsarClient pulsarClient = mock(PulsarClient.class);
    ReaderBuilder readerBuilder = mock(ReaderBuilder.class);
    doReturn(readerBuilder).when(pulsarClient).newReader();
    doReturn(readerBuilder).when(readerBuilder).topic(anyString());
    doReturn(readerBuilder).when(readerBuilder).startMessageId(any());
    doReturn(readerBuilder).when(readerBuilder).readCompacted(anyBoolean());
    doReturn(mock(Reader.class)).when(readerBuilder).create();
    PulsarWorkerService workerService = mock(PulsarWorkerService.class);
    doReturn(pulsarClient).when(workerService).getClient();
    doReturn(mock(PulsarAdmin.class)).when(workerService).getFunctionAdmin();
    KubernetesRuntimeFactory kubernetesRuntimeFactory = mock(KubernetesRuntimeFactory.class);
    doNothing().when(kubernetesRuntimeFactory).initialize(any(WorkerConfig.class), any(AuthenticationConfig.class), any(SecretsProviderConfigurator.class), any(), any(), any());
    doNothing().when(kubernetesRuntimeFactory).setupClient();
    doReturn(true).when(kubernetesRuntimeFactory).externallyManaged();
    KubernetesRuntime kubernetesRuntime = mock(KubernetesRuntime.class);
    doReturn(kubernetesRuntime).when(kubernetesRuntimeFactory).createContainer(any(), any(), any(), any());
    FunctionActioner functionActioner = spy(new FunctionActioner(workerConfig, kubernetesRuntimeFactory, null, null, null, null));
    try (final MockedStatic<RuntimeFactory> runtimeFactoryMockedStatic = Mockito.mockStatic(RuntimeFactory.class)) {
        runtimeFactoryMockedStatic.when(() -> RuntimeFactory.getFuntionRuntimeFactory(anyString())).thenAnswer(invocation -> kubernetesRuntimeFactory);
        // test new assignment update functions
        FunctionRuntimeManager functionRuntimeManager = new FunctionRuntimeManager(workerConfig, workerService, mock(Namespace.class), mock(MembershipManager.class), mock(ConnectorsManager.class), mock(FunctionsManager.class), mock(FunctionMetaDataManager.class), mock(WorkerStatsManager.class), mock(ErrorNotifier.class));
        functionRuntimeManager.setFunctionActioner(functionActioner);
        Function.FunctionMetaData function1 = Function.FunctionMetaData.newBuilder().setPackageLocation(Function.PackageLocationMetaData.newBuilder().setPackagePath("path").build()).setFunctionDetails(Function.FunctionDetails.newBuilder().setTenant("test-tenant").setNamespace("test-namespace").setName("func-1")).build();
        Function.Assignment assignment1 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        /**
         * Test transfer from me to other worker *
         */
        // add existing assignments
        functionRuntimeManager.setAssignment(assignment1);
        // new assignment with different worker
        Function.Assignment assignment2 = Function.Assignment.newBuilder().setWorkerId("worker-2").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        Function.Instance instance = Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build();
        FunctionRuntimeInfo functionRuntimeInfo = new FunctionRuntimeInfo().setFunctionInstance(instance).setRuntimeSpawner(functionActioner.getRuntimeSpawner(instance, function1.getPackageLocation().getPackagePath()));
        functionRuntimeManager.functionRuntimeInfos.put("test-tenant/test-namespace/func-1:0", functionRuntimeInfo);
        functionRuntimeManager.processAssignment(assignment2);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-2").get("test-tenant/test-namespace/func-1:0"), assignment2);
        assertNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0"));
        /**
         * Test transfer from other worker to me *
         */
        Function.Assignment assignment3 = Function.Assignment.newBuilder().setWorkerId("worker-1").setInstance(Function.Instance.newBuilder().setFunctionMetaData(function1).setInstanceId(0).build()).build();
        functionRuntimeManager.processAssignment(assignment3);
        // make sure nothing is called
        verify(functionActioner, times(0)).startFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).terminateFunction(any(FunctionRuntimeInfo.class));
        verify(functionActioner, times(0)).stopFunction(any(FunctionRuntimeInfo.class));
        assertEquals(functionRuntimeManager.workerIdToAssignments.get("worker-1").get("test-tenant/test-namespace/func-1:0"), assignment3);
        assertNull(functionRuntimeManager.workerIdToAssignments.get("worker-2"));
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getFunctionInstance(), functionRuntimeInfo.getFunctionInstance());
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getFunctionDetails(), function1.getFunctionDetails());
        assertEquals(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getInstanceConfig().getInstanceId(), instance.getInstanceId());
        assertTrue(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntimeFactory() instanceof KubernetesRuntimeFactory);
        assertNotNull(functionRuntimeManager.functionRuntimeInfos.get("test-tenant/test-namespace/func-1:0").getRuntimeSpawner().getRuntime());
        verify(kubernetesRuntime, times(1)).reinitialize();
    }
}
Also used : Reader(org.apache.pulsar.client.api.Reader) ReaderBuilder(org.apache.pulsar.client.api.ReaderBuilder) Function(org.apache.pulsar.functions.proto.Function) PulsarClient(org.apache.pulsar.client.api.PulsarClient) PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) RuntimeFactory(org.apache.pulsar.functions.runtime.RuntimeFactory) KubernetesRuntimeFactory(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory) ProcessRuntimeFactory(org.apache.pulsar.functions.runtime.process.ProcessRuntimeFactory) ThreadRuntimeFactory(org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory) KubernetesRuntimeFactoryConfig(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig) Namespace(org.apache.distributedlog.api.namespace.Namespace) AuthenticationConfig(org.apache.pulsar.functions.instance.AuthenticationConfig) SecretsProviderConfigurator(org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator) KubernetesRuntime(org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntime) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Aggregations

HashMap (java.util.HashMap)3 Map (java.util.Map)3 Namespace (org.apache.distributedlog.api.namespace.Namespace)3 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)3 PulsarClient (org.apache.pulsar.client.api.PulsarClient)3 Reader (org.apache.pulsar.client.api.Reader)3 ReaderBuilder (org.apache.pulsar.client.api.ReaderBuilder)3 AuthenticationConfig (org.apache.pulsar.functions.instance.AuthenticationConfig)3 Function (org.apache.pulsar.functions.proto.Function)3 RuntimeFactory (org.apache.pulsar.functions.runtime.RuntimeFactory)3 KubernetesRuntime (org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntime)3 KubernetesRuntimeFactory (org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactory)3 KubernetesRuntimeFactoryConfig (org.apache.pulsar.functions.runtime.kubernetes.KubernetesRuntimeFactoryConfig)3 ProcessRuntimeFactory (org.apache.pulsar.functions.runtime.process.ProcessRuntimeFactory)3 ThreadRuntimeFactory (org.apache.pulsar.functions.runtime.thread.ThreadRuntimeFactory)3 SecretsProviderConfigurator (org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator)3 Test (org.testng.annotations.Test)3