Skip to content
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

test-cli: Pass -v/--verbose flag to Go integration tests #7754

Merged
merged 1 commit into from
Oct 10, 2024
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: 9 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ STATUS="FAILURE"
RUN=()
UNIT_PACKAGES=()
UNIT_FLAGS=()
INTEGRATION_FLAGS=()
FILTER=()

#
Expand All @@ -39,11 +40,6 @@ function print_outcome() {
fi
}

function print_list_of_integration_tests() {
go test -tags integration -list=. ./test/integration/... | grep '^Test'
exit 0
}

function exit_msg() {
# complain to STDERR and exit with error
echo "$*" >&2
Expand Down Expand Up @@ -101,15 +97,14 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat

-l, --lints Adds lint to the list of tests to run
-u, --unit Adds unit to the list of tests to run
-v, --unit-verbose Enables verbose output for unit tests
-v, --verbose Enables verbose output for unit and integration tests
-w, --unit-without-cache Disables go test caching for unit tests
-p <DIR>, --unit-test-package=<DIR> Run unit tests for specific go package(s)
-e, --enable-race-detection Enables race detection for unit and integration tests
-n, --config-next Changes BOULDER_CONFIG_DIR from test/config to test/config-next
-i, --integration Adds integration to the list of tests to run
-s, --start-py Adds start to the list of tests to run
-g, --generate Adds generate to the list of tests to run
-o, --list-integration-tests Outputs a list of the available integration tests
-f <REGEX>, --filter=<REGEX> Run only those tests matching the regular expression

Note:
Expand All @@ -125,7 +120,7 @@ With no options passed, runs standard battery of tests (lint, unit, and integrat
EOM
)"

while getopts luvweciosmgnhp:f:-: OPT; do
while getopts luvwecismgnhp:f:-: OPT; do
if [ "$OPT" = - ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
Expand All @@ -134,12 +129,11 @@ while getopts luvweciosmgnhp:f:-: OPT; do
case "$OPT" in
l | lints ) RUN+=("lints") ;;
u | unit ) RUN+=("unit") ;;
v | unit-verbose ) UNIT_FLAGS+=("-v") ;;
v | verbose ) UNIT_FLAGS+=("-v"); INTEGRATION_FLAGS+=("-v") ;;
w | unit-without-cache ) UNIT_FLAGS+=("-count=1") ;;
p | unit-test-package ) check_arg; UNIT_PACKAGES+=("${OPTARG}") ;;
e | enable-race-detection ) RACE="true"; UNIT_FLAGS+=("-race") ;;
i | integration ) RUN+=("integration") ;;
o | list-integration-tests ) print_list_of_integration_tests ;;
f | filter ) check_arg; FILTER+=("${OPTARG}") ;;
s | start-py ) RUN+=("start") ;;
g | generate ) RUN+=("generate") ;;
Expand Down Expand Up @@ -244,7 +238,11 @@ STAGE="integration"
if [[ "${RUN[@]}" =~ "$STAGE" ]] ; then
print_heading "Running Integration Tests"
flush_redis
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
if [[ "${INTEGRATION_FLAGS[@]}" =~ "-v" ]] ; then
python3 test/integration-test.py --chisel --gotestverbose "${FILTER[@]}"
else
python3 test/integration-test.py --chisel --gotest "${FILTER[@]}"
fi
fi

# Test that just ./start.py works, which is a proxy for testing that
Expand Down
14 changes: 11 additions & 3 deletions test/integration-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if os.environ.get('RACE', 'true') != 'true':
race_detection = False

def run_go_tests(filterPattern=None):
def run_go_tests(filterPattern=None,verbose=False):
"""
run_go_tests launches the Go integration tests. The go test command must
return zero or an exception will be raised. If the filterPattern is provided
Expand All @@ -43,7 +43,10 @@ def run_go_tests(filterPattern=None):
cmdLine = ["go", "test"]
if filterPattern is not None and filterPattern != "":
cmdLine = cmdLine + ["--test.run", filterPattern]
cmdLine = cmdLine + ["-tags", "integration", "-count=1", "-race", "./test/integration"]
cmdLine = cmdLine + ["-tags", "integration", "-count=1", "-race"]
if verbose:
cmdLine = cmdLine + ["-v"]
cmdLine = cmdLine + ["./test/integration"]
subprocess.check_call(cmdLine, stderr=subprocess.STDOUT)

exit_status = 1
Expand All @@ -54,6 +57,8 @@ def main():
help="run integration tests using chisel")
parser.add_argument('--gotest', dest="run_go", action="store_true",
help="run Go integration tests")
parser.add_argument('--gotestverbose', dest="run_go_verbose", action="store_true",
help="run Go integration tests with verbose output")
parser.add_argument('--filter', dest="test_case_filter", action="store",
help="Regex filter for test cases")
# allow any ACME client to run custom command for integration
Expand Down Expand Up @@ -90,7 +95,10 @@ def main():
run_chisel(args.test_case_filter)

if args.run_go:
run_go_tests(args.test_case_filter)
run_go_tests(args.test_case_filter, False)

if args.run_go_verbose:
run_go_tests(args.test_case_filter, True)

if args.custom:
run(args.custom.split())
Expand Down