Skip to content

Commit ccdac65

Browse files
authored
Performance test and inventory-go performance fix (#154)
* Performance Testing * Fix to stop inventory-go sleeping between messages It was taking 1009 seconds to process 1000 messages * Load orders for perf test using k6 as it is faster * More enhancements
1 parent f80dded commit ccdac65

File tree

7 files changed

+302
-3
lines changed

7 files changed

+302
-3
lines changed

grabdish/inventory-go/inventory.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"fmt"
88
"log"
99
"os"
10-
"time"
11-
1210
"github.com/godror/godror"
1311
)
1412

@@ -141,7 +139,6 @@ func listenForMessages(ctx context.Context, db *sql.DB) {
141139
fmt.Println("commiterr:", commiterr)
142140
}
143141
fmt.Println("commit complete for message sent:" + inventoryJsonString)
144-
time.Sleep(1 * time.Second)
145142
}
146143
}
147144

grabdish/k6/placeorder-perf.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2021 Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
import http from 'k6/http';
4+
import { sleep, check } from 'k6';
5+
6+
export default function() {
7+
let orderid=(100000 * __VU + __ITER).toString();
8+
const res = http.get(`https://${__ENV.LB}:443/placeOrder?orderid=${orderid}&itemid=sushi&deliverylocation=London`);
9+
10+
const checkRes = check(res, {
11+
'status is 200': r => r.status === 200,
12+
'status is other': r => r.status !== 200,
13+
});
14+
}

grabdish/k6/test-perf.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
##
3+
## Copyright (c) 2021 Oracle and/or its affiliates.
4+
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5+
6+
set -e
7+
8+
ORDER_COUNT="$1"
9+
10+
if [[ ! $LB =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
11+
echo "Set variable LB to the external IP address of the ext-order service"
12+
exit
13+
fi
14+
15+
./k6 run --vus 20 --iterations $ORDER_COUNT --address localhost:6566 --insecure-skip-tls-verify placeorder-perf.js

grabdish/perf.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
# Make sure this is run via source or .
6+
if ! (return 0 2>/dev/null); then
7+
echo "ERROR: Usage 'source perf.sh'"
8+
exit
9+
fi
10+
11+
echo "Deleting any previous $GRABDISH_LOG/main-perf.log"
12+
rm -f $GRABDISH_LOG/main-perf.log
13+
rm -f $GRABDISH_LOG/perflog-*
14+
15+
$GRABDISH_HOME/utils/main-perf.sh 2>&1 | tee -ai $GRABDISH_LOG/main-perf.log
16+
17+
$GRABDISH_HOME/utils/perf-summary.sh

grabdish/utils/main-perf.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
# Fail on error
6+
set -e
7+
8+
# Check home is set
9+
if test -z "$GRABDISH_HOME"; then
10+
echo "TEST_LOG_FAILED: This script requires GRABDISH_HOME to be set"
11+
exit
12+
fi
13+
14+
if ! state_done SETUP_VERIFIED; then
15+
echo "TEST_LOG_FAILED: Setup is incomplete"
16+
exit
17+
fi
18+
19+
# Check TEST_UI_PASSWORD is set
20+
export TEST_UI_PASSWORD=`kubectl get secret frontendadmin -n msdataworkshop --template={{.data.password}} | base64 --decode`
21+
22+
23+
echo 'PERF_LOG: #####################################'
24+
25+
# Undeploy to make it rerunable
26+
./undeploy.sh
27+
SERVICES="inventory-python inventory-nodejs inventory-dotnet inventory-go inventory-helidon-se inventory-plsql"
28+
for s in $SERVICES; do
29+
cd $GRABDISH_HOME/$s
30+
./undeploy.sh || true
31+
done
32+
33+
# Wait for Pods to stop
34+
while test 0 -lt `kubectl get pods -n msdataworkshop | egrep 'frontend-helidon|inventory-|order-helidon|supplier-helidon-se' | wc -l`; do
35+
echo "Waiting for pods to stop..."
36+
sleep 10
37+
done
38+
39+
# Deploy the java services
40+
SERVICES="frontend-helidon order-helidon supplier-helidon-se"
41+
for s in $SERVICES; do
42+
cd $GRABDISH_HOME/$s
43+
./deploy.sh || true
44+
done
45+
46+
while test 4 -gt `kubectl get pods -n msdataworkshop | egrep 'frontend-helidon||order-helidon|supplier-helidon-se' | grep "1/1" | wc -l`; do
47+
echo "Waiting for pods to start..."
48+
sleep 10
49+
done
50+
51+
52+
# Get the frontend URL
53+
RETRIES=0
54+
while ! state_done FRONTEND_URL; do
55+
IP=`kubectl get services -n msdataworkshop | awk '/frontend/ {print $4}'`
56+
if [[ "$IP" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
57+
state_set FRONTEND_URL "https://$IP"
58+
else
59+
RETRIES=$(($RETRIES + 1))
60+
if test $RETRIES -gt 10; then
61+
echo "PERF_LOG_FAILED: Failed to get FRONTEND_URL"
62+
exit
63+
fi
64+
sleep 5
65+
fi
66+
done
67+
68+
69+
# Is the UI available?
70+
if wget -qO- --no-check-certificate --http-user grabdish --http-password "$TEST_UI_PASSWORD" "$(state_get FRONTEND_URL)" | grep 'GrabDish Explorer' >/dev/null; then
71+
echo "PERF_LOG: Frontend UI Available"
72+
else
73+
echo "PERF_LOG_FAILED_FATAL: Frontend UI Unavailable"
74+
exit
75+
fi
76+
77+
78+
# Polyglot Background Inventory Processing
79+
echo "PERF_LOG: #### Polyglot Background Inventory Processing"
80+
81+
while ! $(state_get NON_JAVA_BUILDS); do
82+
sleep 10
83+
echo "Waiting for NON_JAVA_BUILDS"
84+
done
85+
86+
cd $GRABDISH_HOME
87+
utils/polyglot-perf.sh
88+
logpodnotail frontend > $GRABDISH_LOG/perflog-frontend-from-polyglot
89+
logpodnotail supplier > $GRABDISH_LOG/perflog-supplier-from-polyglot
90+
logpodnotail order > $GRABDISH_LOG/perflog-order-from-polyglot

grabdish/utils/perf-summary.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
echo
2+
echo '#### SUMMARY ####'
3+
grep PERF_LOG $GRABDISH_LOG/main-perf.log
4+
5+
echo
6+
echo '#### STATISTICS ####'
7+
grep PERF_LOG_STAT $GRABDISH_LOG/main-perf.log

grabdish/utils/polyglot-perf.sh

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
# Fail on error
6+
set -e
7+
8+
# Deploy each inventory service and perform perf test
9+
SERVICES="inventory-helidon inventory-dotnet inventory-go inventory-python inventory-nodejs inventory-helidon-se inventory-plsql"
10+
ORDER_COUNT=1000
11+
12+
# Delete all orders payload
13+
function deleteallorders() {
14+
echo '{"serviceName": "order", "commandName": "deleteallorders", "orderId": -1, "orderItem": "", "deliverTo": ""}'
15+
}
16+
17+
function order() {
18+
echo '{"serviceName": "order", "commandName": "'"$2"'", "orderId": '"$1"', "orderItem": "sushi", "deliverTo": "780 PANORAMA DR, San francisco, CA"}'
19+
}
20+
21+
function inventory() {
22+
echo '{"serviceName": "supplier", "commandName": "'"$2"'", "orderId": -1, "orderItem": "'"$1"'", "deliverTo": ""}'
23+
}
24+
25+
function placeOrderTest() {
26+
# Place order
27+
local ORDER_ID="$1"
28+
if ! wget -q --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(order "$ORDER_ID" 'placeOrder')" \
29+
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/placeorder" -O $GRABDISH_LOG/order &>/dev/null;
30+
then
31+
echo "PERF_LOG_FAILED_FATAL: placeOrder $ORDER_ID failed"
32+
exit
33+
fi
34+
}
35+
36+
function addInventoryTest() {
37+
# Add inventory
38+
local ITEM_ID="$1"
39+
if ! wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(inventory "$ITEM_ID" 'addInventory')" \
40+
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/command" -O $GRABDISH_LOG/inventory &>/dev/null;
41+
then
42+
echo "PERF_LOG_FAILED_FATAL: addInventory $ITEM_ID request failed"
43+
exit
44+
fi
45+
}
46+
47+
# Create the ext-order service
48+
cd $GRABDISH_HOME/order-helidon;
49+
kubectl apply -f ext-order-service.yaml -n msdataworkshop
50+
51+
# Install k6
52+
cd $GRABDISH_HOME/k6;
53+
if ! test -f k6; then
54+
wget https://github.com/loadimpact/k6/releases/download/v0.27.0/k6-v0.27.0-linux64.tar.gz;
55+
tar -xzf k6-v0.27.0-linux64.tar.gz;
56+
ln k6-v0.27.0-linux64/k6 k6
57+
fi
58+
59+
# Get LB (may have to retry)
60+
RETRIES=0
61+
while ! state_done EXT_ORDER_IP; do
62+
IP=`kubectl get services -n msdataworkshop | awk '/ext-order/ {print $4}'`
63+
if [[ "$IP" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
64+
state_set EXT_ORDER_IP "$IP"
65+
else
66+
RETRIES=$(($RETRIES + 1))
67+
echo "Waiting for EXT_ORDER IP"
68+
if test $RETRIES -gt 24; then
69+
echo "ERROR: Failed to get EXT_ORDER_IP"
70+
exit
71+
fi
72+
sleep 5
73+
fi
74+
done
75+
76+
77+
for s in $SERVICES; do
78+
echo "PERF_LOG: Testing $s"
79+
80+
# Delete all order (to refresh)
81+
if wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(deleteallorders)" \
82+
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/command" -O $GRABDISH_LOG/order &>/dev/null;
83+
then
84+
echo "PERF_LOG: $s deleteallorders succeeded"
85+
else
86+
echo "PERF_LOG_FAILED_FATAL: $s deleteallorders failed"
87+
exit
88+
fi
89+
90+
91+
# Create a large number of orders
92+
cd $GRABDISH_HOME/k6;
93+
export LB=$(state_get EXT_ORDER_IP)
94+
./test-perf.sh $ORDER_COUNT
95+
96+
# Add the inventory
97+
export TNS_ADMIN=$GRABDISH_HOME/wallet
98+
INVENTORY_DB_SVC="$(state_get INVENTORY_DB_NAME)_tp"
99+
INVENTORY_USER=INVENTORYUSER
100+
DB_PASSWORD=`kubectl get secret dbuser -n msdataworkshop --template={{.data.dbpassword}} | base64 --decode`
101+
U=$INVENTORY_USER
102+
SVC=$INVENTORY_DB_SVC
103+
sqlplus /nolog <<!
104+
105+
connect $U/"$DB_PASSWORD"@$SVC
106+
update inventory set inventorycount=$ORDER_COUNT;
107+
commit;
108+
!
109+
110+
111+
# Deploy the test subject
112+
cd $GRABDISH_HOME/$s
113+
./deploy.sh
114+
115+
if test "$s" != 'inventory-plsql'; then # PL/SQL service is not deployed in k8s and starts immediately
116+
while test 1 -gt `kubectl get pods -n msdataworkshop | grep "${s}" | grep "1/1" | wc -l`; do
117+
echo "Waiting for pod to start..."
118+
sleep 1
119+
done
120+
fi
121+
122+
START_TIME=`date`
123+
START_SECONDS="$(date -u +%s)"
124+
echo "PERF_LOG: $s Processing started at $START_TIME"
125+
126+
# Monitor to see how long it takes to consume all the inventory
127+
while true;
128+
do
129+
if wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(inventory sushi 'getInventory')" \
130+
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/command" -O $GRABDISH_LOG/inventory &>/dev/null;
131+
then
132+
if grep "inventorycount for sushi is now 0" $GRABDISH_LOG/inventory >/dev/null; then
133+
break
134+
fi
135+
else
136+
echo "PERF_LOG_FAILED_FATAL: $s Failed to get inventory count"
137+
exit
138+
fi
139+
sleep 1
140+
done
141+
142+
END_TIME=`date`
143+
END_SECONDS="$(date -u +%s)"
144+
echo "PERF_LOG: $s Processing completed at $END_TIME"
145+
echo "PERF_LOG_STAT: $s Processed $ORDER_COUNT orders in $(($END_SECONDS-$START_SECONDS)) seconds"
146+
147+
logpodnotail inventory > $GRABDISH_LOG/perflog-$s
148+
149+
# Undeploy the test subject
150+
cd $GRABDISH_HOME/$s
151+
./undeploy.sh
152+
153+
# Wait for Pod to stop
154+
while test 0 -lt `kubectl get pods -n msdataworkshop | egrep 'inventory-' | wc -l`; do
155+
echo "Waiting for pod to stop..."
156+
sleep 5
157+
done
158+
159+
done

0 commit comments

Comments
 (0)