gyfora commented on a change in pull request #44: URL: https://github.com/apache/flink-kubernetes-operator/pull/44#discussion_r832925421
########## File path: flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/FlinkOperatorTest.java ########## @@ -0,0 +1,50 @@ +/* + * 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.operator; + +import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration; +import org.apache.flink.kubernetes.operator.utils.FlinkUtils; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; + +/** @link FlinkOperator unit tests. */ +public class FlinkOperatorTest { + + @Test + public void testExecutorServiceUsesReconciliationMaxParallelismFromConfig() { + final var defaultConfig = FlinkUtils.loadDefaultConfig(); + final var operatorConfig = + FlinkOperatorConfiguration.fromConfiguration(defaultConfig.getOperatorConfig()); + final int maxParallelism = operatorConfig.getReconcilerMaxParallelism(); + final int threadCount = maxParallelism == -1 ? Integer.MAX_VALUE : maxParallelism; + System.out.println(threadCount); Review comment: pls remove print ########## File path: flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/FlinkOperatorTest.java ########## @@ -0,0 +1,50 @@ +/* + * 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.operator; + +import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration; +import org.apache.flink.kubernetes.operator.utils.FlinkUtils; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; + +/** @link FlinkOperator unit tests. */ +public class FlinkOperatorTest { + + @Test + public void testExecutorServiceUsesReconciliationMaxParallelismFromConfig() { + final var defaultConfig = FlinkUtils.loadDefaultConfig(); + final var operatorConfig = Review comment: We can remove the `final` keyword from everywhere in this method it's not really necessary and just adds more code ########## File path: flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/FlinkOperator.java ########## @@ -30,47 +31,55 @@ import org.apache.flink.kubernetes.operator.validation.FlinkDeploymentValidator; import io.fabric8.kubernetes.client.DefaultKubernetesClient; +import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.Operator; import io.javaoperatorsdk.operator.api.config.ConfigurationService; import io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider; import io.javaoperatorsdk.operator.config.runtime.DefaultConfigurationService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.concurrent.Executors; + /** Main Class for Flink native k8s operator. */ public class FlinkOperator { private static final Logger LOG = LoggerFactory.getLogger(FlinkOperator.class); - public static void main(String... args) { + private final Operator operator; + private final FlinkDeploymentController controller; + private final FlinkControllerConfig controllerConfig; + + public FlinkOperator() { LOG.info("Starting Flink Kubernetes Operator"); DefaultConfig defaultConfig = FlinkUtils.loadDefaultConfig(); OperatorMetricUtils.initOperatorMetrics(defaultConfig.getOperatorConfig()); - DefaultKubernetesClient client = new DefaultKubernetesClient(); + KubernetesClient client = new DefaultKubernetesClient(); String namespace = client.getNamespace(); if (namespace == null) { namespace = "default"; } - ConfigurationService configurationService = - new ConfigurationServiceOverrider(DefaultConfigurationService.instance()) - .checkingCRDAndValidateLocalModel(false) - .build(); - - Operator operator = new Operator(client, configurationService); - FlinkOperatorConfiguration operatorConfiguration = FlinkOperatorConfiguration.fromConfiguration(defaultConfig.getOperatorConfig()); + ConfigurationServiceOverrider configOverrider = + new ConfigurationServiceOverrider(DefaultConfigurationService.instance()) + .checkingCRDAndValidateLocalModel(false); + configOverrider = setupExecutorService(configOverrider, operatorConfiguration); + ConfigurationService configurationService = configOverrider.build(); Review comment: this is getting long we can move it into a dedicated method or one of the util classes and probably merge with `setupExecutorService` ########## File path: flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/FlinkOperatorTest.java ########## @@ -0,0 +1,50 @@ +/* + * 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.operator; + +import org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration; +import org.apache.flink.kubernetes.operator.utils.FlinkUtils; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; + +/** @link FlinkOperator unit tests. */ +public class FlinkOperatorTest { + + @Test + public void testExecutorServiceUsesReconciliationMaxParallelismFromConfig() { + final var defaultConfig = FlinkUtils.loadDefaultConfig(); Review comment: you should probably create the flink config directly by instantiating a `new Configuration` that will avoid env dependent test behavior and you can easily test the 2 expected behaviour modes here -- 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]
