Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/post-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ jobs:
- uses: ./.github/buildenv
with:
args: ./hadoop-ozone/dev-support/checks/build.sh
bats:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future I am planning to improve all the existing tests:

  1. With adding name to all the steps
  2. Use upper case for the first letter (default for github actions if the name is missing).

This is the same as the others, so I think we can merge it as is.

- name: install bats
run: |
cd /tmp
curl -LSs https://github.com/bats-core/bats-core/archive/v1.2.1.tar.gz | tar xzf -
cd bats-core-1.2.1
sudo ./install.sh /usr/local
- name: run tests
run: ./hadoop-ozone/dev-support/checks/${{ github.job }}.sh
- name: Summary of failures
run: cat target/${{ github.job }}/summary.txt
if: always()
- uses: actions/upload-artifact@master
if: always()
with:
name: ${{ github.job }}
path: target/${{ github.job }}
rat:
name: rat
runs-on: ubuntu-18.04
Expand Down
35 changes: 35 additions & 0 deletions hadoop-ozone/dev-support/checks/bats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "${DIR}/../../.." || exit 1

REPORT_DIR=${OUTPUT_DIR:-"${DIR}/../../../target/bats"}
mkdir -p "${REPORT_DIR}"
REPORT_FILE="${REPORT_DIR}/summary.txt"

rm -f "${REPORT_DIR}/output.log"

find * -path '*/src/test/shell/*' -name '*.bats' -print0 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussion-mode:on

This pattern ("fail at the end") is introduced to execute all the tests even if some of them are failing. It's very useful for long and flaky test runs.

But it's somewhat more complex.

Recently I started to think to use a "fail fast" approach. It can simplify the scripts and we can use set -e to be sure we don't ignore any internal errors.

It's not working everywhere, but here it could.

But I am fine with this approach (which is better to create a summary), just sharing my thoughts.

</discussion-mode:on>

| xargs -0 -n1 bats --formatter tap \
| tee -a "${REPORT_DIR}/output.log"

grep '^\(not ok\|#\)' "${REPORT_DIR}/output.log" > "${REPORT_FILE}"

grep -c '^not ok' "${REPORT_FILE}" > "${REPORT_DIR}/failures"

if [[ -s "${REPORT_FILE}" ]]; then
exit 1
fi
6 changes: 2 additions & 4 deletions hadoop-ozone/dist/src/test/shell/gc_opts.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.



#
# Can be executed with bats (https://github.com/bats-core/bats-core)
# bats gc_opts.bats (FROM THE CURRENT DIRECTORY)
# bats gc_opts.bats
#

source ../../shell/hdds/hadoop-functions.sh
load ../../shell/hdds/hadoop-functions.sh
@test "Setting Hadoop GC parameters: add GC params for server" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=true
export HADOOP_OPTS="Test"
Expand Down