suneet-s commented on code in PR #15445:
URL: https://github.com/apache/druid/pull/15445#discussion_r1439912163


##########
extensions-contrib/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesAndWorkerTaskRunnerFactory.java:
##########
@@ -43,7 +46,7 @@ public class KubernetesAndWorkerTaskRunnerFactory implements 
TaskRunnerFactory<K
   public KubernetesAndWorkerTaskRunnerFactory(
       KubernetesTaskRunnerFactory kubernetesTaskRunnerFactory,
       HttpRemoteTaskRunnerFactory httpRemoteTaskRunnerFactory,
-      RemoteTaskRunnerFactory remoteTaskRunnerFactory,
+      @Nullable RemoteTaskRunnerFactory remoteTaskRunnerFactory,

Review Comment:
   The pattern I've usually seen here is to inject a `Provider<X>` into the 
constructor and then use the config to decide whether or not to call 
`Provider.get()` 
https://github.com/google/guice/wiki/InjectingProviders#injecting-providers. 
   
   Would this technique work? It seems slightly easier to follow as 
`RemoteTaskRunnerFactory` is already injectable from another module, so I'm not 
certain what the expected behavior is when 2 modules try to inject the same 
class.



##########
extensions-contrib/kubernetes-overlord-extensions/src/test/java/org/apache/druid/k8s/overlord/KubernetesOverlordModuleTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.k8s.overlord;
+
+import com.google.inject.Provider;
+import org.apache.druid.indexing.overlord.RemoteTaskRunnerFactory;
+import org.apache.druid.indexing.overlord.hrtr.HttpRemoteTaskRunnerFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class KubernetesOverlordModuleTest
+{
+
+  @Mock
+  private Provider<RemoteTaskRunnerFactory> parentProvider;
+  @Mock
+  private KubernetesAndWorkerTaskRunnerConfig runnerConfig;
+  @Mock
+  private RemoteTaskRunnerFactory remoteTaskRunnerFactory;
+
+  private KubernetesOverlordModule module;
+
+  @Before
+  public void setUp()
+  {
+    module = new KubernetesOverlordModule();
+  }
+
+  @Test
+  public void test_provideNullRemoteTaskRunner_withHttpRunnerType()
+  {
+    
when(runnerConfig.getWorkerType()).thenReturn(HttpRemoteTaskRunnerFactory.TYPE_NAME);
+    assertNull(module.provideRemoteTaskRunnerFactory(parentProvider, 
runnerConfig));
+  }
+
+  @Test
+  public void test_provideRemoteTaskRunner_withRemoteRunnerType()
+  {
+    
when(runnerConfig.getWorkerType()).thenReturn(RemoteTaskRunnerFactory.TYPE_NAME);
+    when(parentProvider.get()).thenReturn(remoteTaskRunnerFactory);
+    assertSame(remoteTaskRunnerFactory, 
module.provideRemoteTaskRunnerFactory(parentProvider, runnerConfig));
+  }

Review Comment:
   Can we add a test here to see that the KubernetesAndWorkerTaskRunnerFactory 
is initialized correctly please



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to