From 9903606081a591c72258ea2b43e9591b950de9c0 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Fri, 1 May 2009 21:19:59 +0200 Subject: [PATCH] Allow gnt-debug submit-job to take multiple args MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Currently “gnt-debug submit-job” takes a single argument and has non-trivial startup-costs; in order to exercise the job system, it is better to be able to submit multiple jobs with a single invocation of the script. This patch extends it to take multiple argument, de-serialize the opcodes and then submit all of them as fast as possible, in order to increase pressure on the master daemon. Signed-off-by: Iustin Pop Reviewed-by: Alexander Schreiber --- man/gnt-debug.sgml | 6 +++--- scripts/gnt-debug | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/man/gnt-debug.sgml b/man/gnt-debug.sgml index 2e624b0..89fd9e4 100644 --- a/man/gnt-debug.sgml +++ b/man/gnt-debug.sgml @@ -146,12 +146,12 @@ submit-job - opcodes_file + opcodes_file - This command builds a list of opcodes from a JSON-format file - and submits them as a single job to the master daemon. It can + This command builds a list of opcodes from JSON-format files + and submits for each file a job to the master daemon. It can be used to test some options that are not available via the command line. diff --git a/scripts/gnt-debug b/scripts/gnt-debug index ff7e01b..d3bf054 100755 --- a/scripts/gnt-debug +++ b/scripts/gnt-debug @@ -71,12 +71,19 @@ def GenericOpCodes(opts, args): """ cl = cli.GetClient() - fname = args[0] - op_data = simplejson.loads(open(fname).read()) - op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data] - jid = cli.SendJob(op_list, cl=cl) - ToStdout("Job id: %s", jid) - cli.PollJob(jid, cl=cl) + job_data = [] + job_ids = [] + for fname in args: + op_data = simplejson.loads(open(fname).read()) + op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data] + job_data.append((fname, op_list)) + for fname, op_list in job_data: + jid = cli.SendJob(op_list, cl=cl) + ToStdout("File '%s', job id: %s", fname, jid) + job_ids.append(jid) + for jid in job_ids: + ToStdout("Waiting for job id %s", jid) + cli.PollJob(jid, cl=cl) return 0 @@ -139,11 +146,11 @@ commands = { help="Select nodes to sleep on"), ], "[opts...] ", "Executes a TestDelay OpCode"), - 'submit-job': (GenericOpCodes, ARGS_ONE, + 'submit-job': (GenericOpCodes, ARGS_ATLEAST(1), [DEBUG_OPT, ], - "", "Submits a job built from a json-file" - " with a list of serialized opcodes"), + "", "Submits jobs built from json files" + " containing a list of serialized opcodes"), 'allocator': (TestAllocator, ARGS_ONE, [DEBUG_OPT, make_option("--dir", dest="direction", -- 1.7.10.4