diff --git a/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh b/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh new file mode 100644 index 000000000000..6146dab871e7 --- /dev/null +++ b/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh @@ -0,0 +1,43 @@ +# 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. +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd ) +ALL_RESULT_DIR="$SCRIPT_DIR/result" +source "$SCRIPT_DIR/../testlib.sh" + +tests=$(find_tests) + +RESULT=0 +# shellcheck disable=SC2044 +for t in ${tests}; do + d="$(dirname "${t}")" + echo "Executing test in ${d}" + + #required to read the .env file from the right location + cd "${d}" || continue + ./test.sh + ret=$? + if [[ $ret -ne 0 ]]; then + RESULT=1 + echo "ERROR: Test execution of ${d} is FAILED!!!!" + fi + cd "$SCRIPT_DIR" + RESULT_DIR="${d}/result" + TEST_DIR_NAME=$(basename ${d}) + rebot -N $TEST_DIR_NAME -o "$ALL_RESULT_DIR"/$TEST_DIR_NAME.xml "$RESULT_DIR"/"*.xml" + cp "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/ + cp "$RESULT_DIR"/*.out* "$ALL_RESULT_DIR"/ || true +done + diff --git a/hadoop-ozone/dist/src/main/compose/ozone-topology/test.sh b/hadoop-ozone/dist/src/main/compose/ozone-topology/test.sh index d4efa4f4af00..392112ba5313 100755 --- a/hadoop-ozone/dist/src/main/compose/ozone-topology/test.sh +++ b/hadoop-ozone/dist/src/main/compose/ozone-topology/test.sh @@ -39,7 +39,7 @@ execute_robot_test scm topology/loaddata.robot stop_containers datanode_1 datanode_2 datanode_3 -execute_robot_test scm topology/readdata.robot +execute_robot_test scm -N readdata-first-half topology/readdata.robot start_containers datanode_1 datanode_2 datanode_3 @@ -49,7 +49,7 @@ wait_for_port datanode_3 9858 60 stop_containers datanode_4 datanode_5 datanode_6 -execute_robot_test scm topology/readdata.robot +execute_robot_test scm -N readdata-second-half topology/readdata.robot stop_docker_env diff --git a/hadoop-ozone/dist/src/main/compose/ozone/test.sh b/hadoop-ozone/dist/src/main/compose/ozone/test.sh index b5b778f22cff..2f57831f88bf 100755 --- a/hadoop-ozone/dist/src/main/compose/ozone/test.sh +++ b/hadoop-ozone/dist/src/main/compose/ozone/test.sh @@ -37,14 +37,14 @@ execute_robot_test scm gdpr for scheme in ofs o3fs; do for bucket in link bucket; do - execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} ozonefs/ozonefs.robot + execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} -N ozonefs-${scheme}-${bucket} ozonefs/ozonefs.robot done done execute_robot_test scm security/ozone-secure-token.robot for bucket in link generated; do - execute_robot_test scm -v BUCKET:${bucket} s3 + execute_robot_test scm -v BUCKET:${bucket} -N s3-${bucket} s3 done execute_robot_test scm recon diff --git a/hadoop-ozone/dist/src/main/compose/ozonesecure/test.sh b/hadoop-ozone/dist/src/main/compose/ozonesecure/test.sh index 076b83a3d52d..eeccb849eedc 100755 --- a/hadoop-ozone/dist/src/main/compose/ozonesecure/test.sh +++ b/hadoop-ozone/dist/src/main/compose/ozonesecure/test.sh @@ -39,12 +39,12 @@ execute_robot_test scm security for scheme in ofs o3fs; do for bucket in link bucket; do - execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} ozonefs/ozonefs.robot + execute_robot_test scm -v SCHEME:${scheme} -v BUCKET_TYPE:${bucket} -N ozonefs-${scheme}-${bucket} ozonefs/ozonefs.robot done done for bucket in link generated; do - execute_robot_test s3g -v BUCKET:${bucket} s3 + execute_robot_test s3g -v BUCKET:${bucket} -N s3-${bucket} s3 done #expects 4 pipelines, should be run before diff --git a/hadoop-ozone/dist/src/main/compose/test-all.sh b/hadoop-ozone/dist/src/main/compose/test-all.sh index da3b80e79eac..15e268867bf1 100755 --- a/hadoop-ozone/dist/src/main/compose/test-all.sh +++ b/hadoop-ozone/dist/src/main/compose/test-all.sh @@ -25,30 +25,15 @@ PROJECT_DIR="$SCRIPT_DIR/.." mkdir -p "$ALL_RESULT_DIR" rm "$ALL_RESULT_DIR/*" || true +source "$SCRIPT_DIR"/testlib.sh + if [ "$OZONE_WITH_COVERAGE" ]; then java -cp "$PROJECT_DIR"/share/coverage/$(ls "$PROJECT_DIR"/share/coverage | grep test-util):"$PROJECT_DIR"/share/coverage/jacoco-core.jar org.apache.hadoop.test.JacocoServer & DOCKER_BRIDGE_IP=$(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}') export HADOOP_OPTS="-javaagent:share/coverage/jacoco-agent.jar=output=tcpclient,address=$DOCKER_BRIDGE_IP,includes=org.apache.hadoop.ozone.*:org.apache.hadoop.hdds.*:org.apache.hadoop.fs.ozone.*" fi -if [[ -n "${OZONE_ACCEPTANCE_SUITE}" ]]; then - tests=$(find "$SCRIPT_DIR" -name test.sh | xargs grep -l "^#suite:${OZONE_ACCEPTANCE_SUITE}$" | sort) - - # 'misc' is default suite, add untagged tests, too - if [[ "misc" == "${OZONE_ACCEPTANCE_SUITE}" ]]; then - untagged="$(find "$SCRIPT_DIR" -name test.sh | xargs grep -L "^#suite:")" - if [[ -n "${untagged}" ]]; then - tests=$(echo ${tests} ${untagged} | xargs -n1 | sort) - fi - fi - - if [[ -z "${tests}" ]]; then - echo "No tests found for suite ${OZONE_ACCEPTANCE_SUITE}" - exit 1 - fi -else - tests=$(find "$SCRIPT_DIR" -name test.sh | grep "${OZONE_TEST_SELECTOR:-""}" | sort) -fi +tests=$(find_tests) RESULT=0 # shellcheck disable=SC2044 @@ -64,11 +49,16 @@ for t in ${tests}; do RESULT=1 echo "ERROR: Test execution of ${d} is FAILED!!!!" fi + cd "$SCRIPT_DIR" RESULT_DIR="${d}/result" - cp "$RESULT_DIR"/robot-*.xml "$RESULT_DIR"/docker-*.log "$RESULT_DIR"/*.out* "$ALL_RESULT_DIR"/ + TEST_DIR_NAME=$(basename ${d}) + rebot -N $TEST_DIR_NAME -o "$ALL_RESULT_DIR"/$TEST_DIR_NAME.xml "$RESULT_DIR"/"*.xml" + cp "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/ + cp "$RESULT_DIR"/*.out* "$ALL_RESULT_DIR"/ || true done -rebot -N "smoketests" -d "$SCRIPT_DIR/result" "$SCRIPT_DIR/result/robot-*.xml" +rebot -N acceptance -d "$ALL_RESULT_DIR" "$ALL_RESULT_DIR"/*.xml + if [ "$OZONE_WITH_COVERAGE" ]; then pkill -f JacocoServer cp /tmp/jacoco-combined.exec "$SCRIPT_DIR"/result diff --git a/hadoop-ozone/dist/src/main/compose/testlib.sh b/hadoop-ozone/dist/src/main/compose/testlib.sh index 5a0563308364..b000c913c1f7 100755 --- a/hadoop-ozone/dist/src/main/compose/testlib.sh +++ b/hadoop-ozone/dist/src/main/compose/testlib.sh @@ -37,6 +37,28 @@ create_results_dir() { chmod ogu+w "$RESULT_DIR" } +## @description find all the test.sh scripts in the immediate child dirs +find_tests(){ + if [[ -n "${OZONE_ACCEPTANCE_SUITE}" ]]; then + tests=$(find . -mindepth 2 -maxdepth 2 -name test.sh | xargs grep -l "^#suite:${OZONE_ACCEPTANCE_SUITE}$" | sort) + + # 'misc' is default suite, add untagged tests, too + if [[ "misc" == "${OZONE_ACCEPTANCE_SUITE}" ]]; then + untagged="$(find . -mindepth 2 -maxdepth 2 -name test.sh | xargs grep -L "^#suite:")" + if [[ -n "${untagged}" ]]; then + tests=$(echo ${tests} ${untagged} | xargs -n1 | sort) + fi + fi + + if [[ -z "${tests}" ]]; then + echo "No tests found for suite ${OZONE_ACCEPTANCE_SUITE}" + exit 1 + fi + else + tests=$(find . -mindepth 2 -maxdepth 2 -name test.sh | grep "${OZONE_TEST_SELECTOR:-""}" | sort) + fi + echo $tests +} ## @description wait until safemode exit (or 180 seconds) wait_for_safemode_exit(){ @@ -114,7 +136,7 @@ execute_robot_test(){ OUTPUT_PATH="$RESULT_DIR_INSIDE/${OUTPUT_FILE}" # shellcheck disable=SC2068 docker-compose exec -T "$CONTAINER" mkdir -p "$RESULT_DIR_INSIDE" \ - && docker-compose exec -T "$CONTAINER" robot -v OM_SERVICE_ID:"${OM_SERVICE_ID}" -v SECURITY_ENABLED:"${SECURITY_ENABLED}" -v OM_HA_PARAM:"${OM_HA_PARAM}" -v KEY_NAME:"${OZONE_BUCKET_KEY_NAME}" ${ARGUMENTS[@]} --log NONE -N "$TEST_NAME" --report NONE "${OZONE_ROBOT_OPTS[@]}" --output "$OUTPUT_PATH" "$SMOKETEST_DIR_INSIDE/$TEST" + && docker-compose exec -T "$CONTAINER" robot -v OM_SERVICE_ID:"${OM_SERVICE_ID}" -v SECURITY_ENABLED:"${SECURITY_ENABLED}" -v OM_HA_PARAM:"${OM_HA_PARAM}" -v KEY_NAME:"${OZONE_BUCKET_KEY_NAME}" ${ARGUMENTS[@]} --log NONE --report NONE "${OZONE_ROBOT_OPTS[@]}" --output "$OUTPUT_PATH" "$SMOKETEST_DIR_INSIDE/$TEST" local -i rc=$? FULL_CONTAINER_NAME=$(docker-compose ps | grep "_${CONTAINER}_" | head -n 1 | awk '{print $1}') diff --git a/hadoop-ozone/dist/src/test/shell/compose_testlib.bats b/hadoop-ozone/dist/src/test/shell/compose_testlib.bats new file mode 100644 index 000000000000..058da64f30d7 --- /dev/null +++ b/hadoop-ozone/dist/src/test/shell/compose_testlib.bats @@ -0,0 +1,37 @@ +#!/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. + + +load ../../main/compose/testlib.sh +@test "Find test recursive, only on one level" { + cd $BATS_TEST_DIRNAME + run find_tests + [[ "$output" == "./test1/test.sh ./test2/test.sh ./test4/test.sh" ]] +} + +@test "Find test by suite" { + OZONE_ACCEPTANCE_SUITE=one + cd $BATS_TEST_DIRNAME + run find_tests + [[ "$output" == "./test4/test.sh" ]] +} + +@test "Find test default suite" { + OZONE_ACCEPTANCE_SUITE=misc + cd $BATS_TEST_DIRNAME + run find_tests + [[ "$output" == "./test1/test.sh ./test2/test.sh" ]] +} diff --git a/hadoop-ozone/dist/src/test/shell/test1/test.sh b/hadoop-ozone/dist/src/test/shell/test1/test.sh new file mode 100644 index 000000000000..b13ca90d239f --- /dev/null +++ b/hadoop-ozone/dist/src/test/shell/test1/test.sh @@ -0,0 +1,15 @@ +#!/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. \ No newline at end of file diff --git a/hadoop-ozone/dist/src/test/shell/test2/test.sh b/hadoop-ozone/dist/src/test/shell/test2/test.sh new file mode 100644 index 000000000000..8dbf5b29721c --- /dev/null +++ b/hadoop-ozone/dist/src/test/shell/test2/test.sh @@ -0,0 +1,17 @@ +#!/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. + +#suite:misc \ No newline at end of file diff --git a/hadoop-ozone/dist/src/test/shell/test3/subtest1/test.sh b/hadoop-ozone/dist/src/test/shell/test3/subtest1/test.sh new file mode 100644 index 000000000000..8dbf5b29721c --- /dev/null +++ b/hadoop-ozone/dist/src/test/shell/test3/subtest1/test.sh @@ -0,0 +1,17 @@ +#!/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. + +#suite:misc \ No newline at end of file diff --git a/hadoop-ozone/dist/src/test/shell/test4/test.sh b/hadoop-ozone/dist/src/test/shell/test4/test.sh new file mode 100644 index 000000000000..accc445711e5 --- /dev/null +++ b/hadoop-ozone/dist/src/test/shell/test4/test.sh @@ -0,0 +1,17 @@ +#!/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. + +#suite:one \ No newline at end of file