Skip to content

Commit

Permalink
Merge pull request #198 from dshearer/maint-1.3-issue-192
Browse files Browse the repository at this point in the history
Maint 1.3 issue 192
  • Loading branch information
dshearer authored Jun 10, 2018
2 parents e8fd5d7 + eaab3dc commit 19135c8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 14 deletions.
17 changes: 16 additions & 1 deletion jobberrunner/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,19 @@ func (jq *JobQueue) Pop(ctx context.Context, now time.Time) *jobfile.Job {
// get next-scheduled job
job := heap.Pop(&jq.q).(*jobfile.Job)

var timeFmt = "Jan _2 15:04:05"

common.Logger.Printf("Next job to run is %v, at %v.", job.Name,
job.NextRunTime.Format(timeFmt))

// sleep till it's time to run it
for now.Before(*job.NextRunTime) {
afterChan := time.After(job.NextRunTime.Sub(now))
sleepDur := job.NextRunTime.Sub(now)

common.Logger.Printf("It is now %v.", now.Format(timeFmt))
common.Logger.Printf("Sleeping for %v.", sleepDur)

afterChan := time.After(sleepDur)
select {
case now = <-afterChan:
case <-ctx.Done():
Expand All @@ -115,6 +125,9 @@ func (jq *JobQueue) Pop(ctx context.Context, now time.Time) *jobfile.Job {
}
}

common.Logger.Printf("It is now %v, which is NOT before %v",
now.Format(timeFmt), job.NextRunTime.Format(timeFmt))

// schedule this job's next run
job.NextRunTime = nextRunTime(job, now.Add(time.Second))
if job.NextRunTime != nil {
Expand All @@ -123,9 +136,11 @@ func (jq *JobQueue) Pop(ctx context.Context, now time.Time) *jobfile.Job {

// decide whether we really should run this job
if job.ShouldRun() {
common.Logger.Printf("Running %v", job.Name)
return job
} else {
// skip this job
common.Logger.Printf("Skipping %v", job.Name)
return jq.Pop(ctx, now)
}
}
Expand Down
6 changes: 6 additions & 0 deletions packaging/debian_9/debian-pkg/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
jobber (1.3.3-pr.2-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.2

-- C. Dylan Shearer <dylan@nekonya.info> Sat, 10 June 2018 10:42:00 -0800

jobber (1.3.3-pr.1-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.1
Expand Down
32 changes: 20 additions & 12 deletions packaging/tail.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ pkg-vm : .vm-is-running ${DESTDIR}${PKGFILE}
(vagrant up && vagrant reload && sleep 10 && vagrant snapshot \
save Base)
touch $@

.vm-is-running : .vm-is-created
vagrant up
touch $@

${DESTDIR}${PKGFILE} : Vagrantfile ${WORK_DIR}/${SRC_TARBALL} \
${PKGFILE_DEPS} .vm-is-running

# copy Jobber source to VM
vagrant scp "${WORK_DIR}/${SRC_TARBALL}" ":${SRC_TARBALL}"
${VAGRANT_SSH} "tar -xzmf ${SRC_TARBALL}"

# make Jobber package
${VAGRANT_SSH} 'mkdir -p work && \
mv ${SRC_TARBALL} work/${SRC_TARBALL} && \
mkdir -p dest && \
make -C ${SRC_TARBALL_DIR}/packaging/${PACKAGING_SUBDIR} \
pkg-local DESTDIR=$${PWD}/dest/ WORK_DIR=$${PWD}/work'

# copy package out of VM
vagrant scp :dest/${PKGFILE_VM_PATH} "${DESTDIR}${PKGFILE}"

touch "$@"

.PHONY : test-vm
Expand All @@ -84,20 +84,20 @@ test-vm : .vm-is-running ${DESTDIR}${PKGFILE} platform_tests.tar
-${VAGRANT_SSH} "${UNINSTALL_PKG_CMD}"
vagrant scp "${DESTDIR}${PKGFILE}" ":${PKGFILE}"
${VAGRANT_SSH} "${INSTALL_PKG_CMD}"

# copy test scripts to VM
vagrant scp platform_tests.tar :platform_tests.tar

# run test scripts
${VAGRANT_SSH} "tar xf platform_tests.tar"
${VAGRANT_SSH} "sudo robot --include ${ROBOT_TAGS} \
platform_tests/test.robot ||:" > testlog.txt

# retrieve test reports
mkdir -p "${DESTDIR}test_report"
vagrant scp :log.html "${DESTDIR}test_report/"
vagrant scp :report.html "${DESTDIR}test_report/"

# finish up
@cat testlog.txt
@egrep '.* critical tests,.* 0 failed[[:space:]]*$$' testlog.txt\
Expand All @@ -109,10 +109,10 @@ play-vm : .vm-is-running ${DESTDIR}${PKGFILE} platform_tests.tar
-${VAGRANT_SSH} "${UNINSTALL_PKG_CMD}"
vagrant scp "${DESTDIR}${PKGFILE}" ":${PKGFILE}"
${VAGRANT_SSH} "${INSTALL_PKG_CMD}"

# copy test scripts to VM
vagrant scp platform_tests.tar :platform_tests.tar

# SSH into VM
vagrant ssh

Expand Down Expand Up @@ -140,4 +140,12 @@ clean-common :
.PHONY : deepclean
deepclean : clean-common
-vagrant destroy -f
rm -f .vm-is-created
rm -f .vm-is-created
.PHONY : shallowclean

.PHONY : shallowclean
shallowclean :
-${VAGRANT_SSH} "rm -rf work dest jobber-* platform_tests* *.html *.xml"
-${VAGRANT_SSH} "sudo systemctl stop jobber; sudo yum -y remove jobber"
rm -rf "${WORK_DIR}" "${DESTDIR}${PKGFILE}" docker/src.tgz \
testlog.txt "${DESTDIR}test_report" platform_tests.tar
6 changes: 6 additions & 0 deletions packaging/ubuntu_14/debian-pkg/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
jobber (1.3.3-pr.2-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.2

-- C. Dylan Shearer <dylan@nekonya.info> Sat, 10 June 2018 10:42:00 -0800

jobber (1.3.3-pr.1-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.1
Expand Down
6 changes: 6 additions & 0 deletions packaging/ubuntu_16/debian-pkg/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
jobber (1.3.3-pr.2-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.2

-- C. Dylan Shearer <dylan@nekonya.info> Sat, 10 June 2018 10:42:00 -0800

jobber (1.3.3-pr.1-1) UNRELEASED; urgency=low

* Release 1.3.3-pr.1
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.3-pr.1
1.3.3-pr.2

0 comments on commit 19135c8

Please sign in to comment.