def test_forbidden_net(): ''' 禁网检测 :return: ''' teacher_main = TeachingMain(configs) teacher_main.click_forbidden_net()
def test_shutdown_tcs(): ''' 关机终端 ''' teacher_main = TeachingMain(configs) tc_list = teacher_main.get_client_ips() teacher_main.click_clients_poweroff() sleep(configs['teachermain']['power_manage']['wait_shutdown']) assert get_clients_alive_num(tc_list) == 0
def test_cancel_quiet(): ''' 退出安静黑屏 ''' teacher_main = TeachingMain(configs) teacher_main.click_cancel_black_screen() sleep(configs['teachermain']['lesson']['wait_quiet']) num = teacher_main.get_quiet_num() logger.info("Total %s desktop is quiet." % num) assert num == 0
def test_switch_local_mode(): ''' 切换为本地考试模式 ''' timeout = configs['teachermain']['lesson']['timeout_switch'] teacher_main = TeachingMain(configs) teacher_main.click_switch_local_mode() switch_time = teacher_main.get_logon_time(timeout) logger.info("Time to switch to local mode: %s" % switch_time) assert switch_time
def test_start_lesson(): ''' 启动课程,如果tc未开机,则自动开机上课 ''' teacher_main = TeachingMain(configs) timeout = configs['teachermain']['lesson']['timeout_start'] teacher_main.start_lesson(configs['teachermain']['stability']['lesson_name']) start_time = teacher_main.get_logon_time(timeout) logger.info("desktop start time: %s" % start_time) assert start_time
def test_lesson_stability(): ''' 上下课稳定性 :return: ''' teacher_main = TeachingMain(configs) loop = configs['teachermain']['stability']['loop'] error_num = 0 timeout = configs['teachermain']['lesson']['timeout_stop'] for i in range(loop): logger.info("Stability Testing, No.%s" % i) logger.info("Stability Testing: Start lesson.") # 上课 teacher_main.start_lesson(configs['teachermain']['stability']['lesson_name']) sleep(configs['teachermain']['stability']['wait']) # 上课结果 logger.info("Stability Testing: Check alive clients.") clients = teacher_main.get_total_clients() offline = teacher_main.get_offline_clients() if offline == 0: # 下课 logger.info("Stability Testing: Stop lesson.") teacher_main.stop_lesson() stop_time = teacher_main.get_logon_time(timeout, clients) logger.info("Time to stop lesson: %s" % stop_time) else: error_num += 1 logger.debug("Backup log files after error." ) get_log_file(os.path.dirname(__file__)) assert error_num == 0
def test_wakeup_host(): ''' 唤醒主机 ''' if is_host_alive(): logger.warning("Host already alive!") else: timeout = configs['teachermain']['power_manage']['wait_wakeup_host'] teacher_main = TeachingMain(configs) teacher_main.click_host_wakeup() wakeup_time = func_timeout_ex(is_host_alive, None, True, timeout) logger.info("Host wakeup time: %s" % wakeup_time) assert wakeup_time
def test_class_over(): ''' 放学 ''' if not is_host_alive(): logger.warning("Host not alive!") else: teacher_main = TeachingMain(configs) teacher_main.click_class_over() #sleep(configs['teachermain']['power_manage']['wait_shutdown_host']) timeout = configs['teachermain']['power_manage']['wait_shutdown_host'] over_time = func_timeout_ex(is_host_alive, 22, False, timeout) logger.info("Host shutdown time: %s" % over_time) tc_list = teacher_main.get_client_ips(configs['tc']['pattern']) alive_num = get_clients_alive_num(tc_list) assert alive_num == 0 assert not is_host_alive()
def test_wakeup_tcs(): ''' 唤醒终端 ''' teacher_main = TeachingMain(configs) tc_list = teacher_main.get_client_ips() tc_num = len([i for line in tc_list for i in line]) timeout = configs['teachermain']['power_manage']['wait_wakeup_tc'] alive_num = get_clients_alive_num(tc_list) if alive_num == 0: teacher_main.click_clients_wakeup() wakeup_time = func_timeout_ex(get_clients_alive_num, tc_list, tc_num, timeout) logger.info("%s clients wakeup time: %s" % (alive_num, wakeup_time)) assert wakeup_time else: logger.warning("Clients already alive!")
def test_launch_webpage(): ''' 基于模式匹配检测远程运行应用程序 :return: ''' teacher_main = TeachingMain(configs) teacher_main.click_launch_webpage() teacher_main.click_remote_open_webpage( configs['teachermain']['remote_page']['page_name']) sleep(configs['teachermain']['remote_page']['run_wait']) clients = teacher_main.get_total_clients() logger.info("Total %s desktop." % clients) pages = teacher_main.get_remote_page_start_num() logger.info("Total %s desktop launched the specify app." % clients) assert clients == pages
def test_stop_lesson(): ''' 下课 ''' timeout = configs['teachermain']['lesson']['timeout_stop'] teacher_main = TeachingMain(configs) clients = teacher_main.get_total_clients() teacher_main.stop_lesson() stop_time = teacher_main.get_logon_time(timeout, clients) logger.info("Time to stop lesson: %s" % stop_time) assert stop_time
def test_keep_quiet(): ''' 安静黑屏 ''' teacher_main = TeachingMain(configs) clients = teacher_main.get_total_clients() logger.info("Total %s desktop." % clients) teacher_main.click_black_screen() sleep(configs['teachermain']['lesson']['wait_quiet']) num = teacher_main.get_quiet_num() logger.info("Total %s desktop is quiet." % num) assert num == clients
def test_restart_tcs(): ''' 重启终端 ''' teacher_main = TeachingMain(configs) tc_list = teacher_main.get_client_ips(configs['tc']['pattern']) tc_num = len([i for line in tc_list for i in line]) alive_num = get_clients_alive_num(tc_list) if alive_num != tc_num: teacher_main.click_clients_wakeup() sleep(configs['teachermain']['power_manage']['wait_wakeup_tc']) teacher_main.click_clients_restart() sleep(configs['teachermain']['power_manage']['wait_shutdown']) alive_num = get_clients_alive_num(tc_list) assert alive_num == 0 sleep(configs['teachermain']['power_manage']['wait_wakeup_tc']) alive_num = get_clients_alive_num(tc_list) assert alive_num == tc_num
def test_restart_lesson(): ''' 重启课程桌面 :return: ''' timeout = configs['teachermain']['lesson']['timeout_stop'] teacher_main = TeachingMain(configs) clients = teacher_main.get_total_clients() teacher_main.restart_lesson() stop_time = teacher_main.get_logon_time(timeout, clients) logger.info("Time to stop lesson: %s" % stop_time) assert stop_time timeout = configs['teachermain']['lesson']['timeout_start'] start_time = teacher_main.get_logon_time(timeout) logger.info("desktop start time: %s" % start_time) assert start_time
def test_logon_desktop_time(): ''' 性能:从唤醒到登录桌面的总时间 ''' teacher_main = TeachingMain(configs) tc_list = teacher_main.get_client_ips() tc_num = len([i for line in tc_list for i in line]) timeout = 150 alive_num = get_clients_alive_num(tc_list) if alive_num == 0: teacher_main.click_clients_wakeup() wakeup_logon_time = teacher_main.get_logon_time(timeout) logger.info("%s clients logon desktop: %s" % (alive_num, wakeup_logon_time)) assert wakeup_logon_time else: logger.warning("Clients already alive!")
def test_enter_portal(): teacher_main = TeachingMain(configs) teacher_main.click_enter_portal()
def test_enter_workspace(): teacher_main = TeachingMain(configs) teacher_main.click_enter_workspace()
def test_black_list(): ''' 黑名单检测 :return: ''' teacher_main = TeachingMain(configs) teacher_main.add_white_black_policy(black=True) teacher_main.apply_black_policy() # 检测黑名单列表 teacher_main.is_all_blacklist() # 检测应用效果 teacher_main.click_launch_webpage() teacher_main.click_remote_open_webpage( configs['teachermain']['remote_page']['page_name']) pages = teacher_main.get_remote_page_start_num() assert pages == 0