summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-05 22:40:40 +0800
committerruki <[email protected]>2020-03-05 10:04:04 +0800
commit84bef3947d0f5ea97ad083e4cbac727f67a266a0 (patch)
tree336abd131305fd637ae93ed14fa8885456d80491 /tests
parent2b76f2067865b587f71af7327ebacb2ce96acb6e (diff)
support to run priority jobs
Diffstat (limited to 'tests')
-rw-r--r--tests/modules/scheduler/runjobs.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/scheduler/runjobs.lua
index 2686dd43f..e8e901a36 100644
--- a/tests/modules/scheduler/runjobs.lua
+++ b/tests/modules/scheduler/runjobs.lua
@@ -10,10 +10,31 @@ function _jobfunc(index)
end
function main()
+
+ -- test callback
+ print("==================================== test callback ====================================")
local t = os.mclock()
runjobs("test", _jobfunc, {total = 100, comax = 6, timeout = 1000, timer = function (running_jobs_indices)
print("%s: timeout (%d ms), running: %s", scheduler.co_running(), os.mclock() - t, table.concat(running_jobs_indices, ","))
end})
+
+ -- test jobs
+ print("==================================== test jobs ====================================")
+ local jobs = {}
+ for i = 1, 3 do
+ for j = 1, 50 do
+ table.insert(jobs, {priority = i, run = function (idx, job)
+ _jobfunc(idx)
+ end})
+ end
+ end
+ t = os.mclock()
+ runjobs("test", jobs, {comax = 6, timeout = 1000, timer = function (running_jobs_indices)
+ print("%s: timeout (%d ms), running: %s", scheduler.co_running(), os.mclock() - t, table.concat(running_jobs_indices, ","))
+ end})
+
+ -- test tips
+ print("==================================== test tips ====================================")
printf("testing .. ")
runjobs("test", function ()
os.sleep(10000)