Skip to content

Commit

Permalink
updated script. add example issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Willfrit committed May 19, 2019
1 parent 02c1b67 commit 921f5d2
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
21 changes: 20 additions & 1 deletion app_test/raft_anim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
Raft leader election implementation with anim log (see tools)
With 5 nodes
<?xml version="1.0" encoding="ISO-8859-1"?>
<topology>
<vertices>
<vertex int_idx="1" role="virtnode" int_vn="1"/>
<vertex int_idx="2" role="virtnode" int_vn="2"/>
<vertex int_idx="3" role="virtnode" int_vn="3"/>
<vertex int_idx="4" role="virtnode" int_vn="4"/>
<vertex int_idx="5" role="virtnode" int_vn="5"/>
</vertices>
<edges>
<edge int_idx="1" int_src="1" int_dst="2" specs="normal"/>
Expand All @@ -16,6 +19,20 @@ Raft leader election implementation with anim log (see tools)
<edge int_idx="4" int_src="2" int_dst="3" specs="normal"/>
<edge int_idx="5" int_src="3" int_dst="1" specs="normal"/>
<edge int_idx="6" int_src="3" int_dst="2" specs="normal"/>
<edge int_idx="7" int_src="1" int_dst="4" specs="normal"/>
<edge int_idx="8" int_src="1" int_dst="5" specs="normal"/>
<edge int_idx="9" int_src="2" int_dst="4" specs="normal"/>
<edge int_idx="10" int_src="2" int_dst="5" specs="normal"/>
<edge int_idx="11" int_src="3" int_dst="4" specs="normal"/>
<edge int_idx="12" int_src="3" int_dst="5" specs="normal"/>
<edge int_idx="13" int_src="4" int_dst="1" specs="normal"/>
<edge int_idx="14" int_src="4" int_dst="2" specs="normal"/>
<edge int_idx="15" int_src="4" int_dst="3" specs="normal"/>
<edge int_idx="16" int_src="4" int_dst="5" specs="normal"/>
<edge int_idx="17" int_src="5" int_dst="1" specs="normal"/>
<edge int_idx="18" int_src="5" int_dst="2" specs="normal"/>
<edge int_idx="19" int_src="5" int_dst="4" specs="normal"/>
<edge int_idx="20" int_src="5" int_dst="3" specs="normal"/>
</edges>
<specs>
<normal dbl_kbps="1520" int_delayms="200"/>
Expand Down Expand Up @@ -169,6 +186,8 @@ end

function trigger_heart_timeout()
state.term = state.term + 1
-- For crash the leader sometime (replace Crash -> CRASH)
-- CRASH POINT 1 2 3 4 5 : RECOVERY 1 : RANDOM 0.05
for k, s in pairs(sockets) do
if s ~= nil then
aSendData(s,heartbeat_msg.." "..state.term)
Expand Down Expand Up @@ -283,7 +302,7 @@ events.run(function()
set_election_timeout()

-- Stop after 10 seconds
events.sleep(20)
events.sleep(35)
print("ANIM EXIT "..job.position)
events.exit()
end)
85 changes: 85 additions & 0 deletions app_test/security_issue_example.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
--[[
WITH this topology and 2 slayds, by pass the topology <-
<?xml version="1.0" encoding="ISO-8859-1"?>
<topology>
<vertices>
<vertex int_idx="1" role="virtnode" int_vn="1" />
<vertex int_idx="2" role="virtnode" int_vn="2" />
</vertices>
<edges>
<edge int_idx="1" int_src="1" int_dst="2" specs="client-stub" int_delayms="250" />
<edge int_idx="2" int_src="2" int_dst="1" specs="client-stub" int_delayms="1000" />
</edges>
<specs>
<client-stub dbl_plr="0" dbl_kbps="10000" int_delayms="5" int_qlen="10" />
</specs>
</topology>
]]--
package.loaded["socket"] = nil
package.loaded["socket.core"] = nil
package.loaded["splay.socket"] = nil


print("SIMPLE_TOPO.LUA START")
socket = require("socket.core")

require("splay.base")
socket = require("socket.core")

local events=require("splay.events")
local rpc=require("splay.rpc")
local net = require("splay.net")
local misc = require("splay.misc")
socket = require("socket.core")


local rtt = 0
local t_end = 0

function print_server(data, ip, port)
print("<<< "..ip..":"..port.." : "..data)
if data == "hello" then
u.s:sendto("world", ip, port)
else
t_end = misc.time()
end
end
print("Start UDP server")
u = net.udp_helper(job.me.port, print_server)

events.run(function()

print("Wait 2 seconds")
events.sleep(2)
print("Start send hello")

local start = misc.time()
for i, n in pairs(job.nodes) do
if i ~= job.position then
print(">>> "..n.ip..":"..n.port.." : hello")
u.s:sendto("hello", n.ip, n.port)
end
end

events.sleep(4)

if t_end == 0 then
local start = misc.time()
for i, n in pairs(job.nodes) do
if i ~= job.position then
print(">>> "..n.ip..":"..n.port.." : hello")
u.s:sendto("hello", n.ip, n.port)
end
end

events.sleep(4)
end

final_time = t_end - start
print("Time to n1 -> hello -> n2 -> world -> n1 : "..final_time)
print("FINAL RTT : "..final_time.." sec")

events.kill(u.server)
end)

print("SIMPLE_TOPO.LUA EXIT")
2 changes: 1 addition & 1 deletion app_test/simple_topo_lat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WITH this topology and 2 slayds
<edge int_idx="2" int_src="2" int_dst="1" specs="client-stub" int_delayms="1000" />
</edges>
<specs>
<client-stub dbl_plr="0" dbl_kbps="50" int_delayms="5" int_qlen="10" />
<client-stub dbl_plr="0" dbl_kbps="10000" int_delayms="5" int_qlen="10" />
</specs>
</topology>
]]--
Expand Down

0 comments on commit 921f5d2

Please sign in to comment.