diff options
author | 2016-01-15 19:40:28 +0800 | |
---|---|---|
committer | 2016-01-15 21:44:45 +0800 | |
commit | 2ed0a4e85f710c24aae778634e9d48920d004f09 (patch) | |
tree | 1a2e7df61d75382374255bafa4ac611e46d359df /yardstick/benchmark/scenarios/networking/ping6.py | |
parent | bb82fb8c9198d6e792b8558bf6eaf4f53710c7fe (diff) |
fix some bug in ipv6 to make it run in ci
JIRA:YARDSTICK-187
Change-Id: Ia15d17afdef145f7b230a8a4d25a61eed5cdfd76
Signed-off-by: kubi <jean.gaoliang@huawei.com>
Diffstat (limited to 'yardstick/benchmark/scenarios/networking/ping6.py')
-rw-r--r-- | yardstick/benchmark/scenarios/networking/ping6.py | 84 |
1 files changed, 73 insertions, 11 deletions
diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index 5d878eb8f..067b8893e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -25,9 +25,12 @@ class Ping6(base.Scenario): # pragma: no cover __scenario_type__ = "Ping6" TARGET_SCRIPT = 'ping6_benchmark.bash' + PRE_SETUP_SCRIPT = 'ping6_pre_setup.bash' SETUP_SCRIPT = 'ping6_setup.bash' + FIND_HOST_SCRIPT = 'ping6_find_host.bash' TEARDOWN_SCRIPT = 'ping6_teardown.bash' METADATA_SCRIPT = 'ping6_metadata.txt' + POST_TEARDOWN_SCRIPT = 'ping6_post_teardown.bash' def __init__(self, scenario_cfg, context_cfg): self.scenario_cfg = scenario_cfg @@ -35,13 +38,23 @@ class Ping6(base.Scenario): # pragma: no cover self.setup_done = False self.run_done = False - def _ssh_host(self): - # ssh host1 - host = self.context_cfg['host'] - host_user = host.get('user', 'ubuntu') - host_ip = host.get('ip', None) - host_pwd = host.get('password', 'root') - LOG.info("user:%s, host:%s", host_user, host_ip) + def _pre_setup(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/pre_setup.sh", + stdin=open(self.pre_setup_script, "rb")) + status, stdout, stderr = self.client.execute( + "sudo bash pre_setup.sh") + + def _ssh_host(self, node_name): + # ssh host + print node_name + nodes = self.context_cfg['nodes'] + node = nodes.get(node_name, None) + host_user = node.get('user', 'ubuntu') + host_ip = node.get('ip', None) + host_pwd = node.get('password', 'root') + LOG.debug("user:%s, host:%s", host_user, host_ip) self.client = ssh.SSH(host_user, host_ip, password=host_pwd) self.client.wait(timeout=600) @@ -51,11 +64,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.SETUP_SCRIPT) + self.pre_setup_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.PRE_SETUP_SCRIPT) + self.ping6_metadata_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', Ping6.METADATA_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + pre_setup = options.get("pre_setup", True) + if pre_setup: + self._pre_setup() + # ssh host1 - self._ssh_host() + self._ssh_host(self.host_list[0]) # run script to setup ipv6 self.client.run("cat > ~/setup.sh", stdin=open(self.setup_script, "rb")) @@ -73,9 +99,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.TARGET_SCRIPT) - if not self.setup_done: - self._ssh_host() + self.ping6_find_host_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.FIND_HOST_SCRIPT) + if not self.setup_done: + options = self.scenario_cfg['options'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + self._ssh_host(self.host_list[0]) + self.client.run("cat > ~/find_host.sh", + stdin=open(self.ping6_find_host_script, "rb")) + cmd = "sudo bash find_host.sh" + LOG.debug("Executing command: %s", cmd) + status, stdout, stderr = self.client.execute(cmd) + host_name = stdout.strip() + print host_name + self._ssh_host(host_name) self.client.run("cat > ~/ping6.sh", stdin=open(self.ping6_script, "rb")) cmd = "sudo bash ping6.sh" @@ -99,8 +140,17 @@ class Ping6(base.Scenario): # pragma: no cover def teardown(self): """teardown the benchmark""" + self.post_teardown_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.POST_TEARDOWN_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'node1') + self.host_list = host_str.split(',') + self.host_list.sort() + if not self.run_done: - self._ssh_host() + self._ssh_host(self.host_list[0]) self.teardown_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', @@ -110,6 +160,10 @@ class Ping6(base.Scenario): # pragma: no cover cmd = "sudo bash teardown.sh" status, stdout, stderr = self.client.execute(cmd) + post_teardown = options.get("post_teardown", True) + if post_teardown: + self._post_teardown() + if status: raise RuntimeError(stderr) @@ -117,3 +171,11 @@ class Ping6(base.Scenario): # pragma: no cover pass else: LOG.error("ping6 teardown failed") + + def _post_teardown(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/post_teardown.sh", + stdin=open(self.post_teardown_script, "rb")) + status, stdout, stderr = self.client.execute( + "sudo bash post_teardown.sh") |