test(elastic_search): fix flaky test
This commit is contained in:
parent
a840925a50
commit
24cb45a643
|
@ -1,5 +1,7 @@
|
||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
|
# hint: run the following if the container fails to start locally
|
||||||
|
# sysctl -w vm.max_map_count=262144
|
||||||
services:
|
services:
|
||||||
setup:
|
setup:
|
||||||
image: public.ecr.aws/elastic/elasticsearch:${ELASTIC_TAG}
|
image: public.ecr.aws/elastic/elasticsearch:${ELASTIC_TAG}
|
||||||
|
@ -54,7 +56,7 @@ services:
|
||||||
- xpack.security.http.ssl.certificate=certs/es01/es01.crt
|
- xpack.security.http.ssl.certificate=certs/es01/es01.crt
|
||||||
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
|
- xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt
|
||||||
- xpack.license.self_generated.type=${LICENSE}
|
- xpack.license.self_generated.type=${LICENSE}
|
||||||
mem_limit: 1073741824
|
mem_limit: 4G
|
||||||
ulimits:
|
ulimits:
|
||||||
memlock:
|
memlock:
|
||||||
soft: -1
|
soft: -1
|
||||||
|
|
|
@ -36,6 +36,7 @@ all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_common_test_helpers:clear_screen(),
|
||||||
ProxyName = "elasticsearch",
|
ProxyName = "elasticsearch",
|
||||||
ESHost = os:getenv("ELASTICSEARCH_HOST", "elasticsearch"),
|
ESHost = os:getenv("ELASTICSEARCH_HOST", "elasticsearch"),
|
||||||
ESPort = list_to_integer(os:getenv("ELASTICSEARCH_PORT", "9200")),
|
ESPort = list_to_integer(os:getenv("ELASTICSEARCH_PORT", "9200")),
|
||||||
|
@ -82,9 +83,6 @@ wait_until_elasticsearch_is_up(Count, Host, Port) ->
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
Apps = ?config(apps, Config),
|
Apps = ?config(apps, Config),
|
||||||
%ProxyHost = ?config(proxy_host, Config),
|
|
||||||
%ProxyPort = ?config(proxy_port, Config),
|
|
||||||
%emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
|
||||||
emqx_cth_suite:stop(Apps),
|
emqx_cth_suite:stop(Apps),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -92,9 +90,6 @@ init_per_testcase(_TestCase, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_testcase(_TestCase, _Config) ->
|
end_per_testcase(_TestCase, _Config) ->
|
||||||
%ProxyHost = ?config(proxy_host, Config),
|
|
||||||
%ProxyPort = ?config(proxy_port, Config),
|
|
||||||
%emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
|
||||||
emqx_bridge_v2_testlib:delete_all_bridges_and_connectors(),
|
emqx_bridge_v2_testlib:delete_all_bridges_and_connectors(),
|
||||||
emqx_common_test_helpers:call_janitor(60_000),
|
emqx_common_test_helpers:call_janitor(60_000),
|
||||||
ok.
|
ok.
|
||||||
|
@ -125,18 +120,20 @@ send_message(Topic) ->
|
||||||
|
|
||||||
check_action_metrics(ActionName, ConnectorName, Expect) ->
|
check_action_metrics(ActionName, ConnectorName, Expect) ->
|
||||||
ActionId = emqx_bridge_v2:id(?TYPE, ActionName, ConnectorName),
|
ActionId = emqx_bridge_v2:id(?TYPE, ActionName, ConnectorName),
|
||||||
Metrics =
|
?retry(
|
||||||
#{
|
300,
|
||||||
match => emqx_resource_metrics:matched_get(ActionId),
|
20,
|
||||||
success => emqx_resource_metrics:success_get(ActionId),
|
?assertEqual(
|
||||||
failed => emqx_resource_metrics:failed_get(ActionId),
|
Expect,
|
||||||
queuing => emqx_resource_metrics:queuing_get(ActionId),
|
#{
|
||||||
dropped => emqx_resource_metrics:dropped_get(ActionId)
|
match => emqx_resource_metrics:matched_get(ActionId),
|
||||||
},
|
success => emqx_resource_metrics:success_get(ActionId),
|
||||||
?assertEqual(
|
failed => emqx_resource_metrics:failed_get(ActionId),
|
||||||
Expect,
|
queuing => emqx_resource_metrics:queuing_get(ActionId),
|
||||||
Metrics,
|
dropped => emqx_resource_metrics:dropped_get(ActionId)
|
||||||
{ActionName, ConnectorName, ActionId}
|
},
|
||||||
|
{ActionName, ConnectorName, ActionId}
|
||||||
|
)
|
||||||
).
|
).
|
||||||
|
|
||||||
action_config(ConnectorName) ->
|
action_config(ConnectorName) ->
|
||||||
|
@ -159,7 +156,8 @@ action(ConnectorName) ->
|
||||||
<<"connector">> => ConnectorName,
|
<<"connector">> => ConnectorName,
|
||||||
<<"resource_opts">> => #{
|
<<"resource_opts">> => #{
|
||||||
<<"health_check_interval">> => <<"30s">>,
|
<<"health_check_interval">> => <<"30s">>,
|
||||||
<<"query_mode">> => <<"sync">>
|
<<"query_mode">> => <<"sync">>,
|
||||||
|
<<"metrics_flush_interval">> => <<"300ms">>
|
||||||
}
|
}
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue