forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_state_evolution.sh
executable file
·78 lines (70 loc) · 3.09 KB
/
test_state_evolution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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")"/common.sh
# For the case of evolution, this test will try to start from a savepoint taken
# with 1.7 (same version) but in which the schema of the (old) avro type differs
# from the current one. The new schema adds an optional field with a default value
# to the old one and verifies that it can see the old value.
#
# The old avro schema of the Address data type was:
#
# {"namespace": "org.apache.flink.formats.parquet.generated",
# "type": "record",
# "name": "Address",
# "fields": [
# {"name": "num", "type": "int"},
# {"name": "street", "type": "string"},
# {"name": "city", "type": "string"},
# {"name": "state", "type": "string"},
# {"name": "zip", "type": "string"}
# ]
# }
#
# while the new is:
#
# {"namespace": "org.apache.flink.avro.generated",
# "type": "record",
# "name": "Address",
# "fields": [
# {"name": "num", "type": "int"},
# {"name": "street", "type": "string"},
# {"name": "city", "type": "string"},
# {"name": "state", "type": "string"},
# {"name": "zip", "type": "string"},
# {"name": "appno", "type": [ "string", "null" ], "default": "123"}
# ]
# }
function run_test {
PARALLELISM=$1
TEST_JOB_JAR="${END_TO_END_DIR}/flink-state-evolution-test/target/StatefulStreamingJob.jar"
BASE_DIR="${TEST_DATA_DIR}/flink-state-evolution-test"
CHECKPOINT_DIR="file://${BASE_DIR}/checkpoints/"
SAVEPOINT_PARENT_DIR="file://${BASE_DIR}/savepoints/"
SAVEPOINT_DIR="file:///${END_TO_END_DIR}/flink-state-evolution-test/savepoints/1.7/"
set_config_key "state.backend.fs.memory-threshold" 1048576
start_cluster
# restart the job from the savepoint from Flink 1.7 with the old Avro Schema
JOB_ID=$($FLINK_DIR/bin/flink run -s $SAVEPOINT_DIR -p $PARALLELISM -d $TEST_JOB_JAR --checkpoint.dir $CHECKPOINT_DIR \
| grep "Job has been submitted with JobID" | sed 's/.* //g')
wait_job_running ${JOB_ID}
wait_num_checkpoints ${JOB_ID} 3
SECOND_SAVEPOINT_DIR=$($FLINK_DIR/bin/flink cancel -s $SAVEPOINT_PARENT_DIR $JOB_ID | grep "Savepoint stored in file" | sed 's/.* //g' | sed 's/\.$//')
echo "Took Savepoint @ ${SECOND_SAVEPOINT_DIR}"
}
run_test 1