Skip to content

Commit

Permalink
同步代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaobangyu committed Oct 26, 2023
1 parent 5cd94ad commit f9e1796
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/autotest/script.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- 脚本
local log_debug = logger.debug
local log_err = logger.err

local Script = singleton()
local prop = property(Script)
prop:accessor("id", nil)


function Script:__init(id)
self.id = id
end

return Script
22 changes: 22 additions & 0 deletions server/autotest/script_mgr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- 任务管理
local log_debug = logger.debug
local log_err = logger.err

local size = qtable.size

local Script = import("autotest/script.lua")

local ScriptMgr = singleton()
local prop = property(ScriptMgr)
prop:reader("scripts", {})

function ScriptMgr:__init()

end

function ScriptMgr:create()

end

quanta.script_mgr = ScriptMgr()
return ScriptMgr
18 changes: 18 additions & 0 deletions server/autotest/task.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- 测试任务
local log_debug = logger.debug
local log_err = logger.err

local Task = singleton()
local prop = property(Task)
prop:accessor("id", nil)
prop:accessor("name", "")
prop:accessor("srv_host", "")
prop:accessor("srv_port", "")
prop:accessor("robots", {})

function Task:__init(id, name)
self.id = id
self.name = name
end

return Task
44 changes: 44 additions & 0 deletions server/autotest/task_mgr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- 任务管理
local log_debug = logger.debug
local log_err = logger.err

local size = qtable.size

local TestTask = import("autotest/testtask.lua")

local TaskMgr = singleton()
local prop = property(TaskMgr)
prop:reader("tasks", {})

function TaskMgr:__init()

end

-- 获取任务
function TaskMgr:get_task(id)
return self.tasks[id]
end

-- 获取数量
function TaskMgr:get_count()
return size(self.tasks)
end

-- 创建任务
function TaskMgr:create(id, name, srv_host, srv_port, robots)
log_debug("[TaskMgr][create]: {}:{} {}:{}", id, name, srv_host, srv_port, robots)
local task = self:get_task()
if task then
log_err("[TaskMgr][create] robot {}:{} {}:{}", id, name, srv_host, srv_port, robots)
return nil
end
task = TestTask(id)
task:set_srv_host(srv_host)
task:set_srv_port(srv_port)
task:set_robots(robots)
self.tasks[id] = task
return task
end

quanta.task_mgr = TaskMgr()
return TaskMgr

0 comments on commit f9e1796

Please sign in to comment.