예제 #1
0
    def set_wireless(self):
        """
        Index: 0
        """
        self.set_callback_fail([
            'close_Cert_Window', 'enable_wired',
            'del_wireless_profile_from_reg', 'close_wireless_callback'
        ])
        SwitchThinProMode("admin")

        cert_path = search_file_from_usb(self.cert_name)
        self.cert_util.import_cert(file_path=cert_path)
        Network.wired_wireless_switch_off()
        Network.disabled_wired()
        self.network.close()
        self.network.open()
        self.network.wireless.click()
        self.network.add.click()
        self.network.ssid.send_keys(self.ap_name)
        self.network.security.click()
        self.network.authentication.click()
        self.network.wpa2_peap.click()
        cert_row = self.network.wpa2_peap_ca_cert
        cert_row.wpa2_peap_ca_cert_open.click()
        self.network.wpa2_peap_cert_thinpro_store.click()
        self.network.wpa2_cert_rootca_pem.click()
        self.network.wpa2_peap_cert_open.click()
        self.network.wpa2_username.send_keys(self.username)
        self.network.wpa2_password.send_keys(self.password)

        self.network.wireless_apply.click()
        self.network.wireless_ok.click()

        self.network.apply.click()
예제 #2
0
    def set_wireless(self):
        """
        Index: 0
        """
        self.set_callback_fail([
            'enable_wired', 'del_wireless_profile_from_reg',
            'close_wireless_callback'
        ])
        SwitchThinProMode("admin")

        Network.wired_wireless_switch_off()
        Network.disabled_wired()
        self.network.close()
        self.network.open()
        self.network.wireless.click()
        self.network.add.click()
        self.network.ssid.send_keys(self.ap_name)
        ssid_hidden = self.network.ssid_hidden
        ssid_hidden.global_unselected_checkbox.click()

        # check ssid hidden can be enabled
        check_box = self.network.ssid_hidden.global_selected_checkbox

        self.network.security.click()
        self.network.authentication.click()
        self.network.wpa2_psk.click()
        self.network.preshared_key.send_keys(self.password)

        self.network.wireless_apply.click()
        self.network.wireless_ok.click()

        self.network.apply.click()
예제 #3
0
    def set_wireless(self):

        self.set_callback_fail([
            'enable_wired', 'del_wireless_profile_from_reg',
            'close_wireless_callback'
        ])
        SwitchThinProMode("admin")

        Network.wired_wireless_switch_off()
        Network.disabled_wired()
        self.network.close()
        self.network.open()
        self.network.wireless.click()
        self.network.add.click()
        self.network.scan_ap.click()
        ap = self.__wait_until_ap_appear()
        ap.click()
        self.network.R1_Linux_Roaming.click()
        self.network.wireless_band.click()
        self.network.GHZ24.click()
        self.network.security.click()
        self.network.authentication.click()
        self.network.wpa2_psk.click()
        self.network.preshared_key.send_keys(self.password)
        self.network.wireless_apply.click()
        self.network.wireless_ok.click()

        self.network.apply.click()
예제 #4
0
    def set_wireless(self):
        """
        Index: 0
        """
        self.set_callback_fail([
            'enable_wired', 'del_wireless_profile_from_reg',
            'close_wireless_callback'
        ])
        SwitchThinProMode("admin")

        Network.wired_wireless_switch_off()
        Network.disabled_wired()
        self.network.close()
        self.network.open()
        self.network.wireless.click()
        self.network.add.click()
        self.network.ssid.send_keys(self.ap_name)
        self.network.security.click()
        self.network.authentication.click()
        self.network.wpa2_eap.click()

        self.network.wpa2_username.send_keys(self.username)
        self.network.wpa2_password.send_keys(self.password)
        self.network.wpa2_eap_fast_provisioning.click()
        self.network.wpa2_eap_allow_auth.click()

        self.network.wireless_apply.click()
        self.network.wireless_ok.click()

        self.network.apply.click()
예제 #5
0
    def set_wired(self):
        self.set_callback_fail(['close_network_panel_callback'])

        SwitchThinProMode("admin")
        self.network.close()
        self.network.open()
        self.network.connection_method.click()
        self.network.automatic.click()
        self.network.apply.click()
        self.network.wait_until_network_connected()
    def ping_after_reboot(self):
        """
        Index: 2
        """
        SwitchThinProMode("admin")

        self.set_callback_fail(['enable_wired',
                                'del_wireless_profile_from_reg'])
        self.network.wait_until_wireless_connected()
        self.__ping_method()
    def set_dns(self):
        """
        Index: 0
        """
        self.set_callback_success(['reboot'])
        self.set_callback_fail(['close_network_panel_callback'])

        SwitchThinProMode("admin")
        self.network.close()
        self.network.open()
        self.network.dns.click()
        self.network.dns_server.send_keys(self.format_dns_server)
        self.network.search_domains.send_keys(self.format_search_domains)
        self.network.apply.click()
        self.network.close()
        self.create_list_index_file_and_suspend(index=1)
 def set_wireless(self):
     """
     Index: 0
     """
     self.set_callback_fail(['enable_wired',
                             'del_wireless_profile_from_reg',
                             'close_ssid_windows'])
     SwitchThinProMode("admin")
     Network.wired_wireless_switch_off()
     Network.disabled_wired()
     time.sleep(5)
     disconnected_wireless = self.network.wireless_tray_disconnected
     disconnected_wireless.click()
     self.network.scan_ap.click()
     disconnected_wireless.click()
     self.network.R1TC24GaxWPA2P.click()
     time.sleep(5)
     self.ssid_panel.password.send_keys(self.password)
     self.ssid_panel.ssid_ok.click()
예제 #9
0
    def set_wired(self):
        """
        Index: 0
        """
        self.set_callback_fail(['close_network_panel_callback'])
        info = StaticIpUtils.read_info_from_yaml()
        format_ip = info["ip"]
        format_mask = info["mask"]
        format_gateway = info["gateway"]

        SwitchThinProMode("admin")
        self.network.close()
        self.network.open()
        self.network.connection_method.click()
        self.network.static.click()
        self.network.ip_address.send_keys(format_ip)
        self.network.mask.send_keys(format_mask)
        self.network.gateway.send_keys(format_gateway)
        self.network.apply.click()
        self.network.wait_until_network_connected()
    def logon_rdp_and_check_logon(self):
        """
        Index: 2
        """
        SwitchThinProMode("admin")

        self.set_callback_success(
            ['close_rdp_callback', 'restore_dns_callback', 'end_and_reboot'])
        self.set_callback_fail(['close_rdp_callback', 'restore_dns_callback'])
        default_settings = {
            "credentialsType": "password",
            "domain": 'tcqa',
            'tlsVersion': 'auto',
            'address': 'auto-update.tcqa.hp',
            "password": '******',
            "username": '******',
            "securityLevel": "0",
            "windowType": "full",
        }
        self.rdp.add_settings(settings=default_settings)
        self.rdp.logon()
        time.sleep(5)
        self.__wait_until_rdp_logon()
예제 #11
0
def main():
    # show_desktop()
    if os.path.exists(get_current_dir('flag.txt')):
        with open(get_current_dir('flag.txt')) as f:
            test_flag = f.read()
            if 'TEST FINISHED' in test_flag.upper():
                return
    if not os.path.exists('time.txt'):
        with open('time.txt', 'w') as f:
            f.write(time.ctime())
    prepare_for_framework()
    additional_path = get_current_dir('Test_Data', 'additional.yml')
    file_obj = YamlOperator(additional_path)
    content = file_obj.read()
    site = content.get('AutoDash_Site')
    if not site:
        load_data_from_ftp()
        script_name = os.path.basename(__file__).split('.')[0]
        add_linux_script_startup([script_name])
        check_water_mark()
    path = get_current_dir('reboot.txt')
    if not os.path.exists(path):
        with open(path, 'w+') as f:
            f.write("0")
        time.sleep(5)
        if os.path.exists(path):
            SwitchThinProMode("admin")
            os.popen('reboot')
            time.sleep(30)
    if not os.path.exists(get_current_dir('Test_Report')):
        os.mkdir(get_current_dir('Test_Report'))
    test_data_path = os.path.join(get_current_dir(), 'Test_Data')
    with open(get_current_dir('flag.txt'), 'w') as f:
        f.write('testing')
    if not os.path.exists(os.path.join(test_data_path, 'script.yml')):
        log.info('script.yml not exist, please check if no cases planned')
        with open(get_current_dir('flag.txt'), 'w') as f:
            f.write('test finished')
        return
    with open(os.path.join(test_data_path, 'script.yml'), 'r') as f:
        scripts = yaml.safe_load(f)
    with open(os.path.join(test_data_path, 'additional.yml'), 'r') as f:
        additional = yaml.safe_load(f)
    for script in scripts:
        script_name, script_status = list(script.items())[0]
        if script_status.upper() == 'NORUN':
            log.info('Begin to Test case {}'.format(script_name))
            try:
                if need_reboot() == 1:
                    change_reboot_status(0)
                    reboot_command()
                memory_check(limit=MEMORY_LIMIT)
                globals()[script_name.split('__')[0]].start(
                    case_name=script_name.split('__')[1], kwargs=additional)
                script[script_name] = 'Finished'
                with open(os.path.join(test_data_path, 'script.yml'),
                          'w') as f:
                    yaml.safe_dump(scripts, f)
            except MemoryNotSufficient as e:
                log.debug(e)
                log.debug("start reboot")
                reboot_command()
            except:
                with open(get_current_dir('Test_Report', 'debug.log'),
                          'a') as f:
                    f.write(traceback.format_exc())
                capture_screen(
                    get_current_dir(
                        'Test_Report',
                        'img',
                        '{}.jpg'.format(script_name.split('__')[1]),
                    ))
                script[script_name] = 'Finished'
                with open(os.path.join(test_data_path, 'script.yml'),
                          'w') as f:
                    yaml.safe_dump(scripts, f)
                steps = {
                    'step_name': 'case exception',
                    'result': 'Fail',
                    'expect': '',  # can be string or pic path
                    'actual': 'img/{}.jpg'.format(script_name.split('__')[1]),
                    'note': traceback.format_exc()
                }
                base_name = get_report_base_name()
                report_file = get_current_dir('Test_Report', base_name)
                # result_file = get_current_dir(r'Test_Report', '{}.yaml'.format(check_ip_yaml()))
                update_cases_result(report_file,
                                    script_name.split('__')[1], steps)
        else:
            log.info('Test case {} status is Finished, Skip test'.format(
                script_name))
    if os.path.exists(path):
        if need_reboot() == 0:
            change_reboot_status(9)
            log.info("Start Reboot before Report")
            reboot_command()
        else:
            os.remove(path)
    if site:
        share_folder = content.get('share_folder')
        host = share_folder.split('/')[0]
        folder_path = '/'.join(share_folder.split('/')[1:])
        user = content.get('user')
        password = content.get('password')
        flag_path = '/{}/{}.txt'.format(folder_path, site)
        log.info('end_flag: {}'.format(flag_path))

        with open(get_current_dir('{}.txt'.format(site)), 'w') as f:
            f.write('test finished')
        ftp = FTPUtils(host, user, password)
        ftp.ftp.cwd('ThinPro_Automation_Site')
        local_folder = get_current_dir('Test_Report')
        ftp_folder = r'/{}/Test_Report'.format(folder_path)

        num = 0
        while True:
            try:

                ftp = FTPUtils(host, user, password)
                log.info('upload Test_Report folder to ftp')
                log.info(local_folder)
                log.info(ftp_folder)
                ftp.new_dir(ftp_folder)
                local_report = get_current_dir('Test_Report',
                                               '{}.yaml'.format(site))
                ftp_report = '/{}/Test_Report/{}.yaml'.format(
                    folder_path, site)
                ftp.upload_file(local_report, ftp_report)
                ftp.upload_file(get_current_dir(r"{}.txt".format(site)),
                                flag_path)
                break
            except:
                if num > 30:
                    traceback.print_exc()
                    break
                else:
                    num += 5
                    time.sleep(5)
    else:
        with open(get_current_dir('flag.txt'), 'w') as f:
            f.write('test finished')
        with open('time.txt') as f:
            start = f.read()
        end = time.ctime()
        report = email_tool.GenerateReport(start, end)
        report.generate()
        file = email_tool.zip_dir()
        log.info('zipped file name: {}'.format(file_obj))
        additional_email = additional.get('email') if additional.get(
            'email') else ''
        email_tool.send_mail(
            recipient=['*****@*****.**', additional_email],
            subject='Automation Report Linux {}'.format(
                zip_file_name(get_report_number(), get_report_value())),
            attachment=file)
        os.remove(file)
        os.remove('time.txt')
        try:
            collect_report()
        except Exception as e:
            print(e)
            log.error(e)