test(emqx_gateway): fix test failures caused by grpc-erl upgrade

This commit is contained in:
Serge Tupchii 2023-12-01 17:55:33 +02:00
parent ac618d331f
commit e455433694
4 changed files with 19 additions and 16 deletions

View File

@ -274,16 +274,17 @@ t_write_failure(Config) ->
health_check_resource_down(Config),
case QueryMode of
sync ->
case EnableBatch of
true ->
%% append to batch always returns ok
?assertMatch(ok, send_message(Config, Data));
false ->
?assertMatch(
{error, {cannot_list_shards, {<<?STREAM>>, econnrefused}}},
send_message(Config, Data)
)
end;
%% Error (call timeout) is expected for both with_batch and without_batch.
%% `health_check_resource_down(Config)` above calls health check and asserts
%% that resource is already down.
%% So, emqx_resource_manager updates it state to disconnected before returning health_check result.
%% After that, emqx_resource_buffer_worker reads resource state and doesn't even attempt calling
%% hstreamdb connector, since it is disconnected, see: emqx_resource_buffer_worker.erl:1163:
%% ```
%% do_call_query(_QM, _Id, _Index, _Ref, _Query, _QueryOpts, _Data) ->
%% ?RESOURCE_ERROR(not_connected, "resource not connected").
%% ```
?assertMatch({error, _}, send_message(Config, Data));
async ->
%% TODO: async mode is not supported yet,
%% but it will return ok if calling emqx_resource_buffer_worker:async_query/3,

View File

@ -50,11 +50,11 @@ init_per_suite(Conf) ->
emqx_config:delete_override_conf_files(),
emqx_config:erase(gateway),
emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_auth, emqx_auth_mnesia, emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([grpc, emqx_conf, emqx_auth, emqx_auth_mnesia, emqx_gateway]),
Conf.
end_per_suite(Conf) ->
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_auth_mnesia, emqx_auth, emqx_conf]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_auth_mnesia, emqx_auth, emqx_conf, grpc]),
Conf.
init_per_testcase(t_gateway_fail, Config) ->

View File

@ -69,7 +69,7 @@ init_per_suite(Config) ->
emqx_gateway_test_utils:load_all_gateway_apps(),
emqx_config:erase(gateway),
init_gateway_conf(),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([grpc, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway]),
application:ensure_all_started(cowboy),
emqx_gateway_auth_ct:start(),
timer:sleep(500),
@ -78,7 +78,9 @@ init_per_suite(Config) ->
end_per_suite(Config) ->
emqx_gateway_auth_ct:stop(),
emqx_config:erase(gateway),
emqx_mgmt_api_test_util:end_suite([cowboy, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway]),
emqx_mgmt_api_test_util:end_suite([
cowboy, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway, grpc
]),
Config.
init_per_testcase(_Case, Config) ->

View File

@ -69,7 +69,7 @@ init_per_suite(Config) ->
emqx_gateway_test_utils:load_all_gateway_apps(),
init_gateway_conf(),
emqx_mgmt_api_test_util:init_suite([
emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway
grpc, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway
]),
meck:new(emqx_authz_file, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_authz_file, create, fun(S) -> S end),
@ -83,7 +83,7 @@ end_per_suite(Config) ->
ok = emqx_authz_test_lib:restore_authorizers(),
emqx_config:erase(gateway),
emqx_mgmt_api_test_util:end_suite([
emqx_gateway, emqx_auth_http, emqx_auth, emqx_conf
emqx_gateway, emqx_auth_http, emqx_auth, emqx_conf, grpc
]),
Config.