def test_pre_execute_copy(self): with mkdtemp() as path: with pushd(path): benchmark = IOSSD() benchmark.pre_execute(None) self.assertTrue(osp.isfile(IOSSD.SCRIPT_NAME)) self.assertTrue(os.access(IOSSD.SCRIPT_NAME, os.X_OK))
def test_executable(self): with pushd(self.temp_dir): benmerge.main([ bensh.main(TestMerge.campaign_file()).campaign_path, bensh.main(TestMerge.campaign_file()).campaign_path, bensh.main(TestMerge.campaign_file()).campaign_path, ])
def main(argv=None): """ben-doc entry point""" arguments = cli_common(__doc__, argv=argv) campaign_path = arguments['CAMPAIGN-DIR'] driver = CampaignDriver(campaign_path=campaign_path) with pushd(campaign_path): render(driver, template=arguments['--template'], ostr=arguments['--output'])
def check_category_metrics(self, category): self.logger.info('testing metrics of category %s', category) self.maxDiff = None with mkdtemp() as top_dir, pushd(top_dir): with open(YAML_REPORT_FILE, 'w') as ostr: yaml.dump(dict(children=['sample-run'], category=category), ostr) with pushd('sample-run'): self.create_sample_run(category) clazz = self.get_benchmark_clazz() benchmark = clazz() with open(YAML_REPORT_FILE, 'w') as ostr: yaml.dump(dict(category=category), ostr) md = MetricsDriver('test-category', benchmark) report = md() parsed_metrics = report.get('metrics', {}) expected_metrics = self.get_expected_metrics(category) self.assertEqual(parsed_metrics, expected_metrics)
def test_pushd(self): cwd = osp.realpath(os.getcwd()) with mkdtemp() as path, pushd(path) as ppath: path = osp.realpath(path) ppath = osp.realpath(ppath) cwd_in_context = osp.realpath(os.getcwd()) self.assertNotEqual(cwd, cwd_in_context) self.assertEqual(path, ppath) self.assertEqual(path, cwd_in_context) self.assertEqual(cwd, osp.realpath(os.getcwd())) self.assertFalse(osp.isdir(path))
def main(argv=None): """ben-elastic entry point""" arguments = cli_common(__doc__, argv=argv) campaign_path = arguments['CAMPAIGN-DIR'] driver = CampaignDriver(campaign_path=campaign_path) es_host = arguments['--es'] if es_host: es_conf = driver.campaign.campaign.export.elasticsearch es_conf.host = es_host driver.campaign.export.elasticsearch.hosts = es_host es_export = ESExporter(driver) with pushd(campaign_path): es_export.export() if argv is not None: return es_export
def _aggregate_tarball(self, path): with mkdtemp(prefix='hpcbench-campaign-result', remove=False) as tmpd: local_output_dir = os.getcwd() with pushd(tmpd): subprocess.check_call(['tar', 'jxf', path]) dirs = [ _dir for _dir in os.listdir(self.remote_output_dir) if osp.isdir(osp.join(self.remote_output_dir, _dir)) ] if len(dirs) != 1: raise Exception('Expected one directory but got: %s' % dirs) shutil.move( osp.join(self.remote_output_dir, dirs[0]), osp.join(local_output_dir, self.node) )
def run(self, *nodes): """Execute benchmarks on every node specified in arguments. If none are given, then execute benchmarks on every nodes specified in the ``network.nodes`` campaign configuration. """ nodes = nodes or self.nodes self._prelude(*nodes) @write_yaml_report def _run(): self._build_installer() runner = functools.partial(run_on_host, self.campaign) if self.campaign.network.max_concurrent_runs > 1: pool = Pool(self.campaign.network.max_concurrent_runs) pool.map(runner, nodes) else: for node in nodes: runner(node) return nodes with pushd(self.campaign_path): _run()
def test_different_host(self): with pushd(self.temp_dir): campaign = TestMerge.campaign_file() bench1 = bensh.main(['-n', 'foo', campaign]) bench2 = bensh.main(['-n', 'bar', campaign]) merge_campaigns(bench1.campaign_path, bench2.campaign_path)
def test_same_host(self): with pushd(self.temp_dir): bench1 = bensh.main(TestMerge.campaign_file()) bench2 = bensh.main(TestMerge.campaign_file()) merge_campaigns(bench1.campaign_path, bench2.campaign_path)
def setUpClass(cls): cls.TEST_DIR = tempfile.mkdtemp() with pushd(TestDriver.TEST_DIR): cls.driver = bensh.main(cls.get_campaign_file()) cls.CAMPAIGN_PATH = osp.join(TestDriver.TEST_DIR, cls.driver.campaign_path)
def test_local(self): with mkdtemp() as temp_dir: with pushd(temp_dir): bennett.main(TestNet.get_campaign_file())
def setUpClass(cls): cls.TEST_DIR = tempfile.mkdtemp(prefix='hpcbench-ut') with pushd(cls.TEST_DIR): cls.driver = bensh.main(cls.get_campaign_file()) cls.CAMPAIGN_PATH = osp.join(cls.TEST_DIR, cls.driver.campaign_path)