From 14496e93fcf0d7f179f3f543a0771837a2dec69c Mon Sep 17 00:00:00 2001 From: Karl Nilsson Date: Wed, 14 Aug 2024 11:06:07 +0100 Subject: [PATCH] Test on 27 And make OTP 27 compatible --- .github/workflows/erlang.yml | 12 +++++------- src/ra_server_proc.erl | 38 ++++++++++++++++++------------------ test/ra_SUITE.erl | 5 +++-- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 61102471..cfbc5343 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -6,24 +6,24 @@ on: pull_request: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - otp: - - "26" + otp_version: [25, 26, 27] steps: - name: CHECKOUT uses: actions/checkout@v2 - name: CONFIGURE ERLANG uses: erlef/setup-beam@v1 with: - otp-version: ${{ matrix.otp }} + otp-version: ${{ matrix.otp_version }} - name: XREF run: make xref - name: DEPS run: make test-deps - name: DIALYZE + if: ${{ matrix.otp_version == 27}} run: make dialyze - name: BUILD run: make test-build @@ -37,7 +37,7 @@ jobs: uses: actions/upload-artifact@v2-preview if: failure() with: - name: ct-logs-${{matrix.otp}} + name: ct-logs-${{matrix.otp_version}} path: logs/* build-bazel: runs-on: ubuntu-20.04 @@ -45,8 +45,6 @@ jobs: fail-fast: false matrix: otp_major: - - "24" - - "25" - "26" steps: - name: CHECKOUT diff --git a/src/ra_server_proc.erl b/src/ra_server_proc.erl index 94b605bf..2def7daf 100644 --- a/src/ra_server_proc.erl +++ b/src/ra_server_proc.erl @@ -33,7 +33,7 @@ %% gen_statem callbacks -export([ init/1, - format_status/2, + format_status/1, handle_event/4, terminate/3, code_change/4, @@ -1075,26 +1075,26 @@ terminate(Reason, StateName, State) -> code_change(_OldVsn, StateName, State, _Extra) -> {ok, StateName, State}. -format_status(Opt, [_PDict, StateName, - #state{server_state = NS, - leader_last_seen = LastSeen, - pending_commands = Pending, - low_priority_commands = Delayed, - pending_notifys = PendingNots, - election_timeout_set = ElectionSet - }]) -> +format_status(#{state := StateName, + data := #state{server_state = NS, + leader_last_seen = LastSeen, + pending_commands = Pending, + low_priority_commands = Delayed, + pending_notifys = PendingNots, + election_timeout_set = ElectionSet + }} = FormatStatus) -> NumPendingNots = maps:fold(fun (_, Corrs, Acc) -> Acc + length(Corrs) end, 0, PendingNots), - [{id, ra_server:id(NS)}, - {opt, Opt}, - {raft_state, StateName}, - {leader_last_seen, LastSeen}, - {num_pending_commands, length(Pending)}, - {num_low_priority_commands, ra_ets_queue:len(Delayed)}, - {num_pending_applied_notifications, NumPendingNots}, - {election_timeout_set, ElectionSet}, - {ra_server_state, ra_server:overview(NS)} - ]. + + FormatStatus#{data => [{id, ra_server:id(NS)}, + {raft_state, StateName}, + {leader_last_seen, LastSeen}, + {num_pending_commands, length(Pending)}, + {num_low_priority_commands, ra_ets_queue:len(Delayed)}, + {num_pending_applied_notifications, NumPendingNots}, + {election_timeout_set, ElectionSet}, + {ra_server_state, ra_server:overview(NS)} + ]}. %%%=================================================================== %%% Internal functions diff --git a/test/ra_SUITE.erl b/test/ra_SUITE.erl index 59f606a4..457cc91f 100644 --- a/test/ra_SUITE.erl +++ b/test/ra_SUITE.erl @@ -1355,8 +1355,9 @@ unknown_local_call(Config) -> end. get_gen_statem_status(Ref) -> - {_, _, _, Items} = sys:get_status(Ref), - proplists:get_value(raft_state, lists:last(Items)). + {_, _, _, Misc} = sys:get_status(Ref), + [{_, State}] = [S || {data, [{"State", S}]} <- lists:last(Misc)], + proplists:get_value(raft_state, State). wait_for_gen_statem_status(Ref, ExpectedStatus, Timeout) when Timeout >= 0 ->