diff options
Diffstat (limited to 'qtip')
-rw-r--r-- | qtip/cli/commands/cmd_report.py | 8 | ||||
-rw-r--r-- | qtip/reporter/console.py | 34 | ||||
-rw-r--r-- | qtip/reporter/templates/base.j2 | 25 | ||||
-rw-r--r-- | qtip/reporter/templates/dpi.j2 | 5 | ||||
-rw-r--r-- | qtip/reporter/templates/ramspeed.j2 | 13 | ||||
-rw-r--r-- | qtip/reporter/templates/report.j2 | 22 | ||||
-rw-r--r-- | qtip/reporter/templates/ssl.j2 | 21 | ||||
-rw-r--r-- | qtip/reporter/templates/timeline.j2 | 4 | ||||
-rw-r--r-- | qtip/reporter/templates/unixbench.j2 | 10 | ||||
-rwxr-xr-x | qtip/scripts/cleanup_creds.sh | 4 | ||||
-rw-r--r-- | qtip/util/env.py | 20 |
11 files changed, 122 insertions, 44 deletions
diff --git a/qtip/cli/commands/cmd_report.py b/qtip/cli/commands/cmd_report.py index c780e847..cb9c70b6 100644 --- a/qtip/cli/commands/cmd_report.py +++ b/qtip/cli/commands/cmd_report.py @@ -10,6 +10,7 @@ import click from qtip.cli.entry import Context +from qtip.reporter.console import ConsoleReporter pass_context = click.make_pass_decorator(Context, ensure=False) @@ -22,6 +23,9 @@ def cli(ctx): @cli.command('show') +@click.argument('metric') @pass_context -def show(ctx): - pass +def show(ctx, metric): + reporter = ConsoleReporter({}) + report = reporter.render(metric) + click.echo(report) diff --git a/qtip/reporter/console.py b/qtip/reporter/console.py index 2b5130a6..64d677ba 100644 --- a/qtip/reporter/console.py +++ b/qtip/reporter/console.py @@ -7,24 +7,40 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import glob +import json +from os import path + from jinja2 import Environment from jinja2 import FileSystemLoader -from os import path from qtip.base import BaseActor +ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir) + class ConsoleReporter(BaseActor): - """ - report benchmark result to console - """ + """ report benchmark result to console """ + def __init__(self, config, parent=None): super(ConsoleReporter, self).__init__(config, parent=parent) # TODO (taseer) load template from config - tpl_loader = FileSystemLoader(path.join(path.dirname(__file__), 'templates')) - env = Environment(loader=tpl_loader) - self._template = env.get_template('timeline.j2') + tpl_path = path.join(path.dirname(__file__), 'templates') + tpl_loader = FileSystemLoader(tpl_path) + self._env = Environment(loader=tpl_loader) + self.result_path = path.join(ROOT_DIR, 'collector') + + def load_result(self): + # TODO (taseer) change result directory format more suitable to filter out + result_dirs = glob.glob('{}/20*'.format(self.result_path)) + # select the last (latest) directory for rendering report, result_dirs[-1] + with open(path.join(self.result_path, result_dirs[-1], 'result.json')) as sample: + result = json.load(sample) + return result - def render(self, var_dict): - out = self._template.render(var_dict) + def render(self, metric): + template = self._env.get_template('base.j2') + var_dict = self.load_result() + var_dict['metric_name'] = metric + out = template.render(var_dict) return out diff --git a/qtip/reporter/templates/base.j2 b/qtip/reporter/templates/base.j2 new file mode 100644 index 00000000..12a27536 --- /dev/null +++ b/qtip/reporter/templates/base.j2 @@ -0,0 +1,25 @@ +Plan Name: {{ plan_name }} +Start Time: {{ start_time }} +Stop Time: {{ stop_time }} +{%- for sys in sut -%} +{% for qpi in sys.qpis %} +{% for bm in qpi.benchmarks %} +{%- if bm.name == metric_name -%} +{%- if metric_name == 'dhrystone' or metric_name == 'whetstone' -%} +{# TODO (taseer) remove hardcoded material #} +{% include 'unixbench.j2' %} +{% else %} +{% include '%s.j2' % metric_name %} +{% endif %} +System Information: + CPU Brand: {{ bm.sysinfo.cpu }} + Disk: {{ bm.sysinfo.disk }} + Host Name: {{ bm.sysinfo.hostname }} + Kernel: {{ bm.sysinfo.kernel }} + Memory: {{ bm.sysinfo.memory }} + Operating System: {{ bm.sysinfo.os }} + Product: {{ bm.sysinfo.product }} +{%- endif -%} +{%- endfor -%} +{%- endfor -%} +{%- endfor -%} diff --git a/qtip/reporter/templates/dpi.j2 b/qtip/reporter/templates/dpi.j2 new file mode 100644 index 00000000..758a821e --- /dev/null +++ b/qtip/reporter/templates/dpi.j2 @@ -0,0 +1,5 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Bits per Second: {{ bm.results.bps }} + Packets per Second: {{ bm.results.pps }}
\ No newline at end of file diff --git a/qtip/reporter/templates/ramspeed.j2 b/qtip/reporter/templates/ramspeed.j2 new file mode 100644 index 00000000..d08d7e2e --- /dev/null +++ b/qtip/reporter/templates/ramspeed.j2 @@ -0,0 +1,13 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Float Addition: {{ bm.results.float_add }} + Float Average: {{ bm.results.float_average }} + Float Copy: {{ bm.results.float_copy }} + Float Scale: {{ bm.results.float_scale }} + Float Triad: {{ bm.results.float_triad }} + Integer Addition: {{ bm.results.integer_add }} + Integer Average: {{ bm.results.integer_average }} + Integer Copy: {{ bm.results.integer_copy}} + Integer Scale: {{ bm.results.integer_scale }} + Integer Triad: {{ bm.results.integer_triad}}
\ No newline at end of file diff --git a/qtip/reporter/templates/report.j2 b/qtip/reporter/templates/report.j2 deleted file mode 100644 index 766e6dde..00000000 --- a/qtip/reporter/templates/report.j2 +++ /dev/null @@ -1,22 +0,0 @@ -{{ title }} - -Plan: {{ plan.name }} - -{{ qpi.name }}: {{ qpi.score }} -Sections: -{% for section in sections %} - {{ section.name }}: {{ section.score }} - - Formula: {{ section.formula }} - Metrics: - {% for metric in section.metrics %} - {{ metric.name }}: {{ metric.score }} - Formula: {{ metric.formula }} - Workloads: - {% for workload in workloads %} - {{ workload.name }}: {{ workload.score }} - {% endfor %} - {% endfor %} -{% endfor %} - -{{ signature }} diff --git a/qtip/reporter/templates/ssl.j2 b/qtip/reporter/templates/ssl.j2 new file mode 100644 index 00000000..b46927a8 --- /dev/null +++ b/qtip/reporter/templates/ssl.j2 @@ -0,0 +1,21 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm.cpu_usage }} +Results: + AES 128 CBC (bytes): + 16: {{ bm.results.aes_128_cbc_16_bytes }} + 64: {{ bm.results.aes_128_cbc_64_bytes }} + 256: {{ bm.results.aes_128_cbc_256_bytes }} + 1024: {{ bm.results.aes_128_cbc_1024_bytes }} + 8192: {{ bm.results.aes_128_cbc_8192_bytes }} + + RSA SIGN: + 512: {{ bm.results.rsa_sign_512 }} + 1024: {{ bm.results.rsa_sign_1024 }} + 2048: {{ bm.results.rsa_sign_2048 }} + 4096: {{ bm.results.rsa_sign_4096 }} + + RSA VERIFY: + 512: {{ bm.results.rsa_verify_512 }} + 1024: {{ bm.results.rsa_verify_1024 }} + 2048: {{ bm.results.rsa_verify_2048 }} + 4096: {{ bm.results.rsa_verify_4096 }}
\ No newline at end of file diff --git a/qtip/reporter/templates/timeline.j2 b/qtip/reporter/templates/timeline.j2 index d4c95c46..ccb089e0 100644 --- a/qtip/reporter/templates/timeline.j2 +++ b/qtip/reporter/templates/timeline.j2 @@ -1,8 +1,8 @@ {{ title }} {% for phase in phases %} -{{ phase.name|upper }}{{ "TIME" }} +{{ phase.name|upper }}{{ "TIME"}} {% for cp in phase.checkpoints %} -{{ cp.name }}{{ cp.timestamp}} +{{ cp.name }}{{ cp.timestamp| indent(15, True)}} {% endfor %} {% endfor %} Total: {{ total }} diff --git a/qtip/reporter/templates/unixbench.j2 b/qtip/reporter/templates/unixbench.j2 new file mode 100644 index 00000000..69006da7 --- /dev/null +++ b/qtip/reporter/templates/unixbench.j2 @@ -0,0 +1,10 @@ +Benchmark: {{ bm.name }} +CPU Usage: {{ bm. cpu_usage }} +Results: + Multi CPU: + Number: {{ bm.results.multi_cpus.num }} + Score: {{ bm.results.multi_cpus.score }} + Single CPU: + Number: {{ bm.results.single_cpu.num }} + Score: {{ bm.results.single_cpu.num }} + Total CPUs: {{ bm.results.total_cpus }}
\ No newline at end of file diff --git a/qtip/scripts/cleanup_creds.sh b/qtip/scripts/cleanup_creds.sh index 1a7ddc1a..ad66ba95 100755 --- a/qtip/scripts/cleanup_creds.sh +++ b/qtip/scripts/cleanup_creds.sh @@ -10,11 +10,11 @@ DEST_IP=$1 PRIVATE_KEY=$2 -HOSTNAME=$(hostname) +PUBLIC_KEY=$3 sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" case "$INSTALLER_TYPE" in fuel) - ssh $sshoptions -i $PRIVATE_KEY root@$DEST_IP "sed -i '/root@$HOSTNAME/d' /root/.ssh/authorized_keys" + ssh $sshoptions -i $PRIVATE_KEY root@$DEST_IP "sed -i '/$PUBLIC_KEY/d' /root/.ssh/authorized_keys" ;; esac diff --git a/qtip/util/env.py b/qtip/util/env.py index d00320c4..9299f8c0 100644 --- a/qtip/util/env.py +++ b/qtip/util/env.py @@ -94,7 +94,8 @@ class AnsibleEnvSetup(object): if not all_files_exist(PRIVATE_KEY, PUBLIC_KEY): logger.info("Generate default keypair {0} under " "{1}".format(KEYNAME, os.environ['HOME'])) - cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048'''.format(PRIVATE_KEY) + cmd = '''ssh-keygen -t rsa -N "" -f {0} -q -b 2048 + -C qtip@insecure'''.format(PRIVATE_KEY) os.system(cmd) self.keypair['private'] = PRIVATE_KEY self.keypair['public'] = PUBLIC_KEY @@ -192,14 +193,19 @@ class AnsibleEnvSetup(object): def cleanup(self): CI_DEBUG = os.getenv('CI_DEBUG') - if CI_DEBUG: + if CI_DEBUG is not None and CI_DEBUG.lower() == 'true': logger.info("DEBUG Mode: please do cleanup by manual.") else: - for ip in self.host_ip_list: - logger.info("Cleanup authorized_keys from {0}...".format(ip)) - cmd = 'bash {0}/cleanup_creds.sh {1} {2}'.format( - SCRIPT_DIR, ip, self.keypair['private']) - os.system(cmd) + with open(self.keypair['public'], 'r') as f: + key = f.read().strip('\n').replace('/', '\/') + if key: + for ip in self.host_ip_list: + logger.info("Cleanup authorized_keys from {0}...".format(ip)) + cmd = '''bash {0}/cleanup_creds.sh {1} {2} "{3}"'''.format( + SCRIPT_DIR, ip, self.keypair['private'], key) + os.system(cmd) + else: + logger.error("Nothing in public key file.") logger.info("Cleanup hostfile and keypair.") clean_file(self.hostfile, |