tillrohrmann commented on a change in pull request #17485:
URL: https://github.com/apache/flink/pull/17485#discussion_r791738550



##########
File path: 
flink-kubernetes/src/test/java/org/apache/flink/kubernetes/highavailability/KubernetesMultipleComponentLeaderElectionDriverTest.java
##########
@@ -56,59 +62,179 @@
             new 
TestExecutorExtension<>(Executors::newSingleThreadScheduledExecutor);
 
     @Test
-    public void testElectionDriverGainsLeadership() throws 
InterruptedException {
-        final Configuration configuration = new Configuration();
-        configuration.setString(KubernetesConfigOptions.CLUSTER_ID, 
CLUSTER_ID);
-        final KubernetesLeaderElectionConfiguration 
leaderElectionConfiguration =
-                new KubernetesLeaderElectionConfiguration("foobar", "barfoo", 
configuration);
-
-        CompletableFuture<KubernetesLeaderElector.LeaderCallbackHandler>
-                leaderCallbackHandlerFuture = new CompletableFuture<>();
-        final FlinkKubeClient flinkKubeClient =
-                TestingFlinkKubeClient.builder()
-                        .setCreateLeaderElectorFunction(
-                                (leaderConfig, callbackHandler) -> {
-                                    
leaderCallbackHandlerFuture.complete(callbackHandler);
-                                    return new TestingFlinkKubeClient
-                                            .TestingKubernetesLeaderElector(
-                                            leaderConfig, callbackHandler);
-                                })
-                        .build();
-
-        final KubernetesConfigMapSharedWatcher configMapSharedWatcher =
-                flinkKubeClient.createConfigMapSharedWatcher(
-                        KubernetesUtils.getConfigMapLabels(
-                                CLUSTER_ID, 
LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY));
-
-        final TestingLeaderElectionListener leaderElectionListener =
-                new TestingLeaderElectionListener();
-
-        final KubernetesMultipleComponentLeaderElectionDriver 
leaderElectionDriver =
-                new KubernetesMultipleComponentLeaderElectionDriver(
-                        leaderElectionConfiguration,
-                        flinkKubeClient,
-                        leaderElectionListener,
-                        configMapSharedWatcher,
-                        testExecutorExtension.getExecutor(),
-                        
testingFatalErrorHandlerExtension.getTestingFatalErrorHandler());
-
-        final KubernetesLeaderElector.LeaderCallbackHandler 
leaderCallbackHandler =
-                leaderCallbackHandlerFuture.join();
-
-        leaderCallbackHandler.isLeader();
-
-        leaderElectionListener.await(LeaderElectionEvent.IsLeaderEvent.class);
+    public void testElectionDriverGainsLeadership() throws Exception {
+        new TestFixture() {
+            {
+                runTest(
+                        () -> {
+                            leaderCallbackGrantLeadership();
+                            
leaderElectionListener.await(LeaderElectionEvent.IsLeaderEvent.class);
+                        });
+            }
+        };
     }
 
     @Test
-    public void testElectionDriverLosesLeadership() throws Exception {}
+    public void testElectionDriverLosesLeadership() throws Exception {
+        new TestFixture() {
+            {
+                runTest(
+                        () -> {
+                            leaderCallbackGrantLeadership();

Review comment:
       This is not a test but the actual signal to give leadership to the 
contender.




-- 
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]


Reply via email to