-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-27160] Add e2e tests for session job
This closes #179.
- Loading branch information
1 parent
57b2eae
commit fb13a14
Showing
9 changed files
with
275 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
################################################################################ | ||
# 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: session-cluster-1 | ||
spec: | ||
image: flink:1.14.3 | ||
flinkVersion: v1_14 | ||
ingress: | ||
template: "/{{namespace}}/{{name}}(/|$)(.*)" | ||
className: "nginx" | ||
annotations: | ||
nginx.ingress.kubernetes.io/rewrite-target: "/$2" | ||
flinkConfiguration: | ||
taskmanager.numberOfTaskSlots: "2" | ||
high-availability: org.apache.flink.kubernetes.highavailability.KubernetesHaServicesFactory | ||
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 | ||
serviceAccount: flink | ||
podTemplate: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-template | ||
spec: | ||
containers: | ||
# Do not change the main container name | ||
- name: flink-main-container | ||
resources: | ||
requests: | ||
ephemeral-storage: 2048Mi | ||
limits: | ||
ephemeral-storage: 2048Mi | ||
volumeMounts: | ||
- mountPath: /opt/flink/volume | ||
name: flink-volume | ||
volumes: | ||
- name: flink-volume | ||
persistentVolumeClaim: | ||
claimName: session-cluster-1-pvc | ||
jobManager: | ||
replicas: 1 | ||
resource: | ||
memory: "1024m" | ||
cpu: 0.5 | ||
taskManager: | ||
resource: | ||
memory: "1024m" | ||
cpu: 0.5 | ||
|
||
--- | ||
apiVersion: flink.apache.org/v1beta1 | ||
kind: FlinkSessionJob | ||
metadata: | ||
namespace: default | ||
name: flink-example-statemachine | ||
spec: | ||
deploymentName: session-cluster-1 | ||
job: | ||
jarURI: https://repo1.maven.org/maven2/org/apache/flink/flink-examples-streaming_2.12/1.14.3/flink-examples-streaming_2.12-1.14.3.jar | ||
parallelism: 2 | ||
upgradeMode: savepoint | ||
entryClass: org.apache.flink.streaming.examples.statemachine.StateMachineExample | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: session-cluster-1-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
|
||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: IngressClass | ||
metadata: | ||
annotations: | ||
ingressclass.kubernetes.io/is-default-class: "true" | ||
labels: | ||
app.kubernetes.io/component: controller | ||
name: nginx | ||
spec: | ||
controller: k8s.io/ingress-nginx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/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. | ||
# | ||
|
||
source "$(dirname "$0")"/utils.sh | ||
|
||
CLUSTER_ID="session-cluster-1" | ||
APPLICATION_YAML="e2e-tests/data/sessionjob-cr.yaml" | ||
TIMEOUT=300 | ||
SESSION_CLUSTER_IDENTIFIER="flinkdep/session-cluster-1" | ||
SESSION_JOB_IDENTIFIER="sessionjob/flink-example-statemachine" | ||
|
||
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 | ||
jm_pod_name=$(get_jm_pod_name $CLUSTER_ID) | ||
|
||
wait_for_logs $jm_pod_name "Completed checkpoint [0-9]+ for job" ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_CLUSTER_IDENTIFIER '.status.jobManagerDeploymentStatus' READY ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_JOB_IDENTIFIER '.status.jobStatus.state' RUNNING ${TIMEOUT} || exit 1 | ||
|
||
job_id=$(kubectl logs $jm_pod_name | grep -E -o 'Job [a-z0-9]+ is submitted' | awk '{print $2}') | ||
|
||
# Kill the JobManager | ||
echo "Kill the $jm_pod_name" | ||
kubectl exec $jm_pod_name -- /bin/sh -c "kill 1" | ||
|
||
# Check the new JobManager recovering from latest successful checkpoint | ||
wait_for_logs $jm_pod_name "Restoring job $job_id from Checkpoint" ${TIMEOUT} || exit 1 | ||
wait_for_logs $jm_pod_name "Completed checkpoint [0-9]+ for job" ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_CLUSTER_IDENTIFIER '.status.jobManagerDeploymentStatus' READY ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_JOB_IDENTIFIER '.status.jobStatus.state' RUNNING ${TIMEOUT} || exit 1 | ||
|
||
echo "Successfully run the Flink Session Job HA test" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/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. | ||
################################################################################ | ||
|
||
source "$(dirname "$0")"/utils.sh | ||
|
||
CLUSTER_ID="session-cluster-1" | ||
APPLICATION_YAML="e2e-tests/data/sessionjob-cr.yaml" | ||
TIMEOUT=300 | ||
SESSION_CLUSTER_IDENTIFIER="flinkdep/$CLUSTER_ID" | ||
SESSION_JOB_NAME="flink-example-statemachine" | ||
SESSION_JOB_IDENTIFIER="sessionjob/$SESSION_JOB_NAME" | ||
|
||
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 | ||
jm_pod_name=$(get_jm_pod_name $CLUSTER_ID) | ||
|
||
wait_for_logs $jm_pod_name "Completed checkpoint [0-9]+ for job" ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_CLUSTER_IDENTIFIER '.status.jobManagerDeploymentStatus' READY ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_JOB_IDENTIFIER '.status.jobStatus.state' RUNNING ${TIMEOUT} || exit 1 | ||
assert_available_slots 0 $CLUSTER_ID | ||
|
||
# Update the FlinkSessionJob and trigger the savepoint upgrade | ||
kubectl patch sessionjob ${SESSION_JOB_NAME} --type merge --patch '{"spec":{"job": {"parallelism": 1 } } }' | ||
|
||
# Check the new JobManager recovering from savepoint | ||
wait_for_logs $jm_pod_name "Restoring job .* from Savepoint" ${TIMEOUT} || exit 1 | ||
wait_for_logs $jm_pod_name "Completed checkpoint [0-9]+ for job" ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_CLUSTER_IDENTIFIER '.status.jobManagerDeploymentStatus' READY ${TIMEOUT} || exit 1 | ||
wait_for_status $SESSION_JOB_IDENTIFIER '.status.jobStatus.state' RUNNING ${TIMEOUT} || exit 1 | ||
assert_available_slots 1 $CLUSTER_ID | ||
|
||
echo "Successfully run the sessionjob savepoint upgrade test" | ||
|
Oops, something went wrong.