From d8e496b88754d8cc12810826a2436273cbdb21c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cruz?= Date: Fri, 20 Nov 2026 18:17:16 -0600 Subject: [PATCH 1/5] [CP-952] Run the test suite on GitHub Actions; fix three stale or racy tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Travis has errored at setup on every build since at least 2025-08 (it can no longer download OTP 21.0.1), so no test has run in CI. The new workflow runs rebar3 eunit on OTP 22.3 (xmpp's version) against a Redis 7 service, on pull requests and pushes to xmpp_only. It is not a required check, and .travis.yml is left as is. Test fixes, all test-only: - connection_failure_during_start_reconnect_test: start_link/5 connects synchronously since 49c714f; use start_link/9 with SyncStart=false. Its failure left trap_exit on and broke 5 eredis_sub_tests. - crash_queue_test: expect {exited, N} before 'DOWN' (sent since 9427287). Its leftover messages broke the next 2 tests. - tcp_closed_rig: a query that reaches the client after the close gets no_connection; accept it (failed 1 in 10 runs locally). Locally (erlang:22 + redis:7): 63 tests, 0 failures, 40 of 40 runs. 🤖 Generated with Claude Code Co-Authored-By: Claude --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ test/eredis_sub_tests.erl | 4 +++- test/eredis_tests.erl | 12 +++++++++--- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..4360deab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + pull_request: + push: + branches: [xmpp_only] + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + eunit: + # x86_64: xmpp, the consumer of this fork, deploys on x86_64. + runs-on: ubuntu-26.04 + timeout-minutes: 15 + services: + redis: + image: redis:7@sha256:2e3eb11462c4e3759e6972678dd051d150ff54b1e60714b3c33b701260172a90 + ports: + - 6379:6379 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # OTP 22.3 matches xmpp's build image. Host network because the tests + # connect to Redis on 127.0.0.1:6379. + - name: rebar3 eunit (OTP 22) + run: >- + docker run --rm --network host -v "$PWD:/w" -w /w + erlang:22@sha256:fe2c572ef1aaed67214c5529b57311f0806f58696fcb2f2a1c9bf33bdc75fe43 + rebar3 eunit diff --git a/test/eredis_sub_tests.erl b/test/eredis_sub_tests.erl index f1544170..2651adca 100644 --- a/test/eredis_sub_tests.erl +++ b/test/eredis_sub_tests.erl @@ -134,7 +134,9 @@ crash_queue_test() -> [eredis:q(Pub, [publish, foo, N]) || N <- lists:seq(1, 12)], receive M1 -> ?assertEqual({message,<<"foo">>,<<"1">>, Sub}, M1) end, - receive M2 -> ?assertEqual({'DOWN', Ref, process, Sub, max_queue_size}, M2) end. + %% The fork tells the controller before it exits (9427287). + receive M2 -> ?assertMatch({exited, _}, M2) end, + receive M3 -> ?assertEqual({'DOWN', Ref, process, Sub, max_queue_size}, M3) end. diff --git a/test/eredis_tests.erl b/test/eredis_tests.erl index 1e3244bf..3dcfd89e 100644 --- a/test/eredis_tests.erl +++ b/test/eredis_tests.erl @@ -167,7 +167,9 @@ connection_failure_during_start_no_reconnect_test() -> connection_failure_during_start_reconnect_test() -> process_flag(trap_exit, true), - Res = eredis:start_link("localhost", 6378, 0, "", 100), + %% start_link/5 connects synchronously in this fork (49c714f), so ask for + %% the async start this test covers. + Res = eredis:start_link("localhost", 6378, 0, "", 100, 5000, false, [], false), ?assertMatch({ok, _}, Res), {ok, ClientPid} = Res, IsDead = receive {'EXIT', ClientPid, _} -> died @@ -199,8 +201,12 @@ tcp_closed_rig(C) -> {3, tcp_closed}], Pids = [ remote_query(DoSend, M) || M <- Msgs ], Results = gather_remote_queries(Pids), - ?assertEqual({error, tcp_closed}, proplists:get_value(1, Results)), - ?assertEqual({error, tcp_closed}, proplists:get_value(2, Results)). + %% A query that reaches the client after the close gets no_connection + %% instead of tcp_closed; either way it errors instead of hanging. + ?assertMatch({error, E} when E =:= tcp_closed; E =:= no_connection, + proplists:get_value(1, Results)), + ?assertMatch({error, E} when E =:= tcp_closed; E =:= no_connection, + proplists:get_value(2, Results)). remote_query(Fun, {Id, Cmd}) -> Parent = self(), From a6d7bd0e56d74c2e5755e1a3f0322c614bf44712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cruz?= Date: Fri, 20 Nov 2026 18:18:55 -0600 Subject: [PATCH 2/5] [CP-952] TEMP: failing test to prove CI goes red (reverted next) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with Claude Code Co-Authored-By: Claude --- test/eredis_parser_tests.erl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/eredis_parser_tests.erl b/test/eredis_parser_tests.erl index c1119e95..0bf89edf 100644 --- a/test/eredis_parser_tests.erl +++ b/test/eredis_parser_tests.erl @@ -323,3 +323,7 @@ status_inside_multibulk_test() -> error_inside_multibulk_test() -> B = <<"*2\r\n-ERR foobar\r\n:1\r\n">>, ?assertEqual({ok, [<<"ERR foobar">>, <<"1">>], init()}, parse(init(), B)). + +%% CP-952 temporary: proves CI goes red. Reverted in the next commit. +ci_red_check_test() -> + ?assertEqual(1, 2). From 456806f350b999fa5974c4f1dae7a0558f8dc1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cruz?= Date: Fri, 20 Nov 2026 18:20:19 -0600 Subject: [PATCH 3/5] [CP-952] Revert the temporary failing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with Claude Code Co-Authored-By: Claude --- test/eredis_parser_tests.erl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/eredis_parser_tests.erl b/test/eredis_parser_tests.erl index 0bf89edf..c1119e95 100644 --- a/test/eredis_parser_tests.erl +++ b/test/eredis_parser_tests.erl @@ -323,7 +323,3 @@ status_inside_multibulk_test() -> error_inside_multibulk_test() -> B = <<"*2\r\n-ERR foobar\r\n:1\r\n">>, ?assertEqual({ok, [<<"ERR foobar">>, <<"1">>], init()}, parse(init(), B)). - -%% CP-952 temporary: proves CI goes red. Reverted in the next commit. -ci_red_check_test() -> - ?assertEqual(1, 2). From b18f759246ca9b6d480e0cadb9a0e64d1c686b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cruz?= Date: Mon, 23 Nov 2026 02:22:28 -0600 Subject: [PATCH 4/5] [CP-952] Make tcp_closed_rig deterministic instead of widening its assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fake close could reach the client before a query; the no_reconnect client then stops and the late eredis:q exits, so gather_remote_queries waited for a result that never came. The rig now suspends the client until both requests are in its mailbox, sends the close, then resumes: the close always lands after the requests and before any Redis reply, so both get {error, tcp_closed}. 🤖 Generated with Claude Code Co-Authored-By: Claude --- test/eredis_tests.erl | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/test/eredis_tests.erl b/test/eredis_tests.erl index 3dcfd89e..e247549c 100644 --- a/test/eredis_tests.erl +++ b/test/eredis_tests.erl @@ -186,27 +186,29 @@ tcp_closed_no_reconnect_test() -> tcp_closed_rig(C). tcp_closed_rig(C) -> - %% fire async requests to add to redis client queue and then trick - %% the client into thinking the connection to redis has been - %% closed. This behavior can be observed when Redis closes an idle - %% connection just as a traffic burst starts. - DoSend = fun(tcp_closed) -> - C ! {tcp_closed, fake_socket}; - (Cmd) -> - eredis:q(C, Cmd) - end, - %% attach an id to each message for later - Msgs = [{1, ["GET", "foo"]}, - {2, ["GET", "bar"]}, - {3, tcp_closed}], - Pids = [ remote_query(DoSend, M) || M <- Msgs ], + %% Queue two requests on the client, then trick it into thinking the + %% connection to redis has been closed. This behavior can be observed + %% when Redis closes an idle connection just as a traffic burst starts. + %% The client is suspended until both requests sit in its mailbox, so + %% the fake close always lands after them and before any Redis reply + %% (nothing reaches the socket until the client resumes). + ok = sys:suspend(C), + Pids = [ remote_query(fun(Cmd) -> eredis:q(C, Cmd) end, M) + || M <- [{1, ["GET", "foo"]}, {2, ["GET", "bar"]}] ], + ok = wait_for_queue_len(C, 2, 100), + C ! {tcp_closed, fake_socket}, + ok = sys:resume(C), Results = gather_remote_queries(Pids), - %% A query that reaches the client after the close gets no_connection - %% instead of tcp_closed; either way it errors instead of hanging. - ?assertMatch({error, E} when E =:= tcp_closed; E =:= no_connection, - proplists:get_value(1, Results)), - ?assertMatch({error, E} when E =:= tcp_closed; E =:= no_connection, - proplists:get_value(2, Results)). + ?assertEqual({error, tcp_closed}, proplists:get_value(1, Results)), + ?assertEqual({error, tcp_closed}, proplists:get_value(2, Results)). + +wait_for_queue_len(_Pid, _Len, 0) -> + {error, queue_len_timeout}; +wait_for_queue_len(Pid, Len, Tries) -> + case process_info(Pid, message_queue_len) of + {message_queue_len, N} when N >= Len -> ok; + _ -> timer:sleep(10), wait_for_queue_len(Pid, Len, Tries - 1) + end. remote_query(Fun, {Id, Cmd}) -> Parent = self(), From ba34f35a0de77a91821acd72aac54f83bc163f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Cruz?= Date: Mon, 23 Nov 2026 03:55:59 -0600 Subject: [PATCH 5/5] [CP-952] Pin the meck test dep to 0.9.2 so eunit runs on OTP 22 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #17 added {meck, "1.2.0"} to the test profile; meck 1.2.0 needs OTP 25 and the CI image (like xmpp's build) is OTP 22.3, so rebar3 eunit stopped before running any test. 0.9.2 is the version xmpp pins on the same OTP. 🤖 Generated with Claude Code Co-Authored-By: Claude --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index dd1c7f34..fea3f4b8 100644 --- a/rebar.config +++ b/rebar.config @@ -6,4 +6,4 @@ %% This allows this project to be used as a dependency by other rebar projects %% that use xref. {xref_checks, []}. -{profiles, [{test, [{deps, [{meck, "1.2.0"}]}]}]}. +{profiles, [{test, [{deps, [{meck, "0.9.2"}]}]}]}.