Skip to content

Commit 601e6fb

Browse files
committed
Validate release date on continuous queues manager
Before performing the job tasks, we need to make sure that the release date is properly configured. This can be simply done by making sure that the current date is not well past the end of the on-sync date, which is calculated by adding 4 weeks to the configured release date. (Normally, on-sync ends 2 weeks after the release, but it's set to 4 weeks in this patch just in case we have an unusually longer on-sync period.) This commit also moves the parameter validation part to its own function, so it can be tested on its own. Additional validation to ensure that the `lastweekdate` is not set after the `releasedate` has also been added.
1 parent 8399dca commit 601e6fb

File tree

2 files changed

+37
-12
lines changed

2 files changed

+37
-12
lines changed

tracker_automations/continuous_manage_queues/continuous_manage_queues.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,11 @@ movemax=${movemax:-3}
7272
lastweekdate=${lastweekdate:-$(date -d "${releasedate} -7day" +%Y-%m-%d)}
7373
dryrun=${dryrun:-}
7474

75-
# Verify that $releasedata has a correct YYYY-MM-DD format
76-
if [[ ! ${releasedate} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
77-
echo "ERROR: \$releasedate. Incorrect YYYY-MM-DD format detected: ${releasedate}"
78-
exit 1
79-
fi
80-
81-
# Verify that $lastweekdate has a correct YYYY-MM-DD format
82-
if [[ ! ${lastweekdate} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
83-
echo "ERROR: \$lastweekdate. Incorrect YYYY-MM-DD format detected: ${lastweekdate}"
84-
exit 1
85-
fi
86-
8775
# Today
8876
nowdate=$(date +%Y%m%d)
8977

78+
run_param_validation $releasedate $lastweekdate
79+
9080
# Decide if we are going to proceed with behaviour A (before release) or behaviour B (after release)
9181
behaviorAB=
9282
if [ $nowdate -lt $(date -d "${releasedate}" +%Y%m%d) ]; then

tracker_automations/continuous_manage_queues/lib.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,38 @@ function run_C() {
389389
echo "$BUILD_NUMBER $BUILD_TIMESTAMP ${issue} moved out from current: held" >> "${logfile}"
390390
done
391391
}
392+
393+
function run_param_validation() {
394+
releasedate=$1
395+
lastweekdate=$2
396+
397+
# Verify that $releasedate has a correct YYYY-MM-DD format
398+
if [[ ! ${releasedate} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
399+
echo "ERROR: \$releasedate. Incorrect YYYY-MM-DD format detected: ${releasedate}"
400+
exit 1
401+
fi
402+
403+
# Verify that $lastweekdate has a correct YYYY-MM-DD format
404+
if [[ ! ${lastweekdate} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
405+
echo "ERROR: \$lastweekdate. Incorrect YYYY-MM-DD format detected: ${lastweekdate}"
406+
exit 1
407+
fi
408+
409+
# Verify that the last week date is not after the release date.
410+
releasedateint=$(date -d "${releasedate}" +%Y%m%d)
411+
lastweekdateint=$(date -d "${lastweekdate}" +%Y%m%d)
412+
if [ $releasedateint -lt $lastweekdateint ]; then
413+
echo "ERROR: The value set for \$lastweekdate ($lastweekdate) is after the \$releasedate ($releasedate)"
414+
exit 1
415+
fi
416+
417+
# Verify that the current date is not well past the on-sync period. (Normally 2 weeks but making it 4 weeks just in case).
418+
nowdate=$(date +%Y%m%d)
419+
onsyncenddate=$(date -d "${releasedate} +28day" +%Y%m%d)
420+
if [ $nowdate -gt $onsyncenddate ]; then
421+
echo "ERROR: The current date is already past the on-sync period. Please make sure the Release date ($releasedate) is configured correctly"
422+
exit 1
423+
fi
424+
425+
echo "Parameters validated"
426+
}

0 commit comments

Comments
 (0)