From fa80c7e436b97b0d6403dfacb36567cde30791bb Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Fri, 15 Dec 2023 14:07:54 +0100 Subject: [PATCH 1/2] chore: upgrade gun and ehttpc - gun from 1.3.9 to 1.3.10 for otp 26 type spec fix - ehttpc from 0.4.11 to 0.4.12 for error handling improvements --- mix.exs | 4 ++-- rebar.config | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index 0e387884b..2b77efcee 100644 --- a/mix.exs +++ b/mix.exs @@ -49,7 +49,7 @@ defmodule EMQXUmbrella.MixProject do {:redbug, github: "emqx/redbug", tag: "2.0.10"}, {:covertool, github: "zmstone/covertool", tag: "2.0.4.1", override: true}, {:typerefl, github: "ieQu1/typerefl", tag: "0.9.1", override: true}, - {:ehttpc, github: "emqx/ehttpc", tag: "0.4.11", override: true}, + {:ehttpc, github: "emqx/ehttpc", tag: "0.4.12", override: true}, {:gproc, github: "emqx/gproc", tag: "0.9.0.1", override: true}, {:jiffy, github: "emqx/jiffy", tag: "1.0.6", override: true}, {:cowboy, github: "emqx/cowboy", tag: "2.9.2", override: true}, @@ -77,7 +77,7 @@ defmodule EMQXUmbrella.MixProject do {:esasl, github: "emqx/esasl", tag: "0.2.0"}, {:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"}, # in conflict by ehttpc and emqtt - {:gun, github: "emqx/gun", tag: "1.3.9", override: true}, + {:gun, github: "emqx/gun", tag: "1.3.10", override: true}, # in conflict by emqx_connector and system_monitor {:epgsql, github: "emqx/epgsql", tag: "4.7.1.1", override: true}, # in conflict by emqx and observer_cli diff --git a/rebar.config b/rebar.config index 6e5cad59f..915e47bf7 100644 --- a/rebar.config +++ b/rebar.config @@ -64,8 +64,8 @@ , {covertool, {git, "https://github.com/zmstone/covertool", {tag, "2.0.4.1"}}} , {gpb, "4.19.9"} , {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}} - , {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}} - , {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.11"}}} + , {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.10"}}} + , {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.12"}}} , {gproc, {git, "https://github.com/emqx/gproc", {tag, "0.9.0.1"}}} , {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.6"}}} , {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.2"}}} From f4286f32086b60f5a9e5f36d73d89ee97ba9484e Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Wed, 20 Dec 2023 16:29:45 +0100 Subject: [PATCH 2/2] test(gcp_pubsub): increase wait timeout and fix falt injection --- .../src/emqx_bridge_gcp_pubsub_client.erl | 3 ++- .../emqx_bridge_gcp_pubsub_producer_SUITE.erl | 22 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_client.erl b/apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_client.erl index 5975ba89b..7091bbf8f 100644 --- a/apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_client.erl +++ b/apps/emqx_bridge_gcp_pubsub/src/emqx_bridge_gcp_pubsub_client.erl @@ -428,7 +428,8 @@ do_get_status(ResourceId, Timeout) -> msg => "ehttpc_health_check_failed", connector => ResourceId, reason => Reason, - worker => Worker + worker => Worker, + wait_time => Timeout }), false end diff --git a/apps/emqx_bridge_gcp_pubsub/test/emqx_bridge_gcp_pubsub_producer_SUITE.erl b/apps/emqx_bridge_gcp_pubsub/test/emqx_bridge_gcp_pubsub_producer_SUITE.erl index f65b80f90..f29fbb9e7 100644 --- a/apps/emqx_bridge_gcp_pubsub/test/emqx_bridge_gcp_pubsub_producer_SUITE.erl +++ b/apps/emqx_bridge_gcp_pubsub/test/emqx_bridge_gcp_pubsub_producer_SUITE.erl @@ -310,7 +310,7 @@ gcp_pubsub_config(Config) -> io_lib:format( "bridges.gcp_pubsub.~s {\n" " enable = true\n" - " connect_timeout = 1s\n" + " connect_timeout = 5s\n" " service_account_json = ~s\n" " payload_template = ~p\n" " pubsub_topic = ~s\n" @@ -1404,8 +1404,23 @@ t_failure_no_body(Config) -> ), ok. +kill_gun_process(EhttpcPid) -> + State = ehttpc:get_state(EhttpcPid, minimal), + GunPid = maps:get(client, State), + true = is_pid(GunPid), + _ = exit(GunPid, kill), + ok. + +kill_gun_processes(ConnectorResourceId) -> + Pool = ehttpc:workers(ConnectorResourceId), + Workers = lists:map(fun({_, Pid}) -> Pid end, Pool), + %% assert there is at least one pool member + ?assertMatch([_ | _], Workers), + lists:foreach(fun(Pid) -> kill_gun_process(Pid) end, Workers). + t_unrecoverable_error(Config) -> ActionResourceId = ?config(action_resource_id, Config), + ConnectorResourceId = ?config(connector_resource_id, Config), TelemetryTable = ?config(telemetry_table, Config), TestPid = self(), FailureNoBodyHandler = @@ -1415,10 +1430,7 @@ t_unrecoverable_error(Config) -> %% kill the gun process while it's waiting for the %% response so we provoke an `{error, _}' response from %% ehttpc. - lists:foreach( - fun(Pid) -> exit(Pid, kill) end, - [Pid || {_, Pid, _, _} <- supervisor:which_children(gun_sup)] - ), + ok = kill_gun_processes(ConnectorResourceId), Rep = cowboy_req:reply( 200, #{<<"content-type">> => <<"application/json">>},