-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_JenkinsJob_SGEJobSubmit.sh
executable file
·386 lines (317 loc) · 13 KB
/
run_JenkinsJob_SGEJobSubmit.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#!/bin/bash
#**************************************************************************************
#
# when set to 1, will kill all related jobs and submit jobs based on codec branch
# when set to 0, jenkins will detect that whether current jobs have been completed.
# ----if not yet, jenkins will skip job submit and output current job status;
# ----if all jobs have been completed, jenkins will
# --1)get test summary
# --2) backup test data
# --3) submit SGE jobs based on given codec Repos and branch
#
#
#**************************************************************************************
runUsage()
{
echo ""
echo " Usage: run_JenkinsJob_SGEJobSubmit.sh \${KillRunningJobFlag} \${TestProfile}"
echo " \${CodecBranch} \${ReposAddr} \${ConfigureFile}"
echo ""
echo " e.g.: "
echo " run_JenkinsJob_SGEJobSubmit.sh false SCC master https://github.com/openh264.git"
echo " run_JenkinsJob_SGEJobSubmit.sh true SCC master https://github.com/openh264.git"
echo " run_JenkinsJob_SGEJobSubmit.sh false SVC master https://github.com/openh264.git"
echo " run_JenkinsJob_SGEJobSubmit.sh true SVC master https://github.com/openh264.git"
echo ""
echo " KillRunningJobFlag ==1, kill current running jobs and submit new jobs"
echo ""
echo " KillRunningJobFlag ==0, check current running jobs; "
echo " 1) if jobs have not completed yet, skip job submittion"
echo " 1) if jobs completed yet,backup test data,clean up test space and submit new jobs"
echo ""
}
runInitial()
{
JenkinsHomeDir="/Users/jenkins"
AttachmentsFolder="Openh264-SGETest/Jenkins-Job-Submit-Log"
AttachmentsDir="${JenkinsHomeDir}/${AttachmentsFolder}"
CurrentDir=`pwd`
SGEJobsTestSpace="${CurrentDir}"
#for job status
FinalTestReportDir="FinalTestReport"
AllTestSummary="AllTestYUVsSummary.txt"
SGEJobsAllTestSummary="${TestProfile}_AllTestYUVsSummary.txt"
AllJobsCompletedFlagFile="AllSGEJobsCompleted.flag"
AllTestResultPassFlag="AllCasesPass.flag"
let " SubmitJobStatusFlag = 0"
#log file for attachments
SGEJobSubmittedLog="SGEJobsSubmittedInfo.log"
SGEJobCancelJobLog="SGEJobsCancelInfo.log"
JobsStatusLog="SGEJobStatus.txt"
CodecReposInfo="CodecReposInfo.log"
DefaultConfigureFile="CaseConfigure/case_${TestProfile}.cfg"
CodecInfoLog="CodecInfo.log"
SummaryInfo=""
SCCStatusLog="SCCSGEJobStatus.txt"
SVCStatusLog="SVCSGEJobStatus.txt"
SCCJobSubmittedDateLog="SCCJobSubmittedDate.txt"
SVCJobSubmittedDateLog="SVCJobSubmittedDate.txt"
JobSubmittedDateLog="JobSubmittedDate.txt"
PrieviousJobBackupLog="${TestProfile}_PreviousJobBackupInfo.txt"
date
DateInfo=`date`
SGEJobStatusLog="${TestProfile}_SGEJobStatus.txt"
}
runKillJob()
{
echo "*****************************************************************************"
echo "*****************************************************************************"
echo Kill jobs before job submittion for ${TestProfile}
echo "*****************************************************************************"
echo "*****************************************************************************"
echo ""
echo ""
if [ ${KillJobsFlag} = "true" ]
then
./run_SGEJobCancel.sh All >${SGEJobCancelJobLog}
fi
echo ""
echo ""
echo "*****************************************************************************"
echo "*****************************************************************************"
}
runSGEJobsUpdate()
{
echo "*****************************************************************************"
echo "*****************************************************************************"
echo Update SGE job info for ${TestProfile}
echo "*****************************************************************************"
echo "*****************************************************************************"
echo ""
echo ""
if [ -e ${SGEJobSubmittedLog} ]
then
./run_SGEJobStatusUpdate.sh ${SGEJobSubmittedLog} ${AllJobsCompletedFlagFile}>${SGEJobStatusLog}
cat ${SGEJobStatusLog}
else
echo "there is no job been sbumitted yet!"
fi
echo ""
echo ""
echo "*****************************************************************************"
echo "*****************************************************************************"
}
runCleanUpAllTestData()
{
echo "*****************************************************************************"
echo "*****************************************************************************"
echo clean up all previous test data before job submit for ${TestProfile}
echo "*****************************************************************************"
echo "*****************************************************************************"
echo ""
echo ""
./run_CleanUpTestSpace.sh
echo ""
echo ""
echo "*****************************************************************************"
echo "*****************************************************************************"
}
runGetPriviousTestSummary()
{
#get summary
if [ -e ${AllJobsCompletedFlagFile} ]
then
echo ""
echo "*****************************************************************************"
echo " Final summary for all previous submitted jobs ---- ${TestProfile}"
echo "*****************************************************************************"
echo ""
./run_GetAllTestResult.sh SGETest ${ConfigureFile} ${AllTestResultPassFlag}
cat ${SGEJobsTestSpace}/${FinalTestReportDir}/${AllTestSummary}
cp ${SGEJobsTestSpace}/${FinalTestReportDir}/${AllTestSummary} ${AttachmentsDir}/${SGEJobsAllTestSummary}
if [ ! -e ${AllTestResultPassFlag} ]
then
echo "*****************************************************************************"
echo " not all cases passed the test for previous submit!"
echo " test profile is ${TestProfile} "
echo " please double check!"
echo "*****************************************************************************"
let " SubmitJobStatusFlag = 1"
fi
fi
}
runSGEJobPreviousTestBackup()
{
echo "*****************************************************************************"
echo "*****************************************************************************"
echo Data backup for ${TestProfile}
echo "*****************************************************************************"
echo "*****************************************************************************"
echo ""
echo ""
if [ -e ${AllJobsCompletedFlagFile} ]
then
./run_BackupTestData.sh ./ ${TestProfile}
else
echo "there is no test summary in current dir"
echo "it may caused by:"
echo " 1) there is no job been submitted for test"
echo " 2) there are still jobs running for test and have not completed yet"
fi
echo ""
echo ""
echo "*****************************************************************************"
echo "*****************************************************************************"
}
runSubmitSGEJobs()
{
./run_Main.sh SGETest ${ConfigureFile} "${CodecBranch}" "${ReposAddr}"
}
runGenerateDateInfo()
{
echo "****************************************" >${JobSubmittedDateLog}
echo "" >>${JobSubmittedDateLog}
echo "Submitted date is:" >>${JobSubmittedDateLog}
echo ${DateInfo} >>${JobSubmittedDateLog}
echo "" >>${JobSubmittedDateLog}
echo "****************************************">>${JobSubmittedDateLog}
}
runCancelAllRunningJobsAndSubmitNewJobs()
{
runSGEJobsUpdate
runGetPriviousTestSummary
runSGEJobPreviousTestBackup >${PrieviousJobBackupLog}
cat ${PrieviousJobBackupLog}
runKillJob
cat ${SGEJobCancelJobLog}
runCleanUpAllTestData
runSubmitSGEJobs
runGenerateDateInfo
SummaryInfo="Cancel all running jobs and submit new jobs"
}
runCheckAndSubmitJobs()
{
if [ ! -e ${SGEJobSubmittedLog} ]
then
runCleanUpAllTestData
runSubmitSGEJobs
else
runSGEJobsUpdate
if [ -e ${AllJobsCompletedFlagFile} ]
then
runSGEJobPreviousTestBackup >${PrieviousJobBackupLog}
cat ${PrieviousJobBackupLog}
runCleanUpAllTestData
runSubmitSGEJobs
runGenerateDateInfo
SummaryInfo="Backup previous test data and submit new jobs based on setting"
else
SummaryInfo="skip job submit as previous jobs have not been completed yet!"
echo ${SummaryInfo}
fi
fi
}
runCopyFilesToAttachedDir()
{
echo ""
echo "*****************************************************************************"
echo " copy files to attached dir for ${TestProfile}"
echo "*****************************************************************************"
[ -e ${CodecReposInfo} ] && cp ${CodecReposInfo} ${AttachmentsDir}/${TestProfile}_${CodecReposInfo}
[ -e ${SGEJobSubmittedLog} ] && cp ${SGEJobSubmittedLog} ${AttachmentsDir}/${TestProfile}_${SGEJobSubmittedLog}
[ -e ${JobsStatusLog} ] && cp ${JobsStatusLog} ${AttachmentsDir}/${TestProfile}_${JobsStatusLog}
[ -e ${SGEJobCancelJobLog} ] && cp ${SGEJobCancelJobLog} ${AttachmentsDir}/${TestProfile}_${JobsStatusLog}
[ -e ${ConfigureFile} ] && cp ${ConfigureFile} ${AttachmentsDir}
[ -e ${CodecInfoLog} ] && cp ${CodecInfoLog} ${AttachmentsDir}/${TestProfile}_${CodecInfoLog}
[ -e ${JobSubmittedDateLog} ] && cp ${JobSubmittedDateLog} ${AttachmentsDir}/${JobSubmittedDateLog}
[ -e ${SGEJobStatusLog} ] && cp ${SGEJobStatusLog} ${AttachmentsDir}/${SGEJobStatusLog}
[ -e ${PrieviousJobBackupLog} ] && cp ${PrieviousJobBackupLog} ${AttachmentsDir}/${PrieviousJobBackupLog}
[ -e ${AllJobsCompletedFlagFile} ] && cp ${AllJobsCompletedFlagFile} ${AttachmentsDir}/${TestProfile}_${AllJobsCompletedFlagFile}
echo ""
echo "*****************************************************************************"
}
runOutputSUmmary()
{
echo ""
echo -e "\033[32m **************************************************************************\033[0m"
echo " TestProfile is ${TestProfile}"
echo " KillJobsFlag is ${KillJobsFlag}"
echo " Configure file is ${ConfigureFile}"
echo " Codec branch is ${CodecBranch}"
echo " ReposAddr is ${ReposAddr}"
echo " SubmitJobStatusFlag is ${SubmitJobStatusFlag}"
echo -e "\033[32m **************************************************************************\033[0m"
echo " SummaryInfo for this job is:"
if [ ${SubmitJobStatusFlag} -eq 0 ]
then
echo " ${SummaryInfo}--all is well!"
echo -e "\033[32m ***************************************************************\n\n\n\033[0m"
exit 0
else
echo " ${SummaryInfo}"
echo " --previous submit jobs failed!"
echo " --please double check "
echo " --and refer detail from privous backup log file--${PrieviousJobBackupLog}"
echo -e "\033[32m ***************************************************************\n\n\n\033[0m"
exit 1
fi
}
runCheck()
{
[ ${ConfigureFile} = "" ] && ConfigureFile=${DefaultConfigureFile}
if [ ! -e ${ConfigureFile} ]
then
echo ""
echo "Configure file ${ConfigureFile} does not exist,please double check!"
echo ""
exit 1
fi
if [ "${TestProfile}" = "SCC" ]
then
JobSubmittedDateLog=${SCCJobSubmittedDateLog}
return 0
elif [ "${TestProfile}" = "SVC" ]
then
JobSubmittedDateLog=${SVCJobSubmittedDateLog}
return 0
else
echo ""
echo " test profile does not support,please refet to the usage!"
echo ""
runUsage
exit 1
fi
}
runMain()
{
runInitial
runCheck
if [ ${KillJobsFlag} = "true" ]
then
runCancelAllRunningJobsAndSubmitNewJobs
else
runCheckAndSubmitJobs
fi
runCopyFilesToAttachedDir
runOutputSUmmary
}
#*************************************************************************
echo ""
echo "*********************************************************"
echo " call bash file is $0"
echo " input parameters is:"
echo " $0 $@"
echo "*********************************************************"
echo ""
if [ $# -lt 4 ]
then
runUsage
exit 1
fi
TestProfile=$1
KillJobsFlag=$2
CodecBranch=$3
ReposAddr=$4
ConfigureFile=$5
runMain
#*************************************************************************