Testing controllers with the Test Harness
Intended Audience: OpenSlice Controller Developers
The OSL Controller Test Harness is a standalone service that stands in for OpenSlice around a generic resource controller. It lets you run, watch and test your controller against the OpenSlice JMS contract on your laptop or in CI, without deploying a full OpenSlice (TMF API, OSOM, Artemis, database and UI).
- Code: https://labs.etsi.org/rep/osl/utilities/org.etsi.osl.util.controllers.testharness
- Interactive explainer (contract, message flows step by step, checks, scenarios, faults): https://osl.etsi.org/utilities/org.etsi.osl.util.controllers.testharness/
- Design document: Design.md
- Developer onboarding: DeveloperWalkthrough.md
Why
A controller talks to OpenSlice only over ActiveMQ: it registers its resource specifications in the catalog,
receives CREATE/UPDATE/DELETE requests from OSOM, and writes resource state back to the inventory (or, for a
planning dry-run, to OSOM's planning callback queue). Mistakes in that loop usually show up only as a service
order that hangs silently in a full deployment, for example:
- a resource reported without X.731 health (
operationalState/administrativeState) folds toPENDINGand the service never moves; - a planning request writes to the real inventory using a placeholder resource id;
- the HELD → UP progression never happens, so OSOM's planning wait loop runs out its budget;
- a queue name or header has a typo, so a message lands where nobody consumes it.
The harness makes these visible and testable.
How it works
The controller under test runs unchanged. Only its broker URL (spring.activemq.brokerUrl) is pointed at
the harness, which plays the OpenSlice side of the contract:
- Broker: an embedded Apache Artemis broker on
:61616(OpenWire and CORE,artemis/artemisby default), or an external broker you already run. - Catalog emulator: answers the
CATALOG.*request/reply queues the controller calls, the way the TMF API service does, from in-memory stores (resource and service specs, production inventory). - OSOM driver: sends
CREATE/UPDATE/DELETErequests toCREATE/<category>/<version>(and the/PLANNINGvariants) in production or planning mode, with the same headers OSOM uses, and records the reply. - Planning emulator: serves
PLANNING.RESOURCE.CREATEORUPDATE, keeps the tentative inventory and runs OSOM's check-deployment wait loop (HELD → UP, or GONE on delete). - Wire recorder: logs every message (direction, queue, headers, body, latency), including messages sent to queues nobody consumes.
- Contract checker: evaluates the controller contract continuously and raises violations.
- Scenario runner and fault injection: scripted pass/fail tests, and a deliberately slow or broken OpenSlice.
Everything is available through a REST API (Swagger UI at /swagger-ui.html), a live SSE event stream
(/api/events) and a web UI at /ui (Dashboard, Spec catalogue, New resource, Inventory, Wire, Scenarios,
Faults, Violations).
Queues
| Direction | Queues |
|---|---|
| Controller → harness (served) | CATALOG.UPDADD.RESOURCESPEC (spec registration), CATALOG.ADD/UPD.RESOURCESPEC, CATALOG.GET.RESOURCESPEC_BY_ID, CATALOG.GET.RESOURCESPEC_BY_NAME_CATEGORY, CATALOG.GET.RESOURCESPEC_BY_CATEGORY, CATALOG.UPD.RESOURCE, CATALOG.UPDADD.RESOURCE, CATALOG.ADD/GET.RESOURCE, CATALOG.GET.RESOURCE_BY_CATEGORY, CATALOG.GET.RESOURCES_BY_FILTER, CATALOG.DELETE.RESOURCE, the CATALOG.*.SERVICESPEC queues, CATALOG.GET.SERVICEORDER_BY_ID, PLANNING.RESOURCE.CREATEORUPDATE |
| Harness → controller (driven) | CREATE/<category>/<version>, UPDATE/<category>/<version>, DELETE/<category>/<version>, and the same with /PLANNING for dry-runs (with the X-OSL-SIMULATION header) |
The harness learns <category> and <version> when the controller registers its specs. Several controllers can
share one harness.
Contract checks
| Rule | Checks |
|---|---|
HEALTH_DECLARED |
Every resource report carries both operationalState and administrativeState. |
PLANNING_PROGRESSION |
A planning create shows HELD, then UP, within the wait budget; a planning delete reaches GONE. |
PLANNING_NO_SIDE_EFFECTS |
While serving a request with X-OSL-SIMULATION, the controller makes no catalog writes, above all none for the placeholder id. |
ACK_UUID_TARGETED |
Follow-up planning callbacks address the uuid the harness acknowledged. |
ESTIMATE_SHAPE |
Estimate headers are numbers, match the callback's phase, and no operation estimate is sent without an operation window. |
PRODUCTION_WRITEBACK |
A production CREATE/UPDATE/DELETE leads to a CATALOG.UPD.RESOURCE for the given resource id within a timeout, with health UP, UP or GONE. |
SPEC_COMPLETE |
Registered specs have a name, category and version, and their characteristics have value types. |
REPLY_WELLFORMED |
The controller's synchronous replies parse as Resource (or are null). |
Quick start
1. Start the harness
With Docker:
docker run --rm --name harness -p 8090:8090 -p 61616:61616 \
labs.etsi.org:5050/osl/utilities/org.etsi.osl.util.controllers.testharness:latest
Or from the source code (Java 17):
git clone https://labs.etsi.org/rep/osl/utilities/org.etsi.osl.util.controllers.testharness.git
cd org.etsi.osl.util.controllers.testharness
mvn package -DskipTests
java -jar target/osl-controller-testharness.jar
Open http://localhost:8090/ui/. To use an external Artemis broker instead of the embedded one, set
HARNESS_BROKER_MODE=external and HARNESS_BROKER_EXTERNAL_URL=tcp://host:61616. Note that the wire log and
consumer counts are then unavailable. See the
README
for all configuration variables.
2. Point your controller at the harness broker
For example, for the example generic controller:
If the controller also runs in a container, put both containers on one Docker network and use
tcp://harness:61616?jms.watchTopicAdvisories=false.
3. Check and drive it
- The Dashboard shows the detected controller and whether it listens on its
CREATE/UPDATE/DELETE[/PLANNING]queues;GET /api/specslists the specs it registered. - Production create (New resource page, or
POST /api/resources): the inventory shows the resource UP. - Planning create (choose planning mode): the tentative inventory shows HELD → UP with creation and operation estimates, and the wire log has no catalog write for the placeholder id.
- The Wire page shows every message, and the Violations page every broken contract rule.
Scenarios (for example in CI)
A scenario is a scripted test in YAML or JSON that ends with a pass/fail report:
name: kubernetes-planning-roundtrip
steps:
- waitForSpec: { name: KubernetesCluster, within: 20s }
- create: { id: k8s, spec: KubernetesCluster, mode: planning,
operationDurationSeconds: 3600, characteristics: { nodeCount: "3" } }
- expectHealth: { resource: k8s, sequence: [HELD, UP], within: 5s }
- expectEstimate: { resource: k8s, phase: creation, present: true }
- delete: { resource: k8s, mode: planning }
- expectHealth: { resource: k8s, final: GONE, within: 5s }
- expectNoViolations: { rules: [PLANNING_NO_SIDE_EFFECTS, HEALTH_DECLARED] }
Run it from the Scenarios page, or from a pipeline:
curl -s -X POST -H "Content-Type: application/yaml" --data-binary @my-scenario.yaml \
"http://localhost:8090/api/scenarios/run?wait=true" | tee report.json | jq -e '.status == "PASSED"'
Fault rules make the harness misbehave on purpose on the queues it serves (DELAY, ERROR_REPLY,
MALFORMED_REPLY, NO_REPLY), from the Faults page, the /api/faults API, or a scenario's fault step, so you
can see how the controller copes with a slow or failing OpenSlice.
The README documents every scenario step, fault option and configuration variable.
