davsclaus commented on code in PR #25611: URL: https://github.com/apache/camel/pull/25611#discussion_r3863240131
########## components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/cluster/integration/ZooKeeperClusterViewLeadershipLostIT.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.camel.component.zookeeper.cluster.integration; + +import java.util.concurrent.TimeUnit; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.cluster.CamelClusterView; +import org.apache.camel.component.zookeeper.cluster.ZooKeeperClusterService; +import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.impl.cluster.ClusteredRoutePolicy; +import org.apache.camel.test.infra.common.services.ContainerService; +import org.apache.camel.test.infra.zookeeper.services.ZooKeeperService; +import org.apache.camel.test.infra.zookeeper.services.ZooKeeperServiceFactory; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.testcontainers.containers.GenericContainer; + +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ZooKeeperClusterViewLeadershipLostIT { + + private static final String NAMESPACE = "my-ns"; + private static final String ROUTE_ID = "clustered-route"; + + @RegisterExtension + static ZooKeeperService service = ZooKeeperServiceFactory.createService(); + + @Test + void leadershipIsReleasedAndReacquiredAroundAZooKeeperOutage() throws Exception { + GenericContainer<?> zooKeeper = ((ContainerService<?>) service).getContainer(); Review Comment: Minor/non-blocking: `((ContainerService<?>) service).getContainer()` assumes `ZooKeeperServiceFactory.createService()` resolves to the local-container mapping. If this module's ITs ever run against the remote-infra mapping (`ZooKeeperRemoteService`), this cast throws `ClassCastException` instead of failing/skipping cleanly. Low risk given no evidence this module's CI uses remote infra today, but worth a defensive `instanceof` check if that ever changes. ########## components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/cluster/ZooKeeperClusterView.java: ########## @@ -110,6 +111,7 @@ protected void doStart() throws Exception { if (leaderSelector == null) { leaderSelector = new LeaderSelector(client, getFullPath(), new CamelLeaderElectionListener()); leaderSelector.setId(getClusterService().getId()); + leaderSelector.autoRequeue(); leaderSelector.start(); } else { leaderSelector.requeue(); Review Comment: Minor/non-blocking: since `doStop()` now unconditionally nulls `leaderSelector`, and `doStart()` can only be re-invoked after a `stop()`, `leaderSelector` will always be `null` here on entry — the `else { leaderSelector.requeue(); }` branch (and the `if (leaderSelector != null)` guard in `doShutdown()`) is now effectively dead code. Not a bug, just worth a follow-up cleanup. -- 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]
