Compare commits

...
6 Commits
Author SHA1 Message Date
fengzeroz ffdf1c747d Merge pull request #1761 from hxy7yx/v2.7-1
fix: add_tags&add_gtags http resp code
2023-12-18 17:08:56 +08:00
hxy7yx c81dbbad20 fix:add_tags and add_gtags http resp code 2023-12-18 16:47:34 +08:00
fengzeroz 1366631690 Merge pull request #1759 from fengzeroz/v2.7
fix(conn): lock conn buf
2023-12-18 16:07:08 +08:00
fengzeroz 8fd4ce669b Merge pull request #1756 from ZhouBox/v2.7
[v2.7]fix:add library update fail error code
2023-12-18 15:38:06 +08:00
fengzero ed6233cf77 fix(conn): lock conn buf 2023-12-18 07:32:59 +00:00
xiang.zhou 53174ac6b2 fix:add library update fail error code 2023-12-18 14:59:30 +08:00
7 changed files with 28 additions and 26 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ Add different types of tags to the group, it should return success
Add a list of tags with errors, it should return the number of successful additions.
${res}= Add Tags modbus-node group ${tag1},${tag2},${tag3},${tag4}
Check Response Status ${res} 200
Check Response Status ${res} 409
Check Error Code ${res} ${NEU_ERR_TAG_NAME_CONFLICT}
Should Be Equal As Integers ${res}[index] 0
@@ -139,7 +139,7 @@ Delete tag from non-existent group, it should return success
Update non-existent tag, it should return failure.
${res}= Update Tags modbus-node group ${tag4}
Check Response Status ${res} 200
Check Response Status ${res} 404
Check Error Code ${res} ${NEU_ERR_TAG_NOT_EXIST}
${res}= Get Tags modbus-node group
+4 -4
View File
@@ -96,7 +96,7 @@ Create a template with invalid tag type, it should fail.
${groups} = Create List ${group}
${res} = Add Template ${g_template} ${g_plugin} ${groups}
Check Response Status ${res} 206
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TAG_TYPE_NOT_SUPPORT}
[Teardown] Del Template ${g_template}
@@ -108,7 +108,7 @@ Create a template with invalid tag address, it should fail.
${groups} = Create List ${group}
${res} = Add Template ${g_template} ${g_plugin} ${groups}
Check Response Status ${res} 206
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TAG_ADDRESS_FORMAT_INVALID}
[Teardown] Del Template ${g_template}
@@ -802,7 +802,7 @@ Add tag with too long name to existing template group, it should fail.
&{tag} = New Tag From ${g_tag1} name=${g_long_str}
${res} = Add Template Tags ${g_template} ${g_group1}[name] ${tag}
Check Response Status ${res} 206
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TAG_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
@@ -1026,7 +1026,7 @@ Update tag name to invalid value, it should fail.
&{tag} = New Tag From ${g_tag1} name=${g_long_str}
${res} = Put Template Tags ${g_template} ${g_group1}[name] ${tag}
Check Response Status ${res} 206
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TAG_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
+4 -3
View File
@@ -92,7 +92,8 @@ void handle_add_tags_resp(nng_aio *aio, neu_resp_add_tag_t *resp)
neu_json_encode_by_fn(&res, neu_json_encode_au_tags_resp, &result);
neu_http_ok(aio, result);
NEU_JSON_RESPONSE_ERROR(resp->error,
{ neu_http_response(aio, resp->error, result); });
free(result);
}
@@ -183,8 +184,8 @@ void handle_add_gtags_resp(nng_aio *aio, neu_resp_add_tag_t *resp)
res.index = resp->index;
neu_json_encode_by_fn(&res, neu_json_encode_au_gtags_resp, &result);
neu_http_ok(aio, result);
NEU_JSON_RESPONSE_ERROR(resp->error,
{ neu_http_response(aio, resp->error, result); });
free(result);
}
+2
View File
@@ -1289,10 +1289,12 @@ int neu_conn_stream_consume(neu_conn_t *conn, void *context,
neu_conn_disconnect(conn);
break;
} else {
pthread_mutex_lock(&conn->mtx);
conn->offset -= used;
memmove(conn->buf, conn->buf + used, conn->offset);
neu_protocol_unpack_buf_init(&protocol_buf, conn->buf,
conn->offset);
pthread_mutex_unlock(&conn->mtx);
}
}
}
+8 -9
View File
@@ -341,12 +341,20 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_PLUGIN_NAME_TOO_LONG:
case NEU_ERR_PLUGIN_NOT_SUPPORT_TEMPLATE:
case NEU_ERR_LIBRARY_ADD_FAIL:
case NEU_ERR_LIBRARY_UPDATE_FAIL:
case NEU_ERR_LIBRARY_MODULE_NOT_EXISTS:
case NEU_ERR_LIBRARY_MODULE_KIND_NOT_SUPPORT:
case NEU_ERR_LIBRARY_MODULE_VERSION_NOT_MATCH:
case NEU_ERR_LIBRARY_NAME_NOT_CONFORM:
case NEU_ERR_LIBRARY_CLIB_NOT_MATCH:
case NEU_ERR_LIBRARY_ARCH_NOT_SUPPORT:
case NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT:
case NEU_ERR_TAG_TYPE_NOT_SUPPORT:
case NEU_ERR_TAG_ADDRESS_FORMAT_INVALID:
case NEU_ERR_TAG_DESCRIPTION_TOO_LONG:
case NEU_ERR_TAG_PRECISION_INVALID:
case NEU_ERR_TAG_NAME_TOO_LONG:
case NEU_ERR_TAG_ADDRESS_TOO_LONG:
status = NNG_HTTP_STATUS_BAD_REQUEST;
break;
case NEU_ERR_FILE_NOT_EXIST:
@@ -382,15 +390,6 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_LIBRARY_SYSTEM_NOT_ALLOW_DEL:
status = NNG_HTTP_STATUS_CONFLICT;
break;
case NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT:
case NEU_ERR_TAG_TYPE_NOT_SUPPORT:
case NEU_ERR_TAG_ADDRESS_FORMAT_INVALID:
case NEU_ERR_TAG_DESCRIPTION_TOO_LONG:
case NEU_ERR_TAG_PRECISION_INVALID:
case NEU_ERR_TAG_NAME_TOO_LONG:
case NEU_ERR_TAG_ADDRESS_TOO_LONG:
status = NNG_HTTP_STATUS_PARTIAL_CONTENT;
break;
default:
if (code >= NEU_ERR_PLUGIN_ERROR_START &&
code <= NEU_ERR_PLUGIN_ERROR_END) {
+6 -6
View File
@@ -382,27 +382,27 @@ class TestModbus:
"attribute": config.NEU_TAG_ATTRIBUTE_RW, "type": config.NEU_TYPE_BYTES}]
response = api.add_tags(node=param[0], group='group', tags=wrong_tag1)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT == response.json()[
'error']
response = api.add_tags(node=param[0], group='group', tags=wrong_tag2)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_TYPE_NOT_SUPPORT == response.json()[
'error']
response = api.add_tags(node=param[0], group='group', tags=wrong_tag3)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_ADDRESS_FORMAT_INVALID == response.json()[
'error']
response = api.add_tags(node=param[0], group='group', tags=wrong_tag4)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_ADDRESS_FORMAT_INVALID == response.json()[
'error']
response = api.add_tags(node=param[0], group='group', tags=wrong_tag5)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_ADDRESS_FORMAT_INVALID == response.json()[
'error']
@@ -571,7 +571,7 @@ class TestModbus:
up_tag[0]['type'] = config.NEU_TYPE_BIT
response = api.update_tags(
node=param[0], group='group', tags=up_tag)
assert 200 == response.status_code
assert 400 == response.status_code
assert error.NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT == response.json()[
'error']
+2 -2
View File
@@ -279,7 +279,7 @@ class TestLog:
]
)
assert 200 == response.status_code
assert 400 == response.status_code
assert NEU_ERR_TAG_TYPE_NOT_SUPPORT == response.json()['error']
response = api.get_group()
@@ -342,7 +342,7 @@ class TestLog:
]
)
assert 200 == response.status_code
assert 409 == response.status_code
assert NEU_ERR_TAG_NAME_CONFLICT == response.json()['error']
response = api.get_group()