Merge pull request #9789 from sstrigler/EMQX-8754-test-function-return-500-of-data-integration-google-pubsub

EMQX 8754 test function return 500 of data integration google pubsub
This commit is contained in:
Stefan Strigler 2023-01-17 22:49:28 +01:00 committed by GitHub
commit f899284e3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 15 deletions

View File

@ -251,7 +251,9 @@ maybe_clear_certs(TmpPath, #{ssl := SslConf} = Conf) ->
case is_tmp_path_conf(TmpPath, SslConf) of case is_tmp_path_conf(TmpPath, SslConf) of
true -> emqx_connector_ssl:clear_certs(TmpPath, Conf); true -> emqx_connector_ssl:clear_certs(TmpPath, Conf);
false -> ok false -> ok
end. end;
maybe_clear_certs(_TmpPath, _ConfWithoutSsl) ->
ok.
is_tmp_path_conf(TmpPath, #{certfile := Certfile}) -> is_tmp_path_conf(TmpPath, #{certfile := Certfile}) ->
is_tmp_path(TmpPath, Certfile); is_tmp_path(TmpPath, Certfile);

View File

@ -86,6 +86,7 @@ init_per_testcase(_, Config) ->
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000), {ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
{Port, Sock, Acceptor} = start_http_server(fun handle_fun_200_ok/2), {Port, Sock, Acceptor} = start_http_server(fun handle_fun_200_ok/2),
[{port, Port}, {sock, Sock}, {acceptor, Acceptor} | Config]. [{port, Port}, {sock, Sock}, {acceptor, Acceptor} | Config].
end_per_testcase(_, Config) -> end_per_testcase(_, Config) ->
Sock = ?config(sock, Config), Sock = ?config(sock, Config),
Acceptor = ?config(acceptor, Config), Acceptor = ?config(acceptor, Config),

View File

@ -171,7 +171,7 @@ create_dry_run(ResourceType, Config) ->
ok = emqx_resource_manager_sup:ensure_child( ok = emqx_resource_manager_sup:ensure_child(
MgrId, ResId, <<"dry_run">>, ResourceType, Config, #{} MgrId, ResId, <<"dry_run">>, ResourceType, Config, #{}
), ),
case wait_for_ready(ResId, 15000) of case wait_for_ready(ResId, 5000) of
ok -> ok ->
remove(ResId); remove(ResId);
{error, Reason} -> {error, Reason} ->

View File

@ -149,31 +149,31 @@ values(get) ->
maps:merge(values(post), ?METRICS_EXAMPLE); maps:merge(values(post), ?METRICS_EXAMPLE);
values(post) -> values(post) ->
#{ #{
<<"pubsub_topic">> => <<"mytopic">>, pubsub_topic => <<"mytopic">>,
<<"service_account_json">> => service_account_json =>
#{ #{
<<"auth_provider_x509_cert_url">> => auth_provider_x509_cert_url =>
<<"https://www.googleapis.com/oauth2/v1/certs">>, <<"https://www.googleapis.com/oauth2/v1/certs">>,
<<"auth_uri">> => auth_uri =>
<<"https://accounts.google.com/o/oauth2/auth">>, <<"https://accounts.google.com/o/oauth2/auth">>,
<<"client_email">> => client_email =>
<<"test@myproject.iam.gserviceaccount.com">>, <<"test@myproject.iam.gserviceaccount.com">>,
<<"client_id">> => <<"123812831923812319190">>, client_id => <<"123812831923812319190">>,
<<"client_x509_cert_url">> => client_x509_cert_url =>
<< <<
"https://www.googleapis.com/robot/v1/" "https://www.googleapis.com/robot/v1/"
"metadata/x509/test%40myproject.iam.gserviceaccount.com" "metadata/x509/test%40myproject.iam.gserviceaccount.com"
>>, >>,
<<"private_key">> => private_key =>
<< <<
"-----BEGIN PRIVATE KEY-----\n" "-----BEGIN PRIVATE KEY-----\n"
"MIIEvQI..." "MIIEvQI..."
>>, >>,
<<"private_key_id">> => <<"kid">>, private_key_id => <<"kid">>,
<<"project_id">> => <<"myproject">>, project_id => <<"myproject">>,
<<"token_uri">> => token_uri =>
<<"https://oauth2.googleapis.com/token">>, <<"https://oauth2.googleapis.com/token">>,
<<"type">> => <<"service_account">> type => <<"service_account">>
} }
}; };
values(put) -> values(put) ->

View File

@ -196,13 +196,17 @@ create_bridge_http(Config, GCPPubSubConfigOverrides) ->
Params = GCPPubSubConfig#{<<"type">> => TypeBin, <<"name">> => Name}, Params = GCPPubSubConfig#{<<"type">> => TypeBin, <<"name">> => Name},
Path = emqx_mgmt_api_test_util:api_path(["bridges"]), Path = emqx_mgmt_api_test_util:api_path(["bridges"]),
AuthHeader = emqx_mgmt_api_test_util:auth_header_(), AuthHeader = emqx_mgmt_api_test_util:auth_header_(),
ProbePath = emqx_mgmt_api_test_util:api_path(["bridges_probe"]),
ProbeResult = emqx_mgmt_api_test_util:request_api(post, ProbePath, "", AuthHeader, Params),
ct:pal("creating bridge (via http): ~p", [Params]), ct:pal("creating bridge (via http): ~p", [Params]),
ct:pal("probe result: ~p", [ProbeResult]),
Res = Res =
case emqx_mgmt_api_test_util:request_api(post, Path, "", AuthHeader, Params) of case emqx_mgmt_api_test_util:request_api(post, Path, "", AuthHeader, Params) of
{ok, Res0} -> {ok, emqx_json:decode(Res0, [return_maps])}; {ok, Res0} -> {ok, emqx_json:decode(Res0, [return_maps])};
Error -> Error Error -> Error
end, end,
ct:pal("bridge creation result: ~p", [Res]), ct:pal("bridge creation result: ~p", [Res]),
?assertEqual(element(1, ProbeResult), element(1, Res)),
Res. Res.
create_rule_and_action_http(Config) -> create_rule_and_action_http(Config) ->
@ -672,7 +676,7 @@ t_create_via_http(Config) ->
create_bridge_http(Config), create_bridge_http(Config),
fun(Res, Trace) -> fun(Res, Trace) ->
?assertMatch({ok, _}, Res), ?assertMatch({ok, _}, Res),
?assertMatch([_], ?of_kind(gcp_pubsub_bridge_jwt_created, Trace)), ?assertMatch([_, _], ?of_kind(gcp_pubsub_bridge_jwt_created, Trace)),
ok ok
end end
), ),