def test_formatted_trace_file(self): mm_config = MahiMahiConfig(self.config, policy=self.policy, client_environment=self.client_environment) trace_lines = trace_for_kbps(self.client_environment.bandwidth) formatted = format_trace_lines(trace_lines) assert mm_config.formatted_trace_file == formatted
def test_record_cmd(self): save_dir = "/tmp/save_dir" mm_config = MahiMahiConfig(self.config) record_cmd = mm_config.record_cmd(save_dir) assert record_cmd[0] == "mm-webrecord" assert record_cmd[1] == save_dir
def test_record_shell_with_cmd(self): save_dir = "/tmp/save_dir" mm_config = MahiMahiConfig(self.config, policy=self.policy) cmd = mm_config.record_shell_with_cmd(save_dir, ["a", "command"]) assert cmd == (mm_config.record_cmd(save_dir) + ["a", "command"])
def test_init_with_client_environment(self): mm_config = MahiMahiConfig(self.config, policy=self.policy, client_environment=self.client_environment) assert isinstance(mm_config, MahiMahiConfig) assert mm_config.policy is self.policy assert mm_config.client_environment is self.client_environment
def test_init_without_policy(self): mm_config = MahiMahiConfig(self.config) assert isinstance(mm_config, MahiMahiConfig) assert mm_config.policy is None assert mm_config.client_environment is None
def get_mahimahi_config() -> MahiMahiConfig: return MahiMahiConfig( config=get_config(), policy=Policy(ActionSpace(get_push_groups())), client_environment=get_random_client_environment(), )