README
¶
BDD test suite (testbdd)
This module contains the BDD scenarios for the OpenShift Serverless Logic operator. Scenarios are written in Gherkin and executed by Godog. Cluster access, OLM/YAML installers and configuration flags come from the bddframework module.
- How it works
- Running the suite
- Tags
- Parameters
- Results and logs
- Cleanup and troubleshooting
- Writing tests
How it works
make run-tests key=value ... testbdd/Makefile turns every key=value into --key "value"
└─ hack/run-tests.sh maps options to Go test flags (--tests.*, --godog.*)
└─ go test ./testbdd main_test.go -> executor.ExecuteBDDTests()
├─ BeforeSuite installs the operator (OLM) unless a scenario installs it itself
├─ per scenario creates a random namespace bdd-xxxx, runs the steps, deletes the namespace
└─ AfterSuite uninstalls what the suite installed, deletes the test CatalogSource
Key behaviour of the executor (executor/bdd_executor.go):
@disabled,@performanceand@upgradeTestsscenarios are excluded automatically unless you request them explicitly.- With
operator_installation_source=olm,BeforeSuitecreates the CatalogSourcebdd-tests-kogito-catalog(fromoperator_catalog_image) inopenshift-marketplace. It then subscribes tologic-operatorinopenshift-operators. - If
operator.versionorupgrade.from_versionis set,BeforeSuiteonly creates the CatalogSource. The scenario then installs the operator with a dedicated step. - Each scenario runs in a fresh namespace, which is deleted afterwards unless
keep_namespace=trueis set.
Running the suite
Prerequisites:
- Go
oconPATHoc loginto an OpenShift cluster with OLM
The kubeconfig used by oc is also used by the suite ($KUBECONFIG or ~/.kube/config).
Run commands from the repository root with make -C testbdd run-tests ..., or from this directory with make run-tests .... The root Makefile also proxies make run-tests.
Dry run (list scenarios, no cluster changes)
make -C testbdd run-tests dry_run=true cr_deployment_only=true tags="@previewMode"
Profile and platform tags with an index (IIB) image
Use this for @devMode, @previewMode and @gitOpsMode:
export IIB_IMAGE="registry-proxy.engineering.redhat.com/rh-osbs/iib:<INDEX>"
make -C testbdd run-tests \
cr_deployment_only=true \
operator_installation_source=olm \
operator_catalog_image="$IIB_IMAGE" \
operator_image_tag="olm-install-ignored" \
tags="@devMode" \
format=pretty \
2>&1 | tee bdd-devMode.log
Why
operator_image_tag? Whenoperator_image_tagis empty, the installer falls back to the community catalog (installers/sonataflow_installer.go). In OLM mode the value itself is not used, so any non-empty placeholder works.
Do not set
operator.versionfor these tags. It disables the global install, and these scenarios have no install step of their own.
@platform: the scenario installs a specific version itself
make -C testbdd run-tests \
cr_deployment_only=true \
operator_installation_source=olm \
operator_catalog_image="$IIB_IMAGE" \
"operator.version=1.39.0" \
tags="@platform" \
format=pretty \
2>&1 | tee bdd-platform.log
The step SonataFlow Operator is installed via OLM installs logic-operator.v<operator.version>. It uses the custom catalog when operator_catalog_image is set, otherwise redhat-operators.
@upgradeTests: OLM upgrade
The from-version is installed from redhat-operators. The to-version must be available in the index image.
make -C testbdd run-tests \
cr_deployment_only=true \
operator_installation_source=olm \
operator_catalog_image="$IIB_IMAGE" \
"upgrade.from_version=1.38.2" \
"upgrade.to_version=1.39.0" \
"upgrade.to_kogito_runtime_version=9.106.0.redhat-00005" \
"upgrade.to_quarkus_core_version=3.33.3.redhat-00007" \
tags="@upgradeTests" \
format=pretty \
2>&1 | tee bdd-upgrade.log
-
Runtime versions:
upgrade.to_kogito_runtime_versionandupgrade.to_quarkus_core_versionhave no default. They build the expected Data Index/Job Service startup log line after the upgrade, for exampledata-index-service-postgresql <kogito> on JVM (powered by Quarkus <quarkus>) started in. Take them from the release notes or from the Data Index pod log of the target version. -
GitOps images: the gitops part of the scenario uses
quay.io/dhanak/callbackstatetimeouts:<from_version>and:<to_version>(callbackstatetimeouts_gitops.yaml). Both tags must exist. -
Before running, check that the from-version is available:
oc get packagemanifests -n openshift-marketplace -l catalog=redhat-operators \ -o jsonpath='{range .items[?(@.metadata.name=="logic-operator")].status.channels[*]}{.name}{": "}{range .entries[*]}{.name}{" "}{end}{"\n"}{end}' -
Design notes: the scenario flow and the planned work are described in
_agents/upgrade-tests.mdandtasks/.
@installation / @smoke: YAML install
These scenarios use the step SonataFlow Operator is deployed, which applies operator.yaml (operator_yaml_uri). They patch the operator image and the related images:
make -C testbdd run-tests \
cr_deployment_only=true \
operator_image_tag="<registry>/openshift-serverless-1-logic-rhel9-operator:<tag>" \
"operator.related_image.base_builder=<registry>/openshift-serverless-1-logic-swf-builder-rhel9:<tag>" \
tags="@installation" \
format=pretty
The script run_custom_operator_test.sh shows a full example with all related images.
Tags
| Tag | Feature file(s) | Operator install | Extra parameters |
|---|---|---|---|
@devMode |
platform_default.feature, platform_with_data_index_and_job_service.feature |
Global (BeforeSuite) |
none |
@previewMode |
platform_configmap_properties.feature, platform_with_data_index_and_job_service.feature |
Global | none |
@gitOpsMode |
platform_default.feature, platform_with_data_index_and_job_service.feature |
Global | none |
@platform |
platform_service_custom_labels.feature |
Scenario step (OLM) | operator.version |
@upgradeTests |
operator_upgrade.feature |
Scenario steps (OLM) | upgrade.* (see above) |
@installation |
install_logic_operator_yaml.feature |
Scenario step (YAML) | operator_image_tag, related images |
@smoke |
deploy_job_service.feature, deploy_data_index_service.feature |
Scenario step (YAML) | operator_image_tag |
@workflows100 |
deploy_100_workflows_with_di_js_postgresql.feature |
Global | none (heavy) |
@disabled |
any | always skipped |
Tag expressions:
"@a": scenarios with taga"~@a": exclude taga"@a && ~@b":abut notb"@a,@b":aorb
Tags are case-sensitive. The smoke=true option is the same as tags="@smoke".
Parameters
Pass parameters to make run-tests as key=value. Run ../hack/run-tests.sh --help for the full list. The most relevant ones:
| Parameter | Purpose |
|---|---|
tags |
Godog tag expression (see above) |
feature |
Run a single feature file, path relative to testbdd/ (for example features/operator/operator_upgrade.feature) |
format |
pretty or junit (default) |
cr_deployment_only |
Deploy via CRs only (no CLI). Always set this. |
operator_installation_source |
olm or yaml (default yaml) |
operator_catalog_image |
Index (IIB) image used for the bdd-tests-kogito-catalog CatalogSource |
operator_image_tag |
Operator image. Required for YAML installs; must be non-empty for global OLM installs (see above). |
operator_yaml_uri |
URL or path of operator.yaml for YAML installs |
operator.related_image.<name> |
Override related images for YAML installs: jobs_service_postgresql, jobs_service_ephemeral, data_index_postgresql, data_index_ephemeral, db_migrator_tool, base_builder, devmode |
operator.version |
Operator version installed by the SonataFlow Operator is installed via OLM step |
upgrade.from_version / upgrade.to_version |
Upgrade source and target versions |
upgrade.to_kogito_runtime_version / upgrade.to_quarkus_core_version |
Versions expected in Data Index/Job Service logs after the upgrade |
olm_namespace |
Namespace for cluster-wide operators (default openshift-operators) |
timeout |
Overall timeout in minutes (default 240) |
load_factor |
Multiplier for all step timeouts on slow clusters (default 1) |
debug |
Verbose logging |
dry_run |
Show scenarios without running them |
show_scenarios / show_steps |
Print the selected scenarios (and steps) before running |
keep_namespace |
Keep scenario namespaces after the run, for debugging |
namespace_name |
Use a fixed namespace name instead of bdd-xxxx |
local_cluster |
Set for local, non-OpenShift clusters (Kind, Minikube) |
domain_suffix |
Domain suffix for exposed services on non-OpenShift clusters |
enable_clean_cluster |
Run hack/clean-cluster-operators.sh and hack/clean-crds.sh before and after. Warning: this deletes all subscriptions, CSVs and InstallPlans in openshift-operators and operators. |
Results and logs
| Location | Content |
|---|---|
| Console | Godog output; format=pretty is the most readable |
logs/junit.xml |
JUnit report |
logs/<namespace>/ |
Pod logs collected for each scenario namespace (bdd-xxxx) and for openshift-operators, openshift-serverless-logic, openshift-marketplace |
logs/operator.yaml |
Patched operator.yaml (YAML installs only) |
/tmp/bdd-exit-code.txt |
Exit code of the last run |
Useful log lines to confirm which operator was installed:
grep -E "Installing custom Kogito operator CatalogSource|Subscribing to operator|Installing SonataFlow operator via OLM|community catalog" bdd-<tag>.log
A line Installing SonataFlow operator using community catalog. in BeforeSuite means the community operator was installed instead of the one from your index image.
Cleanup and troubleshooting
The suite cleans up after itself in normal runs. Check for leftovers after an interrupted run (Ctrl-C or a panic) and after @upgradeTests runs:
oc get subscription,csv -n openshift-operators | grep logic-operator
Remove leftovers:
oc delete subscription logic-operator -n openshift-operators --ignore-not-found
oc get csv -n openshift-operators -o name | grep logic-operator | xargs -r oc delete -n openshift-operators
oc delete catalogsource bdd-tests-kogito-catalog -n openshift-marketplace --ignore-not-found
# old InstallPlans that reference logic-operator
oc get installplan -n openshift-operators \
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.clusterServiceVersionNames[*]}{"\n"}{end}' \
| awk '/logic-operator\./ {print $1}' | xargs -r oc delete installplan -n openshift-operators
Clean up the subscription and CSV first. A leftover subscription is reused as-is by the next run, even if it points to a different catalog.
| Symptom | Cause / fix |
|---|---|
panic: The 'domain_suffix' argument is required using Kubernetes cluster |
The suite did not detect OpenShift. Check oc whoami --show-server and $KUBECONFIG, then log in again. On Kind or Minikube, set local_cluster=true. |
CatalogSource never READY |
The cluster cannot pull the index image. Check the pull secret and the mirror configuration (ICSP/IDMS) for the registry. |
Error bumping events ... could not find the requested resource |
Harmless. The framework still calls the deprecated v1beta1 events API. |
Error while retrieving log ... no route to host on port 10250 |
A node's kubelet is unreachable for log collection. Only logs are lost; check oc get nodes. |
Upgrade teardown logs Error uninstalling service from cluster |
Known issue: the subscription source changes during the upgrade. Use the cleanup commands above. |
Namespaces stuck in Terminating |
hack/clean-stuck-namespaces.sh runs at the end of every run; run it manually if needed. |
Writing tests
Layout
| Path | Content |
|---|---|
features/<area>/*.feature |
Scenarios. Give each scenario a tag from the Tags table, or a new tag documented there. |
steps/*.go |
Step definitions, registered in steps/data.go via register...Steps(ctx, data) |
installers/ |
Operator and Postgres installers (OLM and YAML) |
executor/ |
Suite hooks, tag handling, global install/uninstall |
../test/testdata/ |
YAML fixtures (workflows, platforms, Postgres) |
../test/yaml.go |
Path accessors for fixtures (GetSonataFlow...()) |
Generic steps (namespace creation and similar) live in bddframework/pkg/steps and are registered as well.
Adding a scenario
-
Reuse existing steps where possible. To list every scenario and step for a tag without changing the cluster:
make -C testbdd run-tests dry_run=true show_steps=true cr_deployment_only=true tags="@previewMode"You can also search the step regular expressions:
grep -rn 'ctx.Step(' testbdd/steps bddframework/pkg/steps. -
Put cluster fixtures in
test/testdata/<area>/and add an accessor intest/yaml.go. -
Start with
Given Namespace is created. Each scenario gets its own namespace, available in steps asdata.Namespace. -
Tag the scenario and document the tag in this README.
Adding a step
// steps/<area>.go - register in the area's register function
ctx.Step(`^SonataFlow "([^"]*)" does something within (\d+) minutes?$`, data.sonataFlowDoesSomethingWithinMinutes)
func (data *Data) sonataFlowDoesSomethingWithinMinutes(name string, timeoutInMin int) error {
return framework.WaitForOnOpenshift(data.Namespace, "SonataFlow "+name+" does something", timeoutInMin,
func() (bool, error) {
// return true when the condition is met; return an error only for unrecoverable failures
return false, nil
})
}
Guidelines:
- Poll, don't sleep. If a step takes a
within N minutesargument, useframework.WaitFor...with that timeout. - Assert everything the step text promises. If the text says
expectedResponseContains '...', compare the response. - Use the right namespace:
- workload resources:
data.Namespace - cluster operator resources (CSV, subscriptions,
logic-operator-builder-config):framework.GetClusterOperatorNamespace() - operator install namespace:
installers.LogicOperatorNamespace
- workload resources:
- Use the product names (
logic-operator) for OLM resources, notsonataflow-operator. - New parameters: add the flag and getter in
bddframework/pkg/config/config.go, then add the name toSTRING_TEST_PARAMSorBOOLEAN_TEST_PARAMSinhack/run-tests.sh. Otherwisemake run-testsrejects it.
More patterns (placeholders, gitops templating, waiting helpers) are in _agents/step-authoring.md.
Validate before a PR
(cd bddframework && go vet ./...)
(cd testbdd && go vet ./...)
make -C testbdd run-tests dry_run=true cr_deployment_only=true tags="<your tag>"
Then run the affected tags on a cluster and attach the summary (N scenarios (N passed)) to the PR.