From f99b2363cde9103881011ee8514f4cdacce8db09 Mon Sep 17 00:00:00 2001 From: eeff Date: Fri, 10 Dec 2021 16:18:27 +0800 Subject: [PATCH] Refactor functionality tests Split neuron.robot into common.resource and api_http.resource --- ft/{neuron.robot => api_http.resource} | 63 +--------------------- ft/common.resource | 73 ++++++++++++++++++++++++++ ft/grp_config_api_test.robot | 11 +--- ft/modbus_tcp_test.robot | 11 +--- ft/node_api_test.robot | 6 +-- ft/normal_test.robot | 5 +- ft/opcua_test.robot | 11 +--- ft/tag_api_test.robot | 9 +--- 8 files changed, 83 insertions(+), 106 deletions(-) rename ft/{neuron.robot => api_http.resource} (72%) create mode 100644 ft/common.resource diff --git a/ft/neuron.robot b/ft/api_http.resource similarity index 72% rename from ft/neuron.robot rename to ft/api_http.resource index 6a454883..3c48b943 100644 --- a/ft/neuron.robot +++ b/ft/api_http.resource @@ -1,67 +1,8 @@ *** Settings *** -Library Keyword.Neuron.Read - -*** Variables *** -${NODE_UNKNOWN} 0 -${NODE_DRIVER} 1 -${NODE_WEB} 2 -${NODE_MQTT} 3 -${NODE_STREAM_PROCESSOR} 4 -${NODE_APP} 5 - -${NODE_CTL_START} 0 -${NODE_CTL_STOP} 1 - -${NODE_STATE_IDLE} 0 -${NODE_STATE_INIT} 1 -${NODE_STATE_READY} 2 -${NODE_STATE_RUNNING} 3 -${NODE_STATE_STOP} 4 - -${NODE_LINK_STATE_DISCONNECTED} 0 -${NODE_LINK_STATE_CONNECTING} 1 -${NODE_LINK_STATE_CONNECTED} 2 - -${TAG_ATTRIBUTE_READ} 1 -${TAG_ATTRIBUTE_WRITE} 2 -${TAG_ATTRIBUTE_SUBSCRIBE} 4 -${TAG_ATTRIBUTE_RW} 3 - -${TAG_DATA_TYPE_BYTE} 2 -${TAG_DATA_TYPE_INT8} 3 -${TAG_DATA_TYPE_INT16} 4 -${TAG_DATA_TYPE_INT32} 5 -${TAG_DATA_TYPE_INT64} 6 -${TAG_DATA_TYPE_UINT8} 7 -${TAG_DATA_TYPE_UINT16} 8 -${TAG_DATA_TYPE_UINT32} 9 -${TAG_DATA_TYPE_UINT64} 10 -${TAG_DATA_TYPE_FLOAT} 11 -${TAG_DATA_TYPE_DOUBLE} 12 -${TAG_DATA_TYPE_BOOL} 13 -${TAG_DATA_TYPE_BIT} 14 -${TAG_DATA_TYPE_STRING} 15 - -${PLUGIN_MODBUS_TCP} modbus-tcp-plugin -${PLUGIN_MQTT} mqtt-plugin - -${MQTT_CONFIG_HOST} broker.fengzero.com -${MQTT_CONFIG_REQ_TOPIC} test/mqtt_req -${MQTT_CONFIG_RES_TOPIC} test/mqtt_res -${MQTT_CONFIG} {"req-topic": "${MQTT_CONFIG_REQ_TOPIC}", "res-topic": "${MQTT_CONFIG_RES_TOPIC}", "ssl": false, "host": "${MQTT_CONFIG_HOST}", "port": 1883, "username": "", "password": "", "ca-path":"", "ca-file": ""} - -${MODBUS_TCP_CONFIG} {"host": "127.0.0.1", "port": 60502, "connection_mode": 0} -${OPCUA_CONFIG} {"host": "127.0.0.1", "port": 4840, "username": "user", "password": "123456"} +Library REST http://127.0.0.1:7001 +Resource common.resource *** Keywords *** -To Array - [Arguments] ${str_array} - ${tmp} Array ${str_array} - [RETURN] ${tmp}[0] - -Neuron Ready - Start Neuron - Sleep 3 LOGIN POST /api/v2/login {"name": "admin", "pass":"0000"} diff --git a/ft/common.resource b/ft/common.resource new file mode 100644 index 00000000..26e47345 --- /dev/null +++ b/ft/common.resource @@ -0,0 +1,73 @@ +*** Settings *** +Library Keyword.Neuron.GrpConfig +Library Keyword.Neuron.Neuron +Library Keyword.Neuron.Node +Library Keyword.Neuron.Subscribe +Library Keyword.Neuron.Read +Library Keyword.Neuron.Tag +Library Keyword.Neuron.Tool + +Resource error.resource +Resource simulator.resource + +*** Variables *** +${NODE_UNKNOWN} 0 +${NODE_DRIVER} 1 +${NODE_WEB} 2 +${NODE_MQTT} 3 +${NODE_STREAM_PROCESSOR} 4 +${NODE_APP} 5 + +${NODE_CTL_START} 0 +${NODE_CTL_STOP} 1 + +${NODE_STATE_IDLE} 0 +${NODE_STATE_INIT} 1 +${NODE_STATE_READY} 2 +${NODE_STATE_RUNNING} 3 +${NODE_STATE_STOP} 4 + +${NODE_LINK_STATE_DISCONNECTED} 0 +${NODE_LINK_STATE_CONNECTING} 1 +${NODE_LINK_STATE_CONNECTED} 2 + +${TAG_ATTRIBUTE_READ} 1 +${TAG_ATTRIBUTE_WRITE} 2 +${TAG_ATTRIBUTE_SUBSCRIBE} 4 +${TAG_ATTRIBUTE_RW} 3 + +${TAG_DATA_TYPE_BYTE} 2 +${TAG_DATA_TYPE_INT8} 3 +${TAG_DATA_TYPE_INT16} 4 +${TAG_DATA_TYPE_INT32} 5 +${TAG_DATA_TYPE_INT64} 6 +${TAG_DATA_TYPE_UINT8} 7 +${TAG_DATA_TYPE_UINT16} 8 +${TAG_DATA_TYPE_UINT32} 9 +${TAG_DATA_TYPE_UINT64} 10 +${TAG_DATA_TYPE_FLOAT} 11 +${TAG_DATA_TYPE_DOUBLE} 12 +${TAG_DATA_TYPE_BOOL} 13 +${TAG_DATA_TYPE_BIT} 14 +${TAG_DATA_TYPE_STRING} 15 + +${PLUGIN_MODBUS_TCP} modbus-tcp-plugin +${PLUGIN_MQTT} mqtt-plugin + +${MQTT_CONFIG_HOST} broker.fengzero.com +${MQTT_CONFIG_REQ_TOPIC} test/mqtt_req +${MQTT_CONFIG_RES_TOPIC} test/mqtt_res +${MQTT_CONFIG} {"req-topic": "${MQTT_CONFIG_REQ_TOPIC}", "res-topic": "${MQTT_CONFIG_RES_TOPIC}", "ssl": false, "host": "${MQTT_CONFIG_HOST}", "port": 1883, "username": "", "password": "", "ca-path":"", "ca-file": ""} + +${MODBUS_TCP_CONFIG} {"host": "127.0.0.1", "port": 60502, "connection_mode": 0} +${OPCUA_CONFIG} {"host": "127.0.0.1", "port": 4840, "username": "user", "password": "123456"} + +*** Keywords *** +To Array + [Arguments] ${str_array} + ${tmp} Array ${str_array} + [RETURN] ${tmp}[0] + +Neuron Ready + Start Neuron + Sleep 3 diff --git a/ft/grp_config_api_test.robot b/ft/grp_config_api_test.robot index bc7fd48f..daff9a43 100644 --- a/ft/grp_config_api_test.robot +++ b/ft/grp_config_api_test.robot @@ -1,12 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Library Keyword.Neuron.Tool -Library Keyword.Neuron.Node -Library Keyword.Neuron.GrpConfig -Library Keyword.Neuron.Subscribe -Resource error.robot -Resource neuron.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Context Ready Suite Teardown Neuron Context Stop @@ -203,4 +196,4 @@ Neuron Context Ready Neuron Context Stop LOGOUT - Stop Neuron \ No newline at end of file + Stop Neuron diff --git a/ft/modbus_tcp_test.robot b/ft/modbus_tcp_test.robot index 129b1590..40e6a5f5 100644 --- a/ft/modbus_tcp_test.robot +++ b/ft/modbus_tcp_test.robot @@ -1,14 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Library Keyword.Neuron.Tool -Library Keyword.Neuron.Node -Library Keyword.Neuron.GrpConfig -Library Keyword.Neuron.Subscribe -Library Keyword.Neuron.Tag -Resource error.robot -Resource neuron.robot -Resource simulator.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Context Ready Suite Teardown Stop All Processes diff --git a/ft/node_api_test.robot b/ft/node_api_test.robot index e7dbaaf6..7ea358cb 100644 --- a/ft/node_api_test.robot +++ b/ft/node_api_test.robot @@ -1,9 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Library Keyword.Neuron.Node -Resource error.robot -Resource neuron.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Context Ready Suite Teardown Neuron Context Stop diff --git a/ft/normal_test.robot b/ft/normal_test.robot index e5ccfc47..31f3d37a 100644 --- a/ft/normal_test.robot +++ b/ft/normal_test.robot @@ -1,8 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Resource error.robot -Resource neuron.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Ready Suite Teardown Stop Neuron diff --git a/ft/opcua_test.robot b/ft/opcua_test.robot index 24d2d436..0dacdadd 100644 --- a/ft/opcua_test.robot +++ b/ft/opcua_test.robot @@ -1,14 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Library Keyword.Neuron.Tool -Library Keyword.Neuron.Node -Library Keyword.Neuron.GrpConfig -Library Keyword.Neuron.Subscribe -Library Keyword.Neuron.Tag -Resource error.robot -Resource neuron.robot -Resource simulator.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Context Ready Suite Teardown Stop All Processes diff --git a/ft/tag_api_test.robot b/ft/tag_api_test.robot index a7df97bd..303939ad 100644 --- a/ft/tag_api_test.robot +++ b/ft/tag_api_test.robot @@ -1,11 +1,5 @@ *** Settings *** -Library Keyword.Neuron.Neuron -Library Keyword.Neuron.Tool -Library Keyword.Neuron.Node -Library Keyword.Neuron.Tag -Resource error.robot -Resource neuron.robot -Library REST http://127.0.0.1:7001 +Resource api_http.resource Suite Setup Neuron Context Ready Suite Teardown Neuron Context Stop @@ -208,6 +202,7 @@ Delete tags, it should return success Neuron Context Ready Neuron Ready + ${token} = LOGIN ${jwt} = Catenate Bearer ${token} Set Headers {"Authorization":"${jwt}"}