mirror of
https://github.com/emqx/neuron.git
synced 2026-10-30 16:09:02 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5360d20da1 | ||
|
|
8be6cda1b1 | ||
|
|
f28842224d | ||
|
|
f8e879c989 | ||
|
|
a8ce8c9da0 | ||
|
|
ebc6a076fc | ||
|
|
bbad12cdd6 | ||
|
|
9614b509b1 | ||
|
|
11db02ccf5 | ||
|
|
c0dbdf39ff |
@@ -8,7 +8,7 @@ on:
|
||||
- published
|
||||
|
||||
env:
|
||||
VERSION: 2.7.2
|
||||
VERSION: 2.7.3
|
||||
UI_VERSION: 2.6.3
|
||||
BRANCH: v2.7
|
||||
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ add_library(neuron-base SHARED)
|
||||
target_sources(neuron-base PRIVATE ${NEURON_BASE_SOURCES} ${NEURON_SRC_PARSE})
|
||||
target_include_directories(neuron-base
|
||||
PRIVATE include/neuron src)
|
||||
target_link_libraries(neuron-base libssl.a libcrypto.a)
|
||||
target_link_libraries(neuron-base atomic libssl.a libcrypto.a)
|
||||
target_link_libraries(neuron-base nng libzlog.so jansson jwt
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
add_dependencies(neuron-base neuron-version)
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
#define NEU_VERSION_MAJOR 2
|
||||
#define NEU_VERSION_MINOR 7
|
||||
#define NEU_VERSION_FIX 2
|
||||
#define NEU_VERSION_FIX 3
|
||||
|
||||
#define NEU_GET_VERSION_MAJOR(V) ((0xffff0000 & V) >> 16)
|
||||
#define NEU_GET_VERSION_MINOR(V) ((0x0000ff00 & V) >> 8)
|
||||
#define NEU_GET_VERSION_FIX(V) ((0x000000ff & V))
|
||||
#define NEU_VERSION(MAJOR, MINOR, FIX) ((MAJOR << 16) | (MINOR << 8) | FIX)
|
||||
|
||||
#define NEU_TAG_NAME_LEN 64
|
||||
#define NEU_TAG_NAME_LEN 128
|
||||
#define NEU_TAG_ADDRESS_LEN 128
|
||||
#define NEU_TAG_DESCRIPTION_LEN 128
|
||||
#define NEU_GROUP_MAX_PER_NODE 512
|
||||
|
||||
@@ -1325,8 +1325,8 @@ int add_gtags(neu_adapter_t *adapter, neu_req_add_gtag_t *cmd,
|
||||
if (add_tag_result != 0) {
|
||||
for (int added_group_index = 0; added_group_index < group_index;
|
||||
added_group_index++) {
|
||||
for (int added_tag_index = 0; added_tag_index <=
|
||||
cmd->groups[added_group_index].n_tag;
|
||||
for (int added_tag_index = 0;
|
||||
added_tag_index < cmd->groups[added_group_index].n_tag;
|
||||
added_tag_index++) {
|
||||
neu_adapter_driver_del_tag(
|
||||
(neu_adapter_driver_t *) adapter,
|
||||
|
||||
@@ -90,6 +90,7 @@ static void read_group(int64_t timestamp, int64_t timeout,
|
||||
neu_driver_cache_t *cache, const char *group,
|
||||
UT_array *tags, UT_array *tag_values);
|
||||
static void read_report_group(int64_t timestamp, int64_t timeout,
|
||||
neu_tag_cache_type_e cache_type,
|
||||
neu_driver_cache_t *cache, const char *group,
|
||||
UT_array *tags, UT_array *tag_values);
|
||||
static void update(neu_adapter_t *adapter, const char *group, const char *tag,
|
||||
@@ -224,8 +225,9 @@ static void update_im(neu_adapter_t *adapter, const char *group,
|
||||
data->group = strdup(group);
|
||||
utarray_new(data->tags, neu_resp_tag_value_meta_icd());
|
||||
|
||||
read_report_group(global_timestamp, 0, driver->cache, group, tags,
|
||||
data->tags);
|
||||
read_report_group(global_timestamp, 0,
|
||||
neu_adapter_get_tag_cache_type(&driver->adapter),
|
||||
driver->cache, group, tags, data->tags);
|
||||
|
||||
if (utarray_len(data->tags) > 0) {
|
||||
group_t *find = NULL;
|
||||
@@ -1510,6 +1512,7 @@ static int report_callback(void *usr_data)
|
||||
read_report_group(global_timestamp,
|
||||
neu_group_get_interval(group->group) *
|
||||
NEU_DRIVER_TAG_CACHE_EXPIRE_TIME,
|
||||
neu_adapter_get_tag_cache_type(&group->driver->adapter),
|
||||
group->driver->cache, group->name, tags, data->tags);
|
||||
|
||||
if (utarray_len(data->tags) > 0) {
|
||||
@@ -1683,6 +1686,7 @@ static int read_callback(void *usr_data)
|
||||
}
|
||||
|
||||
static void read_report_group(int64_t timestamp, int64_t timeout,
|
||||
neu_tag_cache_type_e cache_type,
|
||||
neu_driver_cache_t *cache, const char *group,
|
||||
UT_array *tags, UT_array *tag_values)
|
||||
{
|
||||
@@ -1775,7 +1779,8 @@ static void read_report_group(int64_t timestamp, int64_t timeout,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!neu_tag_attribute_test(tag, NEU_ATTRIBUTE_STATIC) &&
|
||||
if (cache_type != NEU_TAG_CACHE_TYPE_NEVER &&
|
||||
!neu_tag_attribute_test(tag, NEU_ATTRIBUTE_STATIC) &&
|
||||
(timestamp - value.timestamp) > timeout && timeout > 0) {
|
||||
if (value.value.type == NEU_TYPE_PTR) {
|
||||
free(value.value.value.ptr.ptr);
|
||||
|
||||
+129
-1
@@ -355,4 +355,132 @@ class TestLog:
|
||||
assert 2 == response.json()['groups'][1]['tag_count']
|
||||
assert 'group_3' == response.json()['groups'][2]['group']
|
||||
assert 3000 == response.json()['groups'][2]['interval']
|
||||
assert 2 == response.json()['groups'][2]['tag_count']
|
||||
assert 2 == response.json()['groups'][2]['tag_count']
|
||||
|
||||
@description(given="multiple groups including same name tags in the first group", when="adding", then="add failed")
|
||||
def test_adding_same_name_gtags_first_group(self):
|
||||
response = api.add_gtags(
|
||||
node='modbus-tcp-tag-test',
|
||||
groups=[
|
||||
{
|
||||
"group": "group_f",
|
||||
"interval": 3000,
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 3,
|
||||
"decimal": 0.01
|
||||
},
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400002",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "group_s",
|
||||
"interval": 3000,
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
},
|
||||
{
|
||||
"name": "tag2",
|
||||
"address": "1!400002",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
assert 409 == response.status_code
|
||||
assert NEU_ERR_TAG_NAME_CONFLICT == response.json()['error']
|
||||
|
||||
@description(given="multiple groups including same name tags in the second group", when="adding", then="add failed")
|
||||
def test_adding_same_name_gtags_second_group(self):
|
||||
response = api.add_gtags(
|
||||
node='modbus-tcp-tag-test',
|
||||
groups=[
|
||||
{
|
||||
"group": "group_f",
|
||||
"interval": 3000,
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 3,
|
||||
"decimal": 0.01
|
||||
},
|
||||
{
|
||||
"name": "tag2",
|
||||
"address": "1!400002",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "group_s",
|
||||
"interval": 3000,
|
||||
"tags": [
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
},
|
||||
{
|
||||
"name": "tag1",
|
||||
"address": "1!400002",
|
||||
"attribute": 3,
|
||||
"type": 9,
|
||||
"precision": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
assert 409 == response.status_code
|
||||
assert NEU_ERR_TAG_NAME_CONFLICT == response.json()['error']
|
||||
|
||||
@description(given="tag name length exceeds 128", when="adding", then="add failed")
|
||||
def test_adding_tag_name_exceeds_128(self):
|
||||
response = api.add_gtags(
|
||||
node='modbus-tcp-tag-test',
|
||||
groups=[{"group": "group","interval": 3000,
|
||||
"tags": [{
|
||||
"name": "Lt7Pa5Q0tKJN2gL3WiYJLnaFzqBq5q5xyJ1vYHxyf2j0IZR7y3RBYxXGQBHwV7dEzD7lIcF1yX9aR3vH8leYxXxHUILk2eVqQBlaQLaROZt9yZ9xQNxKkfy5mySHb79",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 3,
|
||||
"decimal": 0.01}]}])
|
||||
assert 200 == response.status_code
|
||||
assert NEU_ERR_SUCCESS == response.json()['error']
|
||||
|
||||
response = api.add_gtags(
|
||||
node='modbus-tcp-tag-test',
|
||||
groups=[{"group": "group","interval": 3000,
|
||||
"tags": [{
|
||||
"name": "Lt7Pa5Q0tKJN2gL3WiYJLnaFzqBq5q5xyJ1vYHxyf2j0IZR7y3RBYxXGQBHwV7dEzD7lIcF1yX9aR3vH8leYxXxHUILk2eVqQBlaQLaROZt9yZ9xQNxKkfy5mySHb79Y8",
|
||||
"address": "1!400001",
|
||||
"attribute": 3,
|
||||
"type": 3,
|
||||
"decimal": 0.01}]}])
|
||||
assert 400 == response.status_code
|
||||
assert NEU_ERR_TAG_NAME_TOO_LONG == response.json()['error']
|
||||
Reference in New Issue
Block a user