require(qrmarkdown)
require(testthat)
#debug(q.rm)
cleanlog <- function()
{
if(file.exists('testlog'))
system('rm -r testlog')
q.wd('testlog')
dir('testlog')
}
cleanlog()
jid <- q.push(code='ls()')
# TEST QUEUE IN AND OUT
xid = queue.checkin()
queue.push()
ticket.path <- queue.checkout(xid, timer=1)
expect(basename(ticket.path) == basename(jid) , 'fail to pass message')
#
# Test multiple load
#
cleanlog()
# 5 jobs,
for(i in 1: 5)
jid <- q.push(code='ls()')
# 5 agents
doj <- function(i)
{
return ( queue.checkin() )
}
jid.list <- unlist( lapply(1:5, doj))
queue.push()
# check assigned job
expect(length( grep('_y_', dir('testlog/agent/', recursive = TRUE) ) ) == 5, 'five job been assigned')
# check pick up job
pickj <- function(i)
{
return ( queue.checkout(i) )
}
jid.list <- unlist( lapply(jid.list, pickj))
expect(length(jid.list) == 5, 'five job been picked by agent')
# no job now in agent directory
expect(length( dir('testlog/agent') ) == 0, 'removed from activie queue')
expect(q.show()$n.running == 5, '5 jobs must be running')
#
# Test Not enough agent
#
cleanlog()
# 5 jobs,
for(i in 1: 3)
jid <- q.push(code='ls()')
# only one agent
jid < queue.checkin()
res <- queue.push()
expect(length(res) == 1, 'only one job')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.