Преглед изворни кода

Merge pull request #12183 from zmstone/1215-chore-upgrade-ehttpc

chore: upgrade gun and ehttpc
Zaiming (Stone) Shi пре 2 година
родитељ
комит
a53d293bde

+ 2 - 1
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

+ 17 - 5
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">>},

+ 2 - 2
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

+ 2 - 2
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"}}}