def populate_params(cls): for idx in range(len(cls.env.target.bl.bigs)): task = cls.task_prefix + str(idx) cls.params[task] = Periodic(**BIG_WORKLOAD).get() for idx in range(len(cls.env.target.bl.littles)): task = cls.task_prefix + str(idx) cls.params[task] = Periodic(**SMALL_WORKLOAD).get()
def test_invalid_composition(self): """Test that you can't compose tasks with a delay in the second task""" t1 = Periodic() t2 = Periodic(delay_s=1) # Should work fine if delayed task is the first one try: t3 = t2 + t1 except Exception as e: raise AssertionError("Couldn't compose tasks: {}".format(e)) # But not the other way around with self.assertRaises(ValueError): t3 = t1 + t2
def populate_tasks(cls): migrator_workload = BIG_WORKLOAD.copy() migrator_workload["duration_s"] = 9 migrator_workload["delay_s"] = OFFLOAD_MIGRATION_MIGRATOR_DELAY for idx in range(cls.num_tasks): task = "early_starters" + str(idx) cls.params[task] = Periodic(**BIG_WORKLOAD).get() cls.early_starters.append(task) # Tasks that will be idle pulled task = "migrator" + str(idx) cls.params[task] = Periodic(**migrator_workload).get() cls.migrators.append(task)
def __init__(self, name, test_env, cpus, period_ms=100, duty_cycle_pct=50, duration_s=1, kind='profile', num_tasks=1): super(Task, self).__init__("task") self.name = name self.period_ms = period_ms self.duty_cycle_pct = duty_cycle_pct self.duration_s = duration_s self.cpus = cpus allowed_kinds = ['profile', 'custom'] if kind not in allowed_kinds: raise ValueError('{} not allowed, kind can be one of {}' .format(kind, allowed_kinds)) self.kind = kind self.num_tasks = num_tasks # Create rt-app workload t = Periodic(period_ms=period_ms, duty_cycle_pct=duty_cycle_pct, duration_s=duration_s).get() self.wload = RTA(test_env.target, name, test_env.calibration()) if num_tasks > 1: conf_params = {name + "_{}".format(i): t for i in xrange(num_tasks)} else: conf_params = {name: t} self.wload.conf(kind=kind, params=conf_params, run_dir=test_env.target.working_directory)
def populate_params(cls): for idx in range(len(cls.env.target.bl.bigs)): task_name = "busy_thread{}".format(idx) cls.params[task_name] = Periodic( duty_cycle_pct=BIG_DCYCLE, duration_s=WORKLOAD_DURATION_S, period_ms=WORKLOAD_PERIOD_MS, ).get()
def _get_calib_conf(self, calibration): rtapp = RTA(self.target, name='test', calibration=calibration) rtapp.conf(kind='profile', params={'t1': Periodic().get()}, run_dir=self.target_run_dir) with open(rtapp.json) as f: return json.load(f)['global']['calibration']
def populate_params(cls): cls.rtapp = RTA(cls.target,cls.rta_name) cls.rtapp.conf( kind='profile', params={ cls.task_name: Periodic( period_ms=40, duty_cycle_pct=1, duration_s=2, cpus=cls.test_cpu, ).get(), }, run_dir='/tmp' )
def test_profile_periodic_smoke(self): """ Smoketest Periodic rt-app workload Creates a workload using Periodic, tests that the JSON has the expected content, then tests that it can be run. """ rtapp = RTA(self.target, name='test', calibration=self.calibration) rtapp.conf(kind='profile', params={ 'task_p20': Periodic( period_ms=100, duty_cycle_pct=20, duration_s=1, ).get(), }, run_dir=self.target_run_dir) with open(rtapp.json) as f: conf = json.load(f) [phase] = conf['tasks']['task_p20']['phases'].values() self.assertDictEqual( phase, { 'loop': 10, 'run': 20000, 'timer': { 'period': 100000, 'ref': 'task_p20' } }) rtapp.run(out_dir=self.host_out_dir) rtapp_cmds = [ c for c in self.target.executed_commands if 'rt-app' in c ] self.assertListEqual(rtapp_cmds, [self.get_expected_command(rtapp)]) self.assert_output_file_exists('output.log') self.assert_output_file_exists('test_00.json') self.assert_output_file_exists('rt-app-task_p20-0.log') self.assert_can_read_logfile(exp_tasks=['task_p20'])
def test_profile_periodic_smoke(self): """ Smoketest Periodic rt-app workload Creates a workload using Periodic, tests that the JSON has the expected content, then tests that it can be run. """ task = Periodic(period_ms=100, duty_cycle_pct=20, duration_s=1) exp_phases = [{ 'loop': 10, 'run': 20000, 'timer': { 'period': 100000, 'ref': 'my_task' } }] self._do_test(task, exp_phases)
def test_composition(self): """ Test RTA task composition with __add__ Creates a composed workload by +-ing RTATask objects, tests that the JSON has the expected content, then tests running the workload """ light = Periodic(duty_cycle_pct=10, duration_s=1.0, period_ms=10) start_pct = 10 end_pct = 90 delta_pct = 20 num_ramp_phases = ((end_pct - start_pct) / delta_pct) + 1 ramp = Ramp(start_pct=start_pct, end_pct=end_pct, delta_pct=delta_pct, time_s=1, period_ms=50) heavy = Periodic(duty_cycle_pct=90, duration_s=0.1, period_ms=100) task = light + ramp + heavy exp_phases = [ # Light phase: { "loop": 100, "run": 1000, "timer": { "period": 10000, "ref": "my_task" } }, # Ramp phases: { "loop": 20, "run": 5000, "timer": { "period": 50000, "ref": "my_task" } }, { "loop": 20, "run": 15000, "timer": { "period": 50000, "ref": "my_task" } }, { "loop": 20, "run": 25000, "timer": { "period": 50000, "ref": "my_task" } }, { "loop": 20, "run": 35000, "timer": { "period": 50000, "ref": "my_task" } }, { "loop": 20, "run": 45000, "timer": { "period": 50000, "ref": "my_task" } }, # Heavy phase: { "loop": 1, "run": 90000, "timer": { "period": 100000, "ref": "my_task" } } ] self._do_test(task, exp_phases)
def test_composition(self): """ Test RTA task composition with __add__ Creates a composed workload by +-ing RTATask objects, tests that the JSON has the expected content, then tests running the workload """ rtapp = RTA(self.target, name='test', calibration=self.calibration) light = Periodic(duty_cycle_pct=10, duration_s=1.0, period_ms=10) start_pct = 10 end_pct = 90 delta_pct = 20 num_ramp_phases = ((end_pct - start_pct) / delta_pct) + 1 ramp = Ramp(start_pct=start_pct, end_pct=end_pct, delta_pct=delta_pct, time_s=1, period_ms=50) heavy = Periodic(duty_cycle_pct=90, duration_s=0.1, period_ms=100) lrh_task = light + ramp + heavy rtapp.conf(kind='profile', params={'task_ramp': lrh_task.get()}, run_dir=self.target_run_dir) with open(rtapp.json) as f: conf = json.load(f, object_pairs_hook=OrderedDict) phases = conf['tasks']['task_ramp']['phases'].values() exp_phases = [ # Light phase: { "loop": 100, "run": 1000, "timer": { "period": 10000, "ref": "task_ramp" } }, # Ramp phases: { "loop": 20, "run": 5000, "timer": { "period": 50000, "ref": "task_ramp" } }, { "loop": 20, "run": 15000, "timer": { "period": 50000, "ref": "task_ramp" } }, { "loop": 20, "run": 25000, "timer": { "period": 50000, "ref": "task_ramp" } }, { "loop": 20, "run": 35000, "timer": { "period": 50000, "ref": "task_ramp" } }, { "loop": 20, "run": 45000, "timer": { "period": 50000, "ref": "task_ramp" } }, # Heavy phase: { "loop": 1, "run": 90000, "timer": { "period": 100000, "ref": "task_ramp" } } ] self.assertListEqual(phases, exp_phases) rtapp.run(out_dir=self.host_out_dir) rtapp_cmds = [ c for c in self.target.executed_commands if 'rt-app' in c ] self.assertListEqual(rtapp_cmds, [self.get_expected_command(rtapp)]) self.assert_output_file_exists('output.log') self.assert_output_file_exists('test_00.json') self.assert_output_file_exists('rt-app-task_ramp-0.log') self.assert_can_read_logfile(exp_tasks=['task_ramp'])
def populate_params(cls): for i in range(cls.num_tasks): task = cls.task_prefix + str(i) cls.params[task] = Periodic(**SMALL_WORKLOAD).get()