diff --git a/server/autotest.lua b/server/autotest.lua index 2fdc1708..a11fdb17 100644 --- a/server/autotest.lua +++ b/server/autotest.lua @@ -6,8 +6,8 @@ require("LuaPanda").start("127.0.0.1", 8810) quanta.startup(function() import("kernel/protobuf_mgr.lua") import("robot/msg_mgr.lua") - import("autotest/robot_mgr.lua") import("autotest/script_mgr.lua") + import("autotest/robot_mgr.lua") import("autotest/task_mgr.lua") import("autotest/client.lua") end) diff --git a/server/autotest/client.lua b/server/autotest/client.lua index 78c4f923..b565d221 100644 --- a/server/autotest/client.lua +++ b/server/autotest/client.lua @@ -39,7 +39,7 @@ prop:reader("st_list", {}) -- 脚本列表 function Client:__init() log_info("[Client][__init]...") - update_mgr:attach_second5(self) + update_mgr:attach_second(self) end -- 获取主机名称 @@ -90,7 +90,7 @@ function Client:set_status(status) log_info("[client][set_status] status=%s", status) end -function Client:on_second5() +function Client:on_second() self:update() end diff --git a/server/autotest/node.lua b/server/autotest/node.lua index 2e37dfad..287f8672 100644 --- a/server/autotest/node.lua +++ b/server/autotest/node.lua @@ -94,10 +94,9 @@ function Node:send_data(robot) local data = {} for name,field in pairs(self.fields) do local bind_type = 0 - local value = nil -- 属性关联 if bind_type == 0 then - data[name] = value + data[name] = robot[name] -- 协议关联 elseif bind_type == 1 then data[name] = robot:msg_package(field.accord_msg_id) diff --git a/server/autotest/robot/robot.lua b/server/autotest/robot/robot.lua index f92473ee..d11fb8ec 100644 --- a/server/autotest/robot/robot.lua +++ b/server/autotest/robot/robot.lua @@ -90,12 +90,19 @@ function Robot:connect_gateway() return false end --- 发送协议 +-- 发送协议 function Robot:send_msg(cmdid, data) - local ok,res = self:call(cmdid, data) + if not self.login_connect then + if not self:connect_login() then + log_err("[Robot][send_msg] connect login fail, robot:{} task_id:{} cmdid:{}, data:{}", + self:get_openid(), self.task_id, cmdid, data) + return false + end + end + local ok, res = self:call(cmdid, data) if self:check_callback(ok, res) then log_err("[Robot][send_msg] call fail, robot:{} task_id:{} cmdid:{}, data:{} ok:{} res:{}", - self:get_openid(), self.task_id, cmdid, data, ok, res) + self:get_openid(), self.task_id, cmdid, data, ok, res) return false end -- 选择角色后,需要连接网关 @@ -105,7 +112,7 @@ function Robot:send_msg(cmdid, data) ok = self:connect_gateway() if not ok then log_err("[Robot][send_msg] connect gate fail, robot:{} task_id:{} cmdid:{}, data:{} gate_ip:{} gate_port:{}", - self:get_openid(), self.task_id, cmdid, data, self.gate_ip, self.gate_port) + self:get_openid(), self.task_id, cmdid, data, self.gate_ip, self.gate_port) return false end end diff --git a/server/autotest/script.lua b/server/autotest/script.lua index 4c4fb494..11093396 100644 --- a/server/autotest/script.lua +++ b/server/autotest/script.lua @@ -32,7 +32,7 @@ function Script:init_nodes(conf) for _, item in pairs(node_list) do local node = Node(item) self.nodes[node:get_id()] = node - if node.get_type() == "case" then + if node:get_type() == "case" then self.cases[node:get_id()] = node end end diff --git a/server/autotest/task_mgr.lua b/server/autotest/task_mgr.lua index a72d1e6b..b853ebc2 100644 --- a/server/autotest/task_mgr.lua +++ b/server/autotest/task_mgr.lua @@ -37,7 +37,7 @@ function TaskMgr:create(id, name, srv_host, srv_port, robots, st_uuid) task:set_srv_host(srv_host) task:set_srv_port(srv_port) task:set_robots(robots) - task.set_st_uuid(st_uuid) + task:set_st_uuid(st_uuid) self.tasks[id] = task return task end diff --git a/server/autotest/test_cast.lua b/server/autotest/test_cast.lua index 2b382dd8..d9be27d5 100644 --- a/server/autotest/test_cast.lua +++ b/server/autotest/test_cast.lua @@ -78,8 +78,11 @@ function TestCase:update() else -- 请求节点 if node_type == "req" then - local data = self.cur_node:send_data() + local data = self.cur_node:send_data(self.robot) local ok = self.robot:send_msg(self.cur_node.msg_id, data) + if not ok then + return + end -- 下发节点 elseif node_type == "ntf" then -- 用例节点