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

aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit e7a5d5fac60513ab74a7a3f7f1618b4a765be2cb
Author: aldettinger <aldettin...@gmail.com>
AuthorDate: Mon Sep 19 14:42:16 2022 +0200

    master-openshift: migrate itest to use kubernetes cluster service 
auto-configuration #4086
---
 integration-tests/master-openshift/pom.xml                        | 8 ++++++++
 .../apache/camel/quarkus/component/master/it/MasterRoutes.java    | 5 -----
 .../master-openshift/src/main/resources/application.properties    | 3 +++
 .../camel/quarkus/component/master/it/MasterOpenShiftTest.java    | 7 +++++--
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/integration-tests/master-openshift/pom.xml 
b/integration-tests/master-openshift/pom.xml
index e1fc7dc9f1..1986fbc177 100644
--- a/integration-tests/master-openshift/pom.xml
+++ b/integration-tests/master-openshift/pom.xml
@@ -134,6 +134,10 @@
                                     <systemProperties>
                                         
<quarkus.runner>${quarkus.runner}</quarkus.runner>
                                     </systemProperties>
+                                    <environmentVariables>
+                                        <!-- Fake KubernetesClusterService so 
it assumes being run from a pod named leader  -->
+                                        <HOSTNAME>leader</HOSTNAME>
+                                    </environmentVariables>
                                 </configuration>
                             </execution>
                         </executions>
@@ -170,6 +174,10 @@
                             <systemProperties>
                                 
<quarkus.runner>${quarkus.runner}</quarkus.runner>
                             </systemProperties>
+                            <environmentVariables>
+                                <!-- Fake KubernetesClusterService so it 
assumes being run from a pod named leader  -->
+                                <HOSTNAME>leader</HOSTNAME>
+                            </environmentVariables>
                         </configuration>
                     </plugin>
                 </plugins>
diff --git 
a/integration-tests/master-openshift/src/main/java/org/apache/camel/quarkus/component/master/it/MasterRoutes.java
 
b/integration-tests/master-openshift/src/main/java/org/apache/camel/quarkus/component/master/it/MasterRoutes.java
index f2e669da23..a306c469d0 100644
--- 
a/integration-tests/master-openshift/src/main/java/org/apache/camel/quarkus/component/master/it/MasterRoutes.java
+++ 
b/integration-tests/master-openshift/src/main/java/org/apache/camel/quarkus/component/master/it/MasterRoutes.java
@@ -20,7 +20,6 @@ import javax.enterprise.context.ApplicationScoped;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.kubernetes.cluster.KubernetesClusterService;
 import org.eclipse.microprofile.config.inject.ConfigProperty;
 
 @ApplicationScoped
@@ -31,10 +30,6 @@ public class MasterRoutes extends RouteBuilder {
 
     @Override
     public void configure() throws Exception {
-        KubernetesClusterService clusterService = new 
KubernetesClusterService();
-        clusterService.setPodName(applicationId);
-        getContext().addService(clusterService);
-
         // Output the id of the application into a file
         from("master:ns:timer:test?period=100")
                 .id("leader")
diff --git 
a/integration-tests/master-openshift/src/main/resources/application.properties 
b/integration-tests/master-openshift/src/main/resources/application.properties
index 0054a293a2..c2751a5943 100644
--- 
a/integration-tests/master-openshift/src/main/resources/application.properties
+++ 
b/integration-tests/master-openshift/src/main/resources/application.properties
@@ -16,3 +16,6 @@
 ## ---------------------------------------------------------------------------
 
 application.id = leader
+
+quarkus.camel.cluster.kubernetes.enabled = true
+quarkus.camel.cluster.kubernetes.rebalancing = false
diff --git 
a/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
 
b/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
index 40d9f89277..6714a4696c 100644
--- 
a/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
+++ 
b/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
 
 import io.fabric8.openshift.client.server.mock.OpenShiftServer;
 import io.quarkus.test.common.QuarkusTestResource;
@@ -38,6 +39,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
+import org.zeroturnaround.exec.ProcessExecutor;
 import org.zeroturnaround.exec.StartedProcess;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -72,8 +74,9 @@ class MasterOpenShiftTest {
                 "-Dkubernetes.auth.tryServiceAccount=" + 
config.getValue("kubernetes.auth.tryServiceAccount", String.class));
         jvmArgs.add("-Dhttp2.disable=" + config.getValue("http2.disable", 
String.class));
 
-        // Start secondary application process
-        QuarkusProcessExecutor quarkusProcessExecutor = new 
QuarkusProcessExecutor(jvmArgs.toArray(String[]::new));
+        // Start secondary application process faking KubernetesClusterService 
so it assumes being run from a pod named follower
+        Consumer<ProcessExecutor> customizer = pe -> 
pe.environment("HOSTNAME", "follower");
+        QuarkusProcessExecutor quarkusProcessExecutor = new 
QuarkusProcessExecutor(customizer, jvmArgs.toArray(String[]::new));
         StartedProcess process = quarkusProcessExecutor.start();
 
         // Wait until the process is fully initialized

Reply via email to