You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/10/05 03:08:54 UTC

[GitHub] srkukarni closed pull request #2726: Mock out the settting up k8 client part

srkukarni closed pull request #2726: Mock out the settting up k8 client part
URL: https://github.com/apache/pulsar/pull/2726
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 8ba750516d..cba9ebf2d6 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 void doAdmissionChecks(Function.FunctionDetails functionDetails) {
         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 6ed11b34fe..417516ff14 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.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 KubernetesRuntimeTest() throws Exception {
         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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services