Quickstart autovalidation now works on windows (#431)

This commit is contained in:
Charlie Stanley 2021-05-25 15:35:08 -07:00 committed by GitHub
parent 3930248f9d
commit afdc6ffe27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 310 additions and 188 deletions

View File

@ -52,14 +52,14 @@ sleep: 20
docker-compose -f ./docker-compose-single-kafka.yml up -d
```
<!-- END_STEP -->
2. To see the container running locally, run:
```bash
docker ps
```
<!-- END_STEP -->
The output should be similar to this:
```bash
@ -100,8 +100,9 @@ name: Run node app
working_dir: ./nodeapp
background: true
sleep: 5
output_match_mode: substring
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 1 }"
- "== APP == Hello from Kafka!"
@ -109,17 +110,8 @@ expected_stdout_lines:
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 3 }"
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 4 }"
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 5 }"
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 6 }"
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 7 }"
- "== APP == Hello from Kafka!"
- "== APP == { orderId: 8 }"
- "✅ Exited Dapr successfully"
- "✅ Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
-->
```bash
@ -157,26 +149,18 @@ pip3 install requests
name: Run node app
working_dir: ./pythonapp
background: true
sleep: 15
sleep: 25
output_match_mode: substring
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == {'data': {'orderId': 1}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 2}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 3}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 4}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 5}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 6}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 7}, 'operation': 'create'}"
- "== APP == <Response [204]>"
- "== APP == {'data': {'orderId': 8}, 'operation': 'create'}"
- "✅ Exited Dapr successfully"
- "✅ Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
-->
```bash
@ -214,15 +198,19 @@ dapr run --app-id bindings-pythonapp python3 app.py --components-path ./componen
To cleanly stop the dapr microservices, run:
<!-- STEP
output_match_mode: substring
expected_stdout_lines:
- 'app stopped successfully: bindings-nodeapp'
- 'app stopped successfully: bindings-pythonapp'
- 'app stopped successfully: bindings-nodeapp'
- 'app stopped successfully: bindings-pythonapp'
expected_stderr_lines:
name: Shutdown Dapr and Kafka
-->
```bash
dapr stop --app-id bindings-nodeapp
```
```bash
dapr stop --app-id bindings-pythonapp
```
@ -249,8 +237,17 @@ timeout_seconds: 120
```bash
helm repo add bitnami https://charts.bitnami.com/bitnami
```
```bash
helm repo update
```
```bash
kubectl create ns kafka
```
```bash
helm install dapr-kafka bitnami/kafka --wait --namespace kafka -f ./kafka-non-persistence.yaml
```
@ -270,12 +267,10 @@ dapr-kafka-zookeeper-0 1/1 Running 0 2m57s
Now that the Kafka binding is set up, deploy the assets.
1. In your CLI window, navigate to the deploy directory
2. Run:
1. In your CLI window, in the bindings directory run:
<!-- STEP
name: Run kubernetes apps
working_dir: ./deploy
sleep: 30
expected_stdout_lines:
- component.dapr.io/sample-topic created
@ -287,7 +282,7 @@ expected_stdout_lines:
-->
```bash
kubectl apply -f .
kubectl apply -f ./deploy
```
This will deploy bindings-nodeapp and bindings-pythonapp microservices. It will also apply the Kafka bindings component configuration you set up in the last step.
@ -296,14 +291,15 @@ Kubernetes deployments are asyncronous. This means you'll need to wait for the d
```bash
kubectl rollout status deploy/bindings-nodeapp
```
```bash
kubectl rollout status deploy/bindings-pythonapp
```
<!-- END_STEP -->
3. Run `kubectl get pods` to see that pods were correctly provisioned.
2. Run `kubectl get pods` to see that pods were correctly provisioned.
### Observe Logs
@ -392,7 +388,7 @@ Hello from Kafka!
### Cleanup
Once you're done, you can spin down your Kubernetes resources by navigating to the `./deploy` directory and running:
Once you're done, you can spin down your Kubernetes resources by running:
<!-- STEP
name: Cleanup
@ -400,8 +396,7 @@ expected_stdout_lines:
-->
```bash
cd ./deploy
kubectl delete -f .
kubectl delete -f ./deploy
```
This will spin down each resource defined by the .yaml files in the `deploy` directory, including the kafka component.

View File

@ -59,11 +59,12 @@ working_dir: "./go"
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Adding 56.000000 to 3.000000"
- "Exited Dapr successfully"
- "Exited App successfully"
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Adding 52.000000 to 34.000000"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
name: "Run go app"
working_dir: "./go"
background: true
@ -83,7 +84,9 @@ sleep: 2
```bash
#Linux/Mac OS:
export ASPNETCORE_URLS="http://localhost:7000"
```
```bash
#Windows:
set ASPNETCORE_URLS=http://localhost:7000
```
@ -102,12 +105,13 @@ working_dir: "./csharp"
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Subtracting 34 from 52"
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
name: "Run dotnet app"
output_match_mode: substring
working_dir: "./csharp/bin/Debug/netcoreapp3.1"
background: true
env:
@ -128,7 +132,6 @@ sleep: 2
<!-- STEP
name: "Build node app"
working_dir: "./node"
timeout_seconds: 300
-->
- Install dependencies by running the command:
@ -140,11 +143,12 @@ timeout_seconds: 300
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Dividing 144 by 12"
- "Exited Dapr successfully"
- "Exited App successfully"
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Dividing 52 by 34"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
name: "Run node app"
working_dir: "./node"
background: true
@ -183,13 +187,14 @@ working_dir: "./python"
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Calculating 52.0 * 34.0"
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
name: "Run python app"
working_dir: "./python"
output_match_mode: substring
background: true
env:
FLASK_RUN_PORT: "5000"
@ -209,7 +214,6 @@ sleep: 2
<!-- STEP
name: "Build frontend app"
working_dir: "./react-calculator"
timeout_seconds: 600
-->
- Install the required modules
@ -223,10 +227,11 @@ timeout_seconds: 600
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
name: "Run frontent app"
working_dir: "./react-calculator"
background: true
@ -260,43 +265,60 @@ manual_pause_message: "Calculator APP running on http://localhost:8080. Please o
<!-- STEP
expected_stdout_lines:
- "59"
- "86"
- "18"
- "12"
- "1.5294"
- "1768.0"
- '"54"'
- '"total":"54"'
output_match_mode: substring
name: "Curl test"
-->
- To make sure all the apps are working, you can run the following curl commands which will test all the operations:
```bash
curl -w "\n" -s 'http://localhost:8080/calculate/add' -H 'Content-Type: application/json' --data '{"operandOne":"56","operandTwo":"3"}'
curl -w "\n" -s 'http://localhost:8080/calculate/subtract' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
curl -w "\n" -s 'http://localhost:8080/calculate/divide' -H 'Content-Type: application/json' --data '{"operandOne":"144","operandTwo":"12"}'
curl -w "\n" -s 'http://localhost:8080/calculate/multiply' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
curl -w "\n" -s 'http://localhost:8080/persist' -H 'Content-Type: application/json' --data '[{"key":"calculatorState","value":{"total":"54","next":null,"operation":null}}]'
curl -s 'http://localhost:8080/state' | jq '.total'
curl -s http://localhost:8080/calculate/add -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8080/calculate/subtract -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8080/calculate/divide -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8080/calculate/multiply -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8080/persist -H Content-Type:application/json --data @persist.json
```
```bash
curl -s http://localhost:8080/state
```
<!-- END_STEP -->
- You should get the following output:
```bash
59
86
18
12
1.5294117647058822
1768.0
"54"
{"operation":null,"total":"54","next":null}
```
<!-- STEP
expected_stdout_lines:
- '✅ app stopped successfully: addapp'
- '✅ app stopped successfully: subtractapp'
- '✅ app stopped successfully: divideapp'
- '✅ app stopped successfully: multiplyapp'
- '✅ app stopped successfully: frontendapp'
- 'app stopped successfully: addapp'
- 'app stopped successfully: subtractapp'
- 'app stopped successfully: divideapp'
- 'app stopped successfully: multiplyapp'
- 'app stopped successfully: frontendapp'
output_match_mode: substring
name: Cleanup local
-->
@ -306,9 +328,21 @@ name: Cleanup local
```bash
dapr stop --app-id addapp
```
```bash
dapr stop --app-id subtractapp
```
```bash
dapr stop --app-id divideapp
```
```bash
dapr stop --app-id multiplyapp
```
```bash
dapr stop --app-id frontendapp
```
@ -317,7 +351,6 @@ name: Cleanup local
<!-- STEP
name: "cleanup node app"
working_dir: "./node"
timeout_seconds: 300
-->
- Uninstall node modules by navigating to the node directory and run:
@ -372,9 +405,21 @@ expected_stdout_lines:
```bash
kubectl rollout status deploy/addapp
```
```bash
kubectl rollout status deploy/subtractapp
```
```bash
kubectl rollout status deploy/divideapp
```
```bash
kubectl rollout status deploy/multiplyapp
```
```bash
kubectl rollout status deploy/calculator-front-end
```
@ -477,26 +522,41 @@ The client code calls to an Express server, which routes the calls through Dapr
7. **Optional:** If your environment doesn't have easy access to a browser, or you just like using curl
Then you can use the following curl commands to make sure each one of the microservies is working:
<!-- STEP
expected_stdout_lines:
- "59"
- "86"
- "18"
- "12"
- "1.5294"
- "1768.0"
- '"54"'
- '"total":"54"'
output_match_mode: substring
name: "Curl test"
-->
```bash
curl -w "\n" -s 'http://localhost:8000/calculate/add' -H 'Content-Type: application/json' --data '{"operandOne":"56","operandTwo":"3"}'
curl -w "\n" -s 'http://localhost:8000/calculate/subtract' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
curl -w "\n" -s 'http://localhost:8000/calculate/divide' -H 'Content-Type: application/json' --data '{"operandOne":"144","operandTwo":"12"}'
curl -w "\n" -s 'http://localhost:8000/calculate/multiply' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
curl -w "\n" -s 'http://localhost:8000/persist' -H 'Content-Type: application/json' --data '[{"key":"calculatorState","value":{"total":"54","next":null,"operation":null}}]'
curl -s 'http://localhost:8000/state' | jq '.total'
```bash
curl -s http://localhost:8000/calculate/add -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/subtract -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/divide -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/multiply -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/persist -H Content-Type:application/json --data @persist.json
```
```bash
curl -s http://localhost:8000/state
```
<!-- END_STEP -->
@ -504,12 +564,12 @@ curl -s 'http://localhost:8000/state' | jq '.total'
You should get the following output:
```bash
59
86
18
12
1.5294117647058822
1768.0
"54"
{"operation":null,"total":"54","next":null}
```
## Cleanup

View File

@ -0,0 +1 @@
{"operandOne":"52","operandTwo":"34"}

View File

@ -0,0 +1 @@
[{"key":"calculatorState","value":{"total":"54","next":null,"operation":null}}]

View File

@ -33,7 +33,7 @@ dapr init --kubernetes --wait
Sample output:
```
⌛ Making the jump to hyperspace...
Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
✅ Deploying the Dapr control plane to your cluster...
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run `dapr status -k' in your terminal. To get started, go here: https://aka.ms/dapr-getting-started
@ -172,7 +172,7 @@ expected_stdout_lines:
-->
```bash
curl --request POST --data "{\"data\": { \"orderId\": \"42\" } }" --header "Content-Type:application/json" http://localhost:8080/neworder
curl --request POST --data @sample.json --header Content-Type:application/json http://localhost:8080/neworder
```
<!-- END_STEP -->

View File

@ -0,0 +1 @@
{"data":{"orderId":"42"}}

View File

@ -112,6 +112,7 @@ app.get('/order', (_req, res) => {
This calls out to the Redis cache to retrieve the latest value of the "order" key, which effectively allows the Node.js app to be _stateless_.
## Step 3 - Run the Node.js app with Dapr
<!-- STEP
expected_stdout_lines:
expected_stderr_lines:
@ -130,7 +131,7 @@ This will install `express` and `body-parser`, dependencies that are shown in th
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Got a new order! Order ID: 42"
- "== APP == Successfully persisted state."
- "== APP == Got a new order! Order ID: 42"
@ -145,9 +146,10 @@ expected_stdout_lines:
- "== APP == Successfully persisted state."
- "== APP == Got a new order! Order ID: 5"
- "== APP == Successfully persisted state."
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
name: "run npm app"
background: true
sleep: 5
@ -197,27 +199,16 @@ Now that Dapr and the Node.js app are running, you can send POST messages agains
First, POST the message by using Dapr cli in a new command line terminal:
Windows Command Prompt
```sh
dapr invoke --app-id nodeapp --method neworder --data "{\"data\": { \"orderId\": \"42\" } }"
```
Windows PowerShell
```sh
dapr invoke --app-id nodeapp --method neworder --data '{\"data\": { \"orderId\": \"42\" } }'
```
Linux or MacOS
<!-- STEP
expected_stdout_lines:
- "App invoked successfully"
- "App invoked successfully"
expected_stderr_lines:
output_match_mode: substring
name: dapr invoke
-->
```bash
dapr invoke --app-id nodeapp --method neworder --data '{"data": { "orderId": "42" } }'
dapr invoke --app-id nodeapp --method neworder --data-file sample.json
```
<!-- END_STEP -->
@ -231,7 +222,7 @@ name: curl test
-->
```bash
curl -XPOST -d @sample.json -H "Content-Type:application/json" http://localhost:3500/v1.0/invoke/nodeapp/method/neworder
curl -XPOST -d @sample.json -H Content-Type:application/json http://localhost:3500/v1.0/invoke/nodeapp/method/neworder
```
<!-- END_STEP -->
@ -281,8 +272,9 @@ or use Dapr CLI
<!-- STEP
expected_stdout_lines:
- '{"orderId":"42"}'
- "App invoked successfully"
- "App invoked successfully"
expected_stderr_lines:
output_match_mode: substring
name: Persistence test dapr invoke
-->
@ -347,13 +339,14 @@ name: "Install python requirements"
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
name: "run python app"
background: true
sleep: 10
sleep: 30
-->
2. Start the Python App with Dapr:
@ -404,14 +397,18 @@ To stop your services from running, simply stop the "dapr run" process. Alternat
<!-- STEP
expected_stdout_lines:
- 'app stopped successfully: nodeapp'
- 'app stopped successfully: pythonapp'
- 'app stopped successfully: nodeapp'
- 'app stopped successfully: pythonapp'
expected_stderr_lines:
output_match_mode: substring
name: Shutdown dapr
-->
```bash
dapr stop --app-id nodeapp
```
```bash
dapr stop --app-id pythonapp
```

View File

@ -37,10 +37,11 @@ spec:
<!-- STEP
name: Run app with tracing
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
- "You're up and running! Both Dapr and your app logs will appear here."
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 5
-->
@ -56,14 +57,15 @@ cd ../hello-world && npm install && dapr run --app-id hello-tracing --app-port 3
<!-- STEP
expected_stdout_lines:
- "App invoked successfully"
- "App invoked successfully"
expected_stderr_lines:
output_match_mode: substring
name: dapr invoke
sleep: 2
-->
```bash
dapr invoke --app-id hello-tracing --method neworder --data '{"data": { "orderId": "42" } }'
dapr invoke --app-id hello-tracing --method neworder --data-file sample.json
```
<!-- END_STEP -->
@ -90,14 +92,15 @@ To see traces collected through the API:
<!-- STEP
expected_stdout_lines:
- ' "dapr.api": "POST /v1.0/invoke/hello-tracing/method/neworder",'
- '"dapr.api": "POST /v1.0/invoke/hello-tracing/method/neworder",'
expected_stderr_lines:
output_match_mode: substring
name: Curl validate
-->
```bash
curl -s "http://localhost:9411/api/v2/traces?serviceName=hello-tracing&spanName=calllocal%2Fhello-tracing%2Fneworder&limit=10" -H "accept: application/json" | python -m json.tool
curl -s http://localhost:9411/api/v2/traces?spanName=calllocal%2Fhello-tracing%2Fneworder -H accept:application/json -o output.json && python -m json.tool output.json
```
<!-- END_STEP -->
@ -134,8 +137,9 @@ You should see output like the following:
<!-- STEP
expected_stdout_lines:
- 'app stopped successfully: hello-tracing'
- 'app stopped successfully: hello-tracing'
expected_stderr_lines:
output_match_mode: substring
name: Shutdown dapr
-->
@ -286,9 +290,21 @@ expected_stdout_lines:
```bash
kubectl rollout status deploy/addapp
```
```bash
kubectl rollout status deploy/subtractapp
```
```bash
kubectl rollout status deploy/divideapp
```
```bash
kubectl rollout status deploy/multiplyapp
```
```bash
kubectl rollout status deploy/calculator-front-end
```
@ -313,7 +329,7 @@ If this is the first time trying the distributed calculator, find more detailed
name: Port forward
background: true
sleep: 2
timeout_seconds: 100
timeout_seconds: 50
expected_return_code:
-->
@ -331,7 +347,6 @@ To show how observability can help discover and troubleshoot issues on a distrib
<!-- STEP
name: Deploy mmdified multiply app
sleep: 60
expected_stdout_lines:
- 'deployment.apps/multiplyapp configured'
-->
@ -363,20 +378,40 @@ Now go to the calculator UI and perform several calculations. Make sure to use a
**Optional:** You can also use the following curl commands to execute all operations:
<!-- STEP
expected_stdout_lines:
- "59"
- "86"
- "18"
- "12"
- "1.5294"
- "1768.0"
- '"total":"54"'
output_match_mode: substring
name: "Curl test"
-->
```bash
curl -w "\n" -s 'http://localhost:8000/calculate/add' -H 'Content-Type: application/json' --data '{"operandOne":"56","operandTwo":"3"}'
curl -w "\n" -s 'http://localhost:8000/calculate/subtract' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
curl -w "\n" -s 'http://localhost:8000/calculate/divide' -H 'Content-Type: application/json' --data '{"operandOne":"144","operandTwo":"12"}'
curl -w "\n" -s 'http://localhost:8000/calculate/multiply' -H 'Content-Type: application/json' --data '{"operandOne":"52","operandTwo":"34"}'
```bash
curl -s http://localhost:8000/calculate/add -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/subtract -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/divide -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/calculate/multiply -H Content-Type:application/json --data @operands.json
```
```bash
curl -s http://localhost:8000/persist -H Content-Type:application/json --data @persist.json
```
```bash
curl -s http://localhost:8000/state
```
<!-- END_STEP -->
@ -388,7 +423,7 @@ Now go to the Zipkin dashboard by running. (Note: if you are running Dapr locall
name: Port forward
background: true
sleep: 2
timeout_seconds: 1
timeout_seconds: 10
expected_return_code:
-->
@ -435,13 +470,15 @@ As before, you can also access traces through the Zipkin API. The following will
<!-- STEP
expected_stdout_lines:
- ' "name": "calllocal/multiplyapp/multiply",'
- '"name": "calllocal/multiplyapp/multiply",'
output_match_mode: substring
expected_stderr_lines:
name: Curl validate
-->
```bash
curl -s "http://localhost:19411/api/v2/traces?minDuration=250000&limit=10" -H "accept: application/json" | python -m json.tool
curl -s http://localhost:19411/api/v2/traces?minDuration=250000 -H accept:application/json -o output.json && python -m json.tool output.json
```
<!-- END_STEP -->

View File

@ -0,0 +1 @@
{"operandOne":"52","operandTwo":"34"}

View File

@ -0,0 +1 @@
[{"key":"calculatorState","value":{"total":"54","next":null,"operation":null}}]

View File

@ -0,0 +1 @@
{"data":{"orderId":"42"}}

View File

@ -69,12 +69,13 @@ npm install
<!-- STEP
name: Run node subscriber
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == A: This is a test"
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == A: Message on A"
- "== APP == B: Message on B"
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: ./node-subscriber
background: true
sleep: 5
@ -120,12 +121,13 @@ python -m pip install -r requirements.txt
<!-- STEP
name: Run python subscriber
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- '== APP == Received message "This is a test" on topic "A"'
- "You're up and running! Both Dapr and your app logs will appear here."
- '== APP == Received message "Message on A" on topic "A"'
- '== APP == Received message "Message on C" on topic "C"'
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: ./python-subscriber
background: true
sleep: 10
@ -160,6 +162,9 @@ env:
```bash
npm run buildclient
```
```bash
npm install
```
@ -169,12 +174,13 @@ npm install
name: Run react frontent
working_dir: ./react-form
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Publishing: { messageType: 'B', message: 'Message on B' }"
- "== APP == Publishing: { messageType: 'C', message: 'Message on C' }"
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 10
env:
@ -205,7 +211,7 @@ manual_pause_message: "Pubsub APP running on http://localhost:8080. Please open
4. Pick a topic, enter some text and fire off a message! Observe the logs coming through your respective Dapr. Note that the Node.js subscriber receives messages of type "A" and "B", while the Python subscriber receives messages of type "A" and "C". Note that logs are showing up in the console window where you ran each one:
```bash
[0m?[94;1m== APP == Topic A: { id: '5780e2ca-f526-4839-92e5-a0a30aff829a', source: 'react-form', type: 'com.dapr.event.sent', specversion: '0.3',data: { message: 'this is a test' } }
== APP == Listening on port 8080!
```
### Use the CLI to publish messages to subscribers
@ -214,34 +220,20 @@ The Dapr CLI provides a mechanism to publish messages for testing purposes.
1. Use Dapr CLI to publish a message:
* Linux/Mac:
<!-- STEP
expected_stdout_lines:
- "Event published successfully"
- "Event published successfully"
expected_stderr_lines:
output_match_mode: substring
name: Publish with dapr CLI
-->
```bash
dapr publish --publish-app-id react-form --pubsub pubsub --topic A --data '{ "message": "This is a test" }'
dapr publish --publish-app-id react-form --pubsub pubsub --topic A --data-file message_a.json
```
<!-- END_STEP -->
* Windows CMD
```bash
dapr publish --publish-app-id react-form --pubsub pubsub --topic A --data "{ \"message\": \"This is a test\" }"
```
* Windows Powershell
```ps
dapr publish --publish-app-id react-form --pubsub pubsub --topic A --data "{ message: This is a test }"
```
2. **Optional**: Try publishing a message of topic B. You'll notice that only the Node app will receive this message. The same is true for topic 'C' and the python app.
<!-- STEP
@ -255,8 +247,11 @@ expected_stderr_lines:
> **Note:** If you are running in an environment without easy access to a web browser, the following curl commands will simulate a browser request to the node server.
```bash
curl -w "\n" -s 'http://localhost:8080/publish' -H 'Content-Type: application/json' --data '{"messageType":"B","message":"Message on B"}'
curl -s 'http://localhost:8080/publish' -H 'Content-Type: application/json' --data '{"messageType":"C","message":"Message on C"}'
curl -s http://localhost:8080/publish -H Content-Type:application/json --data @message_b.json
```
```bash
curl -s http://localhost:8080/publish -H Content-Type:application/json --data @message_c.json
```
<!-- END_STEP -->
@ -265,16 +260,23 @@ curl -s 'http://localhost:8080/publish' -H 'Content-Type: application/json' --da
<!-- STEP
expected_stdout_lines:
- 'app stopped successfully: node-subscriber'
- 'app stopped successfully: python-subscriber'
- 'app stopped successfully: react-form'
- 'app stopped successfully: node-subscriber'
- 'app stopped successfully: python-subscriber'
- 'app stopped successfully: react-form'
expected_stderr_lines:
output_match_mode: substring
name: Shutdown dapr
-->
```bash
dapr stop --app-id node-subscriber
```
```bash
dapr stop --app-id python-subscriber
```
```bash
dapr stop --app-id react-form
```
@ -326,7 +328,13 @@ Kubernetes deployments are asyncronous. This means you'll need to wait for the d
```bash
kubectl rollout status deploy/node-subscriber
```
```bash
kubectl rollout status deploy/python-subscriber
```
```bash
kubectl rollout status deploy/react-form
```
@ -392,10 +400,17 @@ expected_stderr_lines:
> **Note:** If you are running in an environment without easy access to a web browser, the following curl commands will simulate a browser request to the node server.
```bash
curl -w "\n" -s 'http://localhost:8000/publish' -H 'Content-Type: application/json' --data '{"messageType":"A","message":"Message on A"}'
curl -w "\n" -s 'http://localhost:8000/publish' -H 'Content-Type: application/json' --data '{"messageType":"B","message":"Message on B"}'
curl -s 'http://localhost:8000/publish' -H 'Content-Type: application/json' --data '{"messageType":"C","message":"Message on C"}'
curl -s http://localhost:8000/publish -H Content-Type:application/json --data @message_a.json
```
```bash
curl -s http://localhost:8000/publish -H Content-Type:application/json --data @message_b.json
```
```bash
curl -s http://localhost:8000/publish -H Content-Type:application/json --data @message_c.json
```
<!-- END_STEP -->
@ -482,12 +497,12 @@ This tells Dapr what topics in which pubsub component to subscribe to. When depl
```js
app.post('/A', (req, res) => {
console.log("A: ", req.body);
console.log("A: ", req.body.data.message);
res.sendStatus(200);
});
app.post('/B', (req, res) => {
console.log("B: ", req.body);
console.log("B: ", req.body.data.message);
res.sendStatus(200);
});
```
@ -510,11 +525,13 @@ Again, this is how you tell Dapr what topics in which pubsub component to subscr
@app.route('/A', methods=['POST'])
def a_subscriber():
print(f'A: {request.json}', flush=True)
return json.dumps({'success':True}), 200, {'ContentType':'application/json'}
print('Received message "{}" on topic "{}"'.format(request.json['data']['message'], request.json['topic']), flush=True)
return json.dumps({'success':True}), 200, {'ContentType':'application/json'}
@app.route('/C', methods=['POST'])
def c_subscriber():
print(f'C: {request.json}', flush=True)
print('Received message "{}" on topic "{}"'.format(request.json['data']['message'], request.json['topic']), flush=True)
return json.dumps({'success':True}), 200, {'ContentType':'application/json'}
```

1
pub-sub/message_a.json Normal file
View File

@ -0,0 +1 @@
{"messageType":"A","message":"Message on A"}

1
pub-sub/message_b.json Normal file
View File

@ -0,0 +1 @@
{"messageType":"B","message":"Message on B"}

1
pub-sub/message_c.json Normal file
View File

@ -0,0 +1 @@
{"messageType":"C","message":"Message on C"}

View File

@ -128,12 +128,13 @@ Run Node.js app with Dapr with the local secret store component:
<!-- STEP
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- "You're up and running! Both Dapr and your app logs will appear here."
- "== APP == Fetching URL: http://localhost:3500/v1.0/secrets/localsecretstore/mysecret?metadata.namespace=default"
- "== APP == Base64 encoded secret is: YWJjZA=="
- "Exited Dapr successfully"
- "Exited App successfully"
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: node
name: Run node app
background: true
@ -151,7 +152,7 @@ dapr run --app-id nodeapp --components-path ./components --app-port 3000 --dapr-
The command starts the Dapr application and finally after it is completely initialized, you should see the logs
```
Updating metadata for app command: node app.js
Updating metadata for app command: node app.js
✅ You're up and running! Both Dapr and your app logs will appear here.
```
@ -187,8 +188,9 @@ The application logs should be similar to the following:
To stop your services from running, simply stop the "dapr run" process. Alternatively, you can spin down each of your services with the Dapr CLI "stop" command. For example, to spin down both services, run these commands in a new command line terminal:
<!-- STEP
output_match_mode: substring
expected_stdout_lines:
- 'app stopped successfully: nodeapp'
- 'app stopped successfully: nodeapp'
name: Shutdown dapr
-->
@ -218,7 +220,7 @@ dapr init --kubernetes --wait
Sample output:
```
⌛ Making the jump to hyperspace...
Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
✅ Deploying the Dapr control plane to your cluster...
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run `dapr status -k' in your terminal. To get started, go here: https://aka.ms/dapr-getting-started
@ -333,7 +335,7 @@ Make a request to the node app to fetch the secret. You can use the command belo
<!-- STEP
name: Curl test
expected_stdout_lines:
- "eHl6OTg3Ngo="
- "eHl6OTg3Ng=="
-->
```bash
@ -355,7 +357,7 @@ name: Read logs
expected_stdout_lines:
- 'Node App listening on port 3000!'
- 'Fetching URL: http://localhost:3500/v1.0/secrets/kubernetes/mysecret?metadata.namespace=default'
- 'Base64 encoded secret is: eHl6OTg3Ngo='
- 'Base64 encoded secret is: eHl6OTg3Ng=='
-->
```bash
@ -369,7 +371,7 @@ If all went well, you should see logs like this:
```
Node App listening on port 3000!
Fetching URL: http://localhost:3500/v1.0/secrets/kubernetes/mysecret?metadata.namespace=default
Base64 encoded secret is: eHl6OTg3Ngo=
Base64 encoded secret is: eHl6OTg3Ng==
```
In these logs, you can see that the node app is making a request to dapr to fetch the secret from the secret store. Note: mysecret is the secret that you created in Step 2
@ -388,6 +390,9 @@ expected_stdout_lines:
```bash
kubectl delete -f ./deploy/node.yaml
```
```bash
kubectl delete secret mysecret
```

View File

@ -1 +1 @@
xyz9876
xyz9876

View File

@ -1,3 +1,5 @@
MM_SHELL ?= bash -c
validate:
mm.py -l README.md
mm.py -l -s "${MM_SHELL}" README.md