errose28 commented on a change in pull request #2056:
URL: https://github.com/apache/ozone/pull/2056#discussion_r608141091
##########
File path: hadoop-ozone/dist/src/main/compose/upgrade/testlib.sh
##########
@@ -17,64 +17,133 @@
set -e -o pipefail
+# Fail if required variables are not set.
+set -u
+: "${OZONE_CURRENT_VERSION}"
+set +u
+
_upgrade_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd
)"
+# Cumulative result of all tests run with run_test function.
+# 0 if all passed, 1 if any failed.
+: "${RESULT:=0}"
: "${OZONE_REPLICATION_FACTOR:=3}"
-: "${OZONE_VOLUME:="${COMPOSE_DIR}/data"}"
: "${OZONE_VOLUME_OWNER:=}"
+: "${OZONE_CURRENT_VERSION:=}"
+: "${ALL_RESULT_DIR:="$_upgrade_dir"/result}"
+
+# export for docker-compose
+export OZONE_REPLICATION_FACTOR
source "${_upgrade_dir}/../testlib.sh"
## @description Create the directory tree required for persisting data between
## compose cluster restarts
-create_data_dir() {
+create_data_dirs() {
+ local dirs_to_create="$@"
+
if [[ -z "${OZONE_VOLUME}" ]]; then
return 1
fi
rm -fr "${OZONE_VOLUME}" 2> /dev/null || sudo rm -fr "${OZONE_VOLUME}"
- mkdir -p "${OZONE_VOLUME}"/{dn1,dn2,dn3,om,recon,s3g,scm}
+ mkdir -p $dirs_to_create
fix_data_dir_permissions
}
-## @description Run upgrade steps required for going from one logical version
to another.
-## @param Starting logical version
-## @param Target logical version
-execute_upgrade_steps() {
- local -i from=$1
- local -i to=$2
+## @description Prepares to run an image with `start_docker_env`.
+## @param the version of Ozone to be run.
+## If this is equal to `OZONE_CURRENT_VERSION`, then the ozone runner image
wil be used.
+## Else, a binary image will be used.
+prepare_for_image() {
+ local image_version="$1"
- if [[ ${from} -ge ${to} ]]; then
- return
+ if [[ "$image_version" = "$OZONE_CURRENT_VERSION" ]]; then
+ prepare_for_runner_image
+ else
+ prepare_for_binary_image "$image_version"
fi
+}
- pushd ${_testlib_dir}/../libexec/upgrade
+## @description Runs a callback function only if it exists.
+## @param The name of the function to run.
+callback() {
+ local func="$1"
+ if type -t "$func" > /dev/null; then
Review comment:
Sounds like a good idea. We are not expecting executable files or
anything else here. I'll add it.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]