Skip to content

Commit f28900b

Browse files
committed
shellcheck fix + address review comments
1 parent 8354728 commit f28900b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
set -e
18-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
1918

2019
COMPOSE_ENV_NAME=$(basename "$COMPOSE_DIR")
2120
COMPOSE_FILE=$COMPOSE_DIR/docker-compose.yaml
22-
RESULT_DIR="$COMPOSE_DIR/result"
21+
RESULT_DIR=${RESULT_DIR:-"$COMPOSE_DIR/result"}
2322
RESULT_DIR_INSIDE="/tmp/smoketest/$(basename "$COMPOSE_ENV_NAME")/result"
2423
SMOKETEST_DIR_INSIDE="${OZONE_DIR:-/opt/hadoop}/smoketest"
2524

@@ -75,14 +74,15 @@ execute_robot_test(){
7574
CONTAINER="$1"
7675
TEST="$2"
7776
TEST_NAME=$(basename "$TEST")
78-
TEST_NAME="$(basename $COMPOSE_DIR)-${TEST_NAME%.*}"
77+
TEST_NAME="$(basename "$COMPOSE_DIR")-${TEST_NAME%.*}"
7978
set +e
8079
OUTPUT_NAME="$COMPOSE_ENV_NAME-$TEST_NAME-$CONTAINER"
80+
OUTPUT_PATH="$RESULT_DIR_INSIDE/robot-$OUTPUT_NAME.xml"
8181
docker-compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" mkdir -p "$RESULT_DIR_INSIDE"
82-
docker-compose -f "$COMPOSE_FILE" exec -e SECURITY_ENABLED="${SECURITY_ENABLED}" -T "$CONTAINER" python -m robot --log NONE -N "$TEST_NAME" --report NONE "${OZONE_ROBOT_OPTS[@]}" --output "$RESULT_DIR_INSIDE/robot-$OUTPUT_NAME.xml" "$SMOKETEST_DIR_INSIDE/$TEST"
82+
docker-compose -f "$COMPOSE_FILE" exec -e SECURITY_ENABLED="${SECURITY_ENABLED}" -T "$CONTAINER" python -m robot --log NONE -N "$TEST_NAME" --report NONE "${OZONE_ROBOT_OPTS[@]}" --output "$OUTPUT_PATH" "$SMOKETEST_DIR_INSIDE/$TEST"
8383

84-
export FULL_CONTAINER_NAME=$(docker-compose -f "$COMPOSE_FILE" ps | grep "_${CONTAINER}_" | head -n 1 | awk '{print $1}')
85-
docker cp $FULL_CONTAINER_NAME:$RESULT_DIR_INSIDE "$COMPOSE_DIR"
84+
FULL_CONTAINER_NAME=$(docker-compose -f "$COMPOSE_FILE" ps | grep "_${CONTAINER}_" | head -n 1 | awk '{print $1}')
85+
docker cp "$FULL_CONTAINER_NAME:$OUTPUT_PATH" "$RESULT_DIR/"
8686
set -e
8787

8888
}
@@ -97,8 +97,8 @@ stop_docker_env(){
9797

9898
## @description Generate robot framework reports based on the saved results.
9999
generate_report(){
100-
which rebot > /dev/null 2>&1
101-
if [ "$?" == "0" ]; then
100+
101+
if command -v rebot > /dev/null 2>&1; then
102102
#Generate the combined output and return with the right exit code (note: robot = execute test, rebot = generate output)
103103
rebot -d "$RESULT_DIR" "$RESULT_DIR/robot-*.xml"
104104
else

0 commit comments

Comments
 (0)