Skip to content

Commit

Permalink
同步代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaobangyu committed Oct 27, 2023
1 parent 03e2d24 commit 9dd7cf6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion server/autotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions server/autotest/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

-- 获取主机名称
Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions server/autotest/node.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 11 additions & 4 deletions server/autotest/robot/robot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
-- 选择角色后,需要连接网关
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/autotest/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/autotest/task_mgr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion server/autotest/test_cast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
-- 用例节点
Expand Down

0 comments on commit 9dd7cf6

Please sign in to comment.