diff --git a/server/autotest/script.lua b/server/autotest/script.lua new file mode 100644 index 00000000..de4101b5 --- /dev/null +++ b/server/autotest/script.lua @@ -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 diff --git a/server/autotest/script_mgr.lua b/server/autotest/script_mgr.lua new file mode 100644 index 00000000..27fc1241 --- /dev/null +++ b/server/autotest/script_mgr.lua @@ -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 diff --git a/server/autotest/task.lua b/server/autotest/task.lua new file mode 100644 index 00000000..6436bb02 --- /dev/null +++ b/server/autotest/task.lua @@ -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 diff --git a/server/autotest/task_mgr.lua b/server/autotest/task_mgr.lua new file mode 100644 index 00000000..732d874b --- /dev/null +++ b/server/autotest/task_mgr.lua @@ -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