gyfora commented on code in PR #955: URL: https://github.com/apache/flink-kubernetes-operator/pull/955#discussion_r1994984165
########## e2e-tests/test_batch_job.sh: ########## @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +################################################################################ +# 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. +################################################################################ + +# This script tests basic Flink batch job operations on Kubernetes: +# 1. Deploys a FlinkDeployment for a batch job. +# 2. Waits for the JobManager to become ready. +# 3. Verifies that the job reaches the FINISHED state (first check). +# 4. Sleeps for a configurable duration to test for state persistence. +# 5. Verifies that the job remains in the FINISHED state (second check). +# 6. Checks the operator logs for the expected job state transition message. +# 7. Checks the JobManager logs for successful application completion. +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +source "${SCRIPT_DIR}/utils.sh" + +CLUSTER_ID="flink-example-wordcount-batch" +APPLICATION_YAML="${SCRIPT_DIR}/data/flinkdep-batch-cr.yaml" +APPLICATION_IDENTIFIER="flinkdep/$CLUSTER_ID" +TIMEOUT=300 +SLEEP_DURATION=30 + +on_exit cleanup_and_exit "$APPLICATION_YAML" $TIMEOUT $CLUSTER_ID + +retry_times 5 30 "kubectl apply -f $APPLICATION_YAML" || exit 1 + +wait_for_jobmanager_running $CLUSTER_ID $TIMEOUT + +# Wait for the job to reach the FINISHED state (first check). +wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' FINISHED $TIMEOUT || exit 1 + +echo "Job reached FINISHED state. Sleeping for $SLEEP_DURATION seconds..." +sleep "$SLEEP_DURATION" + +# Verify the job is *still* in the FINISHED state (second check). +wait_for_status $APPLICATION_IDENTIFIER '.status.jobStatus.state' FINISHED $TIMEOUT || exit 1 Review Comment: instead of sleeping and checking again, would it make sense to maybe send in a spec change and make sure the operator re-triggers the batch job correctly? I think that would rule out the savepoint observe errors etc. ########## e2e-tests/data/flinkdep-batch-cr.yaml: ########## @@ -0,0 +1,109 @@ +################################################################################ +# 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. +################################################################################ + +apiVersion: flink.apache.org/v1beta1 +kind: FlinkDeployment +metadata: + namespace: default + name: flink-example-wordcount-batch +spec: + image: flink:1.20 + flinkVersion: v1_20 + ingress: + template: "/{{namespace}}/{{name}}(/|$)(.*)" + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/rewrite-target: "/$2" + flinkConfiguration: + taskmanager.numberOfTaskSlots: "2" + high-availability.type: kubernetes + high-availability.storageDir: file:///opt/flink/volume/flink-ha + state.checkpoints.dir: file:///opt/flink/volume/flink-cp + state.savepoints.dir: file:///opt/flink/volume/flink-sp Review Comment: Do we need HA/checkpoint configs? We could remove this and also simplify the pod template -- 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]
