def test_get_file_names(self): ed = ExperimentDefinition(seed="seeeed", machine="machine", trace_type="double", manifest_list=[{ "share": 0.2, "manifest": "man1.json" }, { "share": 0.8, "manifest": "man2.json" }], workflow_policy="period", workflow_period_s=20, workflow_share=30.0, workflow_handling="manifest", subtraces=[100002, 10003], preload_time_s=3600 * 24 * 3, workload_duration_s=3600 * 24 * 8, work_state="fresher", analysis_state="1") self.assertEqual( ed.get_trace_file_name(), "machine-double-m0.2man1.json" "0.8man2.json" "-period-p20-30.0-manifest-t10000210003-3d-8d-O0.0" "-sseeeed.trace") self.assertEqual( ed.get_qos_file_name(), "machine-double-m0.2man1.json" "0.8man2.json" "-period-p20-30.0-manifest-t10000210003-3d-8d-O0.0" "-sseeeed.qos") self.assertEqual( ed.get_users_file_name(), "machine-double-m0.2man1.json" "0.8man2.json" "-period-p20-30.0-manifest-t10000210003-3d-8d-O0.0" "-sseeeed.users")
def test_generate_trace_files_special(self): ExperimentRunner.configure("tmp/trace_folder", "tmp", True, "myhost", "myUser") ed = ExperimentDefinition( seed="AAAA", machine="edison", trace_type="single", manifest_list=[], workflow_policy="sp-sat-p2-c24-r36000-t4-b100", workflow_period_s=0, workflow_handling="single", preload_time_s=0, start_date=datetime(2016, 1, 1), workload_duration_s=120, overload_target=1.2) er = ExperimentRunner(ed) er._generate_trace_files(ed) trace_file_route = ("tmp/{0}".format(ed.get_trace_file_name())) self.assertTrue(os.path.exists(trace_file_route)) records = trace_gen.extract_records( file_name=trace_file_route, list_trace_location="../bin/list_trace") self.assertEqual(len(records), 8) submit_times = [0, 2, 4, 6, 100, 102, 104, 106] first_submit = int(records[0]["SUBMIT"]) submit_times = [x + first_submit for x in submit_times] for (rec, submit_time) in zip(records, submit_times): self.assertEqual(int(rec["SUBMIT"]), submit_time) self.assertEqual( int(rec["NUM_TASKS"]) * int(rec["CORES_PER_TASK"]), 24) self.assertEqual(int(rec["DURATION"]), 36000) self.assertEqual(int(rec["WCLIMIT"]), 601)
def test_generate_trace_files_overload(self): for seed_string in [ "seeeed", "asdsa", "asdasdasd", "asdasdasdas", "asdasdlkjlkjl", "eworiuwioejrewk", "asjdlkasdlas" ]: ExperimentRunner.configure("tmp/trace_folder", "tmp", True, "myhost", "myUser") self.assertEqual(ExperimentRunner._trace_folder, "tmp/trace_folder") self.assertEqual(ExperimentRunner._trace_generation_folder, "tmp") self.assertEqual(ExperimentRunner._local, True) workload_duration = 4 * 3600 m = Edison2015() total_cores = m.get_total_cores() ed = ExperimentDefinition(seed=seed_string, machine="edison", trace_type="single", manifest_list=[], workflow_policy="no", workflow_period_s=0, workflow_handling="single", preload_time_s=0, start_date=datetime(2016, 1, 1), workload_duration_s=workload_duration, overload_target=1.2) er = ExperimentRunner(ed) er._generate_trace_files(ed) trace_file_route = ("tmp/{0}".format(ed.get_trace_file_name())) self.assertTrue(os.path.exists(trace_file_route)) records = trace_gen.extract_records( file_name=trace_file_route, list_trace_location="../bin/list_trace") acc_core_hours = 0 for rec in records: acc_core_hours += (int(rec["NUM_TASKS"]) * int(rec["CORES_PER_TASK"]) * int(rec["DURATION"])) print("pressure Index:", (float(acc_core_hours) / float(total_cores * workload_duration))) self.assertGreater(acc_core_hours, 1.1 * total_cores * workload_duration) self.assertLess(acc_core_hours, 1.5 * total_cores * workload_duration)