Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit 304d3b5

Browse files
RQ infrastructure work (#21723)
* RQ infrastructure work
1 parent 6ca1ecf commit 304d3b5

File tree

2 files changed

+169
-15
lines changed

2 files changed

+169
-15
lines changed

main/appserver/tests/findbug/run_test.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ findbugs_run(){
5757

5858
}
5959

60-
findbugs_lp_run(){
60+
findbugs_low_priority_all_run(){
6161
M2_HOME=/net/gf-hudson/scratch/gf-hudson/export2/hudson/tools/apache-maven-3.0.3
6262
MAVEN_OPTS="-Xmx512m -Xms256m -XX:MaxPermSize=1024m"; export MAVEN_OPTS
6363
MAVEN_REPO=$WORKSPACE/repository
@@ -81,38 +81,40 @@ generate_findbugs_result(){
8181
mkdir -p $WORKSPACE/results/findbugs_results
8282

8383
# check findbbugs
84+
set +e
8485
cd /net/gf-hudson/scratch/gf-hudson/export2/hudson/tools/findbugs-tool-latest; ./findbugscheck $WORKSPACE/main
8586
if [ $? -ne 0 ]
8687
then
8788
echo "FAILED" > $WORKSPACE/results/findbugs_results/findbugscheck.log
8889
else
8990
echo "SUCCESS" > $WORKSPACE/results/findbugs_results/findbugscheck.log
9091
fi
91-
92+
set -e
9293
# archive the findbugs results
9394
for i in `find $WORKSPACE/main -name findbugsXml.xml`
9495
do
9596
cp $i $WORKSPACE/results/findbugs_results/`echo $i | sed s@"$WORKSPACE"@@g | sed s@"/"@"_"@g`
9697
done
9798
}
9899

99-
generate_findbugs_lp_result(){
100+
generate_findbugs_low_priority_all_result(){
100101
rm -rf $WORKSPACE/results
101-
mkdir -p $WORKSPACE/results/findbugs_lp_results
102+
mkdir -p $WORKSPACE/results/findbugs_low_priority_all_results
102103

103104
# check findbbugs
105+
set +e
104106
cd /net/gf-hudson/scratch/gf-hudson/export2/hudson/tools/findbugs-tool-latest; ./fbcheck $WORKSPACE/main
105107
if [ $? -ne 0 ]
106108
then
107-
echo "FAILED" > $WORKSPACE/results/findbugs_lp_results/findbugscheck.log
109+
echo "FAILED" > $WORKSPACE/results/findbugs_low_priority_all_results/findbugscheck.log
108110
else
109-
echo "SUCCESS" > $WORKSPACE/results/findbugs_lp_results/findbugscheck.log
111+
echo "SUCCESS" > $WORKSPACE/results/findbugs_low_priority_all_results/findbugscheck.log
110112
fi
111-
113+
set -e
112114
# archive the findbugs results
113115
for i in `find $WORKSPACE/main -name findbugsXml.xml`
114116
do
115-
cp $i $WORKSPACE/results/findbugs_lp_results/`echo $i | sed s@"$WORKSPACE"@@g | sed s@"/"@"_"@g`
117+
cp $i $WORKSPACE/results/findbugs_low_priority_all_results/`echo $i | sed s@"$WORKSPACE"@@g | sed s@"/"@"_"@g`
116118
done
117119
}
118120

@@ -127,9 +129,9 @@ run_test_id(){
127129
findbugs_all)
128130
findbugs_run
129131
generate_findbugs_result;;
130-
findbugs_lp)
131-
findbugs_lp_run
132-
generate_findbugs_lp_result;;
132+
findbugs_low_priority_all)
133+
findbugs_low_priority_all_run
134+
generate_findbugs_low_priority_all_result;;
133135
esac
134136
upload_test_results
135137
delete_bundle
@@ -138,7 +140,7 @@ run_test_id(){
138140

139141
list_test_ids(){
140142
echo findbugs_all
141-
echo findbugs_lp
143+
echo findbugs_low_priority_all
142144
}
143145

144146
OPT=$1

main/appserver/tests/rq.sh

Lines changed: 155 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,141 @@
3838
# only if the new code is made subject to such option by the copyright
3939
# holder.
4040

41+
#
42+
# Map style.
43+
# Returns the value for the supplied key
44+
#
45+
# Args: key array_of_key=val
46+
#
47+
get_value_from_key_val_array(){
48+
local _array=${2}
49+
local array=(${_array[*]})
50+
local i=0
51+
while [ ${i} -lt ${#array[*]} ]
52+
do
53+
entry=(`key_val_as_list ${array[${i}]}`)
54+
if [ "${entry[0]}" = "${1}" ] ; then
55+
echo "${entry[1]}"
56+
return 0
57+
fi
58+
i=$((i+1))
59+
done
60+
}
61+
62+
#
63+
# Converts a key=value string into a list
64+
#
65+
# Args: key=value
66+
#
67+
key_val_as_list(){
68+
local param_key=`echo ${1} | cut -d '=' -f1`
69+
local param_value=`echo ${1} | cut -d '=' -f2`
70+
echo "${param_key} ${param_value}"
71+
}
72+
73+
#
74+
# Returns the build parameters of a given test job run
75+
# As space separated string of PARAM_NAME=PARAM_VALUE
76+
#
77+
# Args: BUILD_NUMBER
78+
#
79+
get_test_job_params(){
80+
local url="${HUDSON_URL}/${1}/api/xml?xpath=//parameter&wrapper=list"
81+
curl "${url}" | sed \
82+
-e s@'<list><parameter>'@@g -e s@'</list>'@@g \
83+
-e s@'<parameter>'@@g -e s@'</parameter>'@@g \
84+
-e s@'<name>'@@g -e s@'</name>'@@g \
85+
-e s@'<value>'@'='@g -e s@'</value>'@' '@g -e s@'<value/>'@' '@g
86+
87+
88+
if [ ${PIPESTATUS[0]} -ne 0 ] ; then
89+
# exit with curl status code
90+
return ${PIPESTATUS[0]}
91+
fi
92+
}
93+
94+
#
95+
# Returns true if the test job was triggered by the current PARENT_ID and given TEST_ID
96+
#
97+
# Args: params array to match the job
98+
#
99+
is_test_job_match(){
100+
local array=${2}
101+
local match_params=(${array[*]})
102+
set +e
103+
local job_param=(`get_test_job_params ${1}`)
104+
local error_code=${?}
105+
set -e
106+
107+
if [ ${error_code} -ne 0 ] ; then
108+
# no match
109+
echo false
110+
return 0
111+
fi
112+
# match provided params with job params
113+
local i=0
114+
while [ ${i} -lt ${#match_params[*]} ]
115+
do
116+
local match_entry=(`key_val_as_list ${match_params[${i}]}`)
117+
job_value=`get_value_from_key_val_array ${match_entry[0]} "${job_param[*]}"`
118+
if [ "${job_value}" != "${match_entry[1]}" ] ; then
119+
echo false
120+
return 0
121+
fi
122+
i=$((i+1))
123+
done
124+
# match
125+
echo true
126+
}
127+
128+
#
129+
# Gets the last build number of the test job.
130+
# This will include the currently on-going runs.
131+
#
132+
get_test_job_last_build_number(){
133+
local url="${HUDSON_URL}/api/xml?xpath=//lastBuild/number/text()"
134+
curl "${url}"
135+
local error_code=${?}
136+
if [ ${error_code} -ne 0 ] ; then
137+
exit 1
138+
fi
139+
}
140+
141+
#
142+
# Find a test job for TEST_ID
143+
#
144+
# Args: TEST_ID PREVIOUS_LAST_BUILD
145+
#
146+
find_test_job(){
147+
local previous_last_build=${1}
148+
local last_build=`get_test_job_last_build_number`
149+
150+
# nothing running and nothing new completed
151+
if [ "${previous_last_build}" = "${last_build}" ] ; then
152+
return 1
153+
fi
154+
155+
# look into the newly completed run
156+
local i=$((previous_last_build+1))
157+
while [ ${i} -le ${last_build} ]
158+
do
159+
local params
160+
params[0]="BRANCH=${branch}"
161+
params[1]="TEST_IDS=${test_ids_triggerd}"
162+
params[2]="PR_NUMBER"
163+
params[3]="FORK_ORIGIN=${fork_origin}"
164+
if `is_test_job_match ${i} "${params[*]}"` ; then
165+
# the triggered run is already completed
166+
echo ${i}
167+
return 0
168+
fi
169+
i=$((i+1))
170+
done
171+
172+
# not found
173+
return 1
174+
}
175+
41176
USAGE="Usage: rq -b BRANCH -a ---> For runing all the test ids\n\
42177
or rq -b BRANCH -g TESTGROUPNAME ---> For runing a TESTGROUPNAME\n\
43178
or rq -b BRANCH -t TESTIDS ---> For runing a space separated set of TESTIDS"
@@ -88,7 +223,24 @@ if [[ -z $test_ids ]]; then
88223
echo -e $USAGE
89224
exit 1
90225
fi
91-
226+
fork_origin=`git config --get remote.origin.url`
92227
test_ids_encoded=`echo ${test_ids[@]} | tr ' ' '+'`
93-
params="BRANCH=${branch}&TEST_IDS=${test_ids_encoded}"
94-
curl -X POST "${HUDSON_URL}/buildWithParameters?${params}&delay=0sec" 2> /dev/null
228+
params="BRANCH=${branch}&TEST_IDS=${test_ids_encoded}&FORK_ORIGIN=${fork_origin}"
229+
last_build=`get_test_job_last_build_number`
230+
curl -X POST "${HUDSON_URL}/buildWithParameters?${params}&delay=0sec" 2> /dev/null
231+
test_ids_triggerd=`echo ${test_ids[@]}`
232+
export branch fork_origin test_ids_triggerd
233+
job_build_number=`find_test_job ${last_build}`
234+
printf "###################################################################\n"
235+
printf "###################################################################\n"
236+
if [[ ! -z ${job_build_number} ]]; then
237+
printf "RQ triggered successfully. Please find the RQ link below\n"
238+
printf ${HUDSON_URL}/${job_build_number}
239+
printf "\n"
240+
printf "###################################################################\n"
241+
printf "###################################################################\n"
242+
else
243+
printf "Issue in RQ client.Please check your git settings\n"
244+
printf "###################################################################\n"
245+
printf "###################################################################\n"
246+
fi

0 commit comments

Comments
 (0)