Skip to content

Commit d4c41e5

Browse files
authored
HDDS-11334. Improve EC xcompat acceptance test (#7492)
1 parent 8526f2e commit d4c41e5

10 files changed

Lines changed: 258 additions & 279 deletions

File tree

hadoop-ozone/dist/src/main/compose/testlib.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,29 @@ fi
3030

3131
source ${_testlib_dir}/compose_v2_compatibility.sh
3232

33+
: ${OZONE_COMPOSE_RUNNING:=false}
3334
: ${SCM:=scm}
3435

36+
# create temp directory for test data; only once, even if testlib.sh is sourced again
37+
if [[ -z "${TEST_DATA_DIR:-}" ]] && [[ "${KEEP_RUNNING:-false}" == "false" ]]; then
38+
export TEST_DATA_DIR="$(mktemp -d "${TMPDIR:-/tmp}"/robot-data-XXXXXX)"
39+
chmod go+rx "${TEST_DATA_DIR}"
40+
_compose_delete_test_data() {
41+
rm -frv "${TEST_DATA_DIR}"
42+
}
43+
44+
trap _compose_cleanup EXIT HUP INT TERM
45+
fi
46+
47+
_compose_cleanup() {
48+
if [[ "${OZONE_COMPOSE_RUNNING}" == "true" ]]; then
49+
stop_docker_env || true
50+
fi
51+
if [[ "$(type -t _compose_delete_test_data || true)" == "function" ]]; then
52+
_compose_delete_test_data
53+
fi
54+
}
55+
3556
## @description create results directory, purging any prior data
3657
create_results_dir() {
3758
#delete previous results
@@ -140,13 +161,13 @@ start_docker_env(){
140161

141162
docker-compose --ansi never down --remove-orphans
142163

143-
trap stop_docker_env EXIT HUP INT TERM
144-
145164
opts=""
146165
if has_scalable_datanode; then
147166
opts="--scale datanode=${datanode_count}"
148167
fi
149168

169+
OZONE_COMPOSE_RUNNING=true
170+
trap _compose_cleanup EXIT HUP INT TERM
150171
docker-compose --ansi never up -d $opts
151172

152173
wait_for_safemode_exit
@@ -184,11 +205,11 @@ execute_robot_test(){
184205
local output_name=$(get_output_name)
185206

186207
# find unique filename
187-
declare -i i=0
188-
OUTPUT_FILE="robot-${output_name}1.xml"
189-
while [[ -f $RESULT_DIR/$OUTPUT_FILE ]]; do
190-
let ++i
191-
OUTPUT_FILE="robot-${output_name}${i}.xml"
208+
for ((i=1; i<1000; i++)); do
209+
OUTPUT_FILE="robot-${output_name}$(printf "%03d" ${i}).xml"
210+
if [[ ! -f $RESULT_DIR/$OUTPUT_FILE ]]; then
211+
break;
212+
fi
192213
done
193214

194215
SMOKETEST_DIR_INSIDE="${OZONE_DIR:-/opt/hadoop}/smoketest"
@@ -368,6 +389,7 @@ stop_docker_env(){
368389
for i in $(seq 1 $down_repeats)
369390
do
370391
if docker-compose --ansi never --profile "*" down --remove-orphans; then
392+
OZONE_COMPOSE_RUNNING=false
371393
return
372394
fi
373395
if [[ ${i} -eq 1 ]]; then

hadoop-ozone/dist/src/main/compose/upgrade/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
#suite:compat
18+
#suite:upgrade
1919

2020

2121
TEST_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )

hadoop-ozone/dist/src/main/compose/xcompat/clients.yaml

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,58 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
x-common-config:
18+
&common-config
19+
dns_search: .
20+
env_file:
21+
- docker-config
22+
command: ["sleep","1000000"]
23+
24+
x-old-config:
25+
&old-config
26+
<<: *common-config
27+
volumes:
28+
- ../..:/opt/ozone
29+
- ../_keytabs:/etc/security/keytabs
30+
- ./krb5.conf:/etc/krb5.conf
31+
- ${TEST_DATA_DIR}:/testdata
32+
33+
x-new-config:
34+
&new-config
35+
image: ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION}
36+
<<: *common-config
37+
volumes:
38+
- ../..:/opt/hadoop
39+
- ../_keytabs:/etc/security/keytabs
40+
- ./krb5.conf:/etc/krb5.conf
41+
- ${TEST_DATA_DIR}:/testdata
42+
1743
services:
1844
old_client_1_0_0:
1945
image: ${OZONE_IMAGE}:1.0.0${OZONE_IMAGE_FLAVOR}
20-
env_file:
21-
- docker-config
22-
volumes:
23-
- ../..:/opt/ozone
24-
- ../_keytabs:/etc/security/keytabs
25-
- ./krb5.conf:/etc/krb5.conf
26-
command: ["sleep","1000000"]
46+
<<: *old-config
47+
2748
old_client_1_1_0:
2849
image: ${OZONE_IMAGE}:1.1.0${OZONE_IMAGE_FLAVOR}
29-
env_file:
30-
- docker-config
31-
volumes:
32-
- ../..:/opt/ozone
33-
- ../_keytabs:/etc/security/keytabs
34-
- ./krb5.conf:/etc/krb5.conf
35-
command: ["sleep","1000000"]
50+
<<: *old-config
51+
3652
old_client_1_2_1:
3753
image: ${OZONE_IMAGE}:1.2.1${OZONE_IMAGE_FLAVOR}
38-
env_file:
39-
- docker-config
40-
volumes:
41-
- ../..:/opt/ozone
42-
- ../_keytabs:/etc/security/keytabs
43-
- ./krb5.conf:/etc/krb5.conf
44-
command: ["sleep","1000000"]
54+
<<: *old-config
55+
4556
old_client_1_3_0:
4657
image: ${OZONE_IMAGE}:1.3.0${OZONE_IMAGE_FLAVOR}
47-
env_file:
48-
- docker-config
49-
volumes:
50-
- ../..:/opt/ozone
51-
- ../_keytabs:/etc/security/keytabs
52-
- ./krb5.conf:/etc/krb5.conf
53-
command: ["sleep","1000000"]
58+
<<: *old-config
59+
5460
old_client_1_4_0:
5561
image: ${OZONE_IMAGE}:1.4.0${OZONE_IMAGE_FLAVOR}
56-
env_file:
57-
- docker-config
58-
volumes:
59-
- ../..:/opt/ozone
60-
- ../_keytabs:/etc/security/keytabs
61-
- ./krb5.conf:/etc/krb5.conf
62-
command: ["sleep","1000000"]
62+
<<: *old-config
63+
6364
old_client_1_4_1:
6465
image: ${OZONE_IMAGE}:1.4.1${OZONE_IMAGE_FLAVOR}
65-
env_file:
66-
- docker-config
67-
volumes:
68-
- ../..:/opt/ozone
69-
- ../_keytabs:/etc/security/keytabs
70-
- ./krb5.conf:/etc/krb5.conf
71-
command: ["sleep","1000000"]
66+
<<: *old-config
67+
7268
new_client:
73-
image: ${OZONE_RUNNER_IMAGE}:${OZONE_RUNNER_VERSION}
74-
env_file:
75-
- docker-config
76-
volumes:
77-
- ../..:/opt/hadoop
78-
- ../_keytabs:/etc/security/keytabs
79-
- ./krb5.conf:/etc/krb5.conf
69+
<<: *new-config
8070
environment:
8171
OZONE_OPTS:
82-
command: ["sleep","1000000"]

hadoop-ozone/dist/src/main/compose/xcompat/test.sh

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ source "${COMPOSE_DIR}/../testlib.sh"
3232
export SECURITY_ENABLED=true
3333
: ${OZONE_BUCKET_KEY_NAME:=key1}
3434

35-
old_client() {
36-
OZONE_DIR=/opt/ozone
37-
container=${client}
38-
"$@"
39-
}
35+
echo 'Compatibility Test' > "${TEST_DATA_DIR}"/small
36+
37+
client() {
38+
if [[ "${client_version}" == "${current_version}" ]]; then
39+
OZONE_DIR=/opt/hadoop
40+
container=new_client
41+
else
42+
OZONE_DIR=/opt/ozone
43+
container="old_client_${client_version//./_}"
44+
fi
4045

41-
new_client() {
42-
OZONE_DIR=/opt/hadoop
43-
container=new_client
44-
client_version=${current_version}
4546
"$@"
4647
}
4748

@@ -60,7 +61,7 @@ _write() {
6061
execute_robot_test ${container} -N "xcompat-cluster-${cluster_version}-client-${client_version}-write" \
6162
-v CLIENT_VERSION:${client_version} \
6263
-v CLUSTER_VERSION:${cluster_version} \
63-
-v SUFFIX:${client_version} \
64+
-v TEST_DATA_DIR:/testdata \
6465
compatibility/write.robot
6566
}
6667

@@ -71,87 +72,46 @@ _read() {
7172
-v CLIENT_VERSION:${client_version} \
7273
-v CLUSTER_VERSION:${cluster_version} \
7374
-v DATA_VERSION:${data_version} \
74-
-v SUFFIX:${data_version} \
75+
-v TEST_DATA_DIR:/testdata \
7576
compatibility/read.robot
7677
}
7778

7879
test_cross_compatibility() {
7980
echo "Starting ${cluster_version} cluster with COMPOSE_FILE=${COMPOSE_FILE}"
8081

81-
OZONE_KEEP_RESULTS=true start_docker_env
82+
OZONE_KEEP_RESULTS=true start_docker_env 5
8283

8384
execute_command_in_container kms hadoop key create ${OZONE_BUCKET_KEY_NAME}
8485

8586
_init
8687

87-
new_client _write
88-
new_client _read ${current_version}
88+
# first write with client matching cluster version
89+
client_version="${cluster_version}" client _write
8990

9091
for client_version in "$@"; do
91-
client="old_client_${client_version//./_}"
92-
93-
old_client _write
94-
old_client _read ${client_version}
95-
96-
old_client _read ${current_version}
97-
new_client _read ${client_version}
92+
# skip write, since already done
93+
if [[ "${client_version}" == "${cluster_version}" ]]; then
94+
continue
95+
fi
96+
client _write
9897
done
9998

100-
KEEP_RUNNING=false stop_docker_env
101-
}
102-
103-
test_ec_cross_compatibility() {
104-
echo "Running Erasure Coded storage backward compatibility tests."
105-
# local cluster_versions_with_ec="1.3.0 1.4.0 ${current_version}"
106-
local cluster_versions_with_ec="${current_version}" # until HDDS-11334
107-
# TODO: debug acceptance test failures for client versions 1.0.0 on secure clusters
108-
local non_ec_client_versions="1.1.0 1.2.1"
109-
110-
for cluster_version in ${cluster_versions_with_ec}; do
111-
export COMPOSE_FILE=new-cluster.yaml:clients.yaml cluster_version=${cluster_version}
112-
OZONE_KEEP_RESULTS=true start_docker_env 5
113-
114-
echo -n "Generating data locally... "
115-
dd if=/dev/urandom of=/tmp/1mb bs=1048576 count=1 >/dev/null 2>&1
116-
dd if=/dev/urandom of=/tmp/2mb bs=1048576 count=2 >/dev/null 2>&1
117-
dd if=/dev/urandom of=/tmp/3mb bs=1048576 count=3 >/dev/null 2>&1
118-
echo "done"
119-
echo -n "Copy data into client containers... "
120-
for container in $(docker ps --format '{{.Names}}' | grep client); do
121-
docker cp /tmp/1mb ${container}:/tmp/1mb
122-
docker cp /tmp/2mb ${container}:/tmp/2mb
123-
docker cp /tmp/3mb ${container}:/tmp/3mb
124-
done
125-
echo "done"
126-
rm -f /tmp/1mb /tmp/2mb /tmp/3mb
127-
128-
129-
local prefix=$(LC_CTYPE=C tr -dc '[:alnum:]' < /dev/urandom | head -c 5 | tr '[:upper:]' '[:lower:]')
130-
OZONE_DIR=/opt/hadoop
131-
new_client _kinit
132-
execute_robot_test new_client --include setup-ec-data -N "xcompat-cluster-${cluster_version}-setup-data" -v prefix:"${prefix}" ec/backward-compat.robot
133-
OZONE_DIR=/opt/ozone
134-
135-
for client_version in ${non_ec_client_versions}; do
136-
client="old_client_${client_version//./_}"
137-
unset OUTPUT_PATH
138-
container="${client}" _kinit
139-
execute_robot_test "${client}" --include test-ec-compat -N "xcompat-cluster-${cluster_version}-client-${client_version}-read-${cluster_version}" -v prefix:"${prefix}" ec/backward-compat.robot
99+
for client_version in "$@"; do
100+
for data_version in $(echo "$client_version" "$cluster_version" "$current_version" | xargs -n1 | sort -u); do
101+
client _read ${data_version}
140102
done
141-
142-
KEEP_RUNNING=false stop_docker_env
143103
done
104+
105+
KEEP_RUNNING=false stop_docker_env
144106
}
145107

146108
create_results_dir
147109

148110
# current cluster with various clients
149-
COMPOSE_FILE=new-cluster.yaml:clients.yaml cluster_version=${current_version} test_cross_compatibility ${old_versions}
111+
COMPOSE_FILE=new-cluster.yaml:clients.yaml cluster_version=${current_version} test_cross_compatibility ${old_versions} ${current_version}
150112

151113
# old cluster with clients: same version and current version
152114
for cluster_version in ${old_versions}; do
153115
export OZONE_VERSION=${cluster_version}
154-
COMPOSE_FILE=old-cluster.yaml:clients.yaml test_cross_compatibility ${cluster_version}
116+
COMPOSE_FILE=old-cluster.yaml:clients.yaml test_cross_compatibility ${cluster_version} ${current_version}
155117
done
156-
157-
test_ec_cross_compatibility

0 commit comments

Comments
 (0)