OPCTS - OPC UA Test Server
The opcts tool is a lightweight OPC UA server aimed to validate the IFW opcua
client implementation and in general for integration
tests. It reads a YAML file at startup and builds the
address space (folders, variables, methods) accordingly. The server binary is
ifwCoreOpcts and accepts the YAML path as
its first argument (defaults to config.yaml):
ifwCoreOpcts -c protocol/open62541/test/resource/config/opcua_server.yaml
Command-line options
opcts supports a small CLI:
-h/--help: Print usage.-c/--config <path>: YAML configuration file (defaultconfig.yaml).-e/--endpoint <uri>: Override the OPC UA endpoint URL. Default:opc.tcp://127.0.0.1:4846.
Configuration file
The YAML schema is split into four sections. Unknown keys are ignored, and most fields are mandatory unless marked optional.
server
endpoint: OPC UA endpoint URL, e.g.opc.tcp://0.0.0.0:4840. The port is extracted from this string.namespaceUri: Namespace URI used for all nodes defined in the file.
folders (optional)
List of folders to create before adding nodes and methods. Each entry supports:
name: Display/browse name.nodeId: String node id used when attaching children.parent: Optional parent folder id; defaults toObjects(the standard objects folder in namespace 0).
nodes
List of variable nodes. Supported datatypes are Double, Float,
Int32, UInt32, Int16, UInt16, Boolean and String.
name: Display/browse name.nodeId: String node id for the variable.datatype: One of the supported OPC UA scalar types.folder: Optional parent folder id; defaults toObjects.writable: Optional, defaulttrue. Whenfalseonly read access is enabled.isArray: Optional flag; automatically set wheninitialValuesis present.initialValue: Scalar initial value as a string/number.initialValues: Sequence of values for array nodes; array dimensions are inferred from the length.
Waveform simulation (scalar nodes only) is configured with simulation:
type:sineorramp.intervalMs: Update period in milliseconds (default 1000).For
sine:periodMs(default 10000),amplitude(default 1.0),offset(default 0.0).For
ramp:step(default 1.0),min(default 0.0),max(default 100.0).
methods (optional)
List of method nodes to expose under the namespace.
name/nodeId/folder: Same meaning as variable nodes.inputArguments/outputArguments: Lists of argument objects withname,datatype(same set as variables) and optionaldescription.
Simple server-side simulations can be enabled via simulation:
type: fixedwithoutputs: list of values mapped to the declared output arguments.type: sumInt32: expects twoInt32inputs and returns their sum in the first output argument; remaining outputs are default-initialised.
Example
The integration tests ship an example configuration at
protocol/open62541/test/resource/config/opcua_server.yaml showing folders,
scalar and array nodes, sine/ramp simulations, and two methods (a fixed reply
and an Int32 adder).
server:
endpoint: "opc.tcp://0.0.0.0:4840"
namespaceUri: "http://example.com/integration-test/"
folders:
- name: "TestScalars"
nodeId: "TestScalars"
parent: "Objects"
- name: "TestArrays"
nodeId: "TestArrays"
parent: "Objects"
nodes:
- name: "TestInt32"
nodeId: "TestInt32"
datatype: "Int32"
initialValue: 51
writable: true
folder: "TestScalars"
- name: "TestDouble"
nodeId: "TestDouble"
datatype: "Double"
initialValue: 23.5
writable: true
folder: "TestScalars"
- name: "TestInts"
nodeId: "TestInts"
datatype: "Int32"
isArray: true
initialValues: [2, 3, 4]
folder: "TestArrays"
writable: true
- name: "TempSine"
nodeId: "TempSine"
datatype: "Double"
initialValue: 20.0
writable: true
folder: "TestScalars"
simulation:
type: "sine"
intervalMs: 1000
periodMs: 10000
amplitude: 5.0
offset: 20.0
methods:
- name: "ResetStatus"
nodeId: "ResetStatus"
folder: "TestFolder"
inputArguments: []
outputArguments:
- name: "Success"
datatype: "Boolean"
description: "True if reset succeeded"
simulation:
type: "fixed"
outputs:
- "true"