diff --git a/Makefile b/Makefile index 17acf1ab6..4301b700d 100644 --- a/Makefile +++ b/Makefile @@ -127,11 +127,11 @@ test-api: TEST_DIR=testbdd .PHONY: run-tests -run-tests: +run-tests: generate-all @(cd $(TEST_DIR) && $(MAKE) $@) .PHONY: run-smoke-tests -run-smoke-tests: +run-smoke-tests: generate-all @(cd $(TEST_DIR) && $(MAKE) $@) .PHONY: test-container-builder diff --git a/hack/clean-stuck-namespaces.sh b/hack/clean-stuck-namespaces.sh index 8efd60aa7..f78b1659e 100755 --- a/hack/clean-stuck-namespaces.sh +++ b/hack/clean-stuck-namespaces.sh @@ -17,7 +17,6 @@ script_dir_path=`dirname "${BASH_SOURCE[0]}"` source ${script_dir_path}/env.sh DIR=$(mktemp -d) -LEAK_RESOURCES=( infinispan keycloakclients keycloakusers keycloakrealms kogitoruntimes kogitosupportingservices) oc get namespaces | grep "Terminating" | awk -F " " '{print $1}' > ${DIR}/projects diff --git a/hack/run-tests.sh b/hack/run-tests.sh index 3089ea02d..5c875725c 100755 --- a/hack/run-tests.sh +++ b/hack/run-tests.sh @@ -74,7 +74,7 @@ function usage(){ printf "\n-h | --help\n\tPrint the usage of this script." # tests configuration - printf "\n--test_main_dir {TEST_MAIN_DIR}\n\tWhere to find the `main_test.go` file. Default to `testbdd/`." + printf "\n--test_main_dir {TEST_MAIN_DIR}\n\tWhere to find the 'main_test.go' file. Defaults to 'testbdd/'." printf "\n--feature {FEATURE_PATH}\n\tRun a specific feature file." printf "\n--tags {TAGS}\n\tFilter scenarios by tags." printf "\n\tExpressions can be:" @@ -100,7 +100,7 @@ function usage(){ printf "\n--olm_namespace \n\tSet the namespace which is used for cluster scope operators. Default is 'openshift-operators'." # operator information - printf "\n--operator_image_tag {IMAGE_TAG}\n\tOperator image name. Default is 'quay.io/kiegroup/kogito-operator' one." + printf "\n--operator_image_tag {IMAGE_TAG}\n\tOperator image name." printf "\n--operator_installation_source {TAG}\n\tDefines installation source for the Kogito operator. Options are 'olm' and 'yaml'. Default is yaml." printf "\n--operator_catalog_image {TAG}\n\tDefines image containing operator catalog. Needs to be specified only when operator_installation_source is 'olm'." printf "\n--use_product_operator {TAG}\n\tSet to true to deploy RHPAM Kogito operator, false for using Kogito operator. Default is false." diff --git a/testbdd/README.md b/testbdd/README.md index 62b29e1b9..cb7965c2d 100644 --- a/testbdd/README.md +++ b/testbdd/README.md @@ -7,14 +7,118 @@ Tests also make use of the [BDD Framework](https://github.com/kiegroup/kogito-se ## Run tests -Tests currently support Minikube with OpenShift support coming. - -### Prerequisites -Specific prerequisites for running tests: +**Prerequisites:** * `oc` installed -* `~/.kube/config` targeting the Minikube cluster +* Minikube or OpenShift running +* `~/.kube/config` targeting the cluster + +Command to run tests has the following format: +```bash +$ make run-tests [key=value]* +``` + +You can set these optional keys: + + +- `feature` is a specific feature you want to run. + If you define a relative path, this has to be based on the "test" folder as the run is happening there. + *Default are all enabled features from 'test/features' folder* + Example: feature=features/operator/deploy_quarkus_service.feature +- `tags` to run only specific scenarios. It is using tags filtering. + *Scenarios with '@disabled' tag are always ignored.* + Expression can be: + - "@wip": run all scenarios with wip tag + - "~@wip": exclude all scenarios with wip tag + - "@wip && ~@new": run wip scenarios, but exclude new + - "@wip,@undone": run wip or undone scenarios + + Complete list of supported tags and descriptions can be found in [List of test tags](#list-of-test-tags) +- `concurrent` is the number of concurrent tests to be run. + *Default is 1.* +- `timeout` sets the timeout in minutes for the overall run. + *Default is 240 minutes.* +- `debug` to be set to true to activate debug mode. + *Default is false.* +- `load_factor` sets the tests load factor. Useful for the tests to take into account that the cluster can be overloaded, for example for the calculation of timeouts. + *Default is 1.* +- `ci` to be set if running tests with CI. Give CI name. +- `cr_deployment_only` to be set if you don't have a CLI built. Default will deploy applications via the CLI. +- `load_default_config` sets to true if you want to directly use the default test config (from test/.default_config) +- `format` sets the Godog output format, possible values are 'pretty' or 'junit'. *Default is junit.* +- `container_engine` engine used to interact with images and local containers. + *Default is docker.* +- `domain_suffix` domain suffix used for exposed services. Ignored when running tests on Openshift. +- `http_retry_nb` sets the retry number for all HTTP calls in case it fails (and response code != 500). + *Default is 3.* +- `olm_namespace` Set the namespace which is used for cluster scope operators. Default is 'openshift-operators'. + +- `operator_image_tag` is the Operator image full name. +- `operator_installation_source` Defines what source is used to install the SonataFlow operator. Available options are `olm` and `yaml`. + *Default is yaml*. +- `operator_catalog_image` Specifies catalog image containing SonataFlow operator bundle. Needs to be specified when `operator_installation_source` is set to `olm`. +- `use_product_operator` Set true if you want to run tests using product operator. + +- `operator_yaml_uri` Url or Path to operator.yaml file. + *Default is ../operator.yaml*. + +- `show_scenarios` sets to true to display scenarios which will be executed. + *Default is false.* +- `show_steps` sets to true to display scenarios and their steps which will be executed. + *Default is false.* +- `dry_run` sets to true to execute a dry run of the tests, disable crds updates and display the scenarios which will be executed. + *Default is false.* +- `keep_namespace` sets to true to not delete namespace(s) after scenario run (WARNING: can be resources consuming ...). + *Default is false.* +- `namespace_name` to specify name of the namespace which will be used for scenario execution (intended for development purposes). +- `local_cluster` to be set to true if running tests using a local cluster. + *Default is false.* +- `local_execution` to be set to true if running tests in local using either a local or remote cluster. + *Default is false.* + +Logs will be shown on the Terminal. + +To save the test output in a local file for future reference, run the following command: + +```bash +make run-tests 2>&1 | tee log.out +``` + +#### Running BDD tests with the current branch + +``` +$ make +$ make container-build +$ podman tag quay.io/kiegroup/kogito-serverless-operator-nightly:latest quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest +$ podman push quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest +$ make run-tests cr_deployment_only=true local_cluster=true operator_image_tag=quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest +``` + +**NOTE:** Replace {USERNAME} with the username/group you want to push to. Podman needs to be logged in to quay.io and be able to push to your username/group. If you want to use docker, just append `BUILDER=docker` to the `make container-build` command. + +#### Running smoke tests + +The BDD tests do provide some smoke tests for a quick feedback on basic functionality: + +```bash +$ make run-smoke-tests [key=value]* +``` + +It will run only tests tagged with `@smoke`. +All options from BDD tests do also apply here. + +#### Running devMode tests +```bash +make run-tests cr_deployment_only=true local_cluster=true show_scenarios=true tags=devMode namespace_name=my-namespace operator_image_tag=quay.io/kiegroup/kogito-serverless-operator-nightly:latest +``` + +If you want to have a more readable format, you can specify the `format=pretty` parameter. You can also specify your own operator image. Namespace is always created automatically, however, you can provide its name as in the command above, otherwise it will be automatically generated. + +#### List of test tags -### Run devMode tests -`go test -v --tests.cr_deployment_only=true --tests.dev.local_cluster=true --tests.show_scenarios=true --godog.tags="devMode" --tests.operator_yaml_uri=../operator.yaml --tests.operator_image_tag=quay.io/kiegroup/kogito-serverless-operator-nightly:1.40.x-2023-07-10 --tests.dev.namespace_name=my-namespace` +| Tag name | Tag meaning | +|-----------|-----------------------------------------------------------| +| @smoke | Smoke tests verifying basic functionality | +| @disabled | Disabled tests, usually with comment describing reasons | +| | | +| @devMode | Tests verifying dev mode profile of the deployed workflow | -If you want to have a more readable format, you can specify the `--godog.format=pretty` parameter. You can also specify your own operator image. Namespace is always created automatically, however, you can provide its name as in the command above, otherwise it will be automatically generated. diff --git a/testbdd/features/e2e.feature b/testbdd/features/e2e.feature index 6a2fb80a4..0cc03c301 100644 --- a/testbdd/features/e2e.feature +++ b/testbdd/features/e2e.feature @@ -6,7 +6,7 @@ Feature: Deploy SonataFlow Operator When SonataFlow Operator is deployed When SonataFlowPlatform is deployed When SonataFlow orderprocessing example is deployed - Then SonataFlow "orderprocessing" has the condition "Running" set to "True" within 2 minutes + Then SonataFlow "orderprocessing" has the condition "Running" set to "True" within 5 minutes Then SonataFlow "orderprocessing" is addressable within 1 minute Then HTTP POST request as Cloud Event on SonataFlow "orderprocessing" is successful within 1 minute with path "", headers "content-type= application/json,ce-specversion= 1.0,ce-source= /from/localhost,ce-type= orderEvent,ce-id= f0643c68-609c-48aa-a820-5df423fa4fe0" and body: """json