1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
13 from oslo_serialization import jsonutils
15 import yardstick.ssh as ssh
16 from yardstick.benchmark.scenarios import base
18 LOG = logging.getLogger(__name__)
21 class PluginTest(base.Scenario):
22 """Sample scenario file for testing sample plugin"""
23 __scenario_type__ = "PluginTest"
25 def __init__(self, scenario_cfg, context_cfg):
26 self.scenario_cfg = scenario_cfg
27 self.context_cfg = context_cfg
28 self.setup_done = False
33 nodes = self.context_cfg['nodes']
34 node = nodes.get('host1', None)
35 host_user = node.get('user', 'ubuntu')
36 host_ssh_port = node.get('ssh_port', ssh.DEFAULT_PORT)
37 host_ip = node.get('ip', None)
38 host_pwd = node.get('password', 'root')
39 LOG.debug("user:%s, host:%s", host_user, host_ip)
40 self.client = ssh.SSH(host_user, host_ip, password=host_pwd,
42 self.client.wait(timeout=600)
44 self.setup_done = True
46 def run(self, result):
47 """execute the benchmark"""
49 if not self.setup_done:
52 cmd = "sudo bash test.sh"
54 LOG.debug("Executing command: %s", cmd)
55 status, stdout, stderr = self.client.execute(cmd)
57 raise RuntimeError(stderr)
59 result.update(jsonutils.loads(stdout))