The Job Orchestrator Service is a complete demonstration of all four gRPC communication patterns in a single Python service:
Location: /job-orchestrator-service/
Port: 50055 (Native gRPC) or via Envoy at https://<your-domain>/joborchestrator.JobOrchestrator/
https://grpc-envoy.unified-origin.comhttps://grpc-envoy.qa.akamai.comlocalhost:50055 (when running locally)| Method | Pattern | Description |
|---|---|---|
SubmitJob |
Unary | Submit a new job for execution |
GetJobStatus |
Unary | Query current job status |
PushLogs |
Client Streaming | Stream log lines to server |
WatchJob |
Server Streaming | Real-time job progress updates |
InteractiveSession |
Bidirectional | Two-way job control and events |
SizedInteractiveSession |
Bidirectional | Sized data exchange for testing bi-di streams |
GetSizedResponse |
Server Streaming | Stress/load testing endpoint (streaming) |
UnarySizedResponse |
Unary | Stress/load testing endpoint (single response) |
JustTrailers |
Unary | Send only trailers with no response body |
The Job Orchestrator service supports simulating any gRPC status code for testing error handling using the simulate-grpc-status metadata header. This is useful for:
Usage with grpcurl:
# Simulate PERMISSION_DENIED (status code 7)
grpcurl -plaintext \
-rpc-header "simulate-grpc-status: 7" \
-d '{"name": "test-job"}' \
localhost:50055 \
joborchestrator.JobOrchestrator/SubmitJob
# Simulate UNAVAILABLE through Envoy
grpcurl -insecure \
-rpc-header "simulate-grpc-status: 14" \
-H "x-service-target: job-orchestrator" \
-d '{"name": "test"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
Supported Status Codes:
| Code | Name | Description |
|---|---|---|
| 1 | CANCELLED | The operation was cancelled |
| 2 | UNKNOWN | Unknown error occurred |
| 3 | INVALID_ARGUMENT | Client specified an invalid argument |
| 4 | DEADLINE_EXCEEDED | Deadline expired before operation could complete |
| 5 | NOT_FOUND | Some requested entity was not found |
| 6 | ALREADY_EXISTS | The entity already exists |
| 7 | PERMISSION_DENIED | The caller does not have permission |
| 8 | RESOURCE_EXHAUSTED | Some resource has been exhausted |
| 9 | FAILED_PRECONDITION | Operation rejected due to system state |
| 10 | ABORTED | The operation was aborted |
| 11 | OUT_OF_RANGE | Operation attempted past valid range |
| 12 | UNIMPLEMENTED | Operation not implemented or supported |
| 13 | INTERNAL | Internal server error |
| 14 | UNAVAILABLE | The service is currently unavailable |
| 15 | DATA_LOSS | Unrecoverable data loss or corruption |
| 16 | UNAUTHENTICATED | Request lacks valid authentication credentials |
Test All Status Codes:
# Run automated tests for all status codes
./test_grpc_status_codes.sh localhost:50055
# Test through Envoy with TLS
./test_grpc_status_codes.sh grpc-envoy.qa.akamai.com:443 tls
View in Envoy Access Logs:
The enhanced Envoy access logs now show grpc-status and grpc-message:
[2025-12-30T02:37:59.659Z] "POST /joborchestrator.JobOrchestrator/SubmitJob HTTP/2"
200 - bytes_rx=11 bytes_tx=0 duration=0ms ...
grpc-status=8 grpc-message="Simulated RESOURCE_EXHAUSTED: Some resource has been exhausted"
See GRPC_STATUS_SIMULATION.md for complete documentation.
The service supports simulating large trailer metadata using the auth-token-bin-size header. This is useful for:
Usage:
# Small metadata (100 bytes)
grpcurl -plaintext \
-rpc-header "auth-token-bin-size: 100" \
-d '{"name": "test"}' \
localhost:50055 \
joborchestrator.JobOrchestrator/SubmitJob
# Large metadata (1MB)
grpcurl -plaintext \
-rpc-header "auth-token-bin-size: 1048576" \
-d '{"name": "1mb-test"}' \
localhost:50055 \
joborchestrator.JobOrchestrator/SubmitJob
# Through Envoy
grpcurl -insecure \
-rpc-header "auth-token-bin-size: 10240" \
-H "x-service-target: job-orchestrator" \
-d '{"name": "test"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
Metadata Sizes:
| Size | Description | Use Case |
|---|---|---|
| Default | 4 bytes | Normal operation (no header) |
| 100-1024 | 100B - 1KB | Small tokens, session IDs |
| 10240 | 10KB | Medium headers, JWT tokens |
| 102400 | 100KB | Large certificates, compressed data |
| 1048576 | 1MB | Very large metadata testing |
| 10485760 | 10MB (max) | Maximum allowed size (capped) |
Features:
- Generates random binary data in auth-token-bin trailer
- Automatically caps at 10MB with warning log
- Works with all RPC methods (unary, streaming, bidirectional)
- Compatible with Envoy proxy
Note: Sizes above 10MB are automatically capped to prevent excessive memory usage.
When accessing the Job Orchestrator service through Envoy proxy, you can simulate malformed, duplicate, or missing gRPC trailers using the simulate-grpc-headers header. This is useful for:
β οΈ Important: This feature is implemented as an Envoy Lua filter and only works when accessing the service through Envoy (port 443), not when connecting directly to port 50055.
Usage with grpcurl (through Envoy):
# Malformed trailers mode - sends invalid grpc-status and grpc-message
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: malformed" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
# Duplicate trailers mode - sends multiple grpc-status values
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: duplicate" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
# Malformed retry pushback mode - sends invalid grpc-retry-pushback-ms
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: malformed-retry" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
# Delete trailers mode - removes grpc-status and grpc-message
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: delete" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
Simulation Modes:
| Mode | Header Value | Behavior | Expected Client Error |
|---|---|---|---|
| Malformed | malformed |
Sets grpc-status: INVALID_STATUS (non-numeric)Sets grpc-message with null bytes, invalid UTF-8, and control characters |
Parse error: "strconv.ParseInt: parsing 'INVALID_STATUS': invalid syntax" |
| Malformed Retry | malformed-retry |
Sets grpc-retry-pushback-ms: not-a-number-invalid (invalid retry pushback value) |
Parse error: "strconv.ParseInt: parsing 'not-a-number-invalid': invalid syntax" Client retry mechanism confusion |
| Duplicate | duplicate |
Sends multiple grpc-status headers (0 and 13)Sends multiple grpc-message headers |
Parse error: "strconv.ParseInt: parsing '0,0,13': invalid syntax" Client confusion about which status to use |
| Delete | delete |
Removes grpc-status trailerRemoves grpc-message trailer |
Code: Unknown (missing required trailers) Protocol violation error |
| Custom Trailer | send-<header_name> |
Adds custom trailer <header_name>: <header_name>Example: send-x-custom adds x-custom: x-custom |
Depends on client handling of custom headers Useful for testing custom metadata parsing |
Example Results:
Malformed Mode:
$ grpcurl -insecure -H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: malformed" \
-d '{"name": "test"}' grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
ERROR:
Code: Internal
Message: transport: malformed grpc-status: strconv.ParseInt: parsing "INVALID_STATUS": invalid syntax
Duplicate Mode:
ERROR:
Code: Internal
Message: transport: malformed grpc-status: strconv.ParseInt: parsing "0,0,13": invalid syntax
Delete Mode:
ERROR:
Code: Unknown
Message:
Python Client Example:
import grpc
from generated import job_orchestrator_pb2, job_orchestrator_pb2_grpc
# Connect through Envoy
channel = grpc.insecure_channel('grpc-envoy.qa.akamai.com:443')
stub = job_orchestrator_pb2_grpc.JobOrchestratorStub(channel)
# Test malformed mode
metadata = [('simulate-grpc-headers', 'malformed')]
request = job_orchestrator_pb2.JobSpec(name="test-job")
try:
response = stub.SubmitJob(request, metadata=metadata)
except grpc.RpcError as e:
print(f"Status: {e.code()}")
print(f"Details: {e.details()}")
print(f"Trailing metadata: {e.trailing_metadata()}")
Normal Operation (No Header):
When the simulate-grpc-headers header is not present, requests work normally:
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{"name": "normal-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
# Success response:
{
"job_id": "fe6c9a1c",
"message": "Job 'normal-job' submitted successfully"
}
Technical Details:
/joborchestrator.*simulate-grpc-headers request headerresponse_handle:trailers() APIβ οΈ Warning: This feature is intended for testing/development environments only. Do not use in production as malformed trailers will cause client failures.
The Job Orchestrator service supports mirroring custom response headers through the mirror-response request header. This feature allows clients to dynamically inject custom headers into the response, useful for:
β οΈ Important: This feature is implemented as an Envoy Lua filter and only works when accessing the service through Envoy (port 443), not when connecting directly to port 50055.
Usage with grpcurl (through Envoy):
# Mirror a custom response header
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-H "mirror-response: Response-Content=Microsoft OLE DB Provider for SQL Server error '80040e07'" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
# Multiple custom headers (using multiple requests)
grpcurl -insecure \
-H "mirror-response: X-Custom-Header=CustomValue123" \
-d '{"name": "test-job"}' \
grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SubmitJob
Header Format:
The mirror-response header uses the format: HeaderName=HeaderValue
Response-Content, X-Custom-Error)Example Response:
When sending:
mirror-response: Response-Content=Microsoft OLE DB Provider for SQL Server error '80040e07'
The response will include:
Response-Content: Microsoft OLE DB Provider for SQL Server error '80040e07'
Python Client Example:
import grpc
from generated import job_orchestrator_pb2, job_orchestrator_pb2_grpc
# Connect through Envoy
channel = grpc.insecure_channel('grpc-envoy.qa.akamai.com:443')
stub = job_orchestrator_pb2_grpc.JobOrchestratorStub(channel)
# Test with custom mirrored response header
metadata = [('mirror-response', 'X-Error-Code=SQL_INJECTION_DETECTED')]
request = job_orchestrator_pb2.JobSpec(name="test-job")
response, call = stub.SubmitJob.with_call(request, metadata=metadata)
print(f"Response: {response}")
print(f"Response headers: {call.initial_metadata()}")
Use Cases:
| Use Case | Example Header | Purpose |
|---|---|---|
| Error Simulation | mirror-response: X-Error-Type=Database Connection Failed |
Test error handling with specific error types |
| SQL Error Testing | mirror-response: Response-Content=SQL Server error '80040e07' |
Simulate database error responses |
| Custom Metadata | mirror-response: X-Request-ID=abc-123-def |
Test request tracking header processing |
| Content Type | mirror-response: X-Content-Encoding=gzip |
Validate content encoding handling |
| Security Headers | mirror-response: X-Frame-Options=DENY |
Test security header parsing |
Technical Details:
envoy_on_response functionNormal Operation (No Header):
When the mirror-response header is not present, responses are sent normally without additional headers.
β οΈ Note: This feature is intended for testing/development environments. In production, response headers should be controlled by backend services, not client requests.
This service supports both native gRPC and gRPC-Web protocols:
50055 (job-orchestrator-service direct)grpcurl or Python client443 (HTTPS production) / 8080 (HTTP local)curl with custom protobuf encodingFor gRPC-Web requests, all requests use:
- Content-Type: application/grpc-web+proto
- X-Grpc-Web: 1
- X-User-Agent: grpc-web-javascript/0.1
- x-service-target: job-orchestrator (when using Envoy)
cd job-orchestrator-service
# Install dependencies
make install
# Generate gRPC code
make generate
# Terminal 1: Start server
make server
# Terminal 2: Try the TUI client
make tui
# Or use CLI commands
make cli-submit # Submit a test job (default 10 steps)
make cli-status JOB_ID=<id> # Get job status
make cli-watch JOB_ID=<id> # Watch job updates
make cli-shell JOB_ID=<id> # Interactive session
make cli-logs JOB_ID=<id> FILE=test_logs.txt # Push logs
# Submit jobs with custom number of steps
python -m client.cli submit --name "quick-test" --param steps=3
python -m client.cli submit --name "long-test" --param steps=50 --param env=qa
python -m client.cli submit --name "stress-test" --param steps=500
Pro Tip: Use the steps parameter to control streaming duration:
- Quick tests: steps=3 (completes in ~10 seconds)
- Demo: steps=10 (default, ~30 seconds)
- Load testing: steps=100 or higher (up to 1000 max)
Each step takes 1-3 seconds, so adjust based on your testing needs.
Create a helper script to generate protobuf messages for gRPC-Web requests:
cat > /tmp/job_orchestrator_helper.py << 'EOF'
import struct
import sys
import json
def encode_varint(value):
result = []
while value >= 0x80:
result.append((value & 0x7F) | 0x80)
value >>= 7
result.append(value)
return bytes(result)
def encode_string_field(field_number, value):
string_bytes = value.encode('utf-8')
tag = (field_number << 3) | 2 # Wire type 2 (length-delimited)
return encode_varint(tag) + encode_varint(len(string_bytes)) + string_bytes
def encode_map_field(field_number, key_value_pairs):
"""Encode a map<string, string> field"""
result = b''
for key, value in key_value_pairs.items():
# Each map entry is a nested message with field 1=key, field 2=value
entry = encode_string_field(1, key) + encode_string_field(2, value)
tag = (field_number << 3) | 2
result += encode_varint(tag) + encode_varint(len(entry)) + entry
return result
def create_grpc_frame(message):
"""Create gRPC-Web frame: [flags(1byte)][length(4bytes)][message]"""
return b'\x00' + struct.pack('>I', len(message)) + message
def create_submit_job(name, params):
"""Create SubmitJob request (JobSpec message)"""
message = encode_string_field(1, name) # field 1: name
if params:
message += encode_map_field(2, params) # field 2: params (map)
return create_grpc_frame(message)
def create_job_id(job_id):
"""Create JobId message"""
message = encode_string_field(1, job_id) # field 1: id
return create_grpc_frame(message)
def create_log_line(job_id, line, level="INFO"):
"""Create LogLine message"""
import time
timestamp_ms = int(time.time() * 1000)
message = encode_string_field(1, job_id) # field 1: job_id
message += encode_string_field(2, line) # field 2: line
# field 3: timestamp_ms (varint)
tag = (3 << 3) | 0
message += encode_varint(tag) + encode_varint(timestamp_ms)
message += encode_string_field(4, level) # field 4: level
return create_grpc_frame(message)
def create_control_message(job_id, command, arg=""):
"""Create ControlMessage for interactive session"""
message = encode_string_field(1, job_id) # field 1: job_id
message += encode_string_field(2, command) # field 2: command
if arg:
message += encode_string_field(3, arg) # field 3: arg
return create_grpc_frame(message)
def encode_int64_field(field_number, value):
"""Encode an int64 field (varint)"""
tag = (field_number << 3) | 0 # Wire type 0 (varint)
return encode_varint(tag) + encode_varint(value)
def encode_int32_field(field_number, value):
"""Encode an int32 field (varint)"""
tag = (field_number << 3) | 0 # Wire type 0 (varint)
return encode_varint(tag) + encode_varint(value)
def encode_bool_field(field_number, value):
"""Encode a bool field"""
tag = (field_number << 3) | 0 # Wire type 0 (varint)
return encode_varint(tag) + (b'\x01' if value else b'\x00')
def encode_float_field(field_number, value):
"""Encode a float field (fixed32)"""
tag = (field_number << 3) | 5 # Wire type 5 (fixed32)
return encode_varint(tag) + struct.pack('<f', value)
def create_sized_response_request(stream_size, total_size, delay_ms=0,
compressible=False, include_metadata=True, error_rate=0.0):
"""Create SizedResponseRequest message"""
message = b''
message += encode_int64_field(1, stream_size) # field 1: stream_size
message += encode_int64_field(2, total_size) # field 2: total_size
if delay_ms > 0:
message += encode_int32_field(3, delay_ms) # field 3: delay_ms
if compressible:
message += encode_bool_field(4, compressible) # field 4: compressible
if not include_metadata:
message += encode_bool_field(5, include_metadata) # field 5: include_metadata
if error_rate > 0.0:
message += encode_float_field(6, error_rate) # field 6: error_rate
return create_grpc_frame(message)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python job_orchestrator_helper.py <command> [args...]")
sys.exit(1)
command = sys.argv[1]
if command == "submit_job":
if len(sys.argv) < 3:
print("Usage: python job_orchestrator_helper.py submit_job <name> [key=value ...]")
sys.exit(1)
name = sys.argv[2]
params = {}
for arg in sys.argv[3:]:
if '=' in arg:
key, value = arg.split('=', 1)
params[key] = value
data = create_submit_job(name, params)
elif command == "get_status":
if len(sys.argv) != 3:
print("Usage: python job_orchestrator_helper.py get_status <job_id>")
sys.exit(1)
data = create_job_id(sys.argv[2])
elif command == "watch_job":
if len(sys.argv) != 3:
print("Usage: python job_orchestrator_helper.py watch_job <job_id>")
sys.exit(1)
data = create_job_id(sys.argv[2])
elif command == "log_line":
if len(sys.argv) < 4:
print("Usage: python job_orchestrator_helper.py log_line <job_id> <line> [level]")
sys.exit(1)
job_id = sys.argv[2]
line = sys.argv[3]
level = sys.argv[4] if len(sys.argv) > 4 else "INFO"
data = create_log_line(job_id, line, level)
elif command == "control":
if len(sys.argv) < 4:
print("Usage: python job_orchestrator_helper.py control <job_id> <command> [arg]")
sys.exit(1)
job_id = sys.argv[2]
cmd = sys.argv[3]
arg = sys.argv[4] if len(sys.argv) > 4 else ""
data = create_control_message(job_id, cmd, arg)
elif command == "sized_response":
if len(sys.argv) < 4:
print("Usage: python job_orchestrator_helper.py sized_response <stream_size> <total_size> [delay_ms] [compressible] [include_metadata] [error_rate]")
sys.exit(1)
stream_size = int(sys.argv[2])
total_size = int(sys.argv[3])
delay_ms = int(sys.argv[4]) if len(sys.argv) > 4 else 0
compressible = sys.argv[5].lower() == 'true' if len(sys.argv) > 5 else False
include_metadata = sys.argv[6].lower() == 'true' if len(sys.argv) > 6 else True
error_rate = float(sys.argv[7]) if len(sys.argv) > 7 else 0.0
data = create_sized_response_request(stream_size, total_size, delay_ms,
compressible, include_metadata, error_rate)
else:
print(f"Unknown command: {command}")
sys.exit(1)
sys.stdout.buffer.write(data)
EOF
chmod +x /tmp/job_orchestrator_helper.py
Parser for decoding gRPC-Web responses:
cat > /tmp/parse_job_response.py << 'EOF'
import struct
import sys
import subprocess
import os
def parse_grpc_web_response(response_file, message_type, proto_file="job-orchestrator-service/proto/job_orchestrator.proto"):
"""Parse gRPC-Web binary response and decode using protoc"""
# Read the response data
with open(response_file, "rb") as f:
data = f.read()
if len(data) < 5:
print("Response too short")
return
# Parse gRPC-Web frames
i = 0
frame_count = 0
while i < len(data):
if i + 5 > len(data):
break
flag = data[i]
n = struct.unpack(">I", data[i+1:i+5])[0]
i += 5
if i + n > len(data):
break
body = data[i:i+n]
i += n
if flag == 0: # data frame (uncompressed)
print(f"=== Frame {frame_count} (Data) ===")
# Use protoc to decode the protobuf message
try:
# Get the directory of the proto file
proto_dir = os.path.dirname(os.path.abspath(proto_file))
proto_name = os.path.basename(proto_file)
result = subprocess.run([
"protoc",
f"--proto_path={proto_dir}",
"--decode", message_type,
proto_name
], input=body, capture_output=True, cwd=proto_dir)
if result.returncode == 0:
print(result.stdout.decode('utf-8'))
else:
print(f"Protoc decode error: {result.stderr.decode('utf-8')}")
print(f"Raw hex: {body.hex()}")
except FileNotFoundError:
print("protoc not found, showing raw hex:")
print(f"Raw hex: {body.hex()}")
except Exception as e:
print(f"Error: {e}")
print(f"Raw hex: {body.hex()}")
frame_count += 1
elif flag == 0x80: # trailer frame
print(f"=== Frame {frame_count} (Trailers) ===")
trailer_text = body.decode('utf-8', errors='ignore')
print(trailer_text)
frame_count += 1
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: python parse_job_response.py <response_file> <message_type> [proto_file]")
print("Examples:")
print(" python parse_job_response.py /tmp/response.bin joborchestrator.JobAck")
print(" python parse_job_response.py /tmp/response.bin joborchestrator.JobStatus")
print(" python parse_job_response.py /tmp/response.bin joborchestrator.JobUpdate")
sys.exit(1)
response_file = sys.argv[1]
message_type = sys.argv[2]
proto_file = sys.argv[3] if len(sys.argv) > 3 else "job-orchestrator-service/proto/job_orchestrator.proto"
parse_grpc_web_response(response_file, message_type, proto_file)
EOF
chmod +x /tmp/parse_job_response.py
Submit a new job for execution and receive immediate acknowledgment.
gRPC Definition:
rpc SubmitJob(JobSpec) returns (JobAck);
message JobSpec {
string name = 1;
map<string, string> params = 2; // Special param: "steps" (default: 10, max: 1000)
}
message JobAck {
string job_id = 1;
string message = 2;
}
# List all available services
grpcurl -plaintext localhost:50055 list
# Submit a simple job (default 10 steps)
grpcurl -plaintext -d '{
"name": "smoke-tests"
}' localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
# Submit job with custom number of steps
grpcurl -plaintext -d '{
"name": "quick-test",
"params": {
"steps": "3"
}
}' localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
# Submit job with many steps for long streaming test
grpcurl -plaintext -d '{
"name": "long-running-job",
"params": {
"steps": "50"
}
}' localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
# Submit job with multiple parameters
grpcurl -plaintext -d '{
"name": "integration-tests",
"params": {
"steps": "20",
"env": "qa",
"suite": "smoke",
"timeout": "300"
}
}' localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
# Using proto file explicitly
grpcurl -proto job-orchestrator-service/proto/job_orchestrator.proto \
-plaintext -d '{"name":"deployment","params":{"region":"us-east-1"}}' \
localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
Sample Response:
{
"jobId": "a1b2c3d4",
"message": "Job 'smoke-tests' submitted successfully"
}
# Via HTTPS proxy (production)
grpcurl -insecure -d '{
"name": "production-deployment",
"params": {"env": "prod", "version": "v2.1.0"}
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/SubmitJob
# With service target header (explicit routing)
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{"name":"smoke-tests","params":{"env":"qa"}}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/SubmitJob
# Via local Envoy proxy (development)
grpcurl -plaintext -d '{
"name": "test-job",
"params": {"type": "unit-test"}
}' localhost:8080 joborchestrator.JobOrchestrator/SubmitJob
# Submit a job with custom steps (5 steps for quick test)
python3 /tmp/job_orchestrator_helper.py submit_job "quick-test" steps=5 > /tmp/submit_job.bin
curl -v -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/SubmitJob \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "X-User-Agent: grpc-web-javascript/0.1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/submit_job.bin \
--output /tmp/submit_response.bin \
-k
# Parse the response
python3 /tmp/parse_job_response.py /tmp/submit_response.bin joborchestrator.JobAck
# Job with 100 steps for extensive streaming test
python3 /tmp/job_orchestrator_helper.py submit_job "long-test" steps=100 > /tmp/submit2.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/SubmitJob \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/submit2.bin \
-o /tmp/submit2_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/submit2_response.bin joborchestrator.JobAck
Retrieve current status of a specific job.
gRPC Definition:
rpc GetJobStatus(JobId) returns (JobStatus);
message JobId {
string id = 1;
}
message JobStatus {
string job_id = 1;
string state = 2;
string message = 3;
int64 created_at = 4;
int64 updated_at = 5;
map<string, string> params = 6;
}
# Get status of a specific job
grpcurl -plaintext -d '{"id": "a1b2c3d4"}' \
localhost:50055 joborchestrator.JobOrchestrator/GetJobStatus
# Check multiple jobs
grpcurl -plaintext -d '{"id": "job123"}' \
localhost:50055 joborchestrator.JobOrchestrator/GetJobStatus
grpcurl -plaintext -d '{"id": "job456"}' \
localhost:50055 joborchestrator.JobOrchestrator/GetJobStatus
Sample Response:
{
"jobId": "a1b2c3d4",
"state": "RUNNING",
"message": "Processing step 15/50",
"createdAt": "1733076000000",
"updatedAt": "1733076045000",
"params": {
"steps": "50",
"env": "qa",
"suite": "smoke"
}
}
# External access through Envoy proxy
grpcurl -insecure -d '{"id": "a1b2c3d4"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetJobStatus
# With explicit service routing
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{"id": "job123"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetJobStatus
# Check non-existent job (will return error)
grpcurl -insecure -d '{"id": "nonexistent"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetJobStatus
# Get status of job
python3 /tmp/job_orchestrator_helper.py get_status "a1b2c3d4" > /tmp/get_status.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetJobStatus \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/get_status.bin \
-o /tmp/status_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/status_response.bin joborchestrator.JobStatus
# Check multiple jobs in sequence
for job_id in "job1" "job2" "job3"; do
echo "=== Checking status of $job_id ==="
python3 /tmp/job_orchestrator_helper.py get_status "$job_id" > /tmp/status_${job_id}.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetJobStatus \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/status_${job_id}.bin \
-o /tmp/status_${job_id}_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/status_${job_id}_response.bin joborchestrator.JobStatus
echo
done
Stream real-time job updates as the job progresses.
gRPC Definition:
rpc WatchJob(JobId) returns (stream JobUpdate);
message JobUpdate {
string job_id = 1;
string state = 2;
string detail = 3;
int64 timestamp_ms = 4;
int32 progress_percent = 5;
}
# Watch job updates in real-time
grpcurl -plaintext -d '{"id": "a1b2c3d4"}' \
localhost:50055 joborchestrator.JobOrchestrator/WatchJob
# Watch multiple jobs (separate terminals)
# Terminal 1:
grpcurl -plaintext -d '{"id": "job1"}' \
localhost:50055 joborchestrator.JobOrchestrator/WatchJob
# Terminal 2:
grpcurl -plaintext -d '{"id": "job2"}' \
localhost:50055 joborchestrator.JobOrchestrator/WatchJob
# Using proto file
grpcurl -proto job-orchestrator-service/proto/job_orchestrator.proto \
-plaintext -d '{"id": "a1b2c3d4"}' \
localhost:50055 joborchestrator.JobOrchestrator/WatchJob
Sample Streaming Output (3-step job):
{
"jobId": "a1b2c3d4",
"state": "PENDING",
"detail": "Current state: Initialized",
"timestampMs": "1733076000000",
"progressPercent": 0
}
{
"jobId": "a1b2c3d4",
"state": "RUNNING",
"detail": "Job started (3 steps)",
"timestampMs": "1733076002000",
"progressPercent": 0
}
{
"jobId": "a1b2c3d4",
"state": "RUNNING",
"detail": "Processing step 1/3",
"timestampMs": "1733076005000",
"progressPercent": 33
}
{
"jobId": "a1b2c3d4",
"state": "RUNNING",
"detail": "Processing step 2/3",
"timestampMs": "1733076008000",
"progressPercent": 66
}
{
"jobId": "a1b2c3d4",
"state": "RUNNING",
"detail": "Processing step 3/3",
"timestampMs": "1733076011000",
"progressPercent": 100
}
{
"jobId": "a1b2c3d4",
"state": "COMPLETED",
"detail": "Job completed successfully",
"timestampMs": "1733076014000",
"progressPercent": 100
}
# Watch via HTTPS proxy
grpcurl -insecure -d '{"id": "a1b2c3d4"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/WatchJob
# With service target header
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{"id": "job123"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/WatchJob
# Watch with timeout (10 seconds)
timeout 10 grpcurl -insecure -d '{"id": "a1b2c3d4"}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/WatchJob || true
# Note: Server streaming via curl is limited - shows initial response only
# For full streaming, use grpcurl or native clients
python3 /tmp/job_orchestrator_helper.py watch_job "a1b2c3d4" > /tmp/watch.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/WatchJob \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/watch.bin \
-o /tmp/watch_response.bin \
--no-buffer \
-k
# Parse the response (may contain multiple frames)
python3 /tmp/parse_job_response.py /tmp/watch_response.bin joborchestrator.JobUpdate
Note: For full server streaming support, use grpcurl or the Python CLI client:
python -m client.cli watch --job-id a1b2c3d4
Stream multiple log lines to the server and receive a summary.
gRPC Definition:
rpc PushLogs(stream LogLine) returns (LogSummary);
message LogLine {
string job_id = 1;
string line = 2;
int64 timestamp_ms = 3;
string level = 4;
}
message LogSummary {
string job_id = 1;
int64 total_lines = 2;
int64 error_lines = 3;
int64 warn_lines = 4;
string message = 5;
}
# Client streaming is best done with native gRPC clients
cd job-orchestrator-service
# Push logs from a file
python -m client.cli push-logs --job-id a1b2c3d4 test_logs.txt
# Create a custom log file
cat > /tmp/custom_logs.txt << 'EOF'
INFO: Starting data processing
DEBUG: Loading configuration
INFO: Processing batch 1 of 5
WARN: Slow query detected (2.1s)
ERROR: Connection timeout on attempt 1
INFO: Retrying connection
INFO: Processing batch 2 of 5
INFO: Processing complete
EOF
# Push custom logs
python -m client.cli push-logs --job-id a1b2c3d4 /tmp/custom_logs.txt
Sample Response:
β Logs pushed successfully!
Job ID: a1b2c3d4
Total lines: 8
Error lines: 1
Warning lines: 1
Summary: Processed 8 log lines (1 errors, 1 warnings)
# grpcurl supports client streaming with interactive input
# Each line should be a JSON LogLine message
grpcurl -plaintext -d @ localhost:50055 joborchestrator.JobOrchestrator/PushLogs <<EOF
{"job_id":"a1b2c3d4","line":"INFO: Application started","level":"INFO"}
{"job_id":"a1b2c3d4","line":"ERROR: Connection failed","level":"ERROR"}
{"job_id":"a1b2c3d4","line":"WARN: Retrying...","level":"WARN"}
{"job_id":"a1b2c3d4","line":"INFO: Connection successful","level":"INFO"}
EOF
# Note: Client streaming is NOT supported in standard gRPC-Web protocol
# This is a protocol limitation, not implementation-specific
# Use native gRPC clients (Python CLI, grpcurl) for client streaming
Two-way communication for real-time job control and event streaming.
gRPC Definition:
rpc InteractiveSession(stream ControlMessage) returns (stream SessionEvent);
message ControlMessage {
string job_id = 1;
string command = 2;
string arg = 3;
}
message SessionEvent {
string job_id = 1;
string event_type = 2;
string payload = 3;
int64 timestamp_ms = 4;
}
Supported Commands:
- PAUSE - Pause job execution
- RESUME - Resume paused job
- CANCEL - Cancel job execution
- SET_LOG_LEVEL <level> - Change log level (DEBUG/INFO/WARN/ERROR)
- GET_STATUS - Get current job status
cd job-orchestrator-service
# Start interactive shell
python -m client.cli shell --job-id a1b2c3d4
# Example session:
# > GET_STATUS
# [12:34:56] [STATUS] State: RUNNING, Progress: 30%, Message: Processing step 3/10
# > PAUSE
# [12:35:01] [ACK] Job paused
# > SET_LOG_LEVEL DEBUG
# [12:35:10] [ACK] Log level set to DEBUG
# > RESUME
# [12:35:15] [ACK] Job resumed
# > CANCEL
# [12:35:20] [ACK] Job cancelled
# > quit
# Bidirectional streaming with grpcurl requires interactive input
# Each line sends a ControlMessage, server responses stream back
grpcurl -plaintext -d @ localhost:50055 joborchestrator.JobOrchestrator/InteractiveSession <<EOF
{"job_id":"a1b2c3d4","command":"GET_STATUS"}
{"job_id":"a1b2c3d4","command":"PAUSE"}
{"job_id":"a1b2c3d4","command":"SET_LOG_LEVEL","arg":"DEBUG"}
{"job_id":"a1b2c3d4","command":"RESUME"}
EOF
Sample Session Output:
{
"jobId": "",
"eventType": "ACK",
"payload": "Interactive session started. Available commands: PAUSE, RESUME, CANCEL, SET_LOG_LEVEL, GET_STATUS",
"timestampMs": "1733076000000"
}
{
"jobId": "a1b2c3d4",
"eventType": "STATUS",
"payload": "State: RUNNING, Progress: 30%, Message: Processing step 3/10",
"timestampMs": "1733076001000"
}
{
"jobId": "a1b2c3d4",
"eventType": "ACK",
"payload": "Job paused",
"timestampMs": "1733076002000"
}
{
"jobId": "a1b2c3d4",
"eventType": "ACK",
"payload": "Log level set to DEBUG",
"timestampMs": "1733076003000"
}
{
"jobId": "a1b2c3d4",
"eventType": "ACK",
"payload": "Job resumed",
"timestampMs": "1733076004000"
}
# Note: Bidirectional streaming is NOT fully supported in gRPC-Web
# This is a protocol limitation - use native gRPC for bidi streaming
# Web applications can use WebSockets or polling as alternatives
Exchange sized data packets bidirectionally for testing bidirectional streaming performance, data integrity, and processing workflows.
gRPC Definition:
rpc SizedInteractiveSession(stream SizedDataPacket) returns (stream SizedDataPacket);
message SizedDataPacket {
string packet_id = 1; // Unique packet identifier
string log_file = 2; // Log file content or path
bytes data = 3; // Binary data payload
int64 data_size = 4; // Size of data in bytes
int64 timestamp_ms = 5; // Packet timestamp
map<string, string> metadata = 6; // Additional metadata
bool processed = 7; // Server marks as processed
string checksum = 8; // MD5 checksum of data
string processing_info = 9; // Server processing details
}
Use Cases: - π Bidirectional Testing: Test full-duplex streaming with sized payloads - π¦ Data Processing: Send data packets and receive processed results - β Data Integrity: Verify checksums on bidirectional data flow - π Throughput Testing: Measure bidirectional bandwidth and latency - π Metadata Exchange: Test custom metadata in both directions - π₯ Session Management: Test long-running bidirectional sessions
How It Works:
1. Client sends SizedDataPacket with data, log file, and metadata
2. Server processes packet, calculates checksum, adds processing info
3. Server echoes data back with processed=true and processing metadata
4. Both directions can stream multiple packets
5. Server tracks total bytes received/sent and packet counts
6. Session ends when client closes the stream
β οΈ Important: Interactive vs Scripted Usage
When you open an interactive grpcurl session and paste JSON, shell variables ($(...)) are NOT evaluated. You must use literal values or run commands from a script/heredoc.
Method 1: Interactive Paste (Use Literal Values)
# Step 1: Open the session
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession
# Step 2: Paste this JSON (with literal values - no $ variables):
{
"packet_id": "test-001",
"log_file": "My test log",
"data": "SGVsbG8gV29ybGQ=",
"timestamp_ms": 1737650000000,
"metadata": {"test": "interactive"}
}
# Press Ctrl+D when done to close the stream
Method 2: One-Line Command (No Interactive Session)
# Single packet - copy/paste this entire line
grpcurl -plaintext -d '{
"packet_id": "quick-test",
"log_file": "Quick test log",
"data": "SGVsbG8gV29ybGQ=",
"timestamp_ms": 1737650000000,
"metadata": {"test": "quick"}
}' localhost:50055 joborchestrator.JobOrchestrator/SizedInteractiveSession
Method 3: Heredoc Script (Variables ARE Evaluated)
# Save this as test.sh and run it - variables will be evaluated
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "heredoc-test",
"log_file": "Test with heredoc",
"data": "$(echo -n "Test data" | base64)",
"timestamp_ms": $(date +%s%3N),
"metadata": {"method": "heredoc"}
}
EOF
Method 4: Pre-Generate Values Then Paste
# Step 1: Generate values
echo "packet_id: test-$(date +%s)"
echo "data: $(echo -n "My test data" | base64)"
echo "timestamp: $(date +%s%3N)"
# Step 2: Open session
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession
# Step 3: Copy the generated values and paste with literal values:
{
"packet_id": "test-1737650000",
"log_file": "Generated test",
"data": "TXkgdGVzdCBkYXRh",
"timestamp_ms": 1737650000123,
"metadata": {"method": "pregenerated"}
}
Ready-to-Paste Examples (For Interactive Use):
// Example 1: Minimal packet
{
"packet_id": "minimal-001",
"data": "dGVzdA=="
}
// Example 2: With log file
{
"packet_id": "log-001",
"log_file": "Application started successfully",
"data": "QXBwbGljYXRpb24gc3RhcnRlZCBzdWNjZXNzZnVsbHk="
}
// Example 3: With metadata
{
"packet_id": "meta-001",
"log_file": "Test with metadata",
"data": "VGVzdCB3aXRoIG1ldGFkYXRh",
"timestamp_ms": 1737650000000,
"metadata": {
"source": "test",
"priority": "high"
}
}
// Example 4: Multiple packets - paste them one by one, press Enter after each
{
"packet_id": "multi-001",
"data": "Zmlyc3QgcGFja2V0"
}
{
"packet_id": "multi-002",
"data": "c2Vjb25kIHBhY2tldA=="
}
{
"packet_id": "multi-003",
"data": "dGhpcmQgcGFja2V0"
}
# Basic test: Send single packet and receive processed response
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "test-001",
"log_file": "application.log",
"data": "$(echo -n "Hello World" | base64)",
"data_size": 11,
"timestamp_ms": $(date +%s%3N),
"metadata": {
"filename": "app.log",
"encoding": "utf8"
}
}
EOF
# Send multiple packets in sequence (using heredoc - variables are evaluated)
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "pkt-001",
"log_file": "First log entry",
"data": "$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {"sequence": "1"}
}
{
"packet_id": "pkt-002",
"log_file": "Second log entry",
"data": "$(dd if=/dev/urandom bs=2048 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {"sequence": "2"}
}
{
"packet_id": "pkt-003",
"log_file": "Third log entry",
"data": "$(dd if=/dev/urandom bs=4096 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {"sequence": "3"}
}
EOF
# Simple static example (no shell variables - can copy/paste directly)
grpcurl -plaintext -d '{
"packet_id": "simple-001",
"log_file": "Simple test without shell variables",
"data": "VGVzdCBkYXRhIGhlcmU=",
"timestamp_ms": 1737650000000,
"metadata": {"test": "static"}
}' localhost:50055 joborchestrator.JobOrchestrator/SizedInteractiveSession
# Test with compressible data (repeating pattern)
COMPRESSIBLE_DATA=$(python3 -c "import base64; print(base64.b64encode(b'ABCDEFGH' * 128).decode())")
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "compress-test",
"log_file": "Compressible data test",
"data": "$COMPRESSIBLE_DATA",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"type": "compressible",
"pattern": "ABCDEFGH"
}
}
EOF
# Test data integrity with checksum
DATA_CONTENT="Test data for checksum verification"
DATA_B64=$(echo -n "$DATA_CONTENT" | base64)
CHECKSUM=$(echo -n "$DATA_CONTENT" | md5sum | awk '{print $1}')
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "checksum-test",
"log_file": "Data integrity test",
"data": "$DATA_B64",
"timestamp_ms": $(date +%s%3N),
"checksum": "$CHECKSUM",
"metadata": {
"test": "checksum_verification"
}
}
EOF
# Large data test: Send 100KB packet
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "large-001",
"log_file": "Large data transfer test",
"data": "$(dd if=/dev/urandom bs=102400 count=1 2>/dev/null | base64 -w0)",
"data_size": 102400,
"timestamp_ms": $(date +%s%3N),
"metadata": {
"size": "100KB",
"type": "random"
}
}
EOF
Sample Output:
{
"packetId": "test-001",
"logFile": "application.log",
"data": "SGVsbG8gV29ybGQ=",
"dataSize": "11",
"timestampMs": "1737650000000",
"metadata": {
"encoding": "utf8",
"filename": "app.log",
"packet_count": "1",
"processing_time_ms": "2",
"server_processed": "true"
},
"processed": true,
"checksum": "b10a8db164e0754105b7a99be72e3fe5",
"processingInfo": "{'received_at': 1737650000000, 'packet_number': 1, 'bytes_received': 11, 'total_bytes_received': 11, 'data_type': 'random'}"
}
# Via HTTPS proxy
grpcurl -insecure -d @ grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "envoy-001",
"log_file": "Testing through Envoy",
"data": "$(echo -n "Hello from Envoy" | base64)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"proxy": "envoy"
}
}
EOF
# With service target header
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d @ grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "envoy-002",
"log_file": "Multi-packet test via Envoy",
"data": "$(dd if=/dev/urandom bs=10240 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"size": "10KB"
}
}
EOF
# Performance test through Envoy
for i in {1..5}; do
grpcurl -insecure -d @ grpc-envoy.qa.akamai.com:443 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "perf-$i",
"log_file": "Performance packet $i",
"data": "$(dd if=/dev/urandom bs=50000 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"sequence": "$i"
}
}
EOF
done
#!/bin/bash
# test_sized_interactive_session.sh - Comprehensive bidirectional testing
echo "=== Sized Interactive Session Testing Suite ==="
echo ""
# Test 1: Small packets
echo "Test 1: Small packets (1KB each, 5 packets)"
for i in {1..5}; do
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "small-$i",
"log_file": "Small packet test $i",
"data": "$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"test": "small_packets",
"sequence": "$i"
}
}
EOF
done
echo ""
# Test 2: Medium packets
echo "Test 2: Medium packets (50KB each, 3 packets)"
for i in {1..3}; do
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "medium-$i",
"log_file": "Medium packet test $i",
"data": "$(dd if=/dev/urandom bs=51200 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"test": "medium_packets",
"size": "50KB",
"sequence": "$i"
}
}
EOF
done
echo ""
# Test 3: Compression test
echo "Test 3: Compression test (compressible vs random)"
echo " - Compressible data:"
COMP_DATA=$(python3 -c "import base64; print(base64.b64encode(b'PATTERN' * 1000).decode())")
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "compress-yes",
"log_file": "Compressible pattern",
"data": "$COMP_DATA",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"type": "compressible"
}
}
EOF
echo " - Random data:"
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "compress-no",
"log_file": "Random data",
"data": "$(dd if=/dev/urandom bs=7000 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"type": "random"
}
}
EOF
echo ""
# Test 4: Data integrity with checksum
echo "Test 4: Data integrity (checksum validation)"
TEST_DATA="Critical data requiring checksum validation"
TEST_B64=$(echo -n "$TEST_DATA" | base64)
TEST_MD5=$(echo -n "$TEST_DATA" | md5sum | awk '{print $1}')
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "integrity-001",
"log_file": "Checksum validation test",
"data": "$TEST_B64",
"timestamp_ms": $(date +%s%3N),
"checksum": "$TEST_MD5",
"metadata": {
"test": "checksum",
"expected_md5": "$TEST_MD5"
}
}
EOF
echo ""
# Test 5: Latency test (measure round-trip time)
echo "Test 5: Latency test (10 small packets, measure RTT)"
for i in {1..10}; do
START=$(date +%s%3N)
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF 2>&1 | grep -q "processed"
{
"packet_id": "latency-$i",
"log_file": "Latency test $i",
"data": "$(echo -n "ping" | base64)",
"timestamp_ms": $START,
"metadata": {
"test": "latency"
}
}
EOF
END=$(date +%s%3N)
RTT=$((END - START))
echo " Packet $i RTT: ${RTT}ms"
done
echo ""
echo "=== Testing Complete ==="
#!/usr/bin/env python3
"""Example Python client for SizedInteractiveSession"""
import grpc
import asyncio
import hashlib
import time
import base64
from generated import job_orchestrator_pb2, job_orchestrator_pb2_grpc
async def sized_interactive_session_example():
"""Demonstrate bidirectional sized data exchange"""
# Connect to server
async with grpc.aio.insecure_channel('localhost:50055') as channel:
stub = job_orchestrator_pb2_grpc.JobOrchestratorStub(channel)
# Create request generator
async def request_generator():
# Send multiple packets
for i in range(1, 6):
# Generate test data
data = f"Test data packet {i}".encode() * 100 # ~2KB per packet
checksum = hashlib.md5(data).hexdigest()
packet = job_orchestrator_pb2.SizedDataPacket(
packet_id=f"python-{i}",
log_file=f"Python test packet {i}",
data=data,
data_size=len(data),
timestamp_ms=int(time.time() * 1000),
checksum=checksum
)
packet.metadata['sequence'] = str(i)
packet.metadata['client'] = 'python'
print(f"Sending packet {i}: {len(data)} bytes, checksum={checksum[:8]}...")
yield packet
await asyncio.sleep(0.5) # Small delay between packets
# Call bidirectional streaming RPC
print("Starting SizedInteractiveSession...")
call = stub.SizedInteractiveSession(request_generator())
# Receive responses
async for response in call:
print(f"\nReceived response:")
print(f" Packet ID: {response.packet_id}")
print(f" Data Size: {response.data_size}")
print(f" Processed: {response.processed}")
print(f" Checksum: {response.checksum}")
print(f" Processing Info: {response.processing_info}")
print(f" Metadata: {dict(response.metadata)}")
# Get trailer metadata
trailing_metadata = await call.trailing_metadata()
print(f"\nTrailing metadata:")
for key, value in trailing_metadata:
if key.startswith('session-'):
print(f" {key}: {value}")
if __name__ == '__main__':
asyncio.run(sized_interactive_session_example())
The server tracks and reports these metrics in trailing metadata:
| Metric | Header | Description |
|---|---|---|
| Packets Processed | session-packets-processed |
Total packets exchanged |
| Bytes Received | session-bytes-received |
Total bytes received from client |
| Bytes Sent | session-bytes-sent |
Total bytes sent to client |
| Trace ID | x-trace-id |
Unique session trace identifier |
Example Trailing Metadata:
session-packets-processed: 10
session-bytes-received: 524288
session-bytes-sent: 524288
x-trace-id: a1b2c-d3e4f-5g6h7
grpc-server-stats-bin: [binary data]
endpoint-load-metrics-bin: [binary data]
1. Log File Processing:
# Send log file chunks for processing
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "log-chunk-1",
"log_file": "$(cat /var/log/app.log | head -100 | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"source": "/var/log/app.log",
"lines": "100"
}
}
EOF
2. Data Pipeline Testing:
# Test data transformation pipeline
# Server echoes data back with processing metadata
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "pipeline-001",
"log_file": "Pipeline test data",
"data": "$(cat input.json | base64 -w0)",
"timestamp_ms": $(date +%s%3N),
"metadata": {
"format": "json",
"version": "1.0"
}
}
EOF
3. Bandwidth Testing:
# Measure bidirectional throughput
time bash -c 'for i in {1..100}; do
grpcurl -plaintext -d @ localhost:50055 \
joborchestrator.JobOrchestrator/SizedInteractiveSession <<EOF
{
"packet_id": "bw-$i",
"data": "$(dd if=/dev/urandom bs=10240 count=1 2>/dev/null | base64 -w0)",
"timestamp_ms": $(date +%s%3N)
}
EOF
done'
| Feature | InteractiveSession | SizedInteractiveSession |
|---|---|---|
| Purpose | Job control commands | Sized data exchange |
| Message Type | ControlMessage/SessionEvent | SizedDataPacket |
| Data Payload | Text commands/events | Binary data with metadata |
| Use Case | Job orchestration | Data processing, testing |
| Checksums | No | Yes (MD5) |
| Size Testing | No | Yes (arbitrary sizes) |
| Processing Info | Job-specific | Generic data processing |
Generate configurable-sized streaming responses for load testing and performance benchmarking.
gRPC Definition:
rpc GetSizedResponse(SizedResponseRequest) returns (stream SizedResponseChunk);
message SizedResponseRequest {
int64 stream_size = 1; // Size of each chunk in bytes (max 10MB)
int64 total_size = 2; // Total response size in bytes (max 1GB)
int32 delay_ms = 3; // Delay between chunks in ms (default: 0)
bool compressible = 4; // Generate compressible data (default: false)
bool include_metadata = 5; // Include checksums (default: true)
float error_rate = 6; // Error injection rate 0.0-1.0 (default: 0.0)
}
message SizedResponseChunk {
int32 chunk_number = 1; // Sequential chunk number (1-indexed)
int32 total_chunks = 2; // Total chunks in stream
bytes data = 3; // Chunk payload
int64 chunk_size = 4; // Size of this chunk in bytes
int64 total_sent = 5; // Cumulative bytes sent
int64 timestamp_ms = 6; // Chunk timestamp
string checksum = 7; // MD5 checksum (if metadata enabled)
}
Use Cases: - π Bandwidth Testing: Measure maximum throughput - β±οΈ Latency Testing: Test small chunks with delays - π¦ Compression Testing: Compare compressible vs random data - π₯ Error Handling: Inject random failures for resilience testing - π Backpressure: Simulate slow consumers with delays - β Data Integrity: Verify checksums match
# Small test: 1KB chunks, 5KB total
grpcurl -plaintext -d '{
"stream_size": 1024,
"total_size": 5120,
"delay_ms": 100,
"compressible": false,
"include_metadata": true,
"error_rate": 0.0
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# Medium test: 10KB chunks, 100KB total
grpcurl -plaintext -d '{
"stream_size": 10240,
"total_size": 102400,
"delay_ms": 50,
"compressible": true,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# Large test: 100KB chunks, 1MB total, no delay (max throughput)
grpcurl -plaintext -d '{
"stream_size": 102400,
"total_size": 1048576,
"delay_ms": 0,
"compressible": false,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# Stress test: 1MB chunks, 10MB total
time grpcurl -plaintext -d '{
"stream_size": 1048576,
"total_size": 10485760,
"delay_ms": 0,
"compressible": false,
"include_metadata": false
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse > /dev/null
# Compression test: Compare compressible vs random
# Compressible (repeating pattern):
grpcurl -plaintext -d '{
"stream_size": 100000,
"total_size": 1000000,
"compressible": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse | wc -c
# Random (incompressible):
grpcurl -plaintext -d '{
"stream_size": 100000,
"total_size": 1000000,
"compressible": false
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse | wc -c
# Error injection test: 20% error rate
grpcurl -plaintext -d '{
"stream_size": 10000,
"total_size": 100000,
"error_rate": 0.2,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# Backpressure test: Slow streaming with 500ms delays
grpcurl -plaintext -d '{
"stream_size": 5000,
"total_size": 20000,
"delay_ms": 500,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# Data integrity test: Verify checksums
grpcurl -plaintext -d '{
"stream_size": 10240,
"total_size": 102400,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse | \
grep checksum
Sample Output:
{
"chunkNumber": 1,
"totalChunks": 10,
"data": "eNqrVspIzc...[base64]",
"chunkSize": "10240",
"totalSent": "10240",
"timestampMs": "1733076000000",
"checksum": "4087ba64fb5d80ca8518ffd7991e3442"
}
{
"chunkNumber": 2,
"totalChunks": 10,
"data": "xKcF29kvh2...[base64]",
"chunkSize": "10240",
"totalSent": "20480",
"timestampMs": "1733076000150",
"checksum": "39f61491a0d01197f9e876e8655842b6"
}
...
# Via HTTPS proxy
grpcurl -insecure -d '{
"stream_size": 10240,
"total_size": 102400,
"delay_ms": 100,
"compressible": false,
"include_metadata": true
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetSizedResponse
# With service target header
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{
"stream_size": 50000,
"total_size": 500000,
"compressible": true
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetSizedResponse
# Benchmark through proxy
time grpcurl -insecure -d '{
"stream_size": 1048576,
"total_size": 10485760
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/GetSizedResponse > /dev/null
# Small test: 1KB chunks, 5KB total
python3 /tmp/job_orchestrator_helper.py sized_response 1024 5120 100 false true 0.0 > /tmp/sized_request1.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_request1.bin \
-o /tmp/sized_response1.bin \
--no-buffer \
-k
# Parse the response (will show multiple chunks)
python3 /tmp/parse_job_response.py /tmp/sized_response1.bin joborchestrator.SizedResponseChunk
# Medium test: 10KB chunks, 100KB total with compression
python3 /tmp/job_orchestrator_helper.py sized_response 10240 102400 50 true true 0.0 > /tmp/sized_request2.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_request2.bin \
-o /tmp/sized_response2.bin \
--no-buffer \
-k
python3 /tmp/parse_job_response.py /tmp/sized_response2.bin joborchestrator.SizedResponseChunk
# Throughput test: 100KB chunks, 1MB total (measure time)
python3 /tmp/job_orchestrator_helper.py sized_response 102400 1048576 0 false false 0.0 > /tmp/sized_request_perf.bin
time curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_request_perf.bin \
-o /tmp/sized_response_perf.bin \
--no-buffer \
-k
# Check response size and chunk count
echo "Response size: $(wc -c < /tmp/sized_response_perf.bin) bytes"
python3 /tmp/parse_job_response.py /tmp/sized_response_perf.bin joborchestrator.SizedResponseChunk | grep -c "chunk_number"
# Compression test: Compare compressible vs random
echo "=== Compressible data test ==="
python3 /tmp/job_orchestrator_helper.py sized_response 50000 500000 0 true true 0.0 > /tmp/sized_compress.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_compress.bin \
-o /tmp/sized_compress_response.bin \
-k
echo "Compressible response size: $(wc -c < /tmp/sized_compress_response.bin) bytes"
echo "=== Random data test ==="
python3 /tmp/job_orchestrator_helper.py sized_response 50000 500000 0 false true 0.0 > /tmp/sized_random.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_random.bin \
-o /tmp/sized_random_response.bin \
-k
echo "Random response size: $(wc -c < /tmp/sized_random_response.bin) bytes"
# Data integrity test: Verify checksums are included
python3 /tmp/job_orchestrator_helper.py sized_response 10240 102400 0 false true 0.0 > /tmp/sized_checksum.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_checksum.bin \
-o /tmp/sized_checksum_response.bin \
-k
echo "=== Verifying checksums ==="
python3 /tmp/parse_job_response.py /tmp/sized_checksum_response.bin joborchestrator.SizedResponseChunk | grep checksum
# Backpressure test: Slow streaming with delays
python3 /tmp/job_orchestrator_helper.py sized_response 5000 20000 500 false true 0.0 > /tmp/sized_slow.bin
echo "=== Slow streaming test (500ms delays) ==="
time curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_slow.bin \
-o /tmp/sized_slow_response.bin \
--no-buffer \
-k
echo "Expected duration: ~2 seconds (4 chunks Γ 500ms)"
# Error injection test: 20% error rate (expect failures)
python3 /tmp/job_orchestrator_helper.py sized_response 10000 100000 0 false true 0.2 > /tmp/sized_error.bin
echo "=== Error injection test (20% error rate) ==="
curl -v -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/GetSizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/sized_error.bin \
-o /tmp/sized_error_response.bin \
-k 2>&1 | grep -E "grpc-status|grpc-message"
Sample gRPC-Web Response Output:
=== Frame 0 (Data) ===
chunk_number: 1
total_chunks: 10
data: "\000\001\002\003\004..." [truncated]
chunk_size: 10240
total_sent: 10240
timestamp_ms: 1733680800000
checksum: "4087ba64fb5d80ca8518ffd7991e3442"
=== Frame 1 (Data) ===
chunk_number: 2
total_chunks: 10
data: "\005\006\007\010\011..." [truncated]
chunk_size: 10240
total_sent: 20480
timestamp_ms: 1733680800150
checksum: "39f61491a0d01197f9e876e8655842b6"
...
=== Frame 10 (Trailers) ===
grpc-status:0
grpc-message:
Note on Server Streaming via curl:
- gRPC-Web server streaming works with curl, but responses are buffered
- For real-time streaming visibility, use grpcurl or native gRPC clients
- The --no-buffer flag helps but may not show chunks in real-time
- Best for: measuring total throughput, testing compression, verifying data integrity
- Not ideal for: observing chunk-by-chunk streaming behavior
Helper Command Reference:
# Syntax: sized_response <stream_size> <total_size> [delay_ms] [compressible] [include_metadata] [error_rate]
# Minimal (required params only)
python3 /tmp/job_orchestrator_helper.py sized_response 1024 10240
# With delay
python3 /tmp/job_orchestrator_helper.py sized_response 1024 10240 100
# With compression
python3 /tmp/job_orchestrator_helper.py sized_response 1024 10240 0 true
# Full options
python3 /tmp/job_orchestrator_helper.py sized_response 10240 102400 50 true true 0.0
# Test input validation - Invalid stream_size (0)
grpcurl -plaintext -d '{
"stream_size": 0,
"total_size": 1000
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: stream_size must be greater than 0
# Test input validation - stream_size too large (>10MB)
grpcurl -plaintext -d '{
"stream_size": 11000000,
"total_size": 11000000
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: stream_size cannot exceed 10MB (10485760 bytes)
# Test input validation - total_size too large (>1GB)
grpcurl -plaintext -d '{
"stream_size": 1000,
"total_size": 2000000000
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: total_size cannot exceed 1GB (1073741824 bytes)
# Test input validation - negative delay
grpcurl -plaintext -d '{
"stream_size": 1000,
"total_size": 5000,
"delay_ms": -100
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: delay_ms cannot be negative
# Test input validation - error_rate out of range
grpcurl -plaintext -d '{
"stream_size": 1000,
"total_size": 5000,
"error_rate": 1.5
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: error_rate must be between 0.0 and 1.0
#!/bin/bash
# stress_test_suite.sh - Comprehensive load testing
echo "=== gRPC Stress Testing Suite ==="
echo ""
# Test 1: Throughput (maximize bandwidth)
echo "1. Throughput Test (1MB chunks, 100MB total)"
time grpcurl -plaintext -d '{
"stream_size": 1048576,
"total_size": 104857600,
"delay_ms": 0,
"include_metadata": false
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse > /dev/null
echo ""
# Test 2: Latency (small chunks with timing)
echo "2. Latency Test (1KB chunks, 100KB total, 50ms delay)"
time grpcurl -plaintext -d '{
"stream_size": 1024,
"total_size": 102400,
"delay_ms": 50,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse > /dev/null
echo ""
# Test 3: Compression effectiveness
echo "3. Compression Test"
echo " - Compressible data:"
grpcurl -plaintext -d '{
"stream_size": 100000,
"total_size": 1000000,
"compressible": true
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse 2>/dev/null | wc -c
echo " - Random data:"
grpcurl -plaintext -d '{
"stream_size": 100000,
"total_size": 1000000,
"compressible": false
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse 2>/dev/null | wc -c
echo ""
# Test 4: Error resilience
echo "4. Error Injection Test (30% error rate)"
grpcurl -plaintext -d '{
"stream_size": 10000,
"total_size": 100000,
"error_rate": 0.3
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse 2>&1 | head -20
echo ""
# Test 5: Concurrent connections
echo "5. Concurrency Test (10 parallel connections)"
for i in {1..10}; do
grpcurl -plaintext -d '{
"stream_size": 10000,
"total_size": 50000
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse > /dev/null &
done
wait
echo " All 10 connections completed"
echo ""
echo "=== Stress Testing Complete ==="
Parameters Guide:
| Parameter | Min | Max | Default | Purpose |
|---|---|---|---|---|
stream_size |
1 | 10MB | - | Chunk size for each stream message |
total_size |
1 | 1GB | - | Total data to send across all chunks |
delay_ms |
0 | β | 0 | Artificial delay between chunks |
compressible |
- | - | false | Generate repeating vs random data |
include_metadata |
- | - | true | Include MD5 checksums |
error_rate |
0.0 | 1.0 | 0.0 | Probability of simulated errors |
Testing Scenarios:
stream_size=1048576, total_size=104857600, delay_ms=0stream_size=1024, total_size=102400, delay_ms=50compressible=true vs compressible=falseerror_rate=0.2 to test retry logicdelay_ms=500 to simulate slow consumersinclude_metadata=true and verify checksumsFor detailed documentation, see: GET_SIZED_RESPONSE_README.md
Generate a single sized response for load testing without the overhead of streaming. Unlike GetSizedResponse which returns multiple chunks in a stream, this returns all data in a single unary response.
gRPC Definition:
rpc UnarySizedResponse(SizedResponseRequest) returns (UnarySizedResponseData);
message SizedResponseRequest {
int64 stream_size = 1; // Ignored for unary (for API consistency)
int64 total_size = 2; // Size of response data in bytes (max 100MB)
int32 delay_ms = 3; // Ignored for unary
bool compressible = 4; // Generate compressible data (default: false)
bool include_metadata = 5; // Include checksum (default: true)
float error_rate = 6; // Error injection rate 0.0-1.0 (default: 0.0)
}
message UnarySizedResponseData {
bytes data = 1; // Response payload
int64 data_size = 2; // Size in bytes
int64 timestamp_ms = 3; // Response timestamp
string checksum = 4; // MD5 checksum (if metadata enabled)
}
Use Cases: - π Unary Bandwidth Testing: Measure single-message throughput - π¦ Compression Testing: Compare compressible vs random data in unary calls - π₯ Error Handling: Test unary error responses - β Data Integrity: Verify checksums in single response - π Protocol Comparison: Compare streaming vs unary performance
Key Differences from GetSizedResponse:
- Returns one message instead of streaming multiple chunks
- Max size 100MB (vs 1GB for streaming)
- stream_size and delay_ms parameters are ignored
- Lower overhead for single-shot responses
- Better for testing unary RPC performance
# Small test: 1KB response
grpcurl -plaintext -d '{
"total_size": 1024,
"compressible": false,
"include_metadata": true,
"error_rate": 0.0
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# Medium test: 100KB with compression
grpcurl -plaintext -d '{
"total_size": 102400,
"compressible": true,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# Large test: 10MB unary response
grpcurl -plaintext -d '{
"total_size": 10485760,
"compressible": false,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse > /dev/null
# Performance test: 50MB (measure throughput)
time grpcurl -plaintext -d '{
"total_size": 52428800,
"compressible": false,
"include_metadata": false
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse > /dev/null
# Compression comparison test
echo "=== Compressible data (repeating pattern) ==="
grpcurl -plaintext -d '{
"total_size": 1048576,
"compressible": true
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse | wc -c
echo "=== Random data (incompressible) ==="
grpcurl -plaintext -d '{
"total_size": 1048576,
"compressible": false
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse | wc -c
# Error injection test: 30% error rate
grpcurl -plaintext -d '{
"total_size": 10240,
"error_rate": 0.3,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# Data integrity test: Verify checksum
grpcurl -plaintext -d '{
"total_size": 10240,
"include_metadata": true
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse | grep checksum
Sample Output:
{
"data": "eNqrVspIzc3MU7JSKi4p...[base64 encoded data]",
"dataSize": "10240",
"timestampMs": "1737650000000",
"checksum": "5d41402abc4b2a76b9719d911017c592"
}
# Via HTTPS proxy
grpcurl -insecure -d '{
"total_size": 102400,
"compressible": false,
"include_metadata": true
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/UnarySizedResponse
# With service target header
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-d '{
"total_size": 1048576,
"compressible": true
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/UnarySizedResponse
# Performance benchmark through proxy
time grpcurl -insecure -d '{
"total_size": 10485760,
"include_metadata": false
}' grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/UnarySizedResponse > /dev/null
# Small test: 1KB response
python3 /tmp/job_orchestrator_helper.py sized_response 0 1024 0 false true 0.0 > /tmp/unary_request1.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_request1.bin \
-o /tmp/unary_response1.bin \
-k
# Parse the response
python3 /tmp/parse_job_response.py /tmp/unary_response1.bin joborchestrator.UnarySizedResponseData
# Medium test: 100KB with compression
python3 /tmp/job_orchestrator_helper.py sized_response 0 102400 0 true true 0.0 > /tmp/unary_request2.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_request2.bin \
-o /tmp/unary_response2.bin \
-k
python3 /tmp/parse_job_response.py /tmp/unary_response2.bin joborchestrator.UnarySizedResponseData
# Performance test: 10MB (measure time)
python3 /tmp/job_orchestrator_helper.py sized_response 0 10485760 0 false false 0.0 > /tmp/unary_perf.bin
time curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_perf.bin \
-o /tmp/unary_perf_response.bin \
-k
echo "Response size: $(wc -c < /tmp/unary_perf_response.bin) bytes"
# Compression comparison
echo "=== Compressible data test ==="
python3 /tmp/job_orchestrator_helper.py sized_response 0 1048576 0 true true 0.0 > /tmp/unary_compress.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_compress.bin \
-o /tmp/unary_compress_response.bin \
-k
echo "Compressible response size: $(wc -c < /tmp/unary_compress_response.bin) bytes"
echo "=== Random data test ==="
python3 /tmp/job_orchestrator_helper.py sized_response 0 1048576 0 false true 0.0 > /tmp/unary_random.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_random.bin \
-o /tmp/unary_random_response.bin \
-k
echo "Random response size: $(wc -c < /tmp/unary_random_response.bin) bytes"
# Data integrity test: Verify checksum
python3 /tmp/job_orchestrator_helper.py sized_response 0 10240 0 false true 0.0 > /tmp/unary_checksum.bin
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/UnarySizedResponse \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/unary_checksum.bin \
-o /tmp/unary_checksum_response.bin \
-k
echo "=== Verifying checksum ==="
python3 /tmp/parse_job_response.py /tmp/unary_checksum_response.bin joborchestrator.UnarySizedResponseData | grep checksum
Sample gRPC-Web Response Output:
=== Frame 0 (Data) ===
data: "\000\001\002\003\004..." [10240 bytes]
data_size: 10240
timestamp_ms: 1737650000000
checksum: "5d41402abc4b2a76b9719d911017c592"
=== Frame 1 (Trailers) ===
grpc-status: 0
grpc-message:
grpc-server-stats-bin: [binary data]
grpc-retry-pushback-ms: 1234
endpoint-load-metrics-bin: [binary data]
x-trace-id: a1b2c-d3e4f-5g6h7
# Test input validation - total_size = 0
grpcurl -plaintext -d '{
"total_size": 0
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: total_size must be greater than 0
# Test input validation - total_size too large (>100MB)
grpcurl -plaintext -d '{
"total_size": 110000000
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: total_size cannot exceed 100MB (104857600 bytes) for unary response
# Test input validation - error_rate out of range
grpcurl -plaintext -d '{
"total_size": 1024,
"error_rate": 2.0
}' localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse
# ERROR: Code: InvalidArgument
# Message: Payload not as expected: error_rate must be between 0.0 and 1.0
#!/bin/bash
# compare_streaming_vs_unary.sh - Compare performance
echo "=== Streaming vs Unary Performance Comparison ==="
echo ""
SIZE=10485760 # 10MB test
echo "Test 1: Streaming (GetSizedResponse) - 1MB chunks, 10MB total"
time grpcurl -plaintext -d "{
\"stream_size\": 1048576,
\"total_size\": $SIZE,
\"include_metadata\": false
}" localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse > /tmp/streaming_result.txt
echo "Streaming size: $(wc -c < /tmp/streaming_result.txt) bytes"
echo ""
echo "Test 2: Unary (UnarySizedResponse) - 10MB single response"
time grpcurl -plaintext -d "{
\"total_size\": $SIZE,
\"include_metadata\": false
}" localhost:50055 joborchestrator.JobOrchestrator/UnarySizedResponse > /tmp/unary_result.txt
echo "Unary size: $(wc -c < /tmp/unary_result.txt) bytes"
echo ""
echo "=== Results ==="
echo "Both methods transfer the same amount of data."
echo "Streaming: Better for large transfers, supports backpressure, progress tracking"
echo "Unary: Lower overhead for smaller transfers, simpler client handling"
When to use UnarySizedResponse vs GetSizedResponse:
| Scenario | Use UnarySizedResponse | Use GetSizedResponse |
|---|---|---|
| Response size | < 10MB | > 10MB or any size |
| Progress tracking | Not needed | Required |
| Backpressure | Not applicable | Important |
| Client complexity | Simpler | More complex |
| Memory usage | Buffers entire response | Processes chunks |
| Network efficiency | Single round-trip | Multiple messages |
Send an empty request and receive only gRPC trailers with no meaningful response body. This endpoint is useful for:
gRPC Definition:
rpc JustTrailers(Empty) returns (Empty);
message Empty {
// No fields - completely empty message
}
Trailers Sent:
- grpc-server-stats-bin: Binary server statistics (CPU, memory)
- grpc-retry-pushback-ms: Retry delay hint in milliseconds
- endpoint-load-metrics-bin: Binary load metrics (QPS, connections, latency)
- x-trace-id: Unique request trace identifier
- client-version: gRPC client version
- feature-flags: Feature flag indicators
- auth-token-bin: Binary authentication token (customizable size via auth-token-bin-size header)
# Simple call - returns empty response with trailers
grpcurl -plaintext -d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers
# View with verbose output to see trailers
grpcurl -v -plaintext -d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers
# With custom auth token size (100 bytes)
grpcurl -plaintext \
-rpc-header "auth-token-bin-size: 100" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers
# With large auth token (1MB) for metadata testing
grpcurl -v -plaintext \
-rpc-header "auth-token-bin-size: 1048576" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers
# Test simulated error status
grpcurl -plaintext \
-rpc-header "simulate-grpc-status: 7" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers
# ERROR: Code: PermissionDenied
# Message: Simulated PERMISSION_DENIED: The caller does not have permission
Sample Response (verbose mode):
Resolved method descriptor:
rpc JustTrailers ( .joborchestrator.Empty ) returns ( .joborchestrator.Empty );
Request metadata to send:
(empty)
Response headers received:
content-type: application/grpc
grpc-accept-encoding: identity, deflate, gzip
Response contents:
{
}
Response trailers received:
auth-token-bin: <binary data>
client-version: 1.76.0
endpoint-load-metrics-bin: <binary data>
feature-flags: beta-mode
grpc-retry-pushback-ms: 2341
grpc-server-stats-bin: <binary data>
x-trace-id: 3f8a2-c7d91-4e2b3
Sent 1 request and received 1 response
# Via HTTPS proxy
grpcurl -insecure -d '{}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/JustTrailers
# With service target header
grpcurl -v -insecure \
-H "x-service-target: job-orchestrator" \
-d '{}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/JustTrailers
# With custom metadata size through proxy
grpcurl -insecure \
-H "x-service-target: job-orchestrator" \
-rpc-header "auth-token-bin-size: 10240" \
-d '{}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/JustTrailers
# Test malformed trailers simulation (Envoy only)
grpcurl -v -insecure \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-headers: malformed" \
-d '{}' \
grpc-envoy.qa.akamai.com:443 joborchestrator.JobOrchestrator/JustTrailers
# ERROR: Code: Internal
# Message: transport: malformed grpc-status: strconv.ParseInt: parsing "INVALID_STATUS": invalid syntax
# Create empty request (Empty message has no fields)
python3 -c "import struct; data = b'\\x00' + struct.pack('>I', 0); import sys; sys.stdout.buffer.write(data)" > /tmp/just_trailers.bin
# Send request
curl -v -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/JustTrailers \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "X-User-Agent: grpc-web-javascript/0.1" \
-H "x-service-target: job-orchestrator" \
--data-binary @/tmp/just_trailers.bin \
--output /tmp/just_trailers_response.bin \
-k
# Parse response (will show empty body + trailers)
python3 -c "
import struct
with open('/tmp/just_trailers_response.bin', 'rb') as f:
data = f.read()
i = 0
while i < len(data):
if i + 5 > len(data):
break
flag = data[i]
length = struct.unpack('>I', data[i+1:i+5])[0]
i += 5
body = data[i:i+length]
i += length
if flag == 0:
print('=== Response Body (Empty) ===')
print(f'Length: {length} bytes')
elif flag == 0x80:
print('=== Trailers ===')
print(body.decode('utf-8', errors='ignore'))
"
# With custom auth token size
curl -s -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/JustTrailers \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
-H "auth-token-bin-size: 10240" \
--data-binary @/tmp/just_trailers.bin \
-o /tmp/just_trailers_large_response.bin \
-k
echo "Response size with 10KB auth token: $(wc -c < /tmp/just_trailers_large_response.bin) bytes"
# Test error simulation
curl -v -X POST \
https://grpc-envoy.qa.akamai.com/joborchestrator.JobOrchestrator/JustTrailers \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: job-orchestrator" \
-H "simulate-grpc-status: 14" \
--data-binary @/tmp/just_trailers.bin \
-k 2>&1 | grep -E "< grpc-status|< grpc-message"
# < grpc-status: 14
# < grpc-message: Simulated UNAVAILABLE: The service is currently unavailable
Sample gRPC-Web Response:
=== Response Body (Empty) ===
Length: 0 bytes
=== Trailers ===
grpc-status:0
grpc-message:
grpc-server-stats-bin:<binary>
grpc-retry-pushback-ms:1543
endpoint-load-metrics-bin:<binary>
x-trace-id:7b2f4-9a1c3-d5e87
client-version:1.76.0
feature-flags:beta-mode
auth-token-bin:<binary>
1. Trailer Header Testing:
# Test client's ability to handle various trailer sizes
for size in 100 1000 10000 100000 1000000; do
echo "Testing with $size byte auth token..."
grpcurl -plaintext \
-rpc-header "auth-token-bin-size: $size" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers > /dev/null
echo "β Success"
done
2. Minimal Overhead Benchmark:
# Benchmark fastest possible RPC call
echo "=== Minimal Overhead Benchmark ==="
time for i in {1..100}; do
grpcurl -plaintext -d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers > /dev/null 2>&1
done
echo "Average per call: $(echo 'scale=4; TIME/100' | bc)s"
3. Trailer Inspection:
# Extract and analyze trailer headers
grpcurl -v -plaintext -d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers 2>&1 | \
grep -A 20 "Response trailers received:"
4. Metadata Size Testing:
# Test impact of different metadata sizes on performance
echo "=== Metadata Size Impact Test ==="
for size in 0 1000 10000 100000 1000000; do
echo -n "Size: ${size} bytes - "
time grpcurl -plaintext \
-rpc-header "auth-token-bin-size: $size" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers > /dev/null 2>&1
done
5. Concurrent Trailer Testing:
# Test concurrent calls with trailer-only responses
echo "=== Concurrency Test (100 parallel calls) ==="
for i in {1..100}; do
grpcurl -plaintext -d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers > /dev/null 2>&1 &
done
wait
echo "β All 100 calls completed"
6. Error Status Testing:
# Test all error codes with trailers-only endpoint
for code in {1..16}; do
echo "Testing status code $code..."
grpcurl -plaintext \
-rpc-header "simulate-grpc-status: $code" \
-d '{}' \
localhost:50055 joborchestrator.JobOrchestrator/JustTrailers 2>&1 | \
grep -E "Code:|Message:"
echo ""
done
Key Features:
- β
Empty request and response (minimal payload)
- β
Full set of trailer headers (metrics, trace ID, auth token)
- β
Customizable auth token size via auth-token-bin-size header
- β
Compatible with error simulation via simulate-grpc-status header
- β
Works with malformed trailer simulation (Envoy only)
- β
Useful for benchmarking minimum RPC overhead
- β
Perfect for testing trailer handling in gRPC clients
Note: This endpoint returns the same trailers as other endpoints, but with an empty response body, making it ideal for testing trailer-specific functionality without the overhead of processing response data.
Comprehensive test script demonstrating all RPC patterns:
#!/bin/bash
# job_orchestrator_automation.sh
ENDPOINT="https://grpc-envoy.qa.akamai.com"
SERVICE_TARGET="job-orchestrator"
echo "=== Job Orchestrator Service - Complete Automation Demo ==="
echo "Target: $ENDPOINT"
echo ""
# Step 1: Submit a job (Unary RPC) with custom steps
echo "1. Submitting a new job with 5 steps (UNARY RPC)..."
python3 /tmp/job_orchestrator_helper.py submit_job "automation-test" steps=5 env=qa type=smoke > /tmp/submit.bin
curl -s -X POST "$ENDPOINT/joborchestrator.JobOrchestrator/SubmitJob" \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: $SERVICE_TARGET" \
--data-binary @/tmp/submit.bin \
-o /tmp/submit_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/submit_response.bin joborchestrator.JobAck
# Extract job ID (simplified - in real script use proper parsing)
JOB_ID=$(python3 -c "
import struct
with open('/tmp/submit_response.bin', 'rb') as f:
data = f.read()
if len(data) > 5:
flag = data[0]
length = struct.unpack('>I', data[1:5])[0]
body = data[5:5+length]
# Simple extraction - job_id is field 1
start = body.find(b'\\x0a') + 2
id_len = body[start-1]
print(body[start:start+id_len].decode('utf-8'))
" 2>/dev/null || echo "test-job-123")
echo "Job ID: $JOB_ID"
echo ""
# Step 2: Check job status (Unary RPC)
echo "2. Checking job status (UNARY RPC)..."
sleep 1
python3 /tmp/job_orchestrator_helper.py get_status "$JOB_ID" > /tmp/status.bin
curl -s -X POST "$ENDPOINT/joborchestrator.JobOrchestrator/GetJobStatus" \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: $SERVICE_TARGET" \
--data-binary @/tmp/status.bin \
-o /tmp/status_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/status_response.bin joborchestrator.JobStatus
echo ""
# Step 3: Watch job progress (Server Streaming - using grpcurl)
echo "3. Watching job progress for 20 seconds (SERVER STREAMING RPC)..."
timeout 20 grpcurl -insecure \
-H "x-service-target: $SERVICE_TARGET" \
-d "{\"id\":\"$JOB_ID\"}" \
$ENDPOINT joborchestrator.JobOrchestrator/WatchJob 2>/dev/null || true
echo ""
# Step 4: Push some logs (Client Streaming - using CLI)
echo "4. Pushing logs to job (CLIENT STREAMING RPC)..."
cat > /tmp/automation_logs.txt << 'EOFLOG'
INFO: Automation test started
DEBUG: Initializing test environment
INFO: Running test suite
WARN: Test case 3 took longer than expected
ERROR: Test case 5 failed
INFO: Retrying failed test
INFO: All tests completed
EOFLOG
cd job-orchestrator-service 2>/dev/null || cd /home/grpc-envoy-proxy/job-orchestrator-service
python -m client.cli push-logs --job-id "$JOB_ID" /tmp/automation_logs.txt
cd - > /dev/null
echo ""
# Step 5: Final status check
echo "5. Final status check (UNARY RPC)..."
curl -s -X POST "$ENDPOINT/joborchestrator.JobOrchestrator/GetJobStatus" \
-H "Content-Type: application/grpc-web+proto" \
-H "X-Grpc-Web: 1" \
-H "x-service-target: $SERVICE_TARGET" \
--data-binary @/tmp/status.bin \
-o /tmp/status_final_response.bin \
-k
python3 /tmp/parse_job_response.py /tmp/status_final_response.bin joborchestrator.JobStatus
echo ""
echo "=== Automation Demo Complete ==="
echo ""
echo "Summary of tested RPC patterns:"
echo " β Unary RPC: SubmitJob (5 steps), GetJobStatus"
echo " β Server Streaming: WatchJob (watched all 5 steps)"
echo " β Client Streaming: PushLogs"
echo " βΉ Bidirectional Streaming: Use 'python -m client.cli shell --job-id $JOB_ID'"
echo ""
echo "Tip: Control streaming duration with 'steps' parameter (1-1000)"
echo ""
echo "For interactive bidirectional streaming, run:"
echo " cd job-orchestrator-service"
echo " python -m client.cli shell --job-id $JOB_ID"
chmod +x job_orchestrator_automation.sh
All gRPC-Web responses follow this format: - First 5 bytes: gRPC frame header - Byte 0: Compression flag (0x00 = uncompressed, 0x80 = trailer) - Bytes 1-4: Message length (big-endian uint32) - Remaining bytes: Protobuf message data - Trailers: gRPC status and message headers (in trailer frame)
Example error response:
=== Frame 0 (Trailers) ===
grpc-status:5
grpc-message:Job abc123 not found
βββββββββββββββ ββββββββββββββββββββ
β β 1. SubmitJob β β
β βββββββββββββββββββββΊβ β
β β 2. GetJobStatus β Job Orchestratorβ
β βββββββββββββββββββββΊβ gRPC Server β
β Clients β 3. PushLogs βββΊ β (port 50055) β
β β (stream) β β
β - CLI β 4. WatchJob β Features: β
β - TUI β βββ stream β β’ State store β
β - Web β 5. Interactive β β’ Job execution β
β β ββββΊ stream β β’ Pub/Sub β
βββββββββββββββ ββββββββββββββββββββ
python -m client.cli submit --name smoke-tests --param env=qa
Pattern: Single request β Single response
python -m client.cli push-logs --job-id abc123 test_logs.txt
Pattern: Stream of log lines β Summary response
python -m client.cli watch --job-id abc123
Pattern: Single request β Stream of job updates
python -m client.cli shell --job-id abc123
> PAUSE
> GET_STATUS
> RESUME
> quit
Pattern: Stream of commands β Stream of events
# Test with 10KB chunks, 100KB total
grpcurl -plaintext -d '{
"stream_size": 10240,
"total_size": 102400,
"delay_ms": 100,
"compressible": false,
"include_metadata": true,
"error_rate": 0.0
}' localhost:50055 joborchestrator.JobOrchestrator/GetSizedResponse
Pattern: Configurable request β Stream of sized data chunks
Add to your docker-compose.yaml:
job-orchestrator-service:
build:
context: ./job-orchestrator-service
networks: [default]
expose:
- "50055"
ports:
- "50055:50055"
restart: unless-stopped
Add to envoy.yaml clusters:
- name: job-orchestrator-service
connect_timeout: 2s
type: STRICT_DNS
http2_protocol_options: {}
load_assignment:
cluster_name: job-orchestrator-service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: job-orchestrator-service
port_value: 50055
Add route:
- match:
prefix: "/joborchestrator.JobOrchestrator/"
route:
cluster: job-orchestrator-service
timeout: 60s
job-orchestrator-service/
βββ proto/
β βββ job_orchestrator.proto # Service definition (all 4 patterns)
βββ server/
β βββ main.py # Server with reflection
β βββ service_impl.py # All RPC implementations
β βββ models.py # Job and log models
β βββ state_store.py # In-memory state with pub/sub
βββ client/
β βββ cli.py # CLI for all patterns
β βββ tui_app.py # Full TUI (Textual)
βββ generated/ # Auto-generated protobuf code
βββ Makefile # Build targets
βββ Dockerfile # Container image
βββ README.md # Detailed documentation
Server Side:
- β
Async gRPC with grpc.aio
- β
In-memory state management
- β
Pub/Sub for job updates
- β
Background job execution
- β
gRPC reflection enabled
- β
Graceful shutdown
Client Side: - β CLI with all 4 RPC patterns - β Full-screen TUI using Textual - β Async bidirectional streaming - β Real-time job monitoring - β Interactive job control
# List services (requires reflection)
grpcurl -plaintext localhost:50055 list
# Submit job
grpcurl -plaintext -d '{"name":"test","params":{"env":"qa"}}' \
localhost:50055 joborchestrator.JobOrchestrator/SubmitJob
# Watch job (server streaming)
grpcurl -plaintext -d '{"id":"abc123"}' \
localhost:50055 joborchestrator.JobOrchestrator/WatchJob
For complete details, see: job-orchestrator-service/README.md
This service demonstrates production-ready gRPC patterns with proper async handling, state management, and both CLI and TUI clients! π