diff --git a/ft/error.resource b/ft/error.resource index ca85e004..9c9dfc98 100644 --- a/ft/error.resource +++ b/ft/error.resource @@ -1,40 +1,46 @@ *** Variables *** -${ERR_SUCCESS} 0 -${ERR_INTERNAL} 1001 -${ERR_REQUEST_BODY_INVALID} 1002 -${ERR_REQUEST_PARAM_INVALID} 1003 -${ERR_NEED_TOKEN} 1004 -${ERR_DECODE_TOKEN} 1005 -${ERR_EXPIRED_TOKEN} 1006 -${ERR_VALIDATE_TOKEN} 1007 -${ERR_INVALID_TOKEN} 1008 -${ERR_INVALID_USER_OR_PASSWORD} 1009 -${ERR_PLUGIN_NAME_NOT_FOUND} 2000 -${ERR_NODE_TYPE_INVALID} 2001 -${ERR_NODE_EXIST} 2002 -${ERR_NODE_NOT_EXIST} 2003 -${ERR_GRPCONFIG_NOT_EXIST} 2004 -${ERR_TAG_NOT_EXIST} 2005 -${ERR_TAG_ATTRIBUTE_NOT_SUPPORT} 2006 -${ERR_NODE_SETTING_INVALID} 2007 -${ERR_NODE_SETTING_NOT_EXIST} 2008 -${ERR_GRP_CONFIG_IN_USE} 2009 -${ERR_NODE_NOT_READY} 2010 -${ERR_NODE_IS_RUNNING} 2011 -${ERR_NODE_NOT_RUNNING} 2012 -${ERR_NODE_IS_STOPED} 2013 -${ERR_GRP_NOT_SUBSCRIBE} 2014 -${ERR_TAG_TYPE_NOT_SUPPORT} 2015 -${ERR_GRP_CONFIG_EXIST} 2016 -${ERR_TAG_NAME_EXIST} 2017 -${ERR_TAG_LIST_NOT_EXIST} 2018 -${ERR_TAG_ADDRESS_FORMAT_INVALID} 2019 -${ERR_PLUGIN_LIBRARY_NOT_FOUND} 2020 -${ERR_PLUGIN_LIBRARY_INFO_INVALID} 2021 -${ERR_PLUGIN_LIBRARY_NAME_CONFLICT} 2022 +${ERR_SUCCESS} 0 +${ERR_INTERNAL} 1001 +${ERR_REQUEST_BODY_INVALID} 1002 +${ERR_REQUEST_PARAM_INVALID} 1003 +${ERR_NEED_TOKEN} 1004 +${ERR_DECODE_TOKEN} 1005 +${ERR_EXPIRED_TOKEN} 1006 +${ERR_VALIDATE_TOKEN} 1007 +${ERR_INVALID_TOKEN} 1008 +${ERR_INVALID_USER_OR_PASSWORD} 1009 -${ERR_DEVICE_READ_FAILURE} 3000 -${ERR_DEVICE_WRITE_FAILURE} 3001 +${ERR_NODE_TYPE_INVALID} 2001 +${ERR_NODE_EXIST} 2002 +${ERR_NODE_NOT_EXIST} 2003 +${ERR_NODE_SETTING_INVALID} 2004 +${ERR_NODE_SETTING_NOT_EXIST} 2005 +${ERR_NODE_NOT_READY} 2006 +${ERR_NODE_IS_RUNNING} 2007 +${ERR_NODE_NOT_RUNNING} 2008 +${ERR_NODE_IS_STOPED} 2009 + +${ERR_GRP_CONFIG_NOT_EXIST} 2101 +${ERR_GRP_CONFIG_IN_USE} 2102 +${ERR_GRP_CONFIG_CONFLICT} 2103 + +${ERR_TAG_NOT_EXIST} 2201 +${ERR_TAG_NAME_CONFLICT} 2202 +${ERR_TAG_ATTRIBUTE_NOT_SUPPORT} 2203 +${ERR_TAG_TYPE_NOT_SUPPORT} 2204 +${ERR_TAG_ADDRESS_FORMAT_INVALID} 2205 + +${ERR_LIBRARY_NOT_FOUND} 2301 +${ERR_LIBRARY_INFO_INVALID} 2302 +${ERR_LIBRARY_NAME_CONFLICT} 2303 + +${ERR_PLUGIN_READ_FAILURE} 3000 +${ERR_PLUGIN_WRITE_FAILURE} 3001 +${ERR_PLUGIN_DISCONNECTED} 3002 +${ERR_PLUGIN_TAG_NOT_ALLOW_READ} 3003 +${ERR_PLUGIN_TAG_NOT_ALLOW_WRITE} 3004 +${ERR_PLUGIN_TAG_NOT_EXIST} 3005 +${ERR_PLUGIN_GRP_NOT_SUBSCRIBE} 3006 ${ERR_MQTT_FAILURE} 4000 ${ERR_MQTT_NO_CERTFILESET} 4001 diff --git a/ft/modbus_exception_test.robot b/ft/modbus_exception_test.robot index 6bacb2fc..fb0c854f 100644 --- a/ft/modbus_exception_test.robot +++ b/ft/modbus_exception_test.robot @@ -20,7 +20,7 @@ The connection between the modbus driver and the modbus simulator is disconnecte Sleep 1s 500ms Write Tags ${test_node_id} ${group} {"id": ${tag1_id}, "value": 1} - Integer response body error ${ERR_DEVICE_WRITE_FAILURE} + Integer response body error ${ERR_PLUGIN_WRITE_FAILURE} Node Setting ${test_node_id} {"host": "127.0.0.1", "port": 9000, "connection_mode": 0} diff --git a/ft/modbus_tcp_test.robot b/ft/modbus_tcp_test.robot index b8575e73..869b11aa 100644 --- a/ft/modbus_tcp_test.robot +++ b/ft/modbus_tcp_test.robot @@ -33,9 +33,9 @@ Read unsubscribed point, it should return failure ${res} = Add Tags ${test_node_id} xxgrp ${tag_int16} Sleep 1s 500ms - ${res} = Read Tags ${test_node_id} xxgrp + ${res} = Read Tags ${test_node_id} xxgrp Check Response Status ${res} 200 - Integer $.tags[0].error ${ERR_GRP_NOT_SUBSCRIBE} + Integer $.tags[0].error ${ERR_PLUGIN_GRP_NOT_SUBSCRIBE} ${res} = Del Group Config ${test_node_id} xxgrp Check Response Status ${res} 200 diff --git a/ft/node_api_test.robot b/ft/node_api_test.robot index 19a9c1ac..514afb52 100644 --- a/ft/node_api_test.robot +++ b/ft/node_api_test.robot @@ -10,301 +10,301 @@ POST ping, status can be ok Ping Use the wrong body to crate a node, it should return failure - ${res} = Add Node type=${${NODE_DRIVER}} namexx=test-node plugin_name=test-plugin-name + ${res} = Add Node type=${${NODE_DRIVER}} namexx=test-node plugin_name=test-plugin-name - Check Response Status ${res} 400 - Check Error Code ${res} ${ERR_REQUEST_BODY_INVALID} + Check Response Status ${res} 400 + Check Error Code ${res} ${ERR_REQUEST_BODY_INVALID} Use a plugin name that does not exist to create a node, it should return failure - ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=test-plugin-name + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=test-plugin-name - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_PLUGIN_NAME_NOT_FOUND} + Check Response Status ${res} 404 + Check Error Code ${res} ${ERR_LIBRARY_NOT_FOUND} Use a invalid node type to create a node, it should return failure - ${res} = Add Node type=${10} name=test-node plugin_name=modbus-tcp-plugin + ${res} = Add Node type=${10} name=test-node plugin_name=modbus-tcp-plugin - Check Response Status ${res} 400 - Check Error Code ${res} ${ERR_NODE_TYPE_INVALID} + Check Response Status ${res} 400 + Check Error Code ${res} ${ERR_NODE_TYPE_INVALID} Create a node with the correct body, it should return success - ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp-plugin + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp-plugin - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} Create an existing node, it should return failure - ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp-plugin + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp-plugin - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_EXIST} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_EXIST} Get node with wrong parameters, it will return failure Skip If Not Http API - GET /api/v2/node?tt=${NODE_DRIVER} + GET /api/v2/node?tt=${NODE_DRIVER} Integer response status 400 Integer response body error ${ERR_REQUEST_PARAM_INVALID} Get DRIVER node, it should return all DRIVER node - ${res} = Get Nodes ${NODE_DRIVER} + ${res} = Get Nodes ${NODE_DRIVER} - Check Response Status ${res} 200 + Check Response Status ${res} 200 - FOR ${name} IN sample-driver-adapter modbus-tcp-adapter test-node - Node With Name Should Exist ${res}[nodes] ${name} + FOR ${name} IN sample-driver-adapter modbus-tcp-adapter test-node + Node With Name Should Exist ${res}[nodes] ${name} END Get WEB node, it should return all WEB node - ${res} = Get Nodes ${NODE_WEB} + ${res} = Get Nodes ${NODE_WEB} - Check Response Status ${res} 200 - Node With Name Should Exist ${res}[nodes] default-dashboard-adapter + Check Response Status ${res} 200 + Node With Name Should Exist ${res}[nodes] default-dashboard-adapter Get MQTT node, it should return all mqtt node - ${res} = Get Nodes ${NODE_MQTT} + ${res} = Get Nodes ${NODE_MQTT} - Check Response Status ${res} 200 - Node With Name Should Exist ${res}[nodes] mqtt-adapter + Check Response Status ${res} 200 + Node With Name Should Exist ${res}[nodes] mqtt-adapter Get STREAM PROCESSOR node, it should return all STREAM PROCESSOR node - ${res} = Get Nodes ${NODE_STREAM_PROCESSOR} + ${res} = Get Nodes ${NODE_STREAM_PROCESSOR} - Check Response Status ${res} 200 - Run Keyword If ${res} != &{EMPTY} Fail not an empty object + Check Response Status ${res} 200 + Run Keyword If ${res} != &{EMPTY} Fail not an empty object Get APP node, it should return all APP node - ${res} = Get Nodes ${NODE_APP} + ${res} = Get Nodes ${NODE_APP} - Check Response Status ${res} 200 - Node With Name Should Exist ${res}[nodes] sample-app-adapter + Check Response Status ${res} 200 + Node With Name Should Exist ${res}[nodes] sample-app-adapter Get UNKNOWN type node, it should return empty node - ${res} = Get Nodes ${NODE_UNKNOWN} + ${res} = Get Nodes ${NODE_UNKNOWN} - Check Response Status ${res} 200 - Run Keyword If ${res} != &{EMPTY} Fail not an empty object + Check Response Status ${res} 200 + Run Keyword If ${res} != &{EMPTY} Fail not an empty object Get INVALID type node, it should return failure - ${res} = Get Nodes ${123456} + ${res} = Get Nodes ${123456} - Check Response Status ${res} 400 - Check Error Code ${res} ${ERR_REQUEST_PARAM_INVALID} + Check Response Status ${res} 400 + Check Error Code ${res} ${ERR_REQUEST_PARAM_INVALID} Delete the existing node, it will return success - ${res} = Get Nodes ${NODE_DRIVER} + ${res} = Get Nodes ${NODE_DRIVER} - Check Response Status ${res} 200 - ${node_id} = Get Node By Name ${res}[nodes] test-node - Should Not Be Equal As Integers ${node_id} 0 + Check Response Status ${res} 200 + ${node_id} = Get Node By Name ${res}[nodes] test-node + Should Not Be Equal As Integers ${node_id} 0 - ${res} = Del Node ${node_id} - Check Response Status ${res} 200 + ${res} = Del Node ${node_id} + Check Response Status ${res} 200 - ${res} = Get Nodes ${NODE_DRIVER} - Check Response Status ${res} 200 - ${node_id} = Get Node By Name ${res}[nodes] test-node - Should Be Equal As Integers ${node_id} 0 + ${res} = Get Nodes ${NODE_DRIVER} + Check Response Status ${res} 200 + ${node_id} = Get Node By Name ${res}[nodes] test-node + Should Be Equal As Integers ${node_id} 0 Delete a non-existent node, it will return failure - ${res} = Del Node ${1000} + ${res} = Del Node ${1000} - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_NODE_NOT_EXIST} + Check Response Status ${res} 404 + Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Add setting to non-existent node, it should return failure - ${res} = Node Setting ${999} {"host": "1.1.1.1", "port": 6677, "connection_mode": 0} + ${res} = Node Setting ${999} {"host": "1.1.1.1", "port": 6677, "connection_mode": 0} - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_NODE_NOT_EXIST} + Check Response Status ${res} 404 + Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Get setting from non-existent node, it should return failure - ${res} = Get Node Setting ${999} + ${res} = Get Node Setting ${999} - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_NODE_NOT_EXIST} + Check Response Status ${res} 404 + Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Get setting from a node that has never been set, it should return failure - ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} driver-node ${PLUGIN_MODBUS_TCP} - ${res} = Get Node Setting ${driver_node_id} + ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} driver-node ${PLUGIN_MODBUS_TCP} + ${res} = Get Node Setting ${driver_node_id} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_NODE_SETTING_NOT_EXIST} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_NODE_SETTING_NOT_EXIST} - [Teardown] Del Node Check ${driver_node_id} + [Teardown] Del Node Check ${driver_node_id} Add the correct settings to the node, it should return success - ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} driver-node ${PLUGIN_MODBUS_TCP} - ${res} = Node Setting ${driver_node_id} {"host": "1.1.1.1", "port": 6677, "connection_mode": 0} + ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} driver-node ${PLUGIN_MODBUS_TCP} + ${res} = Node Setting ${driver_node_id} {"host": "1.1.1.1", "port": 6677, "connection_mode": 0} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} Get the setting of node, it should return to the previous setting - ${driver_node_id} = Get Node ID ${NODE_DRIVER} driver-node - ${res} = Get Node Setting ${driver_node_id} - ${params} = Set Variable ${res}[params] + ${driver_node_id} = Get Node ID ${NODE_DRIVER} driver-node + ${res} = Get Node Setting ${driver_node_id} + ${params} = Set Variable ${res}[params] - Check Response Status ${res} 200 - Should Be Equal As Integers ${res}[node_id] ${driver_node_id} - Should Be Equal As Integers ${params}[port] 6677 - Should Be Equal As Strings ${params}[host] 1.1.1.1 - Should Be Equal As Integers ${params}[connection_mode] 0 + Check Response Status ${res} 200 + Should Be Equal As Integers ${res}[node_id] ${driver_node_id} + Should Be Equal As Integers ${params}[port] 6677 + Should Be Equal As Strings ${params}[host] 1.1.1.1 + Should Be Equal As Integers ${params}[connection_mode] 0 Add wrong settings to node, it should return failure - ${driver_node_id} = Get Node ID ${NODE_DRIVER} driver-node - ${res} = Node Setting ${driver_node_id} {"xxhost": "1.1.1.1", "port": 6677, "connection_mode": 0} + ${driver_node_id} = Get Node ID ${NODE_DRIVER} driver-node + ${res} = Node Setting ${driver_node_id} {"xxhost": "1.1.1.1", "port": 6677, "connection_mode": 0} - Check Response Status ${res} 400 - Check Error Code ${res} ${ERR_NODE_SETTING_INVALID} + Check Response Status ${res} 400 + Check Error Code ${res} ${ERR_NODE_SETTING_INVALID} Update a node that does not exist, it should return failure - ${res} = Update Node ${99} test-name + ${res} = Update Node ${99} test-name - Check Response Status ${res} 404 - Check Error Code ${res} ${ERR_NODE_NOT_EXIST} + Check Response Status ${res} 404 + Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Update the name of the node, it should return success - ${app_node_id} = Add Node And Return ID ${NODE_APP} app-node ${PLUGIN_MQTT} - ${res} = Update Node ${app_node_id} test-name + ${app_node_id} = Add Node And Return ID ${NODE_APP} app-node ${PLUGIN_MQTT} + ${res} = Update Node ${app_node_id} test-name - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} - ${res} = Get Nodes ${NODE_APP} - Check Response Status ${res} 200 - Node With Name Should Exist ${res}[nodes] test-name + ${res} = Get Nodes ${NODE_APP} + Check Response Status ${res} 200 + Node With Name Should Exist ${res}[nodes] test-name - [Teardown] Del Node Check ${app_node_id} + [Teardown] Del Node Check ${app_node_id} Start an unconfigured node, it should return failure - ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_INIT} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_DISCONNECTED} + Should Be Equal As Integers ${running_state} ${NODE_STATE_INIT} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_DISCONNECTED} - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_NOT_READY} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_NOT_READY} - [Teardown] Del Node Check ${modbus_node_id} + [Teardown] Del Node Check ${modbus_node_id} Start the configured node, it should return success - ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s - Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Start the stopped node, it should return success - ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node - Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} + Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_STOP} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_STOP} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Start the running node, it should return failure - ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_IS_RUNNING} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_IS_RUNNING} - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} Stop node that is stopped, it should return failure - ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_IS_STOPED} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_IS_STOPED} - [Teardown] Del Node Check ${modbus_node_id} + [Teardown] Del Node Check ${modbus_node_id} Stop node that is ready(init/idle), it should return failure - ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_NOT_RUNNING} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_NOT_RUNNING} - Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} + Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} - ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} + ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - Check Response Status ${res} 409 - Check Error Code ${res} ${ERR_NODE_NOT_RUNNING} + Check Response Status ${res} 409 + Check Error Code ${res} ${ERR_NODE_NOT_RUNNING} - [Teardown] Del Node Check ${modbus_node_id} + [Teardown] Del Node Check ${modbus_node_id} When setting up a READY/RUNNING/STOPED node, the node status will not change - ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s - Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} - Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + Node Setting ${modbus_node_id} {"host": "127.0.0.1", "port": 502, "connection_mode": 0} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_READY} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Node Ctl ${modbus_node_id} ${NODE_CTL_START} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_RUNNING} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} - ${running_state} ${link_state} = Get Node State ${modbus_node_id} + ${running_state} ${link_state} = Get Node State ${modbus_node_id} - Should Be Equal As Integers ${running_state} ${NODE_STATE_STOP} - Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} + Should Be Equal As Integers ${running_state} ${NODE_STATE_STOP} + Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} *** Keywords *** Neuron Context Ready @@ -316,10 +316,10 @@ Neuron Context Ready Neuron Context Stop LOGOUT - Stop Neuron remove_persistence_data=True + Stop Neuron remove_persistence_data=True Del Node Check - [Arguments] ${node_id} - ${res} = Del Node ${node_id} - Check Response Status ${res} 200 - Check Error Code ${res} ${ERR_SUCCESS} + [Arguments] ${node_id} + ${res} = Del Node ${node_id} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} diff --git a/include/neu_errcodes.h b/include/neu_errcodes.h index 1259e25c..98230a62 100644 --- a/include/neu_errcodes.h +++ b/include/neu_errcodes.h @@ -70,29 +70,29 @@ typedef enum { NEU_ERR_INVALID_TOKEN = 1008, NEU_ERR_INVALID_USER_OR_PASSWORD = 1009, - NEU_ERR_PLUGIN_NAME_NOT_FOUND = 2000, - NEU_ERR_NODE_TYPE_INVALID = 2001, - NEU_ERR_NODE_EXIST = 2002, - NEU_ERR_NODE_NOT_EXIST = 2003, - NEU_ERR_GRP_CONFIG_NOT_EXIST = 2004, - NEU_ERR_TAG_NOT_EXIST = 2005, - NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT = 2006, - NEU_ERR_NODE_SETTING_INVALID = 2007, - NEU_ERR_NODE_SETTING_NOT_FOUND = 2008, - NEU_ERR_GRP_CONFIG_IN_USE = 2009, - NEU_ERR_NODE_NOT_READY = 2010, - NEU_ERR_NODE_IS_RUNNING = 2011, - NEU_ERR_NODE_NOT_RUNNING = 2012, - NEU_ERR_NODE_IS_STOPED = 2013, - NEU_ERR_GRP_NOT_SUBSCRIBE = 2014, - NEU_ERR_TAG_TYPE_NOT_SUPPORT = 2015, - NEU_ERR_GRP_CONFIG_EXIST = 2016, - NEU_ERR_TAG_NAME_EXIST = 2017, - NEU_ERR_TAG_LIST_NOT_EXIST = 2018, - NEU_ERR_TAG_ADDRESS_FORMAT_INVALID = 2019, - NEU_ERR_PLUGIN_LIBRARY_NOT_FOUND = 2020, - NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID = 2021, - NEU_ERR_PLUGIN_LIBRARY_NAME_CONFLICT = 2022, + NEU_ERR_NODE_TYPE_INVALID = 2001, + NEU_ERR_NODE_EXIST = 2002, + NEU_ERR_NODE_NOT_EXIST = 2003, + NEU_ERR_NODE_SETTING_INVALID = 2004, + NEU_ERR_NODE_SETTING_NOT_FOUND = 2005, + NEU_ERR_NODE_NOT_READY = 2006, + NEU_ERR_NODE_IS_RUNNING = 2007, + NEU_ERR_NODE_NOT_RUNNING = 2008, + NEU_ERR_NODE_IS_STOPED = 2009, + + NEU_ERR_GRP_CONFIG_NOT_EXIST = 2101, + NEU_ERR_GRP_CONFIG_IN_USE = 2102, + NEU_ERR_GRP_CONFIG_CONFLICT = 2103, + + NEU_ERR_TAG_NOT_EXIST = 2201, + NEU_ERR_TAG_NAME_CONFLICT = 2202, + NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT = 2203, + NEU_ERR_TAG_TYPE_NOT_SUPPORT = 2204, + NEU_ERR_TAG_ADDRESS_FORMAT_INVALID = 2205, + + NEU_ERR_LIBRARY_NOT_FOUND = 2301, + NEU_ERR_LIBRARY_INFO_INVALID = 2302, + NEU_ERR_LIBRARY_NAME_CONFLICT = 2303, // common error codes for plugins NEU_ERR_PLUGIN_READ_FAILURE = 3000, @@ -101,6 +101,7 @@ typedef enum { NEU_ERR_PLUGIN_TAG_NOT_ALLOW_READ = 3003, NEU_ERR_PLUGIN_TAG_NOT_ALLOW_WRITE = 3004, NEU_ERR_PLUGIN_TAG_NOT_EXIST = 3005, + NEU_ERR_PLUGIN_GRP_NOT_SUBSCRIBE = 3006, NEU_ERR_MQTT_FAILURE = 4000, NEU_ERR_MQTT_NO_CERTFILESET = 4001, diff --git a/plugins/modbus/modbus_tcp.c b/plugins/modbus/modbus_tcp.c index d91dc648..9f3f4a14 100644 --- a/plugins/modbus/modbus_tcp.c +++ b/plugins/modbus/modbus_tcp.c @@ -542,7 +542,7 @@ static int modbus_tcp_request(neu_plugin_t *plugin, neu_request_t *req) vector_t *ids = neu_taggrp_cfg_get_datatag_ids(read_req->grp_config); data_resp.data_val = neu_datatag_pack_create(ids->size); - int32_t error = NEU_ERR_GRP_NOT_SUBSCRIBE; + int32_t error = NEU_ERR_PLUGIN_GRP_NOT_SUBSCRIBE; int index = 0; VECTOR_FOR_EACH(ids, iter) diff --git a/plugins/mqtt/command/datatag.c b/plugins/mqtt/command/datatag.c index 0a767b19..ade16bbe 100644 --- a/plugins/mqtt/command/datatag.c +++ b/plugins/mqtt/command/datatag.c @@ -164,7 +164,7 @@ char *command_add_tags(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt, "Add failed, tag name exists, uuid:%s, " "node_id:%d, req_tag_name:%s", mqtt->uuid, req->node_id, req->tags[i].name); - code = NEU_ERR_TAG_NAME_EXIST; + code = NEU_ERR_TAG_NAME_CONFLICT; free(tag); } } @@ -245,7 +245,7 @@ char *command_update_tags(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt, "node_id:%d, tag_id:%d, req_tag_name:%s", mqtt->uuid, req->node_id, req->tags[i].id, req->tags[i].name); - code = NEU_ERR_TAG_NAME_EXIST; + code = NEU_ERR_TAG_NAME_CONFLICT; free(tag); } else { updated = true; diff --git a/plugins/restful/datatag_handle.c b/plugins/restful/datatag_handle.c index a8cdaf09..d6b06acb 100644 --- a/plugins/restful/datatag_handle.c +++ b/plugins/restful/datatag_handle.c @@ -87,7 +87,7 @@ void handle_add_tags(nng_aio *aio) "Add failed, tag name exits, node_id:%d, " "req_tag_name:%s", req->node_id, req->tags[i].name); - code = NEU_ERR_TAG_NAME_EXIST; + code = NEU_ERR_TAG_NAME_CONFLICT; free(tag); } } @@ -218,7 +218,7 @@ void handle_update_tags(nng_aio *aio) "tag_id:%d, req_tag_name:%s", req->node_id, req->tags[i].id, req->tags[i].name); - code = NEU_ERR_TAG_NAME_EXIST; + code = NEU_ERR_TAG_NAME_CONFLICT; free(tag); } else { updated = true; diff --git a/plugins/restful/http.c b/plugins/restful/http.c index e277e257..7b4b9ce8 100644 --- a/plugins/restful/http.c +++ b/plugins/restful/http.c @@ -244,6 +244,7 @@ int http_response(nng_aio *aio, neu_err_code_e code, char *content) case NEU_ERR_PLUGIN_TAG_NOT_ALLOW_READ: case NEU_ERR_PLUGIN_TAG_NOT_ALLOW_WRITE: case NEU_ERR_PLUGIN_TAG_NOT_EXIST: + case NEU_ERR_PLUGIN_GRP_NOT_SUBSCRIBE: status = NNG_HTTP_STATUS_OK; break; case NEU_ERR_EINTERNAL: @@ -263,15 +264,13 @@ int http_response(nng_aio *aio, neu_err_code_e code, char *content) case NEU_ERR_PARAM_IS_WRONG: case NEU_ERR_NODE_TYPE_INVALID: case NEU_ERR_NODE_SETTING_INVALID: - case NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID: + case NEU_ERR_LIBRARY_INFO_INVALID: status = NNG_HTTP_STATUS_BAD_REQUEST; break; - case NEU_ERR_PLUGIN_NAME_NOT_FOUND: + case NEU_ERR_LIBRARY_NOT_FOUND: case NEU_ERR_NODE_NOT_EXIST: case NEU_ERR_GRP_CONFIG_NOT_EXIST: case NEU_ERR_TAG_NOT_EXIST: - case NEU_ERR_GRP_NOT_SUBSCRIBE: - case NEU_ERR_PLUGIN_LIBRARY_NOT_FOUND: status = NNG_HTTP_STATUS_NOT_FOUND; break; case NEU_ERR_NODE_EXIST: @@ -279,10 +278,9 @@ int http_response(nng_aio *aio, neu_err_code_e code, char *content) case NEU_ERR_NODE_IS_RUNNING: case NEU_ERR_NODE_NOT_RUNNING: case NEU_ERR_NODE_IS_STOPED: - case NEU_ERR_TAG_NAME_EXIST: - case NEU_ERR_TAG_LIST_NOT_EXIST: - case NEU_ERR_GRP_CONFIG_EXIST: - case NEU_ERR_PLUGIN_LIBRARY_NAME_CONFLICT: + case NEU_ERR_TAG_NAME_CONFLICT: + case NEU_ERR_GRP_CONFIG_CONFLICT: + case NEU_ERR_LIBRARY_NAME_CONFLICT: status = NNG_HTTP_STATUS_CONFLICT; break; case NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT: diff --git a/src/core/neu_datatag_manager.c b/src/core/neu_datatag_manager.c index 3e5180a8..a8b17d15 100644 --- a/src/core/neu_datatag_manager.c +++ b/src/core/neu_datatag_manager.c @@ -139,7 +139,7 @@ void neu_datatag_mng_destroy(neu_datatag_manager_t *datatag_manager) int neu_datatag_mng_add_grp_config(neu_datatag_manager_t *datatag_manager, neu_taggrp_config_t * grp_config) { - int rv = NEU_ERR_GRP_CONFIG_EXIST; + int rv = NEU_ERR_GRP_CONFIG_CONFLICT; size_t index; pthread_mutex_lock(&datatag_manager->mtx); diff --git a/src/core/neu_manager.c b/src/core/neu_manager.c index c3fa211b..6886e945 100644 --- a/src/core/neu_manager.c +++ b/src/core/neu_manager.c @@ -539,7 +539,7 @@ static neu_err_code_e manager_reg_adapter(neu_manager_t * manager, } if (rv != 0) { log_error("Can't find plugin: %s", reg_param->plugin_name); - return NEU_ERR_PLUGIN_NAME_NOT_FOUND; + return NEU_ERR_LIBRARY_NOT_FOUND; } adapter_reg_entity_t *same_reg_entity; @@ -2160,7 +2160,7 @@ int neu_manager_add_plugin_lib(neu_manager_t * manager, handle = load_plugin_library((char *) cmd->plugin_lib_name, PLUGIN_KIND_SYSTEM, &module_info); if (handle == NULL) { - return NEU_ERR_PLUGIN_LIBRARY_NOT_FOUND; + return NEU_ERR_LIBRARY_NOT_FOUND; } reg_param.plugin_kind = module_info->kind; @@ -2173,12 +2173,12 @@ int neu_manager_add_plugin_lib(neu_manager_t * manager, if (reg_param.plugin_kind != PLUGIN_KIND_STATIC && reg_param.plugin_kind != PLUGIN_KIND_SYSTEM && reg_param.plugin_kind != PLUGIN_KIND_CUSTOM) { - return NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID; + return NEU_ERR_LIBRARY_INFO_INVALID; } if (reg_param.adapter_type <= ADAPTER_TYPE_UNKNOW || reg_param.adapter_type >= ADAPTER_TYPE_MAX) { - return NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID; + return NEU_ERR_LIBRARY_INFO_INVALID; } rv = plugin_manager_reg_plugin(manager->plugin_manager, ®_param, diff --git a/src/core/plugin_manager.c b/src/core/plugin_manager.c index 831c344f..3d7ba69b 100644 --- a/src/core/plugin_manager.c +++ b/src/core/plugin_manager.c @@ -326,7 +326,7 @@ int plugin_manager_reg_plugin(plugin_manager_t * plugin_mng, if (p_plugin_id->id_val == 0) { // There has same registered plugin log_warn("A plugin with same name has already been registered"); - return NEU_ERR_PLUGIN_LIBRARY_NAME_CONFLICT; + return NEU_ERR_LIBRARY_NAME_CONFLICT; } reg_entity_init(®_entity, *p_plugin_id, param);