-
- Notifications
You must be signed in to change notification settings - Fork 1
feat(run_tests.sh): install operators as needed by the tests. #333
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
19 commits Select commit Hold shift + click to select a range
58d1b82 feat(run_tests.sh): install operators as needed by the tests.
razvan fd78a6e implement shellcheck feedback
razvan f6cf1b3 fix more lints
razvan 7b9534a feat(github): run openshift tests from the build workflow
razvan f74657f feat(run_tests.sh): added command line options.
razvan 44b4877 fix(github): do not run openshift tests from forks
razvan fc0764b main merge (fix conflict)
razvan 469f4c2 fix: restore wrongly removed line
razvan 2396c9f Added --skip-release and successfully tested the GH workflow
razvan 7af814e Merge branch 'main' into feat/test-release
razvan 28a7a6c Implement review feedback
razvan e75646a Fix lints
razvan 5a6f7a9 Better help message from run_tests.sh
razvan 297f15e fix more lints
razvan 2f18dab fix typo
razvan d7ed762 Update template/scripts/run_tests.sh
razvan 915e1f8 Update template/scripts/run_tests.sh
razvan eec0ad3 Update template/.github/workflows/build.yml.j2
razvan dc58b12 Update template/.github/workflows/build.yml.j2
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,134 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Run the integration test suite for this operator. | ||
| # | ||
| # If a "tests/release.yaml" file is present, it will install the operators listed | ||
| # in the release file first. The name of the test suite in that file must be "tests". | ||
| # Since each operator test suite has different dependencies, the "tests/release.yaml" | ||
| # file is not included in this repository. | ||
| # | ||
| # Optionally you can provide a specific test suite to run and even a specific | ||
| # test name. | ||
| # | ||
| # Example 1 - run all tests of the openshift suite. | ||
| # | ||
| # ./scripts/run_tests.sh --test-suite openshift --parallel 2 | ||
| # | ||
| # Example 2 - run a specific smoke test of the openshift suite and skip resource deletion. | ||
| # | ||
| # ./scripts/run_tests.sh \ | ||
| # --test-suite openshift \ | ||
| # --test smoke_trino-439_hive-3.1.3_opa-0.61.0_hdfs-3.3.6_zookeeper-3.8.3_s3-use-tls-true_openshift-true \ | ||
adwk67 marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| # --skip-delete | ||
| # | ||
| | ||
| # Check if the test expansion tool beku is installed | ||
| set +e | ||
| which beku > /dev/null 2>&1 | ||
| beku_installed=$? | ||
| set -e | ||
| if [ $beku_installed -ne 0 ]; then | ||
| echo "Please install beku.py to run the tests, see https://github.com/stackabletech/beku.py" | ||
| exit 1 | ||
| fi | ||
| | ||
| echo "Using beku version: $(beku --version)" | ||
| | ||
| # cleanup any old tests | ||
| rm -rf tests/_work | ||
| | ||
| # Expand the tests | ||
| beku | ||
| | ||
| # Run tests, pass the params | ||
| pushd tests/_work | ||
| kubectl kuttl test "$@" | ||
| popd | ||
| | ||
| DIR_NAME=$(dirname "$0") | ||
| REPO_ROOT=$(dirname "$DIR_NAME") | ||
| TEST_ROOT="$REPO_ROOT/tests/_work" | ||
| RELEASE_FILE="$REPO_ROOT/tests/release.yaml" | ||
| BEKU_TEST_SUITE="" | ||
| KUTTL_TEST="" | ||
| KUTTL_SKIP_DELETE="" | ||
| KUTTL_PARALLEL="" | ||
| | ||
| is_installed() { | ||
| local command="$1" | ||
| local install_url="$2" | ||
| | ||
| if ! which "$command" >/dev/null 2>&1; then | ||
| echo "Command [$command] not found. To install it, please see $install_url" | ||
| exit 1 | ||
| fi | ||
| } | ||
| | ||
| install_operators() { | ||
| if [ -f "$RELEASE_FILE" ]; then | ||
| echo "Installing operators with stackablectl version: $(stackablectl --version)" | ||
| stackablectl release install --release-file "$RELEASE_FILE" tests | ||
| else | ||
| echo "No tests/release.yaml found, skipping operator installation" | ||
| fi | ||
| } | ||
| | ||
| expand_test_suite() { | ||
| # Expand the tests | ||
| echo "Running beku version: $(beku --version)" | ||
| if [ -z "$BEKU_TEST_SUITE" ]; then | ||
| echo "No test suite specified, expanding all tests" | ||
| beku | ||
| else | ||
| echo "Expanding test suite: $BEKU_TEST_SUITE" | ||
| beku --suite "$BEKU_TEST_SUITE" | ||
| fi | ||
| } | ||
| | ||
| run_tests() { | ||
| echo "Running kuttl version: $(kubectl-kuttl --version)" | ||
| | ||
| local OPTS=("test") | ||
| | ||
| if [ -n "$KUTTL_SKIP_DELETE" ]; then | ||
| OPTS+=("--skip-delete") | ||
| fi | ||
| | ||
| if [ -n "$KUTTL_PARALLEL" ]; then | ||
| OPTS+=("--parallel $KUTTL_PARALLEL") | ||
| fi | ||
| | ||
| if [ -n "$KUTTL_TEST" ]; then | ||
| OPTS+=("--test=$KUTTL_TEST") | ||
| fi | ||
| | ||
| pushd "$TEST_ROOT" || exit | ||
| kubectl-kuttl ${OPTS[*]} | ||
razvan marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| popd || exit | ||
| } | ||
| | ||
| usage() { | ||
| echo "Usage: $0 [--test-suite <test-suite>] [--test <test-name>] [--skip-delete] [--parallel <number>]" | ||
| } | ||
| | ||
| parse_args() { | ||
| while [[ "$#" -gt 0 ]]; do | ||
| case $1 in | ||
| --skip-delete) | ||
| KUTTL_SKIP_DELETE="true" | ||
| ;; | ||
| --parallel) | ||
| KUTTL_PARALLEL="$2" | ||
| shift | ||
| ;; | ||
| --test-suite) | ||
| BEKU_TEST_SUITE="$2" | ||
| shift | ||
| ;; | ||
| --test) | ||
| KUTTL_TEST="$2" | ||
| shift | ||
| ;; | ||
| *) | ||
| echo "Unknown parameter : $1" | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
| } | ||
| | ||
| main() { | ||
| parse_args "$@" | ||
| | ||
| is_installed beku "https://github.com/stackabletech/beku.py" | ||
| is_installed stackablectl "https://github.com/stackabletech/stackable-cockpit/blob/main/rust/stackablectl/README.md" | ||
| is_installed kubectl "https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/" | ||
| is_installed kubectl-kuttl "https://kuttl.dev/" | ||
| | ||
| expand_test_suite | ||
| install_operators | ||
| run_tests | ||
| } | ||
| | ||
| main $@ | ||
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.