Skip to content

Commit

Permalink
Make running bash funciones more generic
Browse files Browse the repository at this point in the history
We have too many duplicated bash scripts to run different ginkgo
testsuites, so lets try to make a generic script to reduce code
duplication.
  • Loading branch information
jlojosnegros committed Apr 24, 2023
1 parent 951cc09 commit 8c57eab
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 116 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pao-functests: cluster-label-worker-cnf pao-functests-only
pao-functests-only:
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-functests.sh
hack/run-test.sh -t "test/e2e/performanceprofile/functests" -p "--v -r --fail-fast --skip-package='5_latency_testing,2_performance_update' --flake-attempts=2 --junit-report=report.xml" -m "Running Functional Tests"

.PHONY: pao-functests-updating-profile
pao-functests-updating-profile: cluster-label-worker-cnf pao-functests-update-only
Expand All @@ -208,13 +208,13 @@ pao-functests-updating-profile: cluster-label-worker-cnf pao-functests-update-on
pao-functests-update-only:
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-update-testing.sh
hack/run-test.sh -t "test/e2e/performanceprofile/functests/0_config test/e2e/performanceprofile/functests/2_performance_update" -p "-v -r -timeout=5h --fail-fast --flake-attempts=2 --junit-report=report.xml" -m "Running Functional Tests"

.PHONY: pao-functests-latency-testing
pao-functests-latency-testing: dist-latency-tests
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-latency-testing.sh
hack/run-test.sh -t "./test/e2e/performanceprofile/functests/0_config ./test/e2e/performanceprofile/functests/5_latency_testing" -p "--v -r --fail-fast --flake-attempts=2 --junit-report=/tmp/artifacts" -m "Running Functional Tests"

.PHONY: cluster-clean-pao
cluster-clean-pao:
Expand All @@ -231,7 +231,7 @@ build-performance-profile-creator:
.PHONY: performance-profile-creator-tests
performance-profile-creator-tests: build-performance-profile-creator
@echo "Running Performance Profile Creator Tests"
hack/run-perf-profile-creator-functests.sh
hack/run-test.sh -t "test/e2e/performanceprofile/functests-performance-profile-creator" -p "--v -r --fail-fast --flake-attempts=2 --junit-report=/tmp/artifacts" -m "Running Functional Tests"

.PHONY: render-sync
render-sync: build
Expand Down
31 changes: 0 additions & 31 deletions hack/run-functests.sh

This file was deleted.

25 changes: 0 additions & 25 deletions hack/run-latency-testing.sh

This file was deleted.

25 changes: 0 additions & 25 deletions hack/run-perf-profile-creator-functests.sh

This file was deleted.

86 changes: 86 additions & 0 deletions hack/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

readonly CURRENT_SCRIPT=$(basename $0)

HEADER_MESSAGE="Running Tests "

usage() {
print "Usage:"
print " ${CURRENT_SCRIPT} [-h] -s suites -p extraparams [-m header_message]"
print ""
print "Options:"
print " -h Help for ${CURRENT_SCRIPT}"
print " -t list of space separated paths to Testsuites to execute"
print " -p string with extra Params for ginkgo"
print " -m Message header to print before test execution. Default '${HEADER_MESSAGE}'"
}

exit_error() {
print ""
print "error: $*"
exit 1
}

print() {
echo "$*" >&2
}

HEADER_MESSAGE="Running Tests "

main() {
while getopts ':ht:p:m:' OPT; do
case "$OPT" in
h)
usage
exit 0
;;
t)
GINKGO_SUITS="${OPTARG}"
;;
p)
EXTRA_PARAMS="${OPTARG}"
;;
m)
HEADER_MESSAGE="${OPTARG}"
;;
?)
usage
exit_error "invalid argument: ${OPTARG}"
;;
esac
done
shift $((OPTIND - 1))

if [ -z "$GINKGO_SUITS" ] || [ -z "$EXTRA_PARAMS" ]; then
usage
exit_error "Missing arguments -t or -p"
fi

LATENCY_TEST_RUN=${LATENCY_TEST_RUN:-"false"}

which ginkgo
if [ $? -ne 0 ]; then
echo "Downloading ginkgo tool"
go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@v2.6.1
ginkgo version
fi

NO_COLOR=""
if ! which tput &>/dev/null 2>&1 || [[ $(tput -T$TERM colors) -lt 8 ]]; then
echo "Terminal does not seem to support colored output, disabling it"
NO_COLOR="-noColor"
fi

# run the latency tests under the OpenShift CI, just to verify that the image works
if [ -n "${IMAGE_FORMAT}" ]; then
LATENCY_TEST_RUN="true"
fi

MESSAGE="${HEADER_MESSAGE}: ${GINKGO_SUITS}"
print ${MESSAGE}

GINKGO_FLAGS="${NO_COLOR} ${EXTRA_PARAMS} --require-suite ${GINKGO_SUITS}"
GOFLAGS=-mod=vendor ginkgo ${GINKGO_FLAGS}
}

main "$@"
31 changes: 0 additions & 31 deletions hack/run-update-testing.sh

This file was deleted.

0 comments on commit 8c57eab

Please sign in to comment.