github.com/anycable/anycable-go@v1.5.1/features/turbo_rpc_less.testfile (about) 1 launch :anycable, 2 "./dist/anycable-go --turbo_rails_key=s3Krit --jwt_id_key=qwerty " \ 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 payload = {ext: {}.to_json, exp: (Time.now.to_i + 60)} 9 10 token = ::JWT.encode(payload, "qwerty", "HS256") 11 12 verifier = ActiveSupport::MessageVerifier.new("s3Krit", digest: "SHA256", serializer: JSON) 13 signed_stream_name = verifier.generate("chat/2023") 14 15 scenario = [ 16 { 17 client: { 18 protocol: "action_cable", 19 name: "turbo", 20 connection_options: { 21 query: { 22 jid: token 23 } 24 }, 25 actions: [ 26 { 27 subscribe: { 28 channel: "Turbo::StreamsChannel", 29 params: { 30 signed_stream_name: signed_stream_name 31 } 32 } 33 }, 34 ] 35 } 36 } 37 ] 38 39 TEST_COMMAND = <<~CMD 40 bundle exec wsdirector ws://localhost:8080/cable -i #{scenario.to_json} 41 CMD 42 43 run :wsdirector, TEST_COMMAND 44 45 result = stdout(:wsdirector) 46 47 unless result.include?("1 clients, 0 failures") 48 fail "Unexpected scenario result:\n#{result}" 49 end 50 51 # Wait for metrics to be logged 52 sleep 2 53 54 stop :anycable 55 56 logs = stdout(:anycable) 57 58 # We should not see any rpc calls 59 if logs =~ /rpc_call_total=[1-9] rpc_error_total=[1-9] rpc_retries_total=[1-9]/ 60 fail "Expected metrics logs not found:\n#{logs}" 61 end