def add_command(self, run_time, number): run_time = int(run_time) number = int(number) finish_events = { "disco": DiskFinishedEvent, "leitora1": LeitoraUmFinishedEvent, "leitora2": LeitoraDoisFinishedEvent, "impressora1": ImpressoraUmFinishedEvent, "impressora2": ImpressoraDoisFinishedEvent } for _ in range(number): io = { "disco": None, "leitora1": None, "leitora2": None, "impressora1": None, "impressora2": None } last_start_cycles = [1] for dev in io.keys(): io_requests = [] has_device = bool(random.random() < 0.9) if not has_device: continue number_requests = random.randint(1, 5) for i in range(number_requests): io_cycles = random.randint(*io_config[dev]) start_cycle = 1 try: start_cycle = random.randint( last_start_cycles[-1], i * run_time // number_requests - io_cycles) if start_cycle in last_start_cycles: continue last_start_cycles.append(start_cycle) except ValueError: continue io_requests.append((start_cycle, io_cycles)) if len(io_requests): io[dev] = Device(dev, io_requests, finish_events[dev]) job_priority = random.choice(list(JobPriority)) job_size = random.randint(10, 70) new_job = Job(self.job_ids, run_time, job_priority, io, job_size) self.job_ids += 1 self.os.add_job(new_job)
def __init__(self, config, owner=None, simulation=False): threading.Thread.__init__(self) Device.__init__(self, config, owner, simulation) self.on_percent = 0.0 self.last_on_time = 0.0
def __exit__(self, exc_type, exc_val, exc_tb): """Exit method.""" self.main_device.close_driver() self.second_device.close_driver() Device.stop_appium()
def __init__(self, config, owner=None, simulation=False): self.test_temperature = 0.0 Device.__init__(self, config, owner, simulation)