On Fri, Dec 20, 2013 at 10:09 AM, Hrvoje Ribicic <[email protected]> wrote:
> Two command-line options are added: one for confirming that the test > has been started intentionally, and one for showing the method > invocation output, which is useful, but not always needed. > > Signed-off-by: Hrvoje Ribicic <[email protected]> > --- > qa/rapi-workload.py | 32 ++++++++++++++++++++++---------- > 1 file changed, 22 insertions(+), 10 deletions(-) > > diff --git a/qa/rapi-workload.py b/qa/rapi-workload.py > index 495367b..e429f55 100755 > --- a/qa/rapi-workload.py > +++ b/qa/rapi-workload.py > @@ -27,6 +27,7 @@ > # due to invalid name > > import inspect > +import optparse > import sys > import types > > @@ -1049,15 +1050,24 @@ def Workload(client): > qa_config.ReleaseManyNodes(nodes) > > > -def Usage(): > - sys.stderr.write("Usage:\n\trapi-workload.py qa-config-file") > - > - > def Main(): > - if len(sys.argv) < 2: > - Usage() > + parser = optparse.OptionParser(usage="%prog [options] <config-file>") > + parser.add_option("--yes-do-it", dest="yes_do_it", > + action="store_true", > + help="Really execute the tests") > + parser.add_option("--show-invocations", dest="show_invocations", > + action="store_true", > + help="Show which client methods have and have not > been " > + "called") > + (opts, args) = parser.parse_args() > > - qa_config.Load(sys.argv[1]) > + if not opts.yes_do_it: > + print ("Executing this script irreversibly destroys any Ganeti\n" > + "configuration on all nodes involved. If you really want\n" > + "to start testing, supply the --yes-do-it option.") > + sys.exit(1) > + > + qa_config.Load(args[0]) > > # Only the master will be present after a fresh QA cluster setup, so we > have > # to invoke this to get all the other nodes. > @@ -1069,9 +1079,11 @@ def Main(): > > qa_node.TestNodeRemoveAll() > > - # pylint: disable=W0212 > - client._OutputMethodInvocationDetails() > - # pylint: enable=W0212 > + > + if opts.show_invocations: > + # pylint: disable=W0212 > + client._OutputMethodInvocationDetails() > + # pylint: enable=W0212 > > if __name__ == "__main__": > Main() > -- > 1.8.5.1 > > LGTM, thanks -- -- Helga Velroyen | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
