mirror of https://github.com/dapr/quickstarts.git
test mechanical markdown updates
Signed-off-by: Kendall Roden <kendall@diagrid.io>
This commit is contained in:
parent
b06a7fb076
commit
a0e51c82cb
|
@ -41,10 +41,19 @@ pip3 install -r requirements.txt
|
|||
<!-- STEP
|
||||
name: Run multi app run template
|
||||
expected_stdout_lines:
|
||||
- '== APP - job-service == Received job request...'
|
||||
- '== APP - job-service == Executing maintenance job: Oil Change'
|
||||
- '== APP - job-scheduler == Sending request to schedule job: R2-D2'
|
||||
- '== APP - job-scheduler == Job Scheduled: R2-D2'
|
||||
- '== APP - job-scheduler == Sending request to retrieve job: R2-D2'
|
||||
- '== APP - job-scheduler == Job details for R2-D2: {"name":"R2-D2","dueTime":"15s","data":{"@type":"type.googleapis.com/google.protobuf.Value","value":{"@type":"type.googleapis.com/google.protobuf.StringValue","value":"R2-D2:Oil Change"}},"failurePolicy":{"constant":{"interval":"1s","maxRetries":3}}}'
|
||||
- '== APP - job-scheduler == Sending request to schedule job: C-3PO'
|
||||
- '== APP - job-scheduler == Job Scheduled: C-3PO'
|
||||
- '== APP - job-service == Received job request...'
|
||||
- '== APP - job-service == Starting droid: R2-D2'
|
||||
- '== APP - job-service == Executing maintenance job: Oil Change'
|
||||
- '== APP - job-scheduler == Sending request to retrieve job: C-3PO'
|
||||
- '== APP - job-scheduler == Job details for C-3PO: {"name":"C-3PO","dueTime":"20s","data":{"@type":"type.googleapis.com/google.protobuf.Value","value":{"@type":"type.googleapis.com/google.protobuf.StringValue","value":"C-3PO:Limb Calibration"}},"failurePolicy":{"constant":{"interval":"1s","maxRetries":3}}}'
|
||||
- '== APP - job-service == Received job request...'
|
||||
- '== APP - job-service == Starting droid: C-3PO'
|
||||
- '== APP - job-service == Executing maintenance job: Limb Calibration'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
|
@ -68,13 +77,17 @@ The terminal console output should look similar to this, where:
|
|||
- The `C-3PO` job is being executed after 20 seconds.
|
||||
|
||||
```text
|
||||
== APP - job-scheduler == Sending request to schedule job: R2-D2
|
||||
== APP - job-scheduler == Job scheduled: R2-D2
|
||||
== APP - job-scheduler == Sending request to retrieve job: R2-D2
|
||||
== APP - job-scheduler == Job details for R2-D2: {"name":"R2-D2","dueTime":"15s","data":{"@type":"type.googleapis.com/google.protobuf.Value","value":{"@type":"type.googleapis.com/google.protobuf.StringValue","value":"R2-D2:Oil Change"}},"failurePolicy":{"constant":{"interval":"1s","maxRetries":3}}}
|
||||
== APP - job-scheduler == Sending request to schedule job: C-3PO
|
||||
== APP - job-scheduler == Job scheduled: C-3PO
|
||||
== APP - job-service == Received job request...
|
||||
== APP - job-service == Starting droid: R2-D2
|
||||
== APP - job-service == Executing maintenance job: Oil Change
|
||||
== APP - job-service == 127.0.0.1 - - "POST /job/R2-D2 HTTP/1.1" 200 -
|
||||
== APP - job-scheduler == Sending request to retrieve job: C-3PO
|
||||
== APP - job-scheduler == Job details for C-3PO: {"name":"C-3PO","dueTime":"20s","data":{"@type":"type.googleapis.com/google.protobuf.Value","value":{"@type":"type.googleapis.com/google.protobuf.StringValue","value":"C-3PO:Limb Calibration"}},"failurePolicy":{"constant":{"interval":"1s","maxRetries":3}}}
|
||||
== APP - job-service == Received job request...
|
||||
== APP - job-service == Starting droid: C-3PO
|
||||
|
@ -182,4 +195,4 @@ You should see an error message indicating that the job was not found:
|
|||
|
||||
```text
|
||||
{"errorCode":"DAPR_SCHEDULER_GET_JOB","message":"failed to get job due to: rpc error: code = NotFound desc = job not found: c-3po","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","domain":"dapr.io","metadata":{"appID":"job-service","namespace":"default"},"reason":"DAPR_SCHEDULER_GET_JOB"}]}
|
||||
```
|
||||
```
|
||||
|
|
|
@ -16,8 +16,12 @@ R2D2_JOB_BODY = {
|
|||
dapr_host = os.getenv('DAPR_HOST', 'http://localhost')
|
||||
job_service_dapr_http_port = os.getenv('JOB_SERVICE_DAPR_HTTP_PORT', '6280')
|
||||
|
||||
|
||||
def schedule_job(host: str, port: str, job_name: str, job_body: dict) -> None:
|
||||
req_url = f"{host}:{port}/v1.0-alpha1/jobs/{job_name}"
|
||||
|
||||
print(f"Sending request to schedule job: {job_name}", flush=True)
|
||||
|
||||
try:
|
||||
response = requests.post(
|
||||
req_url,
|
||||
|
@ -29,24 +33,33 @@ def schedule_job(host: str, port: str, job_name: str, job_body: dict) -> None:
|
|||
if response.status_code not in [200, 204]:
|
||||
raise Exception(
|
||||
f"Failed to schedule job. Status code: {response.status_code}, Response: {response.text}")
|
||||
|
||||
print(f"Job scheduled: {job_name}", flush=True)
|
||||
|
||||
if response.text:
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error scheduling job {job_name}: {str(e)}", flush=True)
|
||||
raise
|
||||
|
||||
|
||||
def get_job_details(host: str, port: str, job_name: str) -> None:
|
||||
req_url = f"{host}:{port}/v1.0-alpha1/jobs/{job_name}"
|
||||
|
||||
print(f"Sending request to retrieve job: {job_name}", flush=True)
|
||||
|
||||
try:
|
||||
response = requests.get(req_url, timeout=15)
|
||||
if response.status_code in [200, 204]:
|
||||
print(f"Job details for {job_name}: {response.text}", flush=True)
|
||||
else:
|
||||
print(f"Failed to get job details. Status code: {response.status_code}, Response: {response.text}")
|
||||
print(
|
||||
f"Failed to get job details. Status code: {response.status_code}, Response: {response.text}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error getting job details for {job_name}: {str(e)}", flush=True)
|
||||
print(
|
||||
f"Error getting job details for {job_name}: {str(e)}", flush=True)
|
||||
raise
|
||||
|
||||
|
||||
|
@ -67,5 +80,6 @@ def main():
|
|||
get_job_details(dapr_host, job_service_dapr_http_port, "C-3PO")
|
||||
time.sleep(30)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -38,11 +38,22 @@ pip3 install -r requirements.txt
|
|||
<!-- STEP
|
||||
name: Run multi app run template
|
||||
expected_stdout_lines:
|
||||
- '== APP - job-service == Received job request...'
|
||||
- '== APP - job-scheduler == Sending request to schedule job: R2-D2'
|
||||
- '== APP - job-service == Scheduling job: R2-D2'
|
||||
- '== APP - job-service == Job scheduled: R2-D2'
|
||||
- '== APP - job-scheduler == Response: {"name":"R2-D2","job":"Oil Change","dueTime":15}'
|
||||
- '== APP - job-scheduler == Sending request to retrieve job: R2-D2'
|
||||
- '== APP - job-service == Retrieving job: R2-D2'
|
||||
- '== APP - job-scheduler == Job details for R2-D2: {"name":"R2-D2","due_time":"15s","data":{"droid":"R2-D2","task":"Oil Change"}}'
|
||||
- '== APP - job-scheduler == Sending request to schedule job: C-3PO'
|
||||
- '== APP - job-service == Scheduling job: C-3PO'
|
||||
- '== APP - job-service == Job scheduled: C-3PO'
|
||||
- '== APP - job-service == Starting droid: R2-D2'
|
||||
- '== APP - job-service == Executing maintenance job: Oil Change'
|
||||
- '== APP - job-scheduler == Job Scheduled: C-3PO'
|
||||
- '== APP - job-service == Received job request...'
|
||||
- '== APP - job-service == Executing maintenance job: Limb Calibration'
|
||||
- '== APP - job-scheduler == Response: {"name":"C-3PO","job":"Limb Calibration","dueTime":20}'
|
||||
- '== APP - job-scheduler == Sending request to retrieve job: C-3PO'
|
||||
- '== APP - job-service == Retrieving job: C-3PO'
|
||||
- '== APP - job-scheduler == Job details for C-3PO: {"name":"C-3PO","due_time":"20s","data":{"droid":"C-3PO","task":"Limb Calibration"}}'
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
match_order: none
|
||||
|
|
|
@ -46,7 +46,7 @@ def schedule_job(job: DroidJob) -> None:
|
|||
# Accept both 200 and 204 as success codes
|
||||
if response.status_code not in [200, 204]:
|
||||
raise Exception(
|
||||
f"Failed to schedule job. Status code: {response.status_code}, Response: {response.text}")
|
||||
f"Failed to schedule job. Status code: {response.status_code}, Response: {response.text}", flush=True)
|
||||
|
||||
if response.text:
|
||||
print(f"Response: {response.text}")
|
||||
|
@ -69,10 +69,12 @@ def get_job_details(job: DroidJob) -> None:
|
|||
if response.status_code in [200, 204]:
|
||||
print(f"Job details for {job.name}: {response.text}", flush=True)
|
||||
else:
|
||||
print(f"Failed to get job details. Status code: {response.status_code}, Response: {response.text}")
|
||||
print(
|
||||
f"Failed to get job details. Status code: {response.status_code}, Response: {response.text}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error getting job details for {job.name}: {str(e)}", flush=True)
|
||||
print(
|
||||
f"Error getting job details for {job.name}: {str(e)}", flush=True)
|
||||
raise
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue