Skip to content

Commit 99e13f4

Browse files
various test enhancements and MongoDB, Postgres, and Kafka to Oracle DB with TEQ/AQ work (#129)
1 parent 409682f commit 99e13f4

File tree

14 files changed

+166
-31
lines changed

14 files changed

+166
-31
lines changed

grabdish/destroy-multicloud.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,21 @@
77
echo Deleting the Verrazzano custom resource....
88
kubectl delete verrazzano example-verrazzano
99

10+
echo Deleting the Verrazzano operator
11+
kubectl delete -f https://github.com/verrazzano/verrazzano/releases/latest/download/operator.yaml
12+
1013
echo Set verrazzano-managed=false istio-injection=disabled ...
1114
kubectl label namespace msdataworkshop verrazzano-managed=false istio-injection=disabled --overwrite
1215

13-
echo Viewing the uninstall logs...
14-
kubectl logs -f $(kubectl get pod -l job-name=uninstall-example-verrazzano -o jsonpath="{.items[0].metadata.name}")
16+
echo restarting/deleting pods to remove any envoy/sidecars
17+
export SERVICES="frontend order inventory supplier"
18+
for s in $SERVICES; do
19+
echo "deletepod $s ..."
20+
deletepod ${s}
21+
done
22+
23+
echo pods...
24+
pods
25+
26+
echo If necessary the uninstall logs may be viewed here...
27+
echo kubectl logs -f $(kubectl get pod -l job-name=uninstall-example-verrazzano -o jsonpath="{.items[0].metadata.name}")

grabdish/docs/AutoTest.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ sed -i.bak '/grabdish/d' ~/.bashrc
4444
echo "source $PWD/microservices-datadriven/grabdish/env.sh" >>~/.bashrc
4545
source microservices-datadriven/grabdish/env.sh
4646
source setup.sh
47+
4748
```
4849

4950
8. Execute the test
5051
```
5152
source test.sh
53+
5254
```
5355

5456
9. Clean up
5557
```
5658
source destroy.sh
59+
5760
```

grabdish/inventory-nodejs/inventory/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async function processOrder() {
165165
let opStart = process.hrtime.bigint();
166166

167167
try {
168-
// oracledb.autoCommit = false;
168+
oracledb.autoCommit = false;
169169
connection = await oracledb.getConnection();
170170
const orderQueue = await connection.getQueue(queueConfig.orderQueue, queueOptions);
171171
logStats(opName, opStart, process.hrtime.bigint());

grabdish/mongodb-kafka-postgres/install-mongodb.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
kubectl create -f mongodata-persistentvolumeclaim.yaml -n msdataworkshop
66
kubectl create -f mongodb-deployment.yaml -n msdataworkshop
77
kubectl create -f mongodb-service.yaml -n msdataworkshop
8-
#kubectl expose deployment mongodb --type=LoadBalancer -n msdataworkshop # remove as we have service

grabdish/mongodb-kafka-postgres/uninstall-all.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
## Copyright (c) 2021 Oracle and/or its affiliates.
33
## Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
44

5-
kubectl delete -f ./kafka-all.yaml
5+
echo un-install kafka...
6+
kubectl delete -f ./kafka-all.yaml -n msdataworkshop
7+
8+
echo un-install mongodb...
9+
kubectl delete -f mongodb-service.yaml -n msdataworkshop
10+
kubectl delete -f mongodb-deployment.yaml -n msdataworkshop
11+
kubectl delete -f mongodata-persistentvolumeclaim.yaml -n msdataworkshop
12+
13+
echo un-install postgres
14+
kubectl delete -f postgres-service.yaml -n msdataworkshop
15+
kubectl delete -f postgres-deployment.yaml -n msdataworkshop
16+
kubectl delete -f postgres-storage.yaml -n msdataworkshop
17+

grabdish/setup-multicloud.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
# Copyright (c) 2021 Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44

5+
# Fail on error
6+
set -e
7+
58
# The following setup and install of Verrazzano is taken directly from https://verrazzano.io/docs/setup/quickstart/
69
if [[ $1 == "" ]]
710
then
811
echo CLUSTER_NAME argument not provided
9-
echo This can be found in the ~./kube/config file
12+
echo This can be found in the ~/.kube/config file
1013
echo Usage example : ./setup-multicloud.sh cluster-cyxypetwerq
1114
exit
1215
fi

grabdish/test

Lines changed: 0 additions & 1 deletion
This file was deleted.

grabdish/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ if ! (return 0 2>/dev/null); then
88
exit
99
fi
1010

11+
echo Deleting any previous $GRABDISH_LOG/main-test.log
12+
rm $GRABDISH_LOG/main-test.log
13+
rm $GRABDISH_LOG/testlog-*
14+
1115
$GRABDISH_HOME/utils/main-test.sh 2>&1 | tee -ai $GRABDISH_LOG/main-test.log
1216

1317
$GRABDISH_HOME/utils/test-summary.sh

grabdish/utils/crashrecovery-test.sh

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,76 @@
55
# Fail on error
66
set -e
77

8-
# todo...
8+
echo "TEST_LOG: Crash Recovery Install MongoDB, Postgres, and Kafka..."
9+
#Install MongoDB, Postgres, and Kafka
10+
cd $GRABDISH_HOME/mongodb-kafka-postgres;./install-all.sh
11+
echo "TEST_LOG: Crash Recovery waiting for kafka-broker kafka-cat mongodb postgres to start..."
12+
SERVICES="kafka-broker kafka-cat mongodb postgres"
13+
14+
for s in $SERVICES; do
15+
echo "Verify $s pod running..."
16+
while test 1 -gt `kubectl get pods -n msdataworkshop | grep "${s}" | grep "1/1" | wc -l`; do
17+
echo "Waiting for pod to start..."
18+
sleep 5
19+
done
20+
done
21+
22+
echo "TEST_LOG: Crash Recovery kafka-broker kafka-cat mongodb postgres started"
23+
24+
#Undeploy Order, Inventory, and Supplier Services and deploy the MongoDB, Postgres, and Kafka backed Order and Inventory implementations
25+
for i in order-helidon inventory-helidon supplier-helidon-se; do cd $GRABDISH_HOME/$i; ./undeploy.sh; done
26+
cd $GRABDISH_HOME/order-mongodb-kafka ; ./deploy.sh
27+
cd $GRABDISH_HOME/inventory-postgres-kafka ; ./deploy.sh
28+
cd $GRABDISH_HOME
29+
30+
echo "TEST_LOG: Crash Recovery undeployed all and deployed mongodb and postgres services"
31+
32+
SERVICES="order-mongodb-kafka inventory-postgres-kafka"
33+
for s in $SERVICES; do
34+
echo "Verify $s pod running..."
35+
while test 1 -gt `kubectl get pods -n msdataworkshop | grep "${s}" | grep "1/1" | wc -l`; do
36+
echo "Waiting for pod to start..."
37+
sleep 5
38+
done
39+
done
40+
41+
echo "TEST_LOG: Crash Recovery mongodb and postgres pods running "
42+
43+
#Run tests against order-mongodb-kafka inventory-postgres-kafka implementations
44+
SERVICES="mongodb-postgres-kafka"
45+
ORDER_ID=65
46+
47+
for s in $SERVICES; do
48+
echo "Testing $s"
49+
cd $GRABDISH_HOME
50+
ORDER_ID=$(($ORDER_ID + 1000))
51+
utils/func-test.sh "Crash test (success runs) $s" $ORDER_ID $s
52+
done
53+
54+
echo "TEST_LOG: Crash Recovery mongodb and postgres tests complete "
55+
56+
#Undeploy MongoDB, Postgres, and Kafka backed Order and Inventory implementations and deploy the Oracle + TEQ/AQ backed Order and Inventory implementations by copying and running the following commands.
57+
for i in order-mongodb-kafka inventory-postgres-kafka; do cd $GRABDISH_HOME/$i; ./undeploy.sh; done
58+
cd $GRABDISH_HOME/order-helidon ; ./deploy.sh
59+
cd $GRABDISH_HOME/inventory-helidon ; ./deploy.sh
60+
cd $GRABDISH_HOME/supplier-helidon-se ; ./deploy.sh
61+
cd $GRABDISH_HOME
62+
63+
#Un-install MongoDB, Postgres, and Kafka
64+
cd $GRABDISH_HOME/mongodb-kafka-postgres;./uninstall-all.sh
65+
66+
echo "TEST_LOG: Crash Recovery undeployed mongodb and postgres "
67+
68+
#Run tests against Oracle DB + AQ implementations
69+
SERVICES="Oracle-TEQ"
70+
ORDER_ID=65
71+
72+
# currently fails order 1165 due to "success inventory exists"
73+
#for s in $SERVICES; do
74+
# echo "Testing $s"
75+
# cd $GRABDISH_HOME
76+
# ORDER_ID=$(($ORDER_ID + 1100))
77+
# utils/func-test.sh "Crash test (success runs) $s" $ORDER_ID $s
78+
#done
79+
80+
echo "TEST_LOG: Crash Recovery Oracle TEQ/AQ tests complete "

grabdish/utils/func-test.sh

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -e
77

88
TEST_STEP="$1"
99
ORDER_ID="$2"
10-
TEST_SERVICE="$3"
10+
TEST_SERVICE="$3" #currently used solely to name log file
1111

1212
function order() {
1313
echo '{"serviceName": "order", "commandName": "'"$2"'", "orderId": '"$1"', "orderItem": "sushi", "deliverTo": "780 PANORAMA DR, San francisco, CA"}'
@@ -20,7 +20,7 @@ function inventory() {
2020
function placeOrderTest() {
2121
# Place order
2222
local ORDER_ID="$1"
23-
if wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(order "$ORDER_ID" 'placeOrder')" \
23+
if wget -q --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(order "$ORDER_ID" 'placeOrder')" \
2424
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/placeorder" -O $GRABDISH_LOG/order; then
2525
echo "TEST_LOG: $TEST_STEP placeOrder $ORDER_ID succeeded"
2626
else
@@ -29,22 +29,42 @@ function placeOrderTest() {
2929
}
3030

3131
function showOrderTest() {
32+
echo "TEST_LOG: sleep for 20"
33+
sleep 20
3234
# Show order
3335
local ORDER_ID="$1"
3436
local SEARCH_FOR="$2"
35-
if wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(order "$ORDER_ID" 'showorder')" \
37+
if wget -q --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(order "$ORDER_ID" 'showorder')" \
3638
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/command" -O $GRABDISH_LOG/order; then
3739
echo "TEST_LOG: $TEST_STEP showOrder request $1 succeeded"
3840
if grep "$SEARCH_FOR" $GRABDISH_LOG/order >/dev/null; then
39-
echo "TEST_LOG: $TEST_STEP showOrder $ORDER_ID matched"
41+
echo "TEST_LOG: $TEST_STEP showOrder $ORDER_ID matched '$SEARCH_FOR'"
4042
else
41-
echo "TEST_LOG_FAILED: $TEST_STEP showOrder $ORDER_ID nomatch"
43+
echo "TEST_LOG_FAILED: $TEST_STEP showOrder $ORDER_ID expected '$SEARCH_FOR' but got... " | tr '\n' ' ' ;cat $GRABDISH_LOG/order
4244
fi
4345
else
4446
echo "TEST_LOG_FAILED: $TEST_STEP showOrder request $1 failed"
4547
fi
4648
}
4749

50+
function verifyInventoryCountTest() {
51+
local ITEM_ID="$1"
52+
local SEARCH_FOR="$2"
53+
local ORDER_ID="$3"
54+
if wget --http-user grabdish --http-password "$TEST_UI_PASSWORD" --no-check-certificate --post-data "$(inventory "$ITEM_ID" 'getInventory')" \
55+
--header='Content-Type: application/json' "$(state_get FRONTEND_URL)/command" -O $GRABDISH_LOG/inventory; then
56+
echo "TEST_LOG: $TEST_STEP verifyInventoryCountTest request $1 succeeded"
57+
if grep "$SEARCH_FOR" $GRABDISH_LOG/inventory >/dev/null; then
58+
echo "TEST_LOG: $TEST_STEP verifyInventoryCountTest $ITEM_ID after ORDER_ID $ORDER_ID expected inventory count: '$SEARCH_FOR'"
59+
else
60+
echo "TEST_LOG: $TEST_STEP verifyInventoryCountTest $ITEM_ID after ORDER_ID $ORDER_ID unexpected inventory count, not '$SEARCH_FOR'" | tr '\n' ' ' ; cat $GRABDISH_LOG/inventory
61+
echo ...
62+
fi
63+
else
64+
echo "TEST_LOG_FAILED: $TEST_STEP verifyInventoryCountTest $ITEM_ID after ORDER_ID $ORDER_ID request $1 failed"
65+
fi
66+
}
67+
4868
function addInventoryTest() {
4969
# Add inventory
5070
local ITEM_ID="$1"
@@ -58,16 +78,18 @@ function addInventoryTest() {
5878

5979

6080
# Show order and wait for status "no inventory"
81+
82+
verifyInventoryCountTest "sushi" 0 "$ORDER_ID (before placing order)"
83+
6184
placeOrderTest $ORDER_ID
6285

6386
sleep 10
6487

6588
showOrderTest $ORDER_ID 'failed inventory does not exist'
6689

67-
68-
# Add inventory
6990
addInventoryTest "sushi"
7091

92+
verifyInventoryCountTest "sushi" 1 "$ORDER_ID (after adding inventory)"
7193

7294
# Place second order
7395
ORDER_ID=$(($ORDER_ID + 1))
@@ -78,9 +100,10 @@ sleep 10
78100

79101
showOrderTest "$ORDER_ID" 'success inventory exists'
80102

81-
#if [[ $TEST_SERVICE == "dotnet" ]]
103+
verifyInventoryCountTest "sushi" 0 "$ORDER_ID"
104+
82105
if [[ $TEST_SERVICE != "" ]]
83106
then
84-
echo writing service log to $GRABDISH_LOG/testlog-$TEST_SERVICE-$ORDER_ID
85-
logpodnotail $TEST_SERVICE > $GRABDISH_LOG/testlog-$TEST_SERVICE-$ORDER_ID
86-
fi
107+
echo writing log to $GRABDISH_LOG/testlog-$TEST_SERVICE
108+
logpodnotail $TEST_SERVICE > $GRABDISH_LOG/testlog-$TEST_SERVICE
109+
fi

grabdish/utils/logpod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
export k8s_pod=$1
66
for line in $(kubectl get pods -n msdataworkshop | \
7-
grep $k8s_pod | awk '{print $2}'); do
7+
grep $k8s_pod | awk '{print $1}'); do
88
echo "kubectl logs -f $line -n msdataworkshop"
99
kubectl logs -f $line -n msdataworkshop
1010
done

grabdish/utils/logpodnotail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
export k8s_pod=$1
66
for line in $(kubectl get pods -n msdataworkshop | \
7-
grep $k8s_pod | awk '{print $2}'); do
7+
grep $k8s_pod | awk '{print $1}'); do
88
echo "kubectl logs -f $line -n msdataworkshop"
99
kubectl logs $line -n msdataworkshop
1010
done

grabdish/utils/main-test.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export TEST_UI_PASSWORD=`kubectl get secret frontendadmin -n msdataworkshop --te
2323
echo 'TEST_LOG: #####################################'
2424

2525
# WALKTHROUGH
26-
echo "TEST_LOG: #### Testing Lab2: Walkthrough"
26+
echo "TEST_LOG: #### Testing Lab2: Walkthrough Undeploy..."
2727

2828
# Undeploy to make it rerunable
2929
./undeploy.sh
@@ -40,7 +40,7 @@ while test 0 -lt `kubectl get pods -n msdataworkshop | egrep 'frontend-helidon|i
4040
done
4141

4242
# Deploy the java services
43-
echo "TEST_LOG: #### Testing Lab2: Walkthrough"
43+
echo "TEST_LOG: #### Testing Lab2: Walkthrough Deploy..."
4444
cd $GRABDISH_HOME
4545
./deploy.sh
4646

@@ -90,26 +90,32 @@ fi
9090

9191
# Functional test on order 66/67
9292
utils/func-test.sh Walkthrough 66
93+
logpodnotail frontend > $GRABDISH_LOG/testlog-frontend-from-Walkthrough
94+
logpodnotail supplier > $GRABDISH_LOG/testlog-supplier-from-Walkthrough
95+
logpodnotail order > $GRABDISH_LOG/testlog-order-from-Walkthrough
96+
logpodnotail inventory > $GRABDISH_LOG/testlog-inventory-from-Walkthrough
9397

9498

9599
# POLYGLOT
96100
echo "TEST_LOG: #### Testing Lab3: Polyglot"
97-
98101
# Deploy each inventory service and perform functional test
99102
while ! $(state_get NON_JAVA_BUILDS); do
100103
sleep 10
101104
echo "Waiting for NON_JAVA_BUILDS"
102105
done
103106

104107
utils/polyglot-test.sh
108+
echo writing log to $GRABDISH_LOG/testlog-frontend-from-polyglot
109+
logpodnotail frontend > $GRABDISH_LOG/testlog-frontend-from-polyglot
110+
logpodnotail supplier > $GRABDISH_LOG/testlog-supplier-from-polyglot
111+
logpodnotail order > $GRABDISH_LOG/testlog-order-from-polyglot
105112

106-
107-
# SCALING
113+
## SCALING
108114
echo "TEST_LOG: #### Testing Lab4: Scaling"
109115
utils/scaling-test.sh
110-
111-
112-
# TRACING
116+
#
117+
#
118+
## TRACING
113119
echo "TEST_LOG: #### Testing Lab5: Tracing"
114120
utils/tracing-test.sh
115121

@@ -120,7 +126,7 @@ utils/tracing-test.sh
120126

121127
# TRACING
122128
echo "TEST_LOG: #### Testing Lab7: Transactional Tests: Compare MongoDB, Postgres, and Kafka to Oracle DB with TEQ/AQ"
123-
utils/tracing-test.sh
129+
utils/crashrecovery-test.sh
124130

125131
# TEARDOWN
126132
# source destroy.sh

grabdish/utils/polyglot-test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
set -e
77

88
# Deploy each inventory service and perform functional test
9-
SERVICES="inventory-python inventory-nodejs inventory-dotnet inventory-go inventory-helidon-se"
9+
#SERVICES="inventory-python inventory-nodejs inventory-dotnet inventory-go inventory-helidon-se"
10+
SERVICES="inventory-dotnet inventory-go inventory-python inventory-nodejs inventory-helidon-se"
1011
ORDER_ID=66
1112

1213
cd $GRABDISH_HOME/inventory-helidon

0 commit comments

Comments
 (0)