test(iotdb): add template test case for IoTDB
This commit is contained in:
parent
d221f34ce8
commit
6f4b22e376
|
@ -192,6 +192,10 @@ desc(action_parameters) ->
|
||||||
?DESC("action_parameters");
|
?DESC("action_parameters");
|
||||||
desc(action_parameters_data) ->
|
desc(action_parameters_data) ->
|
||||||
?DESC("action_parameters_data");
|
?DESC("action_parameters_data");
|
||||||
|
desc(action_resource_opts) ->
|
||||||
|
"Action Resource Options";
|
||||||
|
desc("creation_opts") ->
|
||||||
|
"Creation Options";
|
||||||
desc(auth_basic) ->
|
desc(auth_basic) ->
|
||||||
"Basic Authentication";
|
"Basic Authentication";
|
||||||
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
||||||
|
|
|
@ -147,6 +147,8 @@ fields("get") ->
|
||||||
|
|
||||||
desc(config) ->
|
desc(config) ->
|
||||||
?DESC("desc_config");
|
?DESC("desc_config");
|
||||||
|
desc(auth_basic) ->
|
||||||
|
"Basic Authentication";
|
||||||
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
||||||
["Configuration for IoTDB using `", string:to_upper(Method), "` method."];
|
["Configuration for IoTDB using `", string:to_upper(Method), "` method."];
|
||||||
desc(_) ->
|
desc(_) ->
|
||||||
|
|
|
@ -589,6 +589,63 @@ t_device_id(Config) ->
|
||||||
iotdb_reset(Config, ConfiguredDevice),
|
iotdb_reset(Config, ConfiguredDevice),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
t_template(Config) ->
|
||||||
|
%% Create without data configured
|
||||||
|
?assertMatch({ok, _}, emqx_bridge_v2_testlib:create_bridge(Config)),
|
||||||
|
ResourceId = emqx_bridge_v2_testlib:resource_id(Config),
|
||||||
|
BridgeId = emqx_bridge_v2_testlib:bridge_id(Config),
|
||||||
|
?retry(
|
||||||
|
_Sleep = 1_000,
|
||||||
|
_Attempts = 20,
|
||||||
|
?assertEqual({ok, connected}, emqx_resource_manager:health_check(ResourceId))
|
||||||
|
),
|
||||||
|
TemplateDeviceId = <<"root.deviceWithTemplate">>,
|
||||||
|
DeviceId = <<"root.deviceWithoutTemplate">>,
|
||||||
|
Topic = <<"some/random/topic">>,
|
||||||
|
iotdb_reset(Config, DeviceId),
|
||||||
|
iotdb_reset(Config, TemplateDeviceId),
|
||||||
|
Payload1 = make_iotdb_payload(DeviceId, "test", "BOOLEAN", true),
|
||||||
|
MessageF1 = make_message_fun(Topic, Payload1),
|
||||||
|
|
||||||
|
is_success_check(
|
||||||
|
emqx_resource:simple_sync_query(ResourceId, {BridgeId, MessageF1()})
|
||||||
|
),
|
||||||
|
|
||||||
|
{ok, {{_, 200, _}, _, Res1_1}} = iotdb_query(Config, <<"select * from ", DeviceId/binary>>),
|
||||||
|
?assertMatch(#{<<"values">> := [[true]]}, emqx_utils_json:decode(Res1_1)),
|
||||||
|
|
||||||
|
iotdb_reset(Config, DeviceId),
|
||||||
|
iotdb_reset(Config, TemplateDeviceId),
|
||||||
|
|
||||||
|
%% reconfigure with data template
|
||||||
|
{ok, _} =
|
||||||
|
emqx_bridge_v2_testlib:update_bridge_api(Config, #{
|
||||||
|
<<"parameters">> => #{
|
||||||
|
<<"device_id">> => TemplateDeviceId,
|
||||||
|
<<"data">> => [
|
||||||
|
#{
|
||||||
|
<<"measurement">> => <<"${payload.measurement}">>,
|
||||||
|
<<"data_type">> => "TEXT",
|
||||||
|
<<"value">> => <<"${payload.device_id}">>
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
is_success_check(
|
||||||
|
emqx_resource:simple_sync_query(ResourceId, {BridgeId, MessageF1()})
|
||||||
|
),
|
||||||
|
|
||||||
|
{ok, {{_, 200, _}, _, Res2_2}} = iotdb_query(
|
||||||
|
Config, <<"select * from ", TemplateDeviceId/binary>>
|
||||||
|
),
|
||||||
|
|
||||||
|
?assertMatch(#{<<"values">> := [[<<DeviceId/binary>>]]}, emqx_utils_json:decode(Res2_2)),
|
||||||
|
|
||||||
|
iotdb_reset(Config, DeviceId),
|
||||||
|
iotdb_reset(Config, TemplateDeviceId),
|
||||||
|
ok.
|
||||||
|
|
||||||
is_empty(null) -> true;
|
is_empty(null) -> true;
|
||||||
is_empty([]) -> true;
|
is_empty([]) -> true;
|
||||||
is_empty([[]]) -> true;
|
is_empty([[]]) -> true;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The bridges for IoTDB have been split so it is available via the connectors and actions APIs. They are still backwards compatible with the old bridge API.
|
|
@ -72,13 +72,12 @@ desc_name.label:
|
||||||
"""Bridge Name"""
|
"""Bridge Name"""
|
||||||
|
|
||||||
config_parameters_timestamp.desc:
|
config_parameters_timestamp.desc:
|
||||||
"""Timestamp. Placeholders in format of ${var} is supported, the finally value can be:</br>
|
"""Timestamp. Placeholders in format of ${var} is supported, the final value can be:</br>
|
||||||
- now: use the `now_ms` which is contained in the payload as timestamp
|
- now: use the `now_ms` which is contained in the payload as timestamp
|
||||||
- now_ms: same as above
|
- now_ms: same as above
|
||||||
- now_us: use the `now_us` which is contained in the payload as timestamp
|
- now_us: use the `now_us` which is contained in the payload as timestamp
|
||||||
- now_ns: use the `now_us` which is contained in the payload as timestamp
|
- now_ns: use the `now_ns` which is contained in the payload as timestamp
|
||||||
- any other: use the value directly as the timestamp
|
- any other: use the value directly as the timestamp"""
|
||||||
"""
|
|
||||||
|
|
||||||
config_parameters_timestamp.label:
|
config_parameters_timestamp.label:
|
||||||
"""Timestamp"""
|
"""Timestamp"""
|
||||||
|
@ -96,8 +95,7 @@ config_parameters_data_type.desc:
|
||||||
- INT32
|
- INT32
|
||||||
- INT64
|
- INT64
|
||||||
- FLOAT
|
- FLOAT
|
||||||
- DOUBLE
|
- DOUBLE"""
|
||||||
"""
|
|
||||||
|
|
||||||
config_parameters_data_type.label:
|
config_parameters_data_type.label:
|
||||||
"""Data type"""
|
"""Data type"""
|
||||||
|
|
|
@ -295,3 +295,5 @@ upstream
|
||||||
priv
|
priv
|
||||||
Syskeeper
|
Syskeeper
|
||||||
msacc
|
msacc
|
||||||
|
now_us
|
||||||
|
ns
|
||||||
|
|
Loading…
Reference in New Issue