aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2017-04-12 15:21:21 +0200
committerMarco Capitani <m.capitani@nextworks.it>2017-04-12 15:21:21 +0200
commit22db738a842f8e21bb49f6431bd671d37073f832 (patch)
treeb7603c93d1f5b5b4e2487d89463f5a5d526be2e2 /tools
parent2b155aa25a2f61ad9bb84c273781a0597c6cef76 (diff)
downloadrumba-22db738a842f8e21bb49f6431bd671d37073f832.tar.gz
rumba-22db738a842f8e21bb49f6431bd671d37073f832.zip
Rumba tester v2: all-in-one testing tool
Deep reworking of the testing tool, it can be provided with a (demo-like) .conf file, a testbed and a prototype, and it auto-runs the experiment. Removed generated testing scripts.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/democonf2rumba.py199
1 files changed, 135 insertions, 64 deletions
diff --git a/tools/democonf2rumba.py b/tools/democonf2rumba.py
index 9a30174..dab7627 100755
--- a/tools/democonf2rumba.py
+++ b/tools/democonf2rumba.py
@@ -3,23 +3,26 @@
import argparse
import re
+import rumba.model as mod
-def make_experiment(filename, bzImage, initramfs):
+
+def make_experiment(filename, experiment_class, experiment_kwargs,
+ testbed_class, testbed_kwargs):
"""
:type filename str
- :param filename: path to the .conf file
- :param bzImage: path to the bzImage file
- :param initramfs: path to the rootfs.cpio file
- :return:
+ :param filename: path to the .conf file
+ :param experiment_class: subclass of mod.Experiment
+ :param experiment_kwargs: args dict for experiment constructor
+ (nodes will be overwritten)
+ :param testbed_class: subclass of mod.Testbed
+ :param testbed_kwargs: args dict for experiment constructor
+ (nodes will be overwritten)
"""
-
shims = {}
nodes = {}
difs = {}
- ex_name = filename.split('/')[-1].split('.')[0]
-
- print('Reading file %s, under project name %s.' % (filename, ex_name))
+ print('Reading file %s.' % (filename,))
with open(filename, 'r') as conf:
@@ -53,9 +56,9 @@ def make_experiment(filename, bzImage, initramfs):
if speed_unit == 'G':
speed = speed * 1000
- shims['shim' + shim] = {'name': 'shim' + shim,
- 'speed': speed,
- 'type': 'eth'}
+ shims[shim] = {'name':shim,
+ 'speed': speed,
+ 'type': 'eth'}
for vm in vm_list:
nodes.setdefault(vm, {'name': vm, 'difs': [],
@@ -98,60 +101,30 @@ def make_experiment(filename, bzImage, initramfs):
# File parsed
- output = '#!/usr/bin/env/python\n\n'
- output += (
- "from rumba.model import *\n\n"
-
- "# import testbed plugins\n"
- "import rumba.testbeds.emulab as emulab\n"
- "import rumba.testbeds.jfed as jfed\n"
- "import rumba.testbeds.faketestbed as fake\n"
- "import rumba.testbeds.qemu as qemu\n\n"
-
- "# import prototype plugins\n"
- "import rumba.prototypes.ouroboros as our\n"
- "import rumba.prototypes.rlite as rl\n"
- "import rumba.prototypes.irati as irati\n\n"
- )
+ parsed_difs = {}
for shim_name, shim in shims.items():
- output += '%(n)s = ShimEthDIF("%(n)s", link_speed=%(speed)s))\n' \
- % {'n': shim_name, 'speed': shim["speed"]}
-
- output += '\n'
+ parsed_difs[shim_name] = (mod.ShimEthDIF(shim_name,
+ link_speed=shim['speed']))
for dif_name, dif in difs.items():
- output += '%(n)s = NormalDIF("%(n)s")\n' % {'n': dif_name}
+ parsed_difs[dif_name] = (mod.NormalDIF(dif_name))
- output += '\n'
+ parsed_nodes = []
+ for node, node_data in nodes.items():
+ name = node_data['name']
+ difs = [parsed_difs[x] for x in node_data['difs']]
+ dif_registrations = {parsed_difs[x]: [parsed_difs[y] for y in l]
+ for x, l in node_data['dif_registrations']
+ .items()}
+ parsed_nodes.append(mod.Node(name, difs, dif_registrations))
- def str_of_list(i):
- return '[' + ', '.join(i) + ']'
+ testbed = testbed_class(**testbed_kwargs)
- def str_of_dict(d):
- return '{' + ', '.join(['%s: %s' % (k, str_of_list(v))
- for (k, v) in d.items()]) + '}'
+ experiment_kwargs['testbed'] = testbed
+ experiment_kwargs['nodes'] = parsed_nodes
- for node, node_data in nodes.items():
- name = node_data['name']
- output += '%(n)s = Node("%(n)s",\n' % {'n': name}
- output += ' difs=%s,\n' \
- % (str_of_list(node_data['difs']))
- output += ' dif_registrations=%s)\n\n' \
- % (str_of_dict(node_data['dif_registrations']))
-
- output += ('tb = qemu.Testbed(exp_name = "%(ex_name)s",\n'
- ' bzimage = "%(bzImage)s",\n'
- ' initramfs = "%(initramfs)s")\n\n'
- 'exp = rl.Experiment(tb, nodes = [a, b, c, d])\n\n'
- 'print(exp)\n\n'
- 'exp.run()\n'
- % {'ex_name': ex_name,
- 'bzImage': bzImage,
- 'initramfs': initramfs})
-
- with open(ex_name + '.py', 'w') as out_file:
- out_file.write(output)
+ return experiment_class(**experiment_kwargs).run()
if __name__ == '__main__':
@@ -160,17 +133,115 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description=description,
epilog=epilog)
- parser.add_argument('config', metavar='CONFIG', type=str,
+
+ prototype = parser.add_mutually_exclusive_group(required=True)
+ prototype.add_argument('--irati', action='store_true', default=False)
+ prototype.add_argument('--ouroboros', action='store_true', default=False)
+ prototype.add_argument('--rlite', action='store_true', default=False)
+
+ parser.add_argument('--config', metavar='CONFIG', type=str,
+ required=True,
help='Path to the config file to parse')
- parser.add_argument('bz_image', metavar='BZIMAGE', type=str,
- help='path to the bzImage file to use')
- parser.add_argument('initramfs', metavar='INITRAMFS', type=str,
- help='path to the initramfs file to use')
+
+ subparsers = parser.add_subparsers(dest='testbed')
+ emulab_p = subparsers.add_parser('emulab', help='Use emulab testbed')
+ jfed_p = subparsers.add_parser('jfed', help='Use jfed testbed')
+ qemu_p = subparsers.add_parser('qemu', help='Use qemu testbed')
+ fake_p = subparsers.add_parser('fake', help='Use fake testbed')
+
+ def setup_testbed_common_args(t_p):
+
+ t_p.add_argument('-E', '--exp_name', metavar='EXP_NAME', type=str,
+ required=True,
+ help='Experiment name')
+ t_p.add_argument('-U', '--username', metavar='USERNAME', type=str,
+ required=True,
+ help='Testbed user name')
+ t_p.add_argument('-P', '--proj_name', metavar='PROJECT_NAME', type=str,
+ help='Project name')
+ t_p.add_argument('-W', '--password', metavar='PASSWORD', type=str,
+ help='Testbed password')
+
+ for t in [emulab_p, jfed_p, qemu_p, fake_p]:
+ setup_testbed_common_args(t)
+
+ qemu_p.add_argument('-B', '--bzimage', metavar='BZIMAGE', type=str,
+ required=True,
+ help='path to the bzImage file to use')
+ qemu_p.add_argument('-I', '--initramfs', metavar='INITRAMFS', type=str,
+ required=True,
+ help='path to the initramfs file to use')
+ qemu_p.add_argument('-V', '--use_vhost', action='store_true',
+ default=False, help='Use vhost')
+ qemu_p.add_argument('-Q', '--qemu_logs_dir', metavar='QEMU_LOGS', type=str,
+ default=None, help='path to the folder for qemu logs')
+
+ emulab_p.add_argument('-R', '--url', metavar='URL', type=str,
+ default="wall2.ilabt.iminds.be",
+ help='Url')
+ emulab_p.add_argument('-I', '--image', metavar='IMG', type=str,
+ default="UBUNTU14-64-STD",
+ help='Ubuntu image')
+
+ jfed_p.add_argument('-C', '--cert_file', metavar='CERT', type=str,
+ required=True,
+ help='Certificate file')
+ jfed_p.add_argument('-J', '--jar', metavar='JAR', type=str,
+ required=True,
+ help='Jfed jar')
+ jfed_p.add_argument('-H', '--exp_hours', metavar='HOURS', type=int,
+ default=2, help='Experiment hours')
+ jfed_p.add_argument('-A', '--authority', metavar='AUTH', type=str,
+ default="wall2.ilabt.iminds.be",
+ help='Authority')
args = parser.parse_args()
+ if args.testbed == 'emulab':
+ import rumba.testbeds.emulab as emulab
+ testbed_class = emulab.Testbed
+ testbed_args = {a.dest: getattr(args, a.dest)
+ for a in emulab_p._actions if a.dest != 'help'}
+ elif args.testbed == 'jfed':
+ import rumba.testbeds.jfed as jfed
+ testbed_class = jfed.Testbed
+ testbed_args = {a.dest: getattr(args, a.dest)
+ for a in jfed_p._actions if a.dest != 'help'}
+ elif args.testbed == 'qemu':
+ import rumba.testbeds.qemu as qemu
+ testbed_class = qemu.Testbed
+ testbed_args = {a.dest: getattr(args, a.dest)
+ for a in qemu_p._actions if a.dest != 'help'}
+ elif args.testbed == 'fake':
+ import rumba.testbeds.faketestbed as fake
+ testbed_class = fake.Testbed
+ testbed_args = {a.dest: getattr(args, a.dest)
+ for a in fake_p._actions if a.dest != 'help'}
+ else:
+ if args.testbed is None:
+ print('Testbed type must be specified!')
+ print(parser.format_help())
+ exit(1)
+ raise ValueError('Unexpected testbed: %s.' % args.testbed)
+
+ if args.irati:
+ import rumba.prototypes.irati as irati
+ experiment_class = irati.Experiment
+ elif args.ouroboros:
+ import rumba.prototypes.ouroboros as ouroboros
+ experiment_class = ouroboros.Experiment
+ elif args.rlite:
+ import rumba.prototypes.rlite as rlite
+ experiment_class = rlite.Experiment
+ else:
+ raise ValueError('Unexpected prototype: %s.' % args.testbed)
+
try:
- make_experiment(args.config, args.bz_image, args.initramfs)
+ make_experiment(args.config,
+ experiment_class=experiment_class,
+ experiment_kwargs={},
+ testbed_class=testbed_class,
+ testbed_kwargs=testbed_args)
except KeyboardInterrupt:
print("Interrupted. Closing down.")