def test_scheduler_times(): """ test wait_times in sum are less than max time """ for _ in itertools.repeat(None, 1000): max_time = 100 wait_times = gen_schedule_wait_times(max_time) time_sum = sum(map(float, wait_times)) # print(wait_times) assert (time_sum < max_time)
warmup_time = int(sys.argv[1]) recording_time = int(sys.argv[2]) is_exploit = int(sys.argv[3]) do_exploit = True if is_exploit < 1: do_exploit = False total_duration = warmup_time + recording_time exploit_time = random.randint(int(recording_time * .3), int(recording_time * .8)) min_user_count = 10 max_user_count = 25 user_count = random.randint(min_user_count, max_user_count) wait_times = [gen_schedule_wait_times(total_duration) for _ in range(user_count)] class CVE_2012_2122(Scenario): def init_victim(self, container, logger): port = get_host_port(container, "3306") try: db = pymysql.connect("localhost", "root", "123456", port=port) try: db.cursor().execute('create database ' + "textDB") except: pass self.db = pymysql.connect("localhost", "root", "123456", "textDB", port) sql = """CREATE TABLE `texts` ( `id` int(11) NOT NULL AUTO_INCREMENT,
def __init__(self, actions, total_duration): self.scheduler = sched.scheduler(time.time, time.sleep) self.actions = actions self.wait_times = gen_schedule_wait_times(total_duration)
def generate_wait_times(self, user_count, duration): wait_times: List[List[float]] = [] for _ in range(user_count): wait_times.append(gen_schedule_wait_times(duration)) return wait_times