This guide covers testing and validation for the OpenShift Lightspeed Operator.
📖 For Testing Fundamentals: See Operator Testing Guide
📖 For Test Implementation: Seetest/e2e/directory for actual test code
Testing layers:
- Unit Tests:
make test(NEVER usego testdirectly) - Bundle/Catalog Validation:
operator-sdk bundle validate/opm validate - E2E Tests:
make test-e2e - Scorecard:
operator-sdk scorecard(OLM best practices) - Preflight: Red Hat certification (optional)
Location: Co-located *_test.go files in each package
Framework: Ginkgo v2 + Gomega
Run:
make test # CRITICAL: Always use make test, sets up envtest + CRDsView coverage:
go tool cover -html=cover.outLocation: test/e2e/
Key files:
suite_test.go- Test setupreconciliation_test.go- OLSConfig reconciliationupgrade_test.go- Upgrade scenariosclient.go- Custom client with wait helpersutils.go- Test utilities (SetupOLSTestEnvironment(),mustGather())
Run:
export KUBECONFIG=/path/to/kubeconfig
export LLM_TOKEN=your-token
make test-e2e
# Run specific test
make test-e2e GINKGO_FOCUS="PostgreSQL"
# Verbose output
make test-e2e GINKGO_V=true
# Increase timeout for slow environments
export CONDITION_TIMEOUT=10m
make test-e2e# Basic validation (automatic with make bundle)
operator-sdk bundle validate ./bundle
# OpenShift-specific
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
# Verbose
operator-sdk bundle validate ./bundle -o text# Validate single catalog
opm validate lightspeed-catalog-4.18
# Validate all catalogs
for d in lightspeed-catalog*; do opm validate $d; doneQuick test:
# 1. Deploy catalog
oc apply -f hack/example_catalogsource.yaml
# 2. Create subscription (see olm-integration-lifecycle.md for full YAML)
oc apply -f subscription.yaml
# 3. Wait and verify
oc get csv -n openshift-lightspeed -w
oc apply -f config/samples/ols_v1alpha1_olsconfig.yaml
oc get olsconfig cluster -o yaml📖 Full Installation Steps: See OLM Integration & Lifecycle
Automated: test/e2e/upgrade_test.go
Manual test:
# 1. Install old version
oc apply -f old-subscription.yaml
# 2. Wait for installation
oc get csv -n openshift-lightspeed -w
# 3. Upgrade (update catalog or subscription)
oc apply -f new-subscription.yaml
# 4. Verify
oc get csv -n openshift-lightspeed -w
oc get olsconfig cluster -o yaml
oc get deployments -n openshift-lightspeed -o yaml | grep image# Run all OLM tests
operator-sdk scorecard bundle/ --selector=suite=olm --wait-time=5m
# Run specific test
operator-sdk scorecard bundle/ --selector=test=basic-check-specCommon tests:
olm-bundle-validation- Bundle structureolm-crds-have-validation- CRD validation rulesolm-spec-descriptors/olm-status-descriptors- UI descriptors
📖 Scorecard Details: See Scorecard Documentation
Red Hat certification (optional):
# Check bundle
preflight check operator bundle/ --docker-config=$HOME/.docker/config.json
# Check image
preflight check container quay.io/org/lightspeed-operator:v0.1.0📖 Preflight Details: See Preflight Documentation
make test # Unit tests
make test-e2e # E2E tests (set KUBECONFIG, LLM_TOKEN)
operator-sdk bundle validate ./bundle # Bundle validation
for d in lightspeed-catalog*; do opm validate $d; done # Catalog validation
operator-sdk scorecard bundle/ --selector=suite=olm # ScorecardE2E tests failing:
make test-e2e 2>&1 | tee test.log
oc logs -n openshift-lightspeed deployment/lightspeed-operator-controller-manager
oc get all -n openshift-lightspeedCommon: Missing LLM_TOKEN, insufficient permissions, timeouts (increase CONDITION_TIMEOUT)
Bundle validation fails:
operator-sdk bundle validate ./bundle -o text # Verbose outputCommon: Invalid CSV syntax, missing required fields, malformed RBAC
Scorecard fails:
operator-sdk scorecard bundle/ --selector=test=<failing-test> -o textCommon: Missing descriptors, CRD validation not defined