mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
126 lines
5.4 KiB
Plaintext
126 lines
5.4 KiB
Plaintext
*** Settings ***
|
|
Library Collections
|
|
Resource common.resource
|
|
Suite Setup Neuron Context Ready
|
|
Suite Teardown Neuron Context Stop
|
|
|
|
*** Variables ***
|
|
|
|
*** Test Cases ***
|
|
Pressure Testing
|
|
${hours} = Set Variable ${1}
|
|
${msecs} = Set Variable ${hours * 3600 * 1000}
|
|
${interval_ms} = Set Variable ${50}
|
|
${count} = Evaluate ${msecs} // ${interval_ms}
|
|
Repeat Keyword ${count} Read Write Loop ${interval_ms}
|
|
|
|
*** Keywords ***
|
|
Neuron Context Ready
|
|
Import Neuron API Resource
|
|
|
|
Copy Persistence Test Data
|
|
|
|
Start Simulator ${MODBUS_TCP_SERVER_SIMULATOR} ${SIMULATOR_DIR}
|
|
Start Simulator ${OPCUA_SERVER_SIMULATOR} ${SIMULATOR_DIR}
|
|
|
|
Neuron Ready
|
|
LOGIN
|
|
|
|
Sleep 10s
|
|
Profile Neuron interval=5 result_dir=${OUTPUT_DIR}
|
|
|
|
|
|
Neuron Context Stop
|
|
Stop Neuron remove_persistence_data=True
|
|
Terminate All Processes kill=false
|
|
|
|
Read Write Loop
|
|
[Arguments] ${interval_ms}
|
|
Ping
|
|
Random Read Then Write Back
|
|
Sleep ${interval_ms}ms
|
|
|
|
Random Read Then Write Back
|
|
${nodes} = Get Driver Nodes
|
|
${node_id} = Get Random Node ${nodes}
|
|
|
|
${res} = Get Group Config ${node_id}
|
|
Return From Keyword If ${res}[group_configs] == @{EMPTY}
|
|
${group} = Get Random Group Config ${res}[group_configs]
|
|
|
|
${dashb_id} = Get Node ID ${NODE_WEB} default-dashboard-adapter
|
|
${res} = Subscribe Group ${node_id} ${dashb_id} ${group}
|
|
Check Response Status ${res} 200
|
|
Check Error Code ${res} ${ERR_SUCCESS}
|
|
|
|
${res} = Read Tags ${node_id} ${group}
|
|
Check Response Status ${res} 200
|
|
|
|
Return From Keyword If ${res}[tags] == @{EMPTY}
|
|
|
|
${vals} = Evaluate [{'value':v['value'], 'id':v['id']} for v in ${res}[tags]] json
|
|
${tags} = Evaluate ",".join(map(json.dumps, ${vals})) json
|
|
${res} = Write Tags ${node_id} ${group} ${tags}
|
|
Check Response Status ${res} 200
|
|
Check Error Code ${res} ${ERR_SUCCESS}
|
|
|
|
Get Driver Nodes
|
|
${res} = Get Nodes ${NODE_DRIVER}
|
|
Check Response Status ${res} 200
|
|
|
|
${nodes} = Set Variable ${res}[nodes]
|
|
FOR ${index} ${value} IN ENUMERATE @{nodes}
|
|
IF $value["name"] == "sample-driver-adapter"
|
|
Remove From List ${nodes} ${index}
|
|
Exit For Loop
|
|
END
|
|
END
|
|
|
|
[Return] ${nodes}
|
|
|
|
Get App Nodes
|
|
${res} = Get Nodes ${NODE_APP}
|
|
Check Response Status ${res} 200
|
|
|
|
${nodes} = Set Variable ${res}[nodes]
|
|
FOR ${index} ${value} IN ENUMERATE @{nodes}
|
|
IF $value["name"] == "sample-app-adapter"
|
|
Remove From List ${nodes} ${index}
|
|
Exit For Loop
|
|
END
|
|
END
|
|
|
|
[Return] ${nodes}
|
|
|
|
Gen Tag Value
|
|
[Arguments] ${type}
|
|
If ${type} == ${TAG_DATA_TYPE_BOOL}
|
|
${val} = Set Variable 1
|
|
If ${type} == ${TAG_DATA_TYPE_BIT}
|
|
${val} = Set Variable 1
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_INT8}
|
|
${val} = Set Variable 128
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_BYTE}
|
|
${val} = Set Variable 255
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_UINT8}
|
|
${val} = Set Variable 255
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_INT16}
|
|
${val} = Set Variable 32768
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_UINT16}
|
|
${val} = Set Variable 65536
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_INT32}
|
|
${val} = Set Variable 2147483648
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_UINT32}
|
|
${val} = Set Variable 4294967295
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_INT64}
|
|
${val} = Set Variable 9223372036854775808
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_UINT64}
|
|
${val} = Set Variable 18446744073709551615
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_FLOAT}
|
|
${val} = Set Variable 3.14159
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_DOUBLE}
|
|
${val} = Set Variable 3.141592653589793
|
|
ELSE IF ${type} == ${TAG_DATA_TYPE_STRING}
|
|
${val} = Set Variable hello, world
|
|
END
|