Skip to content

Commit

Permalink
HDDS-12089. Move execute_debug_tests out of testlib.sh (#7744)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai authored Jan 24, 2025
1 parent db059c6 commit 82c1dda
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
48 changes: 48 additions & 0 deletions hadoop-ozone/dist/src/main/compose/common/replicas-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/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.

prefix=${RANDOM}

volume="cli-debug-volume${prefix}"
bucket="cli-debug-bucket"
key="testfile"

execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-tests.robot

# get block locations for key
chunkinfo="${key}-blocks-${prefix}"
docker-compose exec -T ${SCM} bash -c "ozone debug replicas chunk-info ${volume}/${bucket}/${key}" > "$chunkinfo"
host="$(jq -r '.KeyLocations[0][0]["Datanode-HostName"]' ${chunkinfo})"
container="${host%%.*}"

# corrupt the first block of key on one of the datanodes
datafile="$(jq -r '.KeyLocations[0][0].Locations.files[0]' ${chunkinfo})"
docker exec "${container}" sed -i -e '1s/^/a/' "${datafile}"

execute_robot_test ${SCM} -v "PREFIX:${prefix}" -v "CORRUPT_DATANODE:${host}" debug/ozone-debug-corrupt-block.robot

docker stop "${container}"

wait_for_datanode "${container}" STALE 60
execute_robot_test ${SCM} -v "PREFIX:${prefix}" -v "STALE_DATANODE:${host}" debug/ozone-debug-stale-datanode.robot

wait_for_datanode "${container}" DEAD 60
execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-dead-datanode.robot

docker start "${container}"

wait_for_datanode "${container}" HEALTHY 60
2 changes: 1 addition & 1 deletion hadoop-ozone/dist/src/main/compose/ozone/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ execute_robot_test scm cli
execute_robot_test scm admincli

execute_robot_test scm -v USERNAME:httpfs httpfs
execute_debug_tests
source "$COMPOSE_DIR/../common/replicas-test.sh"

execute_robot_test scm -v SCHEME:o3fs -v BUCKET_TYPE:bucket -N ozonefs-o3fs-bucket ozonefs/ozonefs.robot

Expand Down
35 changes: 0 additions & 35 deletions hadoop-ozone/dist/src/main/compose/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -568,41 +568,6 @@ prepare_for_runner_image() {
export OZONE_TEST_IMAGE="$(get_runner_image_spec "$@")"
}

## @description Executing the Ozone Debug CLI related robot tests
execute_debug_tests() {
local prefix=${RANDOM}

local volume="cli-debug-volume${prefix}"
local bucket="cli-debug-bucket"
local key="testfile"

execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-tests.robot

# get block locations for key
local chunkinfo="${key}-blocks-${prefix}"
docker-compose exec -T ${SCM} bash -c "ozone debug replicas chunk-info ${volume}/${bucket}/${key}" > "$chunkinfo"
local host="$(jq -r '.KeyLocations[0][0]["Datanode-HostName"]' ${chunkinfo})"
local container="${host%%.*}"

# corrupt the first block of key on one of the datanodes
local datafile="$(jq -r '.KeyLocations[0][0].Locations.files[0]' ${chunkinfo})"
docker exec "${container}" sed -i -e '1s/^/a/' "${datafile}"

execute_robot_test ${SCM} -v "PREFIX:${prefix}" -v "CORRUPT_DATANODE:${host}" debug/ozone-debug-corrupt-block.robot

docker stop "${container}"

wait_for_datanode "${container}" STALE 60
execute_robot_test ${SCM} -v "PREFIX:${prefix}" -v "STALE_DATANODE:${host}" debug/ozone-debug-stale-datanode.robot

wait_for_datanode "${container}" DEAD 60
execute_robot_test ${SCM} -v "PREFIX:${prefix}" debug/ozone-debug-dead-datanode.robot

docker start "${container}"

wait_for_datanode "${container}" HEALTHY 60
}

## @description Wait for datanode state
## @param Datanode name, eg datanode_1 datanode_2
## @param State to check for
Expand Down

0 comments on commit 82c1dda

Please sign in to comment.