-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-8962. Ensure docker env is stopped #5011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
94c34ce
HDDS-8962. Ensure docker env is stopped
adoroszlai 174c07a
remove stop_docker_env and generate_report calls from end of script
adoroszlai ae23bce
move failing[12] test scripts to ozone
adoroszlai 2a6e718
add wait_for_port in test-failures1
adoroszlai 306179e
reduce scope of +e
adoroszlai cc26d9b
If the last arg evaluates to 0, let returns 1
adoroszlai 31afbb3
ignore grep exit code
adoroszlai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
hadoop-ozone/dist/src/main/compose/failing1/docker-compose.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
hadoop-ozone/dist/src/main/compose/failing2/docker-compose.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -35,7 +35,3 @@ start_docker_env | |
| startOMs | ||
|
|
||
| execute_robot_test scm omha/testOMHA.robot | ||
|
|
||
| stop_docker_env | ||
|
|
||
| generate_report | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -27,7 +27,3 @@ source "$COMPOSE_DIR/../testlib.sh" | |
| start_docker_env | ||
|
|
||
| execute_robot_test scm s3 | ||
|
|
||
| stop_docker_env | ||
|
|
||
| generate_report | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| # 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. | ||
| set -e | ||
| set -e -o pipefail | ||
|
|
||
| _testlib_this="${BASH_SOURCE[0]}" | ||
| _testlib_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
|
@@ -120,9 +120,9 @@ wait_for_om_leader() { | |
| while [[ $SECONDS -lt 120 ]]; do | ||
| local command="ozone admin om getserviceroles --service-id '${OM_SERVICE_ID}'" | ||
| if [[ "${SECURITY_ENABLED}" == 'true' ]]; then | ||
| status=$(docker-compose exec -T ${SCM} bash -c "kinit -k scm/[email protected] -t /etc/security/keytabs/scm.keytab && $command" | grep LEADER) | ||
| status=$(docker-compose exec -T ${SCM} bash -c "kinit -k scm/[email protected] -t /etc/security/keytabs/scm.keytab && $command" | grep LEADER || true) | ||
| else | ||
| status=$(docker-compose exec -T ${SCM} bash -c "$command" | grep LEADER) | ||
| status=$(docker-compose exec -T ${SCM} bash -c "$command" | grep LEADER || true) | ||
| fi | ||
| if [[ -n "${status}" ]]; then | ||
| echo "Found OM leader for service ${OM_SERVICE_ID}: $status" | ||
|
|
@@ -158,13 +158,12 @@ start_docker_env(){ | |
| export OZONE_SAFEMODE_MIN_DATANODES="${datanode_count}" | ||
|
|
||
| docker-compose --ansi never down | ||
| if ! { docker-compose --ansi never up -d --scale datanode="${datanode_count}" \ | ||
| && wait_for_safemode_exit \ | ||
| && wait_for_om_leader ; }; then | ||
| [[ -n "$OUTPUT_NAME" ]] || OUTPUT_NAME="$COMPOSE_ENV_NAME" | ||
| stop_docker_env | ||
| return 1 | ||
| fi | ||
|
|
||
| trap stop_docker_env EXIT HUP INT TERM | ||
|
|
||
| docker-compose --ansi never up -d --scale datanode="${datanode_count}" | ||
| wait_for_safemode_exit | ||
| wait_for_om_leader | ||
| } | ||
|
|
||
| ## @description Execute robot tests in a specific container. | ||
|
|
@@ -179,20 +178,22 @@ execute_robot_test(){ | |
| unset 'ARGUMENTS[${#ARGUMENTS[@]}-1]' #Remove the last element, remainings are the custom parameters | ||
| TEST_NAME=$(basename "$TEST") | ||
| TEST_NAME="$(basename "$COMPOSE_DIR")-${TEST_NAME%.*}" | ||
| set +e | ||
| [[ -n "$OUTPUT_NAME" ]] || OUTPUT_NAME="$COMPOSE_ENV_NAME-$TEST_NAME-$CONTAINER" | ||
|
|
||
| # find unique filename | ||
| declare -i i=0 | ||
| OUTPUT_FILE="robot-${OUTPUT_NAME}.xml" | ||
| while [[ -f $RESULT_DIR/$OUTPUT_FILE ]]; do | ||
| let i++ | ||
| let ++i | ||
| OUTPUT_FILE="robot-${OUTPUT_NAME}-${i}.xml" | ||
| done | ||
|
|
||
| SMOKETEST_DIR_INSIDE="${OZONE_DIR:-/opt/hadoop}/smoketest" | ||
|
|
||
| OUTPUT_PATH="$RESULT_DIR_INSIDE/${OUTPUT_FILE}" | ||
|
|
||
| set +e | ||
|
|
||
| # shellcheck disable=SC2068 | ||
| docker-compose exec -T "$CONTAINER" mkdir -p "$RESULT_DIR_INSIDE" \ | ||
| && docker-compose exec -T "$CONTAINER" robot \ | ||
|
|
@@ -209,18 +210,12 @@ execute_robot_test(){ | |
| FULL_CONTAINER_NAME=$(docker-compose ps | grep "_${CONTAINER}_" | head -n 1 | awk '{print $1}') | ||
| docker cp "$FULL_CONTAINER_NAME:$OUTPUT_PATH" "$RESULT_DIR/" | ||
|
|
||
| copy_daemon_logs | ||
|
|
||
| if [[ ${rc} -gt 0 ]] && [[ ${rc} -le 250 ]]; then | ||
| create_stack_dumps | ||
| fi | ||
|
|
||
| set -e | ||
|
|
||
| if [[ ${rc} -gt 0 ]]; then | ||
| stop_docker_env | ||
| fi | ||
|
|
||
| return ${rc} | ||
| } | ||
|
|
||
|
|
@@ -263,37 +258,37 @@ copy_daemon_logs() { | |
| ## @param container name | ||
| ## @param specific command to execute | ||
| execute_command_in_container(){ | ||
| set -e | ||
| # shellcheck disable=SC2068 | ||
| docker-compose exec -T "$@" | ||
| set +e | ||
| } | ||
|
|
||
| ## @description Stop a list of named containers | ||
| ## @param List of container names, eg datanode_1 datanode_2 | ||
| stop_containers() { | ||
| set -e | ||
| docker-compose --ansi never stop $@ | ||
| set +e | ||
| } | ||
|
|
||
|
|
||
| ## @description Start a list of named containers | ||
| ## @param List of container names, eg datanode_1 datanode_2 | ||
| start_containers() { | ||
| set -e | ||
| docker-compose --ansi never start $@ | ||
| set +e | ||
| } | ||
|
|
||
| create_containers() { | ||
| set -e | ||
| docker-compose --ansi never up -d $@ | ||
| set +e | ||
| } | ||
|
|
||
| save_container_logs() { | ||
| docker-compose --ansi never logs $@ >> "$RESULT_DIR/docker-$OUTPUT_NAME.log" | ||
| local output_name="${OUTPUT_NAME:-}" | ||
| if [[ -z "${output_name}" ]]; then | ||
| output_name="$COMPOSE_ENV_NAME" | ||
| fi | ||
| if [[ -z "${output_name}" ]]; then | ||
| output_name="$(basename $(pwd))" | ||
| fi | ||
|
|
||
| docker-compose --ansi never logs $@ >> "$RESULT_DIR/docker-${output_name}.log" | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -310,13 +305,9 @@ wait_for_port(){ | |
| SECONDS=0 | ||
|
|
||
| while [[ $SECONDS -lt $timeout ]]; do | ||
| set +e | ||
| docker-compose exec -T ${SCM} /bin/bash -c "nc -z $host $port" | ||
| status=$? | ||
| set -e | ||
| if [ $status -eq 0 ] ; then | ||
| echo "Port $port is available on $host" | ||
| return; | ||
| if docker-compose exec -T ${SCM} /bin/bash -c "nc -z $host $port"; then | ||
| echo "Port $port is available on $host" | ||
| return | ||
| fi | ||
| echo "Port $port is not available on $host yet" | ||
| sleep 1 | ||
|
|
@@ -338,13 +329,9 @@ wait_for_execute_command(){ | |
| SECONDS=0 | ||
|
|
||
| while [[ $SECONDS -lt $timeout ]]; do | ||
| set +e | ||
| docker-compose exec -T $container bash -c '$command' | ||
| status=$? | ||
| set -e | ||
| if [ $status -eq 0 ] ; then | ||
| echo "$command succeed" | ||
| return; | ||
| if docker-compose exec -T $container bash -c '$command'; then | ||
| echo "$command succeed" | ||
| return | ||
| fi | ||
| echo "$command hasn't succeed yet" | ||
| sleep 1 | ||
|
|
@@ -355,6 +342,7 @@ wait_for_execute_command(){ | |
|
|
||
| ## @description Stops a docker-compose based test environment (with saving the logs) | ||
| stop_docker_env(){ | ||
| copy_daemon_logs | ||
| save_container_logs | ||
| if [ "${KEEP_RUNNING:-false}" = false ]; then | ||
| docker-compose --ansi never down | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -126,5 +126,3 @@ for cluster_version in ${old_versions}; do | |
| done | ||
|
|
||
| test_ec_cross_compatibility | ||
|
|
||
| generate_report | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, with the changes in this PR:
copy_daemon_logsandstop_docker_envcalls are removed fromexecute_robot_test()copy_daemon_logsis now called bystop_docker_env()stop_docker_envis now called fromstart_docker_env()Thus whoever calls
start_docker_envlast would have to callstop_docker_envin order to have the logs collected, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @smengcl for the review.
It's like a
ShutdownHookin Java. The shell callsstop_docker_envwhen the test script exits.start_docker_envjust sets it up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah makes sense now. That is exactly what
trapis for. Thanks @adoroszlai .