bddframework

module
v0.0.0-...-8d23563 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0

README

BDD framework (bddframework)

Reusable Go module that the test suite in testbdd builds on. It wraps cluster access, operator installation (OLM and YAML), configuration flags, and a set of generic Gherkin steps.

The module is an extract of the test framework from the Kogito operator. Some packages (Infinispan, Kafka, Keycloak, Hyperfoil, Grafana, MongoDB) are inherited from it and are not used by the current scenarios.

Packages

Package Purpose
pkg/config All --tests.* command-line flags and their getters (config.GetOperatorCatalogImage(), config.GetUpgradeToVersion(), ...)
pkg/framework Cluster helpers: Kubernetes client, namespaces, pods/deployments, logs, waiting (WaitFor*), OLM (CatalogSource, Subscription, CSV), command execution (CreateCommand)
pkg/framework/client Kubernetes/OpenShift client and OpenShift detection (IsOpenshift())
pkg/installers ServiceInstaller implementations: OlmClusterWideServiceInstaller, YamlClusterWideServiceInstaller, ...; tracks what was installed so the suite can uninstall it
pkg/steps Generic steps shared by suites (for example Namespace is created) and the base Data struct
pkg/gherkin Feature parsing and tag filtering (used for dry runs and show_scenarios)
pkg/meta, pkg/api, pkg/types Scheme registration and shared types

Frequently used helpers

// Poll until the condition is true or the timeout (in minutes, scaled by load_factor) expires
framework.WaitForOnOpenshift(namespace, "description", timeoutInMin, func() (bool, error) { ... })

// Pods and deployments
framework.WaitForPodsWithLabel(namespace, "label-key", "label-value", count, timeoutInMin)
framework.GetDeployment(namespace, name)

// Run oc/kubectl
out, err := framework.CreateCommand("oc", "get", "csv", "-n", namespace).Execute()

// OLM
framework.GetClusterOperatorNamespace()      // openshift-operators on OpenShift
framework.GetCustomKogitoOperatorCatalog()   // bdd-tests-kogito-catalog (from operator_catalog_image)
framework.GetProductCatalog()                // redhat-operators

// Logging
framework.GetLogger(namespace).Info("message", "key", value)

Adding a configuration flag

  1. Add a field to the env struct, a set.StringVar/set.BoolVar call in BindFlags, and a getter in pkg/config/config.go. Flags are registered with the tests. prefix.
  2. Add the flag name (without the prefix) to STRING_TEST_PARAMS or BOOLEAN_TEST_PARAMS in hack/run-tests.sh, so make run-tests key=value accepts it.
  3. Document the flag in testbdd/README.md.

Development

cd bddframework
go vet ./...
make test        # go mod tidy, go fmt, go vet, go test ./...

Changes here affect the whole suite. Also vet the testbdd module and dry-run a few tags (see testbdd/README.md).

Directories

Path Synopsis
pkg
api
api/app/v1beta1
Package v1beta1 contains API Schema definitions for the app v1beta1 API group +kubebuilder:object:generate=true +groupName=app.kiegroup.org
Package v1beta1 contains API Schema definitions for the app v1beta1 API group +kubebuilder:object:generate=true +groupName=app.kiegroup.org
api/hyperfoil/v1alpha2
Package v1alpha2 contains API Schema definitions for the v1alpha2 API group +kubebuilder:object:generate=true +groupName=hyperfoil.io
Package v1alpha2 contains API Schema definitions for the v1alpha2 API group +kubebuilder:object:generate=true +groupName=hyperfoil.io
framework/client
Package client encapsulates all calls to Kubernetes/OpenShift API into meaningful functions
Package client encapsulates all calls to Kubernetes/OpenShift API into meaningful functions
framework/client/kubernetes
Package kubernetes encapsulates all calls to the Kubernetes API into meaningful functions for use by the CLI and controllers
Package kubernetes encapsulates all calls to the Kubernetes API into meaningful functions for use by the CLI and controllers
framework/infrastructure/grafana
Package grafana contains grafana API versions.
Package grafana contains grafana API versions.
framework/infrastructure/grafana/v1alpha1
Package v1alpha1 contains API Schema definitions for the integreatly v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=integreatly.org
Package v1alpha1 contains API Schema definitions for the integreatly v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=integreatly.org
framework/infrastructure/infinispan
Package infinispan contains infinispan API versions.
Package infinispan contains infinispan API versions.
framework/infrastructure/infinispan/v1
Package v1 contains API Schema definitions for the infinispan v1 API group +k8s:deepcopy-gen=package,register +groupName=infinispan.org
Package v1 contains API Schema definitions for the infinispan v1 API group +k8s:deepcopy-gen=package,register +groupName=infinispan.org
framework/infrastructure/kafka
Package kafka contains kafka API versions.
Package kafka contains kafka API versions.
framework/infrastructure/kafka/v1beta2
Package v1beta2 contains API Schema definitions for the kafka v1beta2 API group +k8s:deepcopy-gen=package,register +groupName=kafka.strimzi.io +kubebuilder:skip
Package v1beta2 contains API Schema definitions for the kafka v1beta2 API group +k8s:deepcopy-gen=package,register +groupName=kafka.strimzi.io +kubebuilder:skip
framework/infrastructure/keycloak
Package keycloak contains keycloak API versions.
Package keycloak contains keycloak API versions.
framework/infrastructure/keycloak/v1alpha1
Package v1alpha1 contains API Schema definitions for the keycloak v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=keycloak.org
Package v1alpha1 contains API Schema definitions for the keycloak v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=keycloak.org
framework/infrastructure/mongodb
Package mongodb contains mongodb API versions.
Package mongodb contains mongodb API versions.
framework/infrastructure/mongodb/v1
Package v1 contains API Schema definitions for the mongodb v1 API group +k8s:deepcopy-gen=package,register +groupName=mongodbcommunity.mongodb.com +versionName=v1
Package v1 contains API Schema definitions for the mongodb v1 API group +k8s:deepcopy-gen=package,register +groupName=mongodbcommunity.mongodb.com +versionName=v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL