forked from jbosstm/quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.sh
executable file
·241 lines (216 loc) · 13.2 KB
/
quickstart.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/bin/bash
function fatal {
comment_on_pull "Tests failed ($BUILD_URL): $1"
echo "$1"; exit 1
}
set -x
[ $WORKSPACE ] || fatal "please set WORKSPACE to the quickstarts directory"
function comment_on_pull
{
if [ "$COMMENT_ON_PULL" = "" ]; then return; fi
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F '/' '{ print $2 }')
if [ "$PULL_NUMBER" != "" ]
then
JSON="{ \"body\": \"$1\" }"
curl -d "$JSON" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/issues/$PULL_NUMBER/comments
else
echo "Not a pull request, so not commenting"
fi
}
# Expects one argument as an integer number and adjust it
# with multiplication by MFACTOR value, if it's defined
function timeout_adjust {
local re='^[0-9]+$'
[[ "$1" =~ $re ]] || return 1 # is parameter defined and is it an int number?
# is MFACTOR defined and is it an int number or is equal-or-less-or-equal than 1
if ! [[ "$MFACTOR" =~ $re ]] || [ "$MFACTOR" -le 1 ]; then
echo $1
return 0
fi
echo $(($MFACTOR * $1))
}
function int_env {
cd $WORKSPACE
export GIT_ACCOUNT=jbosstm
export GIT_REPO=quickstart
export MFACTOR=${MFACTOR:-1}
export -f timeout_adjust || echo "Function timeout_adjust won't be used in the subshells as it can't be exported"
NARAYANA_REPO=${NARAYANA_REPO:-jbosstm}
NARAYANA_BRANCH="${NARAYANA_BRANCH:-main}"
QUICKSTART_NARAYANA_VERSION=${QUICKSTART_NARAYANA_VERSION:-7.1.1.Final-SNAPSHOT}
REDUCE_SPACE=${REDUCE_SPACE:-0}
[ $NARAYANA_CURRENT_VERSION ] || export NARAYANA_CURRENT_VERSION="7.1.1.Final-SNAPSHOT"
PULL_NUMBER=$(echo $GIT_BRANCH | awk -F 'pull' '{ print $2 }' | awk -F '/' '{ print $2 }')
if [ "$PULL_NUMBER" != "" ]
then
PULL_DESCRIPTION=$(curl -H "Authorization: token $GITHUB_TOKEN" -s https://api.github.com/repos/$GIT_ACCOUNT/$GIT_REPO/pulls/$PULL_NUMBER)
if [[ $PULL_DESCRIPTION =~ "\"state\": \"closed\"" ]]; then
echo "pull closed"
exit 0
fi
fi
# WildFly 27 requires JDK 11 (see JBTM-3582 for details)
_jdk=`which_java`
if [ "$_jdk" -lt 11 ]; then
fatal "Narayana does not support JDKs less than 11"
fi
}
function which_java {
type -p java 2>&1 > /dev/null
if [ $? = 0 ]; then
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
_java="$JAVA_HOME/bin/java"
else
unset _java
fi
if [[ "$_java" ]]; then
version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ $version = 17* ]]; then
echo 17
elif [[ $version = 11* ]]; then
echo 11
fi
fi
}
function rebase_quickstart_repo {
cd $WORKSPACE
git remote add upstream https://github.com/jbosstm/quickstart.git
export BRANCHPOINT=main
git branch $BRANCHPOINT origin/$BRANCHPOINT
git pull --rebase --ff-only origin $BRANCHPOINT
if [ $? -ne 0 ]; then
comment_on_pull "Narayana rebase on $BRANCHPOINT failed. Please rebase it manually: $BUILD_URL"
exit -1
fi
}
function build_narayana {
cd $WORKSPACE
# INITIALIZE ENV
export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m"
#rm -rf ~/.m2/repository/
rm -rf narayana
git clone https://github.com/${NARAYANA_REPO}/narayana.git -b ${NARAYANA_BRANCH}
echo "Checking if need Narayana PR"
if [ -n "$NY_BRANCH" ]; then
echo "Building NY PR"
[ $? = 0 ] || fatal "git clone https://github.com/${NARAYANA_REPO}/narayana.git failed"
cd narayana
git fetch origin +refs/pull/*/head:refs/remotes/jbosstm/pull/*/head
[ $? = 0 ] || fatal "git fetch of pulls failed"
git checkout $NY_BRANCH
[ $? = 0 ] || fatal "git fetch of pull branch failed"
cd ../
fi
if [ $? != 0 ]; then
comment_on_pull "Checkout failed: $BUILD_URL";
exit -1
fi
cd narayana
./build.sh clean install -B -DskipTests -Pcommunity
if [ $? != 0 ]; then
comment_on_pull "Narayana build failed: $BUILD_URL";
exit -1
fi
if [ $REDUCE_SPACE = 1 ]; then
echo "Deleting check out - assuming all artifacts are in the .m2"
cd ..
rm -rf narayana
fi
}
function download_and_update_as {
[ ! -z "${WILDFLY_RELEASE_VERSION}" ] || fatal "No WILDFLY_RELEASE_VERSION specified"
cd $WORKSPACE
# Check if the needed files are available in the m2 cache
filesToCheck=(~/.m2/repository/org/jboss/narayana/rts/restat-api/${NARAYANA_CURRENT_VERSION}/restat-api-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/restat-bridge/${NARAYANA_CURRENT_VERSION}/restat-bridge-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/restat-integration/${NARAYANA_CURRENT_VERSION}/restat-integration-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/restat-util/${NARAYANA_CURRENT_VERSION}/restat-util-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/xts/jbossxts/${NARAYANA_CURRENT_VERSION}/jbossxts-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/jbosstxbridge/${NARAYANA_CURRENT_VERSION}/jbosstxbridge-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/jts/narayana-jts-integration/${NARAYANA_CURRENT_VERSION}/narayana-jts-integration-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/jts/narayana-jts-idlj/${NARAYANA_CURRENT_VERSION}/narayana-jts-idlj-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-service-base/${NARAYANA_CURRENT_VERSION}/lra-service-base-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-service-base/${NARAYANA_CURRENT_VERSION}/lra-service-base-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-service-base/${NARAYANA_CURRENT_VERSION}/lra-service-base-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-coordinator-jar/${NARAYANA_CURRENT_VERSION}/lra-coordinator-jar-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-client/${NARAYANA_CURRENT_VERSION}/lra-client-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/narayana-lra/${NARAYANA_CURRENT_VERSION}/narayana-lra-${NARAYANA_CURRENT_VERSION}.jar ~/.m2/repository/org/jboss/narayana/rts/lra-proxy-api/${NARAYANA_CURRENT_VERSION}/lra-proxy-api-${NARAYANA_CURRENT_VERSION}.jar)
goOffline=false
for fileToCheck in "${filesToCheck[@]}"; do
echo Checking $fileToCheck
[ -f $fileToCheck ] || goOffline=true
done
if [ $goOffline = true ]; then
./build.sh dependency:go-offline -DskipTests
fi
if [ ! -f wildfly-${WILDFLY_RELEASE_VERSION}.zip ]; then
echo "Downloading AS"
wget -N https://github.com/wildfly/wildfly/releases/download/${WILDFLY_RELEASE_VERSION}/wildfly-${WILDFLY_RELEASE_VERSION}.zip
[ $? -eq 0 ] || fatal "Could not download https://github.com/wildfly/wildfly/releases/download/${WILDFLY_RELEASE_VERSION}/wildfly-${WILDFLY_RELEASE_VERSION}.zip"
fi
rm -rf wildfly-${WILDFLY_RELEASE_VERSION}
unzip wildfly-${WILDFLY_RELEASE_VERSION}.zip
cp ~/.m2/repository/org/jboss/narayana/rts/restat-api/${NARAYANA_CURRENT_VERSION}/restat-api-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/main/restat-api-*.jar
[ $? -eq 0 ] || fatal "Could not copy restat-api-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/restat-bridge/${NARAYANA_CURRENT_VERSION}/restat-bridge-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/main/restat-bridge-*.jar
[ $? -eq 0 ] || fatal "Could not copy restat-bridge-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/restat-integration/${NARAYANA_CURRENT_VERSION}/restat-integration-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/main/restat-integration-*.jar
[ $? -eq 0 ] || fatal "Could not copy restat-integration-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/restat-util/${NARAYANA_CURRENT_VERSION}/restat-util-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/main/restat-util-*.jar
[ $? -eq 0 ] || fatal "Could not copy restat-util-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/xts/jbossxts/${NARAYANA_CURRENT_VERSION}/jbossxts-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/xts/main/jbossxts-*.jar
[ $? -eq 0 ] || fatal "Could not copy jbossxts-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/jbosstxbridge/${NARAYANA_CURRENT_VERSION}/jbosstxbridge-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/xts/main/jbosstxbridge-*.jar
[ $? -eq 0 ] || fatal "Could not copy jbosstxbridge-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/jts/narayana-jts-integration/${NARAYANA_CURRENT_VERSION}/narayana-jts-integration-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/jts/integration/main/narayana-jts-integration-*.jar
[ $? -eq 0 ] || fatal "Could not copy narayana-jts-integration-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/jts/narayana-jts-idlj/${NARAYANA_CURRENT_VERSION}/narayana-jts-idlj-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/jts/main/narayana-jts-idlj-*.jar
[ $? -eq 0 ] || fatal "Could not copy narayana-jts-idlj-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/lra-service-base/${NARAYANA_CURRENT_VERSION}/lra-service-base-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-coordinator/main/lra-service-base-*.jar
[ $? -eq 0 ] || fatal "Could not copy lra-service-base-${NARAYANA_CURRENT_VERSION}.jar to lra-coordinator"
cp ~/.m2/repository/org/jboss/narayana/rts/lra-service-base/${NARAYANA_CURRENT_VERSION}/lra-service-base-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-participant/main/lra-service-base-*.jar
[ $? -eq 0 ] || fatal "Could not copy lra-service-base-${NARAYANA_CURRENT_VERSION}.jar to lra-participant"
cp ~/.m2/repository/org/jboss/narayana/rts/lra-coordinator-jar/${NARAYANA_CURRENT_VERSION}/lra-coordinator-jar-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-coordinator/main/lra-coordinator-jar-*.jar
[ $? -eq 0 ] || fatal "Could not copy lra-coordinator.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/lra-client/${NARAYANA_CURRENT_VERSION}/lra-client-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-participant/main/lra-client-*.jar
[ $? -eq 0 ] || fatal "Could not copy lra-client-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/narayana-lra/${NARAYANA_CURRENT_VERSION}/narayana-lra-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-participant/main/narayana-lra-*.jar
[ $? -eq 0 ] || fatal "Could not copy narayana-lra-${NARAYANA_CURRENT_VERSION}.jar"
cp ~/.m2/repository/org/jboss/narayana/rts/lra-proxy-api/${NARAYANA_CURRENT_VERSION}/lra-proxy-api-${NARAYANA_CURRENT_VERSION}.jar wildfly-${WILDFLY_RELEASE_VERSION}/modules/system/layers/base/org/jboss/narayana/rts/lra-participant/main/lra-proxy-api-*.jar
[ $? -eq 0 ] || fatal "Could not copy lra-proxy-api-${NARAYANA_CURRENT_VERSION}.jar"
if [ $REDUCE_SPACE = 1 ]; then
echo "Deleting wildfly-${WILDFLY_RELEASE_VERSION}.zip to reduce disk usage"
rm wildfly-${WILDFLY_RELEASE_VERSION}.zip
fi
export JBOSS_HOME=${WORKSPACE}/wildfly-${WILDFLY_RELEASE_VERSION}
init_jboss_home
cd $WORKSPACE
}
function init_jboss_home {
[ -d $JBOSS_HOME ] || fatal "missing AS - $JBOSS_HOME is not a directory"
echo "JBOSS_HOME=$JBOSS_HOME"
cp ${JBOSS_HOME}/docs/examples/configs/standalone-xts.xml ${JBOSS_HOME}/standalone/configuration
cp ${JBOSS_HOME}/docs/examples/configs/standalone-rts.xml ${JBOSS_HOME}/standalone/configuration
# configuring bigger connection timeout for jboss cli (WFLY-13385)
CONF="${JBOSS_HOME}/bin/jboss-cli.xml"
sed -e 's#^\(.*</jboss-cli>\)#<connection-timeout>30000</connection-timeout>\n\1#' "$CONF" > "$CONF.tmp" && mv "$CONF.tmp" "$CONF"
grep 'connection-timeout' "${CONF}"
#Enable remote debugger
echo JAVA_OPTS='"$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8797,server=y,suspend=n"' >> "$JBOSS_HOME"/bin/standalone.conf
}
function run_quickstarts {
cd $WORKSPACE
echo Running quickstarts
./build.sh -B clean install -fae -DskipX11Tests=true -Dversion.narayana=$QUICKSTART_NARAYANA_VERSION
if [ $? != 0 ]; then
comment_on_pull "Pull failed: $BUILD_URL";
exit -1
else
comment_on_pull "Pull passed: $BUILD_URL"
fi
}
int_env
functionCalled=false
if [ $# -eq 1 ]; then
if [ "$1" == "download_and_update_as" ]; then
download_and_update_as
functionCalled=true
fi
fi
if [ $functionCalled = false ]; then
comment_on_pull "Started testing this pull request: $BUILD_URL"
rebase_quickstart_repo
build_narayana
if [ -z "$JBOSS_HOME" ]; then
download_and_update_as "$@"
fi
run_quickstarts
fi