From 3dbb9f1e29ce49a29a39ea8c8c101cabfc9cba40 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 30 Jul 2024 15:32:58 +0200 Subject: [PATCH 1/3] Test on Erlang 27 Update worker_pool --- .github/workflows/ci.yml | 4 ++-- rebar.config | 6 +++++- rebar.lock | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17965e0..6d06f34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: name: OTP ${{matrix.otp_vsn}} strategy: matrix: - otp_vsn: ['26.2', '25.3', '24.3'] + otp_vsn: ['27.0.1', '26.2', '25.3', '24.3'] rebar_vsn: ['3.22.0'] runs-on: 'ubuntu-22.04' env: @@ -29,4 +29,4 @@ jobs: - run: make test - run: make ct - run: make dialyzer - if: ${{ matrix.otp == '26.2' }} + if: ${{ matrix.otp == '27.0.1' }} diff --git a/rebar.config b/rebar.config index c113214..2d3f11a 100644 --- a/rebar.config +++ b/rebar.config @@ -12,7 +12,7 @@ {bbmustache, "1.12.2"}, {uuid, "2.0.7", {pkg, uuid_erl}}, {gun, "2.0.1"}, - {worker_pool, "6.2.0"}, + {worker_pool, "6.2.1"}, {fast_tls, "1.1.21"}, {fast_scram, "0.6.0"} ]}. @@ -21,6 +21,10 @@ {project_plugins, [rebar3_hex, {rebar3_codecov, "0.6.0"}]}. +{overrides, [ + {override, worker_pool, [{minimum_otp_vsn, "24"}]} +]}. + {relx, [{release, {escalus, "0.0.1"}, [escalus]}, {dev_mode, true}, diff --git a/rebar.lock b/rebar.lock index 385e2db..efb643d 100644 --- a/rebar.lock +++ b/rebar.lock @@ -11,7 +11,7 @@ {<<"p1_utils">>,{pkg,<<"p1_utils">>,<<"1.0.26">>},1}, {<<"quickrand">>,{pkg,<<"quickrand">>,<<"2.0.7">>},1}, {<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.7">>},0}, - {<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.2.0">>},0}]}. + {<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.2.1">>},0}]}. [ {pkg_hash,[ {<<"base16">>, <<"F0549F732E03BE8124ED0D19FD5EE52146CC8BE24C48CBC3F23AB44B157F11A2">>}, @@ -26,7 +26,7 @@ {<<"p1_utils">>, <<"67B0C4AC9FA3BA3EF563B31AA111B0A004439A37FAC85E027F1C3617E1C7EC6C">>}, {<<"quickrand">>, <<"D2BD76676A446E6A058D678444B7FDA1387B813710D1AF6D6E29BB92186C8820">>}, {<<"uuid">>, <<"B2078D2CC814F53AFA52D36C91E08962C7E7373585C623F4C0EA6DFB04B2AF94">>}, - {<<"worker_pool">>, <<"506DE38C528A81ED2C6A80A419B83DDE6DA5E295BD320BDF4D35A69AFEB0247A">>}]}, + {<<"worker_pool">>, <<"BD98A0BE1D20057AE9967CBE73D263AEA5BE14BBE4C73CAFEB1378572FF14561">>}]}, {pkg_hash_ext,[ {<<"base16">>, <<"06EA2D48343282E712160BA89F692B471DB8B36ABE8394F3445FF9032251D772">>}, {<<"bbmustache">>, <<"688B33A4D5CC2D51F575ADF0B3683FC40A38314A2F150906EDCFC77F5B577B3B">>}, @@ -40,5 +40,5 @@ {<<"p1_utils">>, <<"D0379E8C1156B98BD64F8129C1DE022FCCA4F2FDB7486CE73BF0ED2C3376B04C">>}, {<<"quickrand">>, <<"B8ACBF89A224BC217C3070CA8BEBC6EB236DBE7F9767993B274084EA044D35F0">>}, {<<"uuid">>, <<"4E4C5CA3461DC47C5E157ED42AA3981A053B7A186792AF972A27B14A9489324E">>}, - {<<"worker_pool">>, <<"E1DED160797FBE656AD683109DBD741B520097DF17BDF7B51E3E4697073A6E62">>}]} + {<<"worker_pool">>, <<"64E560DE08CA5E7DB8BD4CDCC7B744B0659696194E3BC9E56239BA4A0F7E24F9">>}]} ]. From 67f424a4bbba23fbeee7074c7ef0f1dbfe7971a8 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 30 Jul 2024 15:58:11 +0200 Subject: [PATCH 2/3] Wait for process to stop in escalus_fresh:stop/0 --- src/escalus_fresh.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/escalus_fresh.erl b/src/escalus_fresh.erl index 1943163..83ca0f4 100644 --- a/src/escalus_fresh.erl +++ b/src/escalus_fresh.erl @@ -121,7 +121,20 @@ start(_Config) -> application:ensure_all_started(worker_pool), ensure_table_present(nasty_global_table()). stop(_) -> - nasty_global_table() ! bye. + case whereis(nasty_global_table()) of + undefined -> + ok; + Pid -> + Mon = erlang:monitor(process, Pid), + Pid ! bye, + receive + {'DOWN', Mon, process, Pid, _Reason} -> + ok + after 5000 -> + error(stop_fresh_timeout) + end + end. + -spec clean() -> no_return() | ok. clean() -> wpool:start_sup_pool(unregister_pool, [{workers, ?UNREGISTER_WORKERS}, From 755e39e9ebbf96403e0eb8d9eca3435a34fc1f23 Mon Sep 17 00:00:00 2001 From: Mikhail Uvarov Date: Tue, 30 Jul 2024 16:04:20 +0200 Subject: [PATCH 3/3] Fix race condition in ensure_table_present --- src/escalus_fresh.erl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/escalus_fresh.erl b/src/escalus_fresh.erl index 83ca0f4..7a89423 100644 --- a/src/escalus_fresh.erl +++ b/src/escalus_fresh.erl @@ -192,12 +192,23 @@ do_delete_users(Conf) -> ensure_table_present(T) -> + Parent = self(), + StartRef = make_ref(), RunDB = fun() -> ets:new(T, [named_table, public]), + Parent ! {started, StartRef}, receive bye -> ok end end, case ets:info(T) of undefined -> - P = spawn(RunDB), - erlang:register(T, P); + {Pid, Mon} = spawn_monitor(RunDB), + receive + {started, StartRef} -> + erlang:register(T, Pid), + erlang:demonitor(Mon); + {'DOWN', Mon, process, Pid, _Reason} -> + ok + after 5000 -> + error(failed_to_start_fresh_table) + end; _nasty_table_is_there_well_run_with_it -> ok end.