You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by sa...@apache.org on 2018/10/05 03:09:07 UTC

[pulsar] branch master updated: Mock out the settting up k8 client part (#2726)

This is an automated email from the ASF dual-hosted git repository.

sanjeevrk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new c7b9119  Mock out the settting up k8 client part (#2726)
c7b9119 is described below

commit c7b911921219f374d11c20ea1e1fb8109e985543
Author: Sanjeev Kulkarni <sa...@gmail.com>
AuthorDate: Thu Oct 4 20:08:52 2018 -0700

    Mock out the settting up k8 client part (#2726)
---
 .../apache/pulsar/functions/runtime/KubernetesRuntimeFactory.java  | 3 ++-
 .../org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeFactory.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeFactory.java
index 8ba7505..cba9ebf 100644
--- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeFactory.java
+++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeFactory.java
@@ -141,7 +141,8 @@ public class KubernetesRuntimeFactory implements RuntimeFactory {
         KubernetesRuntime.doChecks(functionDetails);
     }
 
-    private void setupClient() throws Exception {
+    @VisibleForTesting
+    void setupClient() throws Exception {
         if (appsClient == null) {
             if (k8Uri == null) {
                 log.info("k8Uri is null thus going by defaults");
diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java
index 6ed11b3..417516f 100644
--- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java
+++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java
@@ -32,6 +32,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static org.powermock.api.mockito.PowerMockito.doNothing;
+import static org.powermock.api.mockito.PowerMockito.spy;
 import static org.testng.Assert.assertEquals;
 
 /**
@@ -67,8 +69,9 @@ public class KubernetesRuntimeTest {
         this.pulsarAdminUrl = "http://localhost:8080";
         this.stateStorageServiceUrl = "bk://localhost:4181";
         this.logDirectory = "logs/functions";
-        this.factory = new KubernetesRuntimeFactory(null, null, null, null,
-            false, null, pulsarServiceUrl, pulsarAdminUrl, stateStorageServiceUrl, null);
+        this.factory = spy(new KubernetesRuntimeFactory(null, null, null, null,
+            false, null, pulsarServiceUrl, pulsarAdminUrl, stateStorageServiceUrl, null));
+        doNothing().when(this.factory).setupClient();
     }
 
     @AfterMethod