Method: NamedTests#client_compressed_streaming

Defined in:
src/ruby/pb/test/client.rb

#client_compressed_streamingObject



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'src/ruby/pb/test/client.rb', line 389

def client_compressed_streaming
  # first request used also by the probe
  first_request = StreamingInputCallRequest.new(
    payload: Payload.new(type: :COMPRESSABLE, body: nulls(27_182)),
    expect_compressed: BoolValue.new(value: true)
  )

  # send a probe to see if CompressedResponse is supported on the server
  send_probe_for_compressed_request_support do
    request_uncompressed_args = {
      COMPRESSION_REQUEST_ALGORITHM => 'identity'
    }
    @stub.streaming_input_call([first_request],
                               metadata: request_uncompressed_args)
  end

  second_request = StreamingInputCallRequest.new(
    payload: Payload.new(type: :COMPRESSABLE, body: nulls(45_904)),
    expect_compressed: BoolValue.new(value: false)
  )

  # Create the requests messages and the corresponding write flags
  # for each message
  requests = WriteFlagSettingStreamingInputEnumerable.new([
    { request: first_request,
      write_flag: 0 },
    { request: second_request,
      write_flag: GRPC::Core::WriteFlags::NO_COMPRESS }
  ])

  # Create the call_op, pass it to the requests enumerable, and
  # run the call
  call_op = @stub.streaming_input_call(requests,
                                       return_op: true)
  requests.call_op = call_op
  resp = call_op.execute

  wanted_aggregate_size = 73_086

  assert("#{__callee__}: aggregate payload size is incorrect") do
    wanted_aggregate_size == resp.aggregated_payload_size
  end
end