From 629024ea2be2102695c4ccd807570544da691f2d Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Thu, 16 Jan 2025 18:14:50 +0100 Subject: [PATCH 1/4] chore: bump dependencies to OTP-27-ready versions --- rebar.config | 6 +++--- src/ekka_cluster_etcd.erl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rebar.config b/rebar.config index 456a523..4a6441b 100644 --- a/rebar.config +++ b/rebar.config @@ -2,8 +2,8 @@ {minimum_otp_vsn, "21.0"}. {deps, [{jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}, - {eetcd, {git, "https://github.com/zhongwencool/eetcd", {tag, "v0.3.4"}}}, - {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe", {tag, "1.0.0"}}}, + {eetcd, {git, "https://github.com/zhongwencool/eetcd", {tag, "v0.5.0"}}}, + {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe", {tag, "1.0.10"}}}, {mria, {git, "https://github.com/emqx/mria", {tag, "0.8.11"}}} ]}. @@ -37,7 +37,7 @@ {profiles, [{test, [{plugins, [{coveralls, {git, "https://github.com/emqx/coveralls-erl", {branch, "github"}}}]}, - {deps, [{meck, "0.8.13"}, + {deps, [{meck, "1.0.0"}, {proper, "1.3.0"} ]}, {erl_opts, [debug_info]}, diff --git a/src/ekka_cluster_etcd.erl b/src/ekka_cluster_etcd.erl index 77360b6..6c00f15 100644 --- a/src/ekka_cluster_etcd.erl +++ b/src/ekka_cluster_etcd.erl @@ -343,9 +343,9 @@ init(Options) -> Servers = proplists:get_value(server, Options, []), Prefix = proplists:get_value(prefix, Options), Hosts = [remove_scheme(Server) || Server <- Servers], - {Transport, TransportOpts} = case ssl_options(Options) of - [] -> {tcp, []}; - [SSL] -> SSL + TransportOpts = case ssl_options(Options) of + [] -> [{transport, tcp}]; + [{ssl, TLSOpts}] -> [{transport, tls}, {tls_opts, TLSOpts}] end, %% At the time of writing, the etcd connection process does not %% close when this process dies. So, when this processes is @@ -354,7 +354,7 @@ init(Options) -> %% that no connection with this name exists before opening it %% (again). eetcd:close(?MODULE), - {ok, _Pid} = eetcd:open(?MODULE, Hosts, Transport, TransportOpts), + {ok, _Pid} = eetcd:open(?MODULE, Hosts, TransportOpts), {ok, #{'ID' := ID}} = eetcd_lease:grant(?MODULE, 5), {ok, Pid2} = eetcd_lease:keep_alive(?MODULE, ID), true = link(Pid2), From 29c4c1efa0e3695fad64f6716561d856407915c0 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 23 Dec 2024 14:58:56 +0100 Subject: [PATCH 2/4] chore: replace `jiffy` with `jsone` For ease of maintenance. Given that the affected codepaths are not performance-critical, and JSON binaries are usually moderately sized, impact should be negligible. --- rebar.config | 4 ++-- src/ekka.app.src | 1 + src/ekka_httpc.erl | 4 ++-- test/mod_etcd.erl | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rebar.config b/rebar.config index 4a6441b..a4dbfc1 100644 --- a/rebar.config +++ b/rebar.config @@ -1,7 +1,7 @@ %% -*- mode:erlang -*- {minimum_otp_vsn, "21.0"}. -{deps, [{jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}, +{deps, [{jsone, "1.9.0"}, {eetcd, {git, "https://github.com/zhongwencool/eetcd", {tag, "v0.5.0"}}}, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe", {tag, "1.0.10"}}}, {mria, {git, "https://github.com/emqx/mria", {tag, "0.8.11"}}} @@ -31,7 +31,7 @@ {dialyzer, [{warnings, [unknown]}, - {plt_extra_apps, [jiffy, mria]} + {plt_extra_apps, [mria]} ]}. {profiles, diff --git a/src/ekka.app.src b/src/ekka.app.src index 7836c87..e5ec25c 100644 --- a/src/ekka.app.src +++ b/src/ekka.app.src @@ -11,6 +11,7 @@ stdlib, inets, eetcd, + jsone, snabbkaffe, mria ]}, diff --git a/src/ekka_httpc.erl b/src/ekka_httpc.erl index 933ade1..477b19a 100644 --- a/src/ekka_httpc.erl +++ b/src/ekka_httpc.erl @@ -99,9 +99,9 @@ parse_response({ok, {{_, Code, _}, _Headers, Body}}) -> parse_response({ok, {Code, Body}}) -> parse_response({ok, Code, Body}); parse_response({ok, 200, Body}) -> - {ok, jiffy:decode(iolist_to_binary(Body), [return_maps])}; + {ok, jsone:decode(iolist_to_binary(Body))}; parse_response({ok, 201, Body}) -> - {ok, jiffy:decode(iolist_to_binary(Body), [return_maps])}; + {ok, jsone:decode(iolist_to_binary(Body))}; parse_response({ok, 204, _Body}) -> {ok, []}; parse_response({ok, Code, Body}) -> diff --git a/test/mod_etcd.erl b/test/mod_etcd.erl index b1ba0bd..959eb59 100644 --- a/test/mod_etcd.erl +++ b/test/mod_etcd.erl @@ -30,7 +30,7 @@ do(_Req = #mod{method = "GET", request_uri = "/v2/keys/" ++ _Uri}) -> Nodes) } }, - Response = {200, binary_to_list(jiffy:encode(Body))}, + Response = {200, binary_to_list(jsone:encode(Body))}, {proceed, [{response, Response}]}; do(_Req = #mod{request_uri = "/v2/keys/" ++ _Uri}) -> {proceed, [{response, {200, "{\"errorCode\": 0}"}}]}; From cea1c5fe727dd7aa481fe29534cea89a7b227029 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 23 Dec 2024 15:06:06 +0100 Subject: [PATCH 3/4] ci: enable Erlang/OTP 27 builds --- .github/workflows/run_test_case.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_test_case.yaml b/.github/workflows/run_test_case.yaml index 485e1e2..f277900 100644 --- a/.github/workflows/run_test_case.yaml +++ b/.github/workflows/run_test_case.yaml @@ -11,9 +11,14 @@ on: jobs: run_test_case: runs-on: ubuntu-latest - + strategy: + matrix: + builder: + - "ghcr.io/emqx/emqx-builder/5.3-5:1.15.7-26.2.1-2-ubuntu24.04" + - "ghcr.io/emqx/emqx-builder/5.4-3:1.17.3-27.2-1-ubuntu24.04" + container: - image: ghcr.io/emqx/emqx-builder/5.3-5:1.15.7-26.2.1-2-ubuntu24.04 + image: ${{ matrix.builder }} steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 From c073ad9cacac10b1b1e185d4369f5c45a5087fe7 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 23 Dec 2024 15:50:32 +0100 Subject: [PATCH 4/4] ci: avoid name clashes in matrix jobs --- .github/workflows/run_test_case.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run_test_case.yaml b/.github/workflows/run_test_case.yaml index f277900..a676000 100644 --- a/.github/workflows/run_test_case.yaml +++ b/.github/workflows/run_test_case.yaml @@ -13,12 +13,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - builder: - - "ghcr.io/emqx/emqx-builder/5.3-5:1.15.7-26.2.1-2-ubuntu24.04" - - "ghcr.io/emqx/emqx-builder/5.4-3:1.17.3-27.2-1-ubuntu24.04" + otp: + - vsn: "26.2.1-2" + builder: "5.3-5:1.15.7-26.2.1-2-ubuntu24.04" + - vsn: "27.2-1" + builder: "5.4-3:1.17.3-27.2-1-ubuntu24.04" container: - image: ${{ matrix.builder }} + image: "ghcr.io/emqx/emqx-builder/${{ matrix.otp.builder }}" steps: - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 @@ -33,6 +35,7 @@ jobs: make eunit make ct make cover + - name: Coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -41,9 +44,9 @@ jobs: - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 if: always() with: - name: logs + name: "logs-${{ matrix.otp.vsn }}" path: _build/test/logs - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: cover + name: "cover-${{ matrix.otp.vsn }}" path: _build/test/cover