You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/01/28 07:43:23 UTC

[GitHub] [flink] wangyang0918 commented on a change in pull request #18461: [FLINK-20830][Kubernetes]Add type of Headless_Cluster_IP for external…

wangyang0918 commented on a change in pull request #18461:
URL: https://github.com/apache/flink/pull/18461#discussion_r794261375



##########
File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/services/ServiceTypeTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.flink.kubernetes.kubeclient.services;
+
+import org.apache.flink.kubernetes.KubernetesClientTestBase;
+import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/** Tests for {@link ServiceType}. */
+public class ServiceTypeTest extends KubernetesClientTestBase {
+
+    @Test
+    public void testServiceClassify() {
+        Assert.assertEquals(

Review comment:
       Let's trying to using the `org.hamcrest.MatcherAssert.assertThat` in the new introduced test.

##########
File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/KubernetesClientTestBase.java
##########
@@ -174,13 +179,29 @@ protected Service buildExternalServiceWithClusterIP() {
                         .build();
 
         return buildExternalService(
-                KubernetesConfigOptions.ServiceExposedType.ClusterIP, servicePort, null);
+                KubernetesConfigOptions.ServiceExposedType.ClusterIP, servicePort, null, null);
+    }
+
+    protected Service buildExternalServiceWithHeadlessClusterIP() {
+        final ServicePort servicePort =
+                new ServicePortBuilder()
+                        .withName(Constants.REST_PORT_NAME)
+                        .withPort(REST_PORT)
+                        .withNewTargetPort(REST_PORT)
+                        .build();
+
+        return buildExternalService(
+                KubernetesConfigOptions.ServiceExposedType.ClusterIP,
+                servicePort,
+                null,
+                HeadlessClusterIPService.HEADLESS_CLUSTER_IP);
     }
 
     private Service buildExternalService(
             KubernetesConfigOptions.ServiceExposedType serviceExposedType,
             ServicePort servicePort,
-            @Nullable ServiceStatus serviceStatus) {
+            @Nullable ServiceStatus serviceStatus,
+            @Nullable String clusterIP) {

Review comment:
       I think `boolean isHeadlessSvc` might be better here.

##########
File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java
##########
@@ -126,15 +126,16 @@ public String getClusterDescription() {
 
     private String getWebMonitorAddress(Configuration configuration) throws Exception {
         AddressResolution resolution = AddressResolution.TRY_ADDRESS_RESOLUTION;
-        if (configuration.get(KubernetesConfigOptions.REST_SERVICE_EXPOSED_TYPE)
-                == KubernetesConfigOptions.ServiceExposedType.ClusterIP) {
+        KubernetesConfigOptions.ServiceExposedType serviceType =

Review comment:
       nit: `serviceType` could be final.

##########
File path: flink-kubernetes/src/test/java/org/apache/flink/kubernetes/kubeclient/decorators/ExternalServiceDecoratorTest.java
##########
@@ -118,5 +119,17 @@ public void testSetServiceExposedType() throws IOException {
         assertEquals(
                 KubernetesConfigOptions.ServiceExposedType.ClusterIP.name(),
                 ((Service) servicesWithClusterIP.get(0)).getSpec().getType());
+

Review comment:
       Have such assert into a separate test looks better. And let's try to use the `assertThat` in the new introduced test.




-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org