From 316760237b98a70de39bd709c825e6b4f4e4efa0 Mon Sep 17 00:00:00 2001 From: gc87 Date: Fri, 22 Apr 2022 18:07:15 +0800 Subject: [PATCH] refactor(mqtt): remove ft of mqtt cmd --- ft/api_mqtt.resource | 247 +++++++++++++++-------------------- ft/common.resource | 27 +--- ft/grp_config_api_test.robot | 30 +++++ ft/node_api_test.robot | 52 ++++++++ ft/tag_api_test.robot | 22 ++++ 5 files changed, 215 insertions(+), 163 deletions(-) diff --git a/ft/api_mqtt.resource b/ft/api_mqtt.resource index 11e2cecc..bb0be016 100644 --- a/ft/api_mqtt.resource +++ b/ft/api_mqtt.resource @@ -78,184 +78,153 @@ Check Response Status [Arguments] ${result} ${status} Log To Console MQTT API does not need to check status +_Http Check Response Status + [Arguments] ${result} ${status} + Integer response status ${status} + LOGIN ${token} = _Http LOGIN Add MQTT Node ${mqtt_node} = _Http Get Node ID ${NODE_MQTT} mqtt-adapter _Http Node Setting ${mqtt_node} ${MQTT_CONFIG} _Http Node Ctl ${mqtt_node} ${NODE_CTL_START} - _Http LOGOUT Sleep 1s Connect ${MQTT_CONFIG_HOST} ${MQTT_CONFIG_PORT} client_id=neuron-ft clean_session=${true} Subscribe ${TOPIC_STATUS_RES} qos=0 timeout=5 - Subscribe ${TOPIC_NODE_RES} qos=0 timeout=5 - Subscribe ${TOPIC_GCONFIG_RES} qos=0 timeout=5 - Subscribe ${TOPIC_TAGS_RES} qos=0 timeout=5 - Subscribe ${TOPIC_PLUGIN_RES} qos=0 timeout=5 - Subscribe ${TOPIC_SUBSCRIBE_RES} qos=0 timeout=5 Subscribe ${TOPIC_READ_RES} qos=0 timeout=5 Subscribe ${TOPIC_WRITE_RES} qos=0 timeout=5 - Subscribe ${TOPIC_TTYS_RES} qos=0 timeout=5 - Subscribe ${TOPIC_SCHEMA_RES} qos=0 timeout=5 - Subscribe ${TOPIC_SETTING_RES} qos=0 timeout=5 - Subscribe ${TOPIC_CTR_RES} qos=0 timeout=5 - Subscribe ${TOPIC_STATE_RES} qos=0 timeout=5 LOGOUT + _Http LOGOUT Unsubscribe All And Clear Messages Disconnect Add MQTT Node _Http Add Node type=${${NODE_MQTT}} name=mqtt-adapter plugin_name=mqtt +Add Plugin + [Arguments] ${node_type} ${name} ${kind} ${lib_name} + POST /api/v2/plugin {"node_type": ${node_type}, "name": ${name}, "kind": ${kind}, "lib_name": ${lib_name}} + + ${res} = Object response body + [RETURN] ${res}[0] + Add Node - [Arguments] &{args} - ${payload} = evaluate json.dumps(${args}) json - ${res} = Pub And Recv ${MQTT_CMD_ADD} ${payload} ${TOPIC_NODE_REQ} ${TOPIC_NODE_RES} + [Arguments] &{args} + POST /api/v2/node ${args} - [RETURN] ${res} - -Add Node And Return ID - [Arguments] ${node_type} ${node_name} ${plugin_name} - ${res} = Add Node type=${${node_type}} name=${node_name} plugin_name=${plugin_name} - Should Be Equal As Integers ${res}[error] ${ERR_SUCCESS} - - ${node_id} = Get Node ID ${node_type} ${node_name} - Should Not Be Equal As Integers ${node_id} 0 - - [RETURN] ${node_id} - -Get Nodes - [Arguments] ${node_type} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_type": ${node_type} } ${TOPIC_NODE_REQ} ${TOPIC_NODE_RES} - - [RETURN] ${res} - -Del Node - [Arguments] ${node_id} - ${res} = Pub And Recv ${MQTT_CMD_DELETE} {"id": ${node_id}} ${TOPIC_NODE_REQ} ${TOPIC_NODE_RES} - - [RETURN] ${res} + ${res} = Object response body + [RETURN] ${res}[0] Get Node ID [Arguments] ${node_type} ${node_name} - ${res} = Get Nodes ${node_type} - ${node_id} Get Node By Name ${res}[nodes] ${node_name} - + GET /api/v2/node?type=${node_type} + Integer response status 200 + ${tmp} Array $.nodes + ${node_id} Get Node By Name ${tmp}[0] ${node_name} + Should Not Be Equal As Integers ${node_id} 0 [RETURN] ${node_id} Node Setting [Arguments] ${node_id} ${config} - ${res} = Pub And Recv ${MQTT_CMD_SET} {"node_id": ${node_id}, "params": ${config}} ${TOPIC_SETTING_REQ} ${TOPIC_SETTING_RES} - - [RETURN] ${res} - -Get Node Setting - [Arguments] ${node_id} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_id": ${node_id}} ${TOPIC_SETTING_REQ} ${TOPIC_SETTING_RES} - - [RETURN] ${res} - -Get Node State - [Arguments] ${node_id} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_id": ${node_id}} ${TOPIC_STATE_REQ} ${TOPIC_STATE_RES} - - [RETURN] ${res}[running] ${res}[link] + POST /api/v2/node/setting {"node_id": ${node_id}, "params": ${config}} + Integer response status 200 Node Ctl - [Arguments] ${node_id} ${cmd} - ${res} = Pub And Recv ${MQTT_CMD_NONE} {"id": ${node_id}, "cmd": ${cmd}} ${TOPIC_CTR_REQ} ${TOPIC_CTR_RES} + [Arguments] ${node_id} ${cmd} + POST /api/v2/node/ctl {"id": ${node_id}, "cmd": ${cmd}} + ${res} = Object response body - [RETURN] ${res} + [RETURN] ${res}[0] + +Add Group Config + [Arguments] ${node_id} ${grp_config_name} ${interval} + POST /api/v2/gconfig {"name": "${grp_config_name}", "node_id": ${node_id}, "interval": ${interval}} + ${res} = Object response body + + [RETURN] ${res}[0] + +Update Group Config + [Arguments] ${node_id} ${grp_config_name} ${interval} + PUT /api/v2/gconfig {"node_id": ${node_id}, "name": "${grp_config_name}", "interval": ${interval}} + ${res} = Object response body + + [RETURN] ${res}[0] + +Subscribe Group + [Arguments] ${driver_node_id} ${app_node_id} ${group_config_name} + POST /api/v2/subscribe {"src_node_id": ${driver_node_id}, "dst_node_id": ${app_node_id}, "name": "${group_config_name}"} + ${res} = Object response body + + [RETURN] ${res}[0] + +Add Tags + [Arguments] ${node_id} ${group} ${tags} + POST /api/v2/tags {"node_id": ${node_id}, "group_config_name": "${group}", "tags": [${tags}]} + ${res} = Object response body + + [RETURN] ${res}[0] + +Add Tag And Return ID + [Arguments] ${node_id} ${group} ${tag} + ${res} = Add Tags ${node_id} ${group} ${tag} + Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} + ${tmp} = evaluate json.loads('''${tag}''') json + + Run Keyword And Return Get Tag ID ${node_id} ${group} ${tmp}[name] + +Get Tags + [Arguments] ${node_id} ${group} + GET /api/v2/tags?node_id=${node_id}&group_config_name=${group} + ${res} = Object response body + + [RETURN] ${res}[0] + +Update Tags + [Arguments] ${node_id} ${group} ${tags} + Put /api/v2/tags {"node_id": ${node_id}, "group_config_name": "${group}", "tags": [${tags}]} + ${res} = Object response body + + [RETURN] ${res}[0] + +Del Tags + [Arguments] ${node_id} ${group} ${ids} + DELETE /api/v2/tags {"node_id": ${node_id}, "group_config_name": "${group}", "ids": [${ids}]} + ${res} = Object response body + + [RETURN] ${res}[0] + +Get Tag ID + [Arguments] ${node_id} ${group} ${tag_name} + ${res} = Get Tags ${node_id} ${group} + Check Response Status ${res} 200 + + ${id} = Tag Find By Name ${res}[tags] ${tag_name} + Should Not Be Equal As Integers ${id} 0 + + [Return] ${id} + +Add Node And Return ID + [Arguments] ${node_type} ${node_name} ${plugin_name} + ${res} = Add Node type=${${node_type}} name=${node_name} plugin_name=${plugin_name} + + Log ${res} + _Http Check Response Status ${res} 200 + Check Error Code ${res} ${ERR_SUCCESS} + + ${node_id} = Get Node ID ${node_type} ${node_name} + Should Not Be Equal As Integers ${node_id} 0 + + [RETURN] ${node_id} Ping ${res} = Pub And Recv ${MQTT_CMD_NONE} {} ${TOPIC_PING_REQ} ${TOPIC_STATUS_RES} -Add Group Config - [Arguments] ${node_id} ${grp_config_name} ${interval} - ${res} = Pub And Recv ${MQTT_CMD_ADD} {"name": "${grp_config_name}", "node_id": ${node_id}, "interval": ${interval}} ${TOPIC_GCONFIG_REQ} ${TOPIC_GCONFIG_RES} - - [RETURN] ${res} - -Get Group Config - [Arguments] ${node_id} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_id": ${node_id}} ${TOPIC_GCONFIG_REQ} ${TOPIC_GCONFIG_RES} - - [RETURN] ${res} - -Update Group Config - [Arguments] ${node_id} ${grp_config_name} ${interval} - ${res} = Pub And Recv ${MQTT_CMD_UPDATE} {"name": "${grp_config_name}", "node_id": ${node_id}, "interval": ${interval}} ${TOPIC_GCONFIG_REQ} ${TOPIC_GCONFIG_RES} - - [RETURN] ${res} - -Del Group Config - [Arguments] ${node_id} ${grp_config_name} - ${res} = Pub And Recv ${MQTT_CMD_DELETE} {"name": "${grp_config_name}", "node_id": ${node_id}} ${TOPIC_GCONFIG_REQ} ${TOPIC_GCONFIG_RES} - - [RETURN] ${res} - -Subscribe Group - [Arguments] ${driver_node_id} ${app_node_id} ${group_config_name} - ${res} = Pub And Recv ${MQTT_CMD_ADD} {"src_node_id": ${driver_node_id}, "dst_node_id": ${app_node_id}, "name": "${group_config_name}"} ${TOPIC_SUBSCRIBE_REQ} ${TOPIC_SUBSCRIBE_RES} - - [RETURN] ${res} - -Get Subscribe Group - [Arguments] ${node_id} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_id": ${node_id}} ${TOPIC_SUBSCRIBE_REQ} ${TOPIC_SUBSCRIBE_RES} - - [RETURN] ${res} - -Unsubscribe Group - [Arguments] ${driver_node_id} ${app_node_id} ${group_config_name} - ${res} = Pub And Recv ${MQTT_CMD_DELETE} {"src_node_id": ${driver_node_id}, "dst_node_id": ${app_node_id}, "name": "${group_config_name}"} ${TOPIC_SUBSCRIBE_REQ} ${TOPIC_SUBSCRIBE_RES} - - [RETURN] ${res} - -Add Tags - [Arguments] ${node_id} ${group} ${tags} - ${res} = Pub And Recv ${MQTT_CMD_ADD} {"node_id": ${node_id}, "group_config_name": "${group}", "tags": [${tags}]} ${TOPIC_TAGS_REQ} ${TOPIC_TAGS_RES} - - [RETURN] ${res} - -Add Tag And Return ID - [Arguments] ${node_id} ${group} ${tag} - ${res} = Pub And Recv ${MQTT_CMD_ADD} {"node_id": ${node_id}, "group_config_name": "${group}", "tags": [${tag}]} ${TOPIC_TAGS_REQ} ${TOPIC_TAGS_RES} - - Check Error Code ${res} ${ERR_SUCCESS} - ${tmp} = evaluate json.loads('''${tag}''') json - - Run Keyword And Return Get Tag ID ${node_id} ${group} ${tmp}[name] - -Get Tags - [Arguments] ${node_id} ${group} - ${res} = Pub And Recv ${MQTT_CMD_GET} {"node_id": ${node_id}, "group_config_name": "${group}"} ${TOPIC_TAGS_REQ} ${TOPIC_TAGS_RES} - [Return] ${res} -Update Tags - [Arguments] ${node_id} ${group} ${tags} - ${res} = Pub And Recv ${MQTT_CMD_UPDATE} {"node_id": ${node_id}, "group_config_name": "${group}", "tags": [${tags}]} ${TOPIC_TAGS_REQ} ${TOPIC_TAGS_RES} - - [Return] ${res} - -Del Tags - [Arguments] ${node_id} ${group} ${ids} - ${res} = Pub And Recv ${MQTT_CMD_DELETE} {"node_id": ${node_id}, "group_config_name": "${group}", "ids": [${ids}]} ${TOPIC_TAGS_REQ} ${TOPIC_TAGS_RES} - - [Return] ${res} - -Get Tag ID - [Arguments] ${node_id} ${group} ${tag_name} - ${res} = Get Tags ${node_id} ${group} - - ${id} = Tag Find By Name ${res}[tags] ${tag_name} - - [Return] ${id} - Read Tags [Arguments] ${node_name} ${group} ${res} = Pub And Recv ${MQTT_CMD_NONE} {"node_name": "${node_name}", "group_name": "${group}"} ${TOPIC_READ_REQ} ${TOPIC_READ_RES} diff --git a/ft/common.resource b/ft/common.resource index 59623355..f66702bb 100644 --- a/ft/common.resource +++ b/ft/common.resource @@ -58,41 +58,17 @@ ${TAG_DATA_TYPE_STRING} 15 ${PLUGIN_MODBUS_TCP} modbus-tcp ${PLUGIN_MQTT} mqtt -${MQTT_CMD_GET} get -${MQTT_CMD_SET} set -${MQTT_CMD_ADD} add -${MQTT_CMD_UPDATE} update -${MQTT_CMD_DELETE} delete ${MQTT_CMD_NONE} ${MQTT_CLIENTID} 123456 ${TOPIC_PING_REQ} neuron/${MQTT_CLIENTID}/ping -${TOPIC_NODE_REQ} neuron/${MQTT_CLIENTID}/node/req -${TOPIC_GCONFIG_REQ} neuron/${MQTT_CLIENTID}/gconfig/req -${TOPIC_TAGS_REQ} neuron/${MQTT_CLIENTID}/tags/req -${TOPIC_PLUGIN_REQ} neuron/${MQTT_CLIENTID}/plugin/req -${TOPIC_SUBSCRIBE_REQ} neuron/${MQTT_CLIENTID}/subscribe/req ${TOPIC_READ_REQ} neuron/${MQTT_CLIENTID}/read/req ${TOPIC_WRITE_REQ} neuron/${MQTT_CLIENTID}/write/req -${TOPIC_TTYS_REQ} neuron/${MQTT_CLIENTID}/ttys/req -${TOPIC_SCHEMA_REQ} neuron/${MQTT_CLIENTID}/schema/plugin/req -${TOPIC_SETTING_REQ} neuron/${MQTT_CLIENTID}/node/setting/req -${TOPIC_CTR_REQ} neuron/${MQTT_CLIENTID}/node/ctl/req -${TOPIC_STATE_REQ} neuron/${MQTT_CLIENTID}/node/state/req ${TOPIC_STATUS_RES} neuron/${MQTT_CLIENTID}/status -${TOPIC_NODE_RES} neuron/${MQTT_CLIENTID}/node/resp -${TOPIC_GCONFIG_RES} neuron/${MQTT_CLIENTID}/gconfig/resp -${TOPIC_TAGS_RES} neuron/${MQTT_CLIENTID}/tags/resp -${TOPIC_PLUGIN_RES} neuron/${MQTT_CLIENTID}/plugin/resp -${TOPIC_SUBSCRIBE_RES} neuron/${MQTT_CLIENTID}/subscribe/resp ${TOPIC_READ_RES} neuron/${MQTT_CLIENTID}/read/resp ${TOPIC_WRITE_RES} neuron/${MQTT_CLIENTID}/write/resp ${TOPIC_TTYS_RES} neuron/${MQTT_CLIENTID}/ttys/resp -${TOPIC_SCHEMA_RES} neuron/${MQTT_CLIENTID}/schema/plugin/resp -${TOPIC_SETTING_RES} neuron/${MQTT_CLIENTID}/node/setting/resp -${TOPIC_CTR_RES} neuron/${MQTT_CLIENTID}/node/ctl/resp -${TOPIC_STATE_RES} neuron/${MQTT_CLIENTID}/node/state/resp ${MQTT_UUID} 123456-789abc-123456-aabbcc ${MQTT_CONFIG_HOST} 127.0.0.1 @@ -158,6 +134,9 @@ Skip If Not Http API Skip If Not MQTT API Skip If $NEURON_API != "mqtt" Current API is not `mqtt`, just skip +Skip If MQTT API + Skip If $NEURON_API == "mqtt" Current API is not `mqtt`, just skip + Copy Persistence Test Data ${data_set} = Get Variable Value ${DATASET} total-10k ${data_dir} = Set Variable ${test_data_dir}/persistence/${data_set} diff --git a/ft/grp_config_api_test.robot b/ft/grp_config_api_test.robot index ca7af1ff..9168029b 100644 --- a/ft/grp_config_api_test.robot +++ b/ft/grp_config_api_test.robot @@ -12,48 +12,64 @@ ${app_node} app-node *** Test Cases *** Add group config under non-existent node, it should return failure + Skip If MQTT API + ${res} = Add Group Config ${1234} ${test_gconfig} 1000 Check Response Status ${res} 404 Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Add group config under existent node, it should return success + Skip If MQTT API + ${res} = Add Group Config ${test_node_id} ${test_gconfig} 1000 Check Response Status ${res} 200 Check Error Code ${res} ${ERR_SUCCESS} Delete a non-existent group config, it should return failure + Skip If MQTT API + ${res} = Del Group Config ${test_node_id} xxxx Check Response Status ${res} 404 Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} Delete a group config from non-existent node, it should return failure + Skip If MQTT API + ${res} = Del Group Config ${1234} ${test_gconfig} Check Response Status ${res} 404 Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} Delete a group config, it should return success + Skip If MQTT API + ${res} = Del Group Config ${test_node_id} ${test_gconfig} Check Response Status ${res} 200 Check Error Code ${res} ${ERR_SUCCESS} Update a non-existent group config, it should return failure + Skip If MQTT API + ${res} = Update Group Config ${test_node_id} xxxx 2000 Check Response Status ${res} 404 Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} Update a group config from non-existent node, it should return failure + Skip If MQTT API + ${res} = Update Group Config ${1234} ${test_gconfig} 2000 Check Response Status ${res} 404 Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} Add a group config to the node, then get the group config from this node, it should return the group config + Skip If MQTT API + ${res} = Add Group Config ${test_node_id} ${test_gconfig} 1000 Check Response Status ${res} 200 @@ -67,6 +83,8 @@ Add a group config to the node, then get the group config from this node, it sho Should Be Equal As Integers ${config}[interval] 1000 Update the interval of the test group config, it should return success + Skip If MQTT API + ${res} = Update Group Config ${test_node_id} ${test_gconfig} 2000 Check Response Status ${res} 200 @@ -80,6 +98,8 @@ Update the interval of the test group config, it should return success Should Be Equal As Integers ${config}[interval] 2000 North APP subscribe non-existent group config, it should return failure + Skip If MQTT API + ${app_node_id} = Add Node And Return ID ${NODE_MQTT} ${app_node} ${PLUGIN_MQTT} ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} ${driver_node} ${PLUGIN_MODBUS_TCP} @@ -89,6 +109,8 @@ North APP subscribe non-existent group config, it should return failure Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} North APP subscribe group config, it should return success + Skip If MQTT API + ${app_node_id} = Get Node ID ${NODE_MQTT} ${app_node} ${driver_node_id} = Get Node ID ${NODE_DRIVER} ${driver_node} ${res} = Add Group Config ${driver_node_id} grp_config 1000 @@ -99,6 +121,8 @@ North APP subscribe group config, it should return success Check Error Code ${res} ${ERR_SUCCESS} Query the subscribers of the group config, it should return all nodes subscribed to this group + Skip If MQTT API + ${app_node_id} = Get Node ID ${NODE_MQTT} ${app_node} ${driver_node_id1} = Get Node ID ${NODE_DRIVER} ${driver_node} @@ -139,6 +163,8 @@ Query the subscribers of the group config, it should return all nodes subscribed Delete the subscribe group config, it should return failure + Skip If MQTT API + ${driver_node_id1} = Get Node ID ${NODE_DRIVER} ${driver_node} ${res} = Del Group Config ${driver_node_id1} grp_config @@ -147,6 +173,8 @@ Delete the subscribe group config, it should return failure Check Error Code ${res} ${ERR_GRP_CONFIG_IN_USE} North APP unsubscribe non-existent group config, it should return failure + Skip If MQTT API + ${app_node_id} = Get Node ID ${NODE_MQTT} ${app_node} ${driver_node_id} = Get Node ID ${NODE_DRIVER} ${driver_node} ${res} = Unsubscribe Group ${driver_node_id} ${app_node_id} xxgrp_config @@ -155,6 +183,8 @@ North APP unsubscribe non-existent group config, it should return failure Check Error Code ${res} ${ERR_GRPCONFIG_NOT_EXIST} North APP unsubscribe group config, it should return success + Skip If MQTT API + ${app_node_id} = Get Node ID ${NODE_MQTT} ${app_node} ${driver_node_id1} = Get Node ID ${NODE_DRIVER} ${driver_node} ${driver_node_id2} = Get Node ID ${NODE_DRIVER} driver-node2 diff --git a/ft/node_api_test.robot b/ft/node_api_test.robot index acc219a6..2cd29be4 100644 --- a/ft/node_api_test.robot +++ b/ft/node_api_test.robot @@ -7,9 +7,13 @@ Suite Teardown Neuron Context Stop *** Test Cases *** POST ping, status can be ok + Skip If MQTT API + Ping Use the wrong body to create a node, it should return failure + Skip If MQTT API + ${res} = Add Node type=${${NODE_DRIVER}} namexx=test-node plugin_name=test-plugin-name Check Response Status ${res} 400 @@ -17,6 +21,8 @@ Use the wrong body to create a node, it should return failure Use a plugin name that does not exist to create a node, it should return failure + Skip If MQTT API + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=test-plugin-name Check Response Status ${res} 404 @@ -24,18 +30,24 @@ Use a plugin name that does not exist to create a node, it should return failure Use a invalid node type to create a node, it should return failure + Skip If MQTT API + ${res} = Add Node type=${10} name=test-node plugin_name=modbus-tcp Check Response Status ${res} 400 Check Error Code ${res} ${ERR_NODE_TYPE_INVALID} Create a node with the correct body, it should return success + Skip If MQTT API + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp Check Response Status ${res} 200 Check Error Code ${res} ${ERR_SUCCESS} Create an existing node, it should return failure + Skip If MQTT API + ${res} = Add Node type=${${NODE_DRIVER}} name=test-node plugin_name=modbus-tcp Check Response Status ${res} 409 @@ -49,6 +61,8 @@ Get node with wrong parameters, it will return failure Integer response body error ${ERR_REQUEST_PARAM_INVALID} Get DRIVER node, it should return all DRIVER node + Skip If MQTT API + ${res} = Get Nodes ${NODE_DRIVER} Check Response Status ${res} 200 @@ -58,12 +72,16 @@ Get DRIVER node, it should return all DRIVER node END Get WEB node, it should return all WEB node + Skip If MQTT API + ${res} = Get Nodes ${NODE_WEB} Check Response Status ${res} 200 Node With Name Should Exist ${res}[nodes] default-dashboard-adapter Get MQTT node, it should return all mqtt node + Skip If MQTT API + ${res} = Add Node type=${${NODE_MQTT}} name=mqtt-adapter plugin_name=mqtt ${res} = Get Nodes ${NODE_MQTT} @@ -72,18 +90,24 @@ Get MQTT node, it should return all mqtt node Get UNKNOWN type node, it should return empty node + Skip If MQTT API + ${res} = Get Nodes ${NODE_UNKNOWN} Check Response Status ${res} 200 Run Keyword If ${res}[nodes] != @{EMPTY} Fail not an empty object Get INVALID type node, it should return failure + Skip If MQTT API + ${res} = Get Nodes ${123456} Check Response Status ${res} 400 Check Error Code ${res} ${ERR_REQUEST_PARAM_INVALID} Delete the existing node, it will return success + Skip If MQTT API + ${res} = Get Nodes ${NODE_DRIVER} Check Response Status ${res} 200 @@ -99,24 +123,32 @@ Delete the existing node, it will return success Should Be Equal As Integers ${node_id} 0 Delete a non-existent node, it will return failure + Skip If MQTT API + ${res} = Del Node ${1000} Check Response Status ${res} 404 Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Add setting to non-existent node, it should return failure + Skip If MQTT API + ${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} Get setting from non-existent node, it should return failure + Skip If MQTT API + ${res} = Get Node Setting ${999} 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 + Skip If MQTT API + ${driver_node_id} = Add Node And Return ID ${NODE_DRIVER} driver-node ${PLUGIN_MODBUS_TCP} ${res} = Get Node Setting ${driver_node_id} @@ -126,6 +158,8 @@ Get setting from a node that has never been set, it should return failure [Teardown] Del Node Check ${driver_node_id} Add the correct settings to the node, it should return success + Skip If MQTT API + ${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} @@ -133,6 +167,8 @@ Add the correct settings to the node, it should return success Check Error Code ${res} ${ERR_SUCCESS} Get the setting of node, it should return to the previous setting + Skip If MQTT API + ${driver_node_id} = Get Node ID ${NODE_DRIVER} driver-node ${res} = Get Node Setting ${driver_node_id} ${params} = Set Variable ${res}[params] @@ -144,6 +180,8 @@ Get the setting of node, it should return to the previous setting Should Be Equal As Integers ${params}[connection_mode] 0 Add wrong settings to node, it should return failure + Skip If MQTT API + ${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} @@ -151,6 +189,8 @@ Add wrong settings to node, it should return failure Check Error Code ${res} ${ERR_NODE_SETTING_INVALID} Start an unconfigured node, it should return failure + Skip If MQTT API + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s @@ -168,6 +208,8 @@ Start an unconfigured node, it should return failure [Teardown] Del Node Check ${modbus_node_id} Start the configured node, it should return success + Skip If MQTT API + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s @@ -188,6 +230,8 @@ Start the configured node, it should return success Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Start the stopped node, it should return success + Skip If MQTT API + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} @@ -208,6 +252,8 @@ Start the stopped node, it should return success Should Be Equal As Integers ${link_state} ${NODE_LINK_STATE_CONNECTING} Start the running node, it should return failure + Skip If MQTT API + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_START} @@ -219,6 +265,8 @@ Start the running node, it should return failure Check Error Code ${res} ${ERR_SUCCESS} Stop node that is stopped, it should return failure + Skip If MQTT API + ${modbus_node_id} = Get Node ID ${NODE_DRIVER} modbus-test-node ${res} = Node Ctl ${modbus_node_id} ${NODE_CTL_STOP} @@ -228,6 +276,8 @@ Stop node that is stopped, it should return failure [Teardown] Del Node Check ${modbus_node_id} Stop node that is ready(init/idle), it should return failure + Skip If MQTT API + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s @@ -246,6 +296,8 @@ Stop node that is ready(init/idle), it should return failure [Teardown] Del Node Check ${modbus_node_id} When setting up a READY/RUNNING/STOPED node, the node status will not change + Skip If MQTT API + ${modbus_node_id} = Add Node And Return ID ${NODE_DRIVER} modbus-test-node ${PLUGIN_MODBUS_TCP} Sleep 1s diff --git a/ft/tag_api_test.robot b/ft/tag_api_test.robot index 162e50ce..efb18e63 100644 --- a/ft/tag_api_test.robot +++ b/ft/tag_api_test.robot @@ -11,6 +11,8 @@ ${tag2} {"name": "tag2", "address": "1!00001", "attribute": 3, "type *** Test Cases *** Add different types of tags to the group, it should return success + Skip If MQTT API + Add Group Config ${test_node_id} ${test_gconfig} 1000 ${res} = Add Tags ${test_node_id} ${test_gconfig} ${tag1},${tag2} @@ -20,6 +22,8 @@ Add different types of tags to the group, it should return success [Teardown] Del Group Config Check ${test_node_id} ${test_gconfig} Add tags to the non-existent group, the group will be created automatically + Skip If MQTT API + ${res} = Add Tags ${test_node_id} ${test_gconfig} ${tag1},${tag2} Check Response Status ${res} 200 @@ -28,6 +32,8 @@ Add tags to the non-existent group, the group will be created automatically [Teardown] Del Group Config Check ${test_node_id} ${test_gconfig} When the attribute of the tag added is incorrect, it should return partial success + Skip If MQTT API + ${res} = Add Tags ${test_node_id} ${test_gconfig} {"name": "tag1", "address": "1!400001", "attribute": 8, "type": 4},{"name": "tag2", "address": "1!00001", "attribute": 3, "type": 14} Check Response Status ${res} 206 @@ -36,18 +42,24 @@ When the attribute of the tag added is incorrect, it should return partial succe [Teardown] Del Group Config Check ${test_node_id} ${test_gconfig} Add tags to non-existent node, it should return failure + Skip If MQTT API + ${res} = Add Tags ${999} ${test_gconfig} ${tag1},${tag2} Check Response Status ${res} 404 Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Delete tag from non-existent group config, it should return failure + Skip If MQTT API + ${res} = Del Tags ${test_node_id} ${test_gconfig} 1,2,3 Check Response Status ${res} 404 Check Error Code ${res} ${ERR_NODE_NOT_EXIST} Delete non-existent tags, it should return success + Skip If MQTT API + Add Group Config ${test_node_id} ${test_gconfig} 1000 ${res} = Del Tags ${test_node_id} ${test_gconfig} 1,2,3 @@ -56,12 +68,16 @@ Delete non-existent tags, it should return success Check Error Code ${res} ${ERR_SUCCESS} Query tag from non-existent node, it should return failure + Skip If MQTT API + ${res} = Get Tags ${999} ${test_gconfig} Check Response Status ${res} 404 Check Error Code ${res} ${ERR_NODE_NOT_EXIST} After adding the tag, query the tag, it should return the added tag + Skip If MQTT API + ${res} = Add Tags ${test_node_id} ${test_gconfig} ${tag1},${tag2} Check Response Status ${res} 200 @@ -80,6 +96,8 @@ After adding the tag, query the tag, it should return the added tag Should Be Equal As Integers ${ret} 0 Update tags, it should return success + Skip If MQTT API + ${tag1_id} = Get Tag ID ${test_node_id} ${test_gconfig} tag1 ${tag2_id} = Get Tag ID ${test_node_id} ${test_gconfig} tag2 @@ -100,6 +118,8 @@ Update tags, it should return success Should Be Equal As Integers ${ret} 0 Update non-existent tags, it should return partial success + Skip If MQTT API + ${tag1_id} = Get Tag ID ${test_node_id} ${test_gconfig} tag11 ${res} = Update Tags ${test_node_id} ${test_gconfig} {"id": ${tag1_id}, "name": "tag11", "type": 4, "attribute": 1, "address": "1!400002"},{"id": 7788, "name": "tag22", "type": 4, "attribute": 1, "address": "3!100001"} @@ -119,6 +139,8 @@ Update non-existent tags, it should return partial success Should Be Equal As Integers ${ret} 0 Delete tags, it should return success + Skip If MQTT API + ${tag1_id} = Get Tag ID ${test_node_id} ${test_gconfig} tag11 ${tag2_id} = Get Tag ID ${test_node_id} ${test_gconfig} tag22