-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.sh
executable file
·86 lines (53 loc) · 1.67 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
if [[ !$LUCEE_VERSION ]]; then
LUCEE_VERSION=5.4.5.23
fi
if [ -f "java/jars/lucee-light-$LUCEE_VERSION.jar" ]; then
echo "lucee-light-$LUCEE_VERSION.jar already there, skipping download"
else
#download lucee jar
echo "Downloading lucee-light-$LUCEE_VERSION.jar"
echo "https://cdn.lucee.org/lucee-light-$LUCEE_VERSION.jar"
curl --location -o java/jars/lucee-light-$LUCEE_VERSION.jar https://cdn.lucee.org/lucee-light-$LUCEE_VERSION.jar
cp java/jars/lucee-light-$LUCEE_VERSION.jar test/jars/
fi
cd java
#compile java
gradle build
cd ..
cp java/build/libs/foundeo-fuseless.jar test/jars/
cd test
gradle build
sam local start-api --port 3003 --debug &
SAM_PID=$!
#give it a chance to startup
echo -e "Sleeping for 5...\n"
sleep 5
echo "Running: http://127.0.0.1:3003/assert.cfm"
http_code=$(curl --verbose -s --header "Content-Type: application/json" --request POST --data '{"x":1}' -o /tmp/result.txt -w '%{http_code}' 'http://127.0.0.1:3003/assert.cfm?requestMethod=POST&requestContentType=application/json&requestBody=%7B%22x%22%3A1%7D&contentLength=7';)
echo "Finished with Status: $http_code "
echo -e "\n-----\n"
#output the result
cat /tmp/result.txt
echo -e "\n-----\n"
echo "SAM PID: $SAM_PID"
kill $SAM_PID
ps
if [ "$http_code" -ne 222 ]; then
#fail if status code is not 222
echo "Failed Status Code was not 222"
exit 1
fi
echo "Testing Events"
echo -e "\n-----\n"
sam local generate-event s3 put > /tmp/test-event.json
echo "Created Test Event"
cat /tmp/test-event.json
sam local invoke FuselessTestEvent --event /tmp/test-event.json
echo -e "\n-----\n"
echo "DONE TESTING"
pstree
#ensure everything is terminated
killall sam
ps -f
exit 0