-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·73 lines (61 loc) · 2.42 KB
/
run.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
#!/usr/bin/env bash
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
set -e
if [ -z $SVRONLY ]; then
mvn clean install $@
fi
[ $DEBUG ] || DEBUG=0
[ $SVRONLY ] || SVRONLY=0
[ $SUSPEND ] || SUSPEND=y
export PORT=8787
export JDWP=-agentlib:jdwp=transport=dt_socket,server=y,suspend=$SUSPEND,address=
function getDebugArgs {
[ $DEBUG -eq 1 ] && echo "$JDWP"$1 || echo ""
}
[ $NARAYANA_VERSION ] || NARAYANA_VERSION=5.7.2.Final
if [ ! -d narayana-full-$NARAYANA_VERSION ]; then
wget -nc http://www.jboss.org/jbosstm/downloads/$NARAYANA_VERSION/binary/narayana-full-$NARAYANA_VERSION-bin.zip
unzip narayana-full-$NARAYANA_VERSION-bin.zip
fi
java $(getDebugArgs $PORT) -jar narayana-full-$NARAYANA_VERSION/rts/lra/lra-coordinator-swarm.jar -Dswarm.http.port=8080 -Dswarm.transactions.object-store-path=../parent &
ID1=$!
((PORT++))
java $(getDebugArgs $PORT) -jar narayana-full-$NARAYANA_VERSION/rts/lra/lra-coordinator-swarm.jar -Dswarm.http.port=8081 -Dswarm.transactions.object-store-path=../subordinate &
ID2=$!
((PORT++))
java $(getDebugArgs $PORT) -jar hotel-service/target/lra-test-swarm.jar -Dswarm.http.port=8082 &
ID3=$!
((PORT++))
java $(getDebugArgs $PORT) -jar flight-service/target/lra-test-swarm.jar -Dswarm.http.port=8083 -Dlra.http.port=8081 &
ID4=$!
((PORT++))
java $(getDebugArgs $PORT) -jar trip-controller/target/lra-test-swarm.jar -Dswarm.http.port=8084 -Dlra.http.port=8080 &
ID5=$!
((PORT++))
if [ $SVRONLY -ne 1 ]; then
echo "Waiting for all the servers to start"
sleep 30
echo "Running close case"
BOOKINGID=$(curl -X POST "http://localhost:8084/?hotelName=TheGrand&flightNumber1=BA123&flightNumber2=RH456" -sS | jq -r ".id")
curl -X PUT http://localhost:8084/`urlencode $BOOKINGID` -sS | jq
echo "Running cancel case"
BOOKINGID=$(curl -X POST "http://localhost:8084/?hotelName=TheGrand&flightNumber1=BA123&flightNumber2=RH456" -sS | jq -r ".id")
curl -X DELETE http://localhost:8084/`urlencode $BOOKINGID` -sS | jq
fi
if [ $DEBUG -eq 1 ] || [ $SVRONLY -eq 1 ]; then
echo "Processes are still running ($ID1 $ID2 $ID3 $ID4 $ID5) press any key to end them" && read
fi
kill -9 $ID1 $ID2 $ID3 $ID4 $ID5