7
7
8
8
TEST_STEP=" $1 "
9
9
ORDER_ID=" $2 "
10
- TEST_SERVICE=" $3 "
10
+ TEST_SERVICE=" $3 " # currently used solely to name log file
11
11
12
12
function order() {
13
13
echo ' {"serviceName": "order", "commandName": "' " $2 " ' ", "orderId": ' " $1 " ' , "orderItem": "sushi", "deliverTo": "780 PANORAMA DR, San francisco, CA"}'
@@ -20,7 +20,7 @@ function inventory() {
20
20
function placeOrderTest() {
21
21
# Place order
22
22
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' ) " \
24
24
--header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /placeorder" -O $GRABDISH_LOG /order; then
25
25
echo " TEST_LOG: $TEST_STEP placeOrder $ORDER_ID succeeded"
26
26
else
@@ -29,22 +29,42 @@ function placeOrderTest() {
29
29
}
30
30
31
31
function showOrderTest() {
32
+ echo " TEST_LOG: sleep for 20"
33
+ sleep 20
32
34
# Show order
33
35
local ORDER_ID=" $1 "
34
36
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' ) " \
36
38
--header=' Content-Type: application/json' " $( state_get FRONTEND_URL) /command" -O $GRABDISH_LOG /order; then
37
39
echo " TEST_LOG: $TEST_STEP showOrder request $1 succeeded"
38
40
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 ' "
40
42
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
42
44
fi
43
45
else
44
46
echo " TEST_LOG_FAILED: $TEST_STEP showOrder request $1 failed"
45
47
fi
46
48
}
47
49
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
+
48
68
function addInventoryTest() {
49
69
# Add inventory
50
70
local ITEM_ID=" $1 "
@@ -58,16 +78,18 @@ function addInventoryTest() {
58
78
59
79
60
80
# Show order and wait for status "no inventory"
81
+
82
+ verifyInventoryCountTest " sushi" 0 " $ORDER_ID (before placing order)"
83
+
61
84
placeOrderTest $ORDER_ID
62
85
63
86
sleep 10
64
87
65
88
showOrderTest $ORDER_ID ' failed inventory does not exist'
66
89
67
-
68
- # Add inventory
69
90
addInventoryTest " sushi"
70
91
92
+ verifyInventoryCountTest " sushi" 1 " $ORDER_ID (after adding inventory)"
71
93
72
94
# Place second order
73
95
ORDER_ID=$(( $ORDER_ID + 1 ))
@@ -78,9 +100,10 @@ sleep 10
78
100
79
101
showOrderTest " $ORDER_ID " ' success inventory exists'
80
102
81
- # if [[ $TEST_SERVICE == "dotnet" ]]
103
+ verifyInventoryCountTest " sushi" 0 " $ORDER_ID "
104
+
82
105
if [[ $TEST_SERVICE != " " ]]
83
106
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
0 commit comments