From 3f2ac348859bccb0dd7ebcd8830b2ca902bf5ebc Mon Sep 17 00:00:00 2001 From: Willfrit Date: Sun, 28 Apr 2019 21:39:20 +0200 Subject: [PATCH] Fix delete job + crash point test --- app_test/crash_point.lua | 53 ++++++++++++++++++++++++++++++++++++++++ cli.py | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 app_test/crash_point.lua diff --git a/app_test/crash_point.lua b/app_test/crash_point.lua new file mode 100644 index 0000000..618a40e --- /dev/null +++ b/app_test/crash_point.lua @@ -0,0 +1,53 @@ +print("CRASH_POINT.LUA START") + +require("splay.base") +local math = require("math") +local net = require("splay.net") +local misc = require("splay.misc") + +function receive(s) + local ip, port = s:getpeername() + while events.yield() do + local data, err = s:receive("*l") + print("I received : "..data) + -- CRASH POINT 2 : STOP : AFTER 6 + end +end + +function send(s) + while events.yield() do + -- CRASH POINT 1 : RECOVERY 1 : AFTER 3 + events.sleep(0.5) + print("I send data") + s:send("I AM "..job.position.."\n") + end +end + +function init(s, connect) + local ip, port = s:getpeername() + print("Connection accepted with : "..ip..":"..port) +end + +function final(s) + local ip, port = s:getpeername() + print("Closing: "..ip..":"..port) +end + +events.run(function() + -- Accept connection from other nodes + net.server(job.me.port, {initialize = init, send = send, receive = receive, finalize = final}) + + -- Launch connection to each orther node + events.thread(function () + events.sleep(1) + for i, n in pairs(job.nodes) do + if n.port ~= job.me.port or n.ip ~= job.me.ip then + print("Try to begin connection to "..n.ip..":"..n.port.." - index "..i) + net.client(n, {initialize = init, send = send, receive = receive, finalize = final}) + end + end + end) + + -- Crash point or kill before +end) + diff --git a/cli.py b/cli.py index faa6831..8ff2c25 100755 --- a/cli.py +++ b/cli.py @@ -86,7 +86,7 @@ def kill_job(job_id): headers = authentified_headers() response = requests.delete(endpoint, headers=headers) check_response(response) - click.echo(response.json()) + click.echo("Success kill") @main.command() @click.argument('job_id', nargs=1)