@@ -48,17 +48,23 @@ defmodule Realtime.MetricsPusherTest do
4848 body = Req.Test . raw_body ( conn )
4949 decompressed_body = :zlib . gunzip ( body )
5050
51- # Must have a tenant metric or a global metric
52- assert Regex . match? ( ~r/ beam_stats_run_queue_count/ , decompressed_body ) or
53- Regex . match? ( ~r/ realtime_channel_input_bytes/ , decompressed_body )
54-
55- send ( parent , :req_called )
51+ # Collect decompressed bodies so we can assert that one has global metrics
52+ # and the other has tenant metrics.
53+ send ( parent , { :req_called , decompressed_body } )
5654 Req.Test . text ( conn , "" )
5755 end )
5856
5957 { :ok , _pid } = start_and_allow_pusher ( opts )
60- assert_receive :req_called , 100
61- assert_receive :req_called , 100
58+
59+ # Receive both request bodies
60+ assert_receive { :req_called , body1 } , 100
61+ assert_receive { :req_called , body2 } , 100
62+
63+ # One request must contain a global-only metric, the other a tenant-only metric.
64+ assert ( Regex . match? ( ~r/ beam_stats_run_queue_count/ , body1 ) and
65+ Regex . match? ( ~r/ realtime_channel_input_bytes.*tenant=/ , body2 ) ) or
66+ ( Regex . match? ( ~r/ beam_stats_run_queue_count/ , body2 ) and
67+ Regex . match? ( ~r/ realtime_channel_input_bytes.*tenant=/ , body1 ) )
6268 end
6369
6470 test "sends request successfully without auth header" do
0 commit comments