mirror of https://github.com/dapr/quickstarts.git
Added tests for service invocation (#576)
* Added tests for service invocation Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local> * Removed go binary files Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local> Co-authored-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
This commit is contained in:
parent
aeef211dd2
commit
fd6f7dd1ba
|
@ -12,57 +12,79 @@ And one order processor service:
|
|||
|
||||
- Dotnet order-processor service `order-processor`
|
||||
|
||||
### Run Dotnet checkout with Dapr
|
||||
### Run Dotnet order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to the `checkout` directory:
|
||||
|
||||
```bash
|
||||
cd checkout
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
1. Open a new terminal window and navigate to `order-processor` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Dotnet dependencies
|
||||
working_dir: ./checkout
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/csharp/http/order-processor
|
||||
dotnet restore
|
||||
dotnet build
|
||||
```
|
||||
|
||||
3. Run the Dotnet checkout app with Dapr:
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Dotnet order-processor app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run order-processor service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order received : Order { orderId = 10 }'
|
||||
- "Exited Dapr successfully"
|
||||
- "Exited App successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/csharp/http/order-processor
|
||||
dapr run --app-port 7001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
### Run Dotnet checkout with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to the `checkout` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Dotnet dependencies
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/csharp/http/checkout
|
||||
dotnet restore
|
||||
dotnet build
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Dotnet checkout app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run checkout service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order passed: Order { OrderId = 1 }'
|
||||
- '== APP == Order passed: Order { OrderId = 2 }'
|
||||
- "Exited App successfully"
|
||||
- "Exited Dapr successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/csharp/http/checkout
|
||||
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- dotnet run
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
### Run Dotnet order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `order-processor` directory:
|
||||
|
||||
```bash
|
||||
cd order-processor
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Dotnet dependencies
|
||||
working_dir: ./order-processor
|
||||
-->
|
||||
|
||||
```bash
|
||||
dotnet restore
|
||||
dotnet build
|
||||
```
|
||||
|
||||
3. Run the Dotnet order-processor app with Dapr:
|
||||
|
||||
```bash
|
||||
dapr run --app-port 6001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
|
@ -12,55 +12,76 @@ And one order processor service:
|
|||
|
||||
- Go order-processor service `order-processor`
|
||||
|
||||
### Run Go checkout with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory:
|
||||
|
||||
```bash
|
||||
cd checkout
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Go dependencies
|
||||
working_dir: ./checkout
|
||||
-->
|
||||
|
||||
```bash
|
||||
go build app.go
|
||||
```
|
||||
|
||||
3. Run the Go checkout app with Dapr:
|
||||
|
||||
```bash
|
||||
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- go run app.go
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
### Run Go order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `order-processor` directory:
|
||||
|
||||
```bash
|
||||
cd order-processor
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Go dependencies
|
||||
working_dir: ./order-processor
|
||||
name: Build Go file
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/go/http/order-processor
|
||||
go build app.go
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
3. Run the Go order-processor app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run order-processor service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order received : {"orderId":10}'
|
||||
- "Exited Dapr successfully"
|
||||
- "Exited App successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/go/http/order-processor
|
||||
dapr run --app-port 6001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- go run app.go
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
### Run Go checkout with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory:
|
||||
|
||||
<!-- STEP
|
||||
name: Build Go file
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/go/http/checkout
|
||||
go build app.go
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Go checkout app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run checkout service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order passed: "{\"orderId\":1}"'
|
||||
- '== APP == Order passed: "{\"orderId\":2}"'
|
||||
- "Exited App successfully"
|
||||
- "Exited Dapr successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/go/http/checkout
|
||||
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- go run app.go
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
|
@ -43,6 +43,6 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("Order passed: ", string(result))
|
||||
fmt.Println("Order passed: ", string(result))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -14,7 +15,7 @@ func getOrder(w http.ResponseWriter, r *http.Request) {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
log.Printf("Order received : %s", string(data))
|
||||
fmt.Println("Order received : ", string(data))
|
||||
obj, err := json.Marshal(string(data))
|
||||
if err != nil {
|
||||
log.Println("Error in reading the result obj")
|
||||
|
|
|
@ -12,55 +12,77 @@ And one order-processor service:
|
|||
|
||||
- Node order-processor service `order-processor`
|
||||
|
||||
### Run Node checkout with Dapr
|
||||
### Run Node order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory:
|
||||
|
||||
```bash
|
||||
cd checkout
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
1. Open a new terminal window and navigate to `order-processor` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Node dependencies
|
||||
working_dir: ./checkout
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/javascript/http/order-processor
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Run the Node checkout app with Dapr:
|
||||
<!-- END_STEP -->
|
||||
|
||||
3. Run the Node order-processor app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run order-processor service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order received: { orderId: 10 }'
|
||||
- "Exited Dapr successfully"
|
||||
- "Exited App successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/javascript/http/order-processor
|
||||
dapr run --app-port 5001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- npm start
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
### Run Node checkout with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Node dependencies
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/javascript/http/checkout
|
||||
npm install
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Node checkout app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run checkout service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order passed: {"orderId":1}'
|
||||
- '== APP == Order passed: {"orderId":2}'
|
||||
- "Exited App successfully"
|
||||
- "Exited Dapr successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/javascript/http/checkout
|
||||
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- npm start
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
### Run Node order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `order-processor` directory:
|
||||
|
||||
```bash
|
||||
cd order-processor
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Node dependencies
|
||||
working_dir: ./order-processor
|
||||
-->
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Run the Node order-processor app with Dapr:
|
||||
|
||||
```bash
|
||||
dapr run --app-port 6001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- npm start
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
|
@ -12,55 +12,77 @@ And one order processor service:
|
|||
|
||||
- Python order-processor service `order-processor`
|
||||
|
||||
### Run Python checkout with Dapr
|
||||
### Run Python order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory:
|
||||
|
||||
```bash
|
||||
cd checkout
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
1. Open a new terminal window and navigate to `order-processor` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Python dependencies
|
||||
working_dir: ./checkout
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/python/http/order-processor
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
3. Run the Python checkout app with Dapr:
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Python order-processor app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run order-processor service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order received : {"orderId": 10}'
|
||||
- "Exited Dapr successfully"
|
||||
- "Exited App successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/python/http/order-processor
|
||||
dapr run --app-port 5001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- python3 app.py
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
### Run Python checkout with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `checkout` directory and install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Python dependencies
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/python/http/checkout
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Run the Python checkout app with Dapr:
|
||||
|
||||
<!-- STEP
|
||||
name: Run checkout service
|
||||
expected_stdout_lines:
|
||||
- "You're up and running! Both Dapr and your app logs will appear here."
|
||||
- '== APP == Order passed: {"orderId": 1}'
|
||||
- '== APP == Order passed: {"orderId": 2}'
|
||||
- "Exited App successfully"
|
||||
- "Exited Dapr successfully"
|
||||
expected_stderr_lines:
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
sleep: 10
|
||||
-->
|
||||
|
||||
```bash
|
||||
cd service_invocation/python/http/checkout
|
||||
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- python3 app.py
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
### Run Python order-processor with Dapr
|
||||
|
||||
1. Open a new terminal window and navigate to `order-processor` directory:
|
||||
|
||||
```bash
|
||||
cd order-processor
|
||||
```
|
||||
|
||||
2. Install dependencies:
|
||||
|
||||
<!-- STEP
|
||||
name: Install Python dependencies
|
||||
working_dir: ./order-processor
|
||||
-->
|
||||
|
||||
```bash
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
3. Run the Python order-processor app with Dapr:
|
||||
|
||||
```bash
|
||||
dapr run --app-port 6001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- python3 app.py
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
|
@ -11,7 +11,7 @@ base_url = os.getenv('BASE_URL', 'http://localhost') + ':' + os.getenv(
|
|||
# Adding app id as part of the header
|
||||
headers = {'dapr-app-id': 'order-processor'}
|
||||
|
||||
for i in range(1, 10):
|
||||
for i in range(1, 11):
|
||||
order = {'orderId': i}
|
||||
|
||||
# Invoking a service
|
||||
|
@ -20,6 +20,6 @@ for i in range(1, 10):
|
|||
data=json.dumps(order),
|
||||
headers=headers
|
||||
)
|
||||
logging.info('Order passed: ' + json.dumps(order))
|
||||
print('Order passed: ' + json.dumps(order))
|
||||
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Reference in New Issue