def test_sha1hash(self): c = make_system_composition('localhost') c.jvm = JVM('path', 'options') h = sha1() update_hasher(h, c.jvm.hash()) update_hasher(h, c.node_setting.hash()) self.assertEqual(c.hash(), h.hexdigest())
def test_client_cycle(self): c = make_system_composition() w = ScalaBench('jython') f = DacapoHarness() s = Send() r = Receive() p = Print() c.jvm.workload = w c.flow = [f >> f >> s] j = Job(c, [r >> p]) self.assertFalse(j.check())
def setUp(self): self.workload = ScalaBench('dummy') self.workload.out['test'].append(42) self.tool = HProf('') self.tool.out['test'].append(23) self.filter = DacapoHarness() self.filter.out['test'].append(5) self.comp = make_system_composition() self.comp.jvm.workload = self.workload self.comp.jvm.tool = self.tool self.comp.flow = [Edge(self.workload, self.filter)]
def test_wrapped_jvm(self): c = make_system_composition() c.jvm = ValgrindJVM('jvm') w = ScalaBench('jython') s = Send() r = Receive() p = Print() c.jvm.workload = w c.flow = [c.jvm >> ('valgrind_log', 'payload') >> s] j = Job(c, [r >> p]) self.assertTrue(j.check())
def test_wrong_output(self): c = make_system_composition() w = ScalaBench('jython') f = DacapoHarness() s = Send() r = Receive() p = Print() c.jvm.workload = w c.flow = [w >> ('a', 'stderr') >> f >> s] j = Job(c, [r >> p]) self.assertFalse(j.check())
def test_save_relative(self): s = "'tis a test string" save_file = 'penchy-save-test' comp = make_system_composition() comp.node_setting.path = '/tmp' save_path = os.path.join(comp.node_setting.path, save_file) save = Save(save_file) save.run(data=s, **{':environment:' : {'current_composition': comp}}) with open(save_path) as f: self.assertEqual(f.read(), s) os.remove(save_path)
def test_valid_job(self): c = make_system_composition() w = ScalaBench('jython') f = DacapoHarness() s = Send() r = Receive() p = Print() c.jvm.workload = w c.flow = [w >> f >> ('times', 'payload') >> s] j = Job(c, [r >> p]) self.assertTrue(j.check())
def test_server_cycle(self): c = make_system_composition() w = ScalaBench('jython') f = DacapoHarness() s = Send() r = Receive() p = Print() m = MockPipelineElement() m.inputs = Types(('a', int)) m.outputs = Types(('a', int)) c.jvm.workload = w c.flow = [w >> f >> s] j = Job(c, [r >> m >> m >> p]) self.assertFalse(j.check())
def test_correct_path(self): comp = make_system_composition() comp.flow = [Print() >> Print()] j = Job(comp, [Receive() >> Print()]) path = j.visualize() self.assertTrue(os.path.exists(path)) path_pdf = j.visualize('pdf') self.assertTrue(os.path.exists(path_pdf)) self.assertTrue(path_pdf.endswith('.pdf')) self.assertFalse(os.path.exists(os.path.splitext(path)[0])) self.assertFalse(os.path.exists(os.path.splitext(path_pdf)[0])) os.remove(path) os.remove(path_pdf)
def test_relative_copy(self): s = "'tis a test string" comp = make_system_composition() comp.node_setting.path = '/tmp' with NamedTemporaryFile(delete=False) as f: path = f.name write(f, s) self.assertTrue(os.path.exists(path)) backup_file = 'penchy-backup-test' backup_path = os.path.join(comp.node_setting.path, backup_file) b = BackupFile(backup_file) b.run(filename=path, **{':environment:' : {'current_composition' : comp}}) # did backup? with open(backup_path) as f: self.assertEqual(f.read(), s) # did not modify backuped file? with open(path) as f: self.assertEqual(f.read(), s) os.remove(path) os.remove(os.path.join(comp.node_setting.path, backup_path))
def test_hash(self): c = make_system_composition() self.assertIn(c, set((c,)))
def setUp(self): self.single_host = [make_system_composition('192.168.1.10')] self.multi_host = [make_system_composition('192.168.1.11'), make_system_composition('192.168.1.11')] self.job = Job(self.single_host + self.multi_host, [])
def test_empty_workload(self): config = make_system_composition() config.jvm.tool = HProf('') self.assertSetEqual(Job(config, [], [])._get_client_dependencies(config), HProf.DEPENDENCIES)
def test_no_workload(self): c = make_system_composition() j = Job(c, []) self.assertFalse(j.check())
def setUp(self): self.job = Job(make_system_composition(), [])