github.com/anycable/anycable-go@v1.5.1/features/streams.testfile (about)

     1  launch :anycable,
     2    "./dist/anycable-go --public " \
     3    "--metrics_rotate_interval=1 --metrics_log --metrics_log_filter=rpc_call_total,rpc_error_total,rpc_retries_total",
     4    capture_output: true
     5  
     6  wait_tcp 8080
     7  
     8  scenario = [
     9    {
    10      client: {
    11        protocol: "action_cable",
    12        name: "streamer",
    13        actions: [
    14          {
    15            subscribe: {
    16              channel: "$pubsub",
    17              params: {
    18                stream_name: "stream/2023"
    19              }
    20            }
    21          },
    22        ]
    23      }
    24    }
    25  ]
    26  
    27  TEST_COMMAND = <<~CMD
    28    bundle exec wsdirector ws://localhost:8080/cable -i #{scenario.to_json}
    29  CMD
    30  
    31  run :wsdirector, TEST_COMMAND
    32  
    33  result = stdout(:wsdirector)
    34  
    35  unless result.include?("1 clients, 0 failures")
    36    fail "Unexpected scenario result:\n#{result}"
    37  end
    38  
    39  # Wait for metrics to be logged
    40  sleep 2
    41  
    42  stop :anycable
    43  
    44  logs = stdout(:anycable)
    45  
    46  # We should not see any rpc calls
    47  if logs =~ /rpc_call_total=[1-9] rpc_error_total=[1-9] rpc_retries_total=[1-9]/
    48    fail "Expected metrics logs not found:\n#{logs}"
    49  end