gyfora commented on code in PR #512:
URL:
https://github.com/apache/flink-kubernetes-operator/pull/512#discussion_r1098514245
##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/HealthProbeTest.java:
##########
@@ -15,37 +15,51 @@
* limitations under the License.
*/
-package org.apache.flink.kubernetes.operator.health;
+package org.apache.flink.kubernetes.operator;
import org.apache.flink.configuration.Configuration;
-import org.apache.flink.kubernetes.operator.config.FlinkConfigManager;
import
org.apache.flink.kubernetes.operator.config.KubernetesOperatorConfigOptions;
+import org.apache.flink.kubernetes.operator.health.HealthProbe;
import org.apache.flink.util.NetUtils;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
+import io.javaoperatorsdk.operator.Operator;
import org.junit.jupiter.api.Test;
import java.net.HttpURLConnection;
import java.net.URL;
import static
org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus.OK;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-/** Test for Health probe and endpoint logic. */
-public class OperatorHealthServiceTest {
+/** @link Health probe unit tests */
+@EnableKubernetesMockClient(crud = true)
+public class HealthProbeTest {
+ KubernetesClient client;
@Test
- public void testHealthService() throws Exception {
+ public void testHealthProbe() throws Exception {
try (var port = NetUtils.getAvailablePort()) {
var conf = new Configuration();
conf.set(KubernetesOperatorConfigOptions.OPERATOR_HEALTH_PROBE_PORT,
port.getPort());
- var healthService = new OperatorHealthService(new
FlinkConfigManager(conf));
- healthService.start();
- assertTrue(callHealthEndpoint(conf));
- HealthProbe.INSTANCE.markUnhealthy();
- assertFalse(callHealthEndpoint(conf));
- healthService.stop();
+ FlinkOperator operator =
+ new FlinkOperator(conf) {
+ Operator createOperator() {
+ return new Operator(client);
+ }
+ };
+ try {
Review Comment:
It's true, unfortunately the operator is not very testable this way (not
easy to mock and also it's impossible to restart the operator). We can assume
that method works correctly I think
--
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]