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

     1  launch :rpc, "bundle exec anyt --only-rpc"
     2  wait_tcp 50051
     3  
     4  launch :anycable,
     5    "./dist/anycable-go --pong_timeout=1"
     6  wait_tcp 8080
     7  
     8  scenario = [
     9    client: {
    10      multiplier: 1,
    11      connection_options: {
    12        subprotocol: "actioncable-v1-ext-json",
    13        query: {
    14          pi: "1",
    15          ptp: "ns",
    16        }
    17      },
    18      actions: [
    19        {
    20          receive: {
    21            "data>": {
    22              type: "welcome"
    23            }
    24          }
    25        },
    26        {
    27          receive: {
    28            "data>": {
    29              type: "ping"
    30            }
    31          }
    32        },
    33        {
    34          sleep: {
    35            time: 0.5
    36          }
    37        },
    38        {
    39          send: {
    40            data: {
    41              command: "pong"
    42            }
    43          }
    44        },
    45        {
    46          receive: {
    47            "data>": {
    48              type: "ping"
    49            }
    50          }
    51        },
    52        {
    53          sleep: {
    54            time: 1
    55          }
    56        },
    57        {
    58          receive: {
    59            data: {
    60              type: "disconnect",
    61              reason: "no_pong",
    62              reconnect: true
    63            }
    64          }
    65        }
    66      ]
    67    }
    68  ]
    69  
    70  TEST_COMMAND = <<~CMD
    71    bundle exec wsdirector ws://localhost:8080/cable -i #{scenario.to_json}
    72  CMD
    73  
    74  run :wsdirector, TEST_COMMAND
    75  
    76  result = stdout(:wsdirector)
    77  
    78  if result !~ /1 clients, 0 failures/
    79    fail "Unexpected scenario result:\n#{result}"
    80  end