Ejemplo n.º 1
0
def step_impl(context, client):
    if client == "windows":
        winclient = Windows_Controller(
            RUNNER_CONFIG.get('OEM_CLIENT', "mozypro"))
        winclient.set_unconfigured_status()
        winclient.reset_reg(RUNNER_CONFIG.get('ENVIRONMENT', "QA12"))
        winclient.restart_services(force=True)
Ejemplo n.º 2
0
def after_scenario(context, scenario):
    context.tc.end_time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    context.tc.duration = int(scenario.duration)
    context.tc.test_result = scenario.status

    if context.senddb:

        if not (RUNNER_CONFIG.get("PRODUCT") or '').lower() == 'mts':
            native_client = NativeClientFactory.get_client(product=RUNNER_CONFIG.get("PRODUCT"),
                                                           oem=RUNNER_CONFIG.get("OEM_CLIENT"))

            KPIHelper.testcase = context.tc.name
            KPIHelper.extract_kpi(native_client.controller.log, starttime=context.log_starttime, hostname=context.tc.machine_hostname, ip=context.tc.machine_ip, env=context.env)

        if "-" in KPIHelper.thost:
            context.tc.thost = KPIHelper.thost.split("-")[1]     # tds06-ut4.triton.mozy.com
        else:
            context.tc.thost = KPIHelper.thost        # ut4.triton.mozy.com

        context.tc.write_to_elasticsearch()

    log = context.log_capture
    for line in log.getvalue().splitlines():
        if line.find("ERROR") >=0:
            LogHelper.error(line)
    def __get_downloaded_image(cls):
        result = None

        import glob
        installer_path = ConfigAdapter.get_installer_path(product='MAC')
        build = RUNNER_CONFIG.get("BUILD")
        images = glob.glob(installer_path +
                           '/*{build}*.dmg'.format(build=build))

        if len(images) != 0:  # == 0:
            # raise StandardError('Package was not downloaded successfully')
            result = images[0]
        else:
            job = RUNNER_CONFIG.get("JOB")
            if job is None or job == 'null':
                job = cls.default_job

            brand = RUNNER_CONFIG.get("OEM_CLIENT")
            if brand is None or brand == 'null':
                pattern = cls.default_pattern
            else:
                pattern = ".*" + MacController.normalize_brand_name(
                    brand) + ".*"

            packages = cls.download_package(job, build, pattern)
            if len(packages) != 0:
                result = packages[0]

        return result
Ejemplo n.º 4
0
def step_impl(context, activate_type, client):
    result = None
    oem_client = RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")
    env = RUNNER_CONFIG.get('ENVIRONMENT', "QA12")
    email = ""
    password = ""
    productkey = ""
    encryption_key = ""
    subdomain = ""
    relytrust = ""

    for row in context.table:
        if oem_client.upper() == row.get(
                'oem').upper() and env.upper() == row.get('env').upper():
            email = row.get('email')
            password = row.get('password')
            productkey = row.get('product_key')
            encryption_type = row.get('encryption_type')
            encryption_key = row.get('encryption_key')
            subdomain = row.get('subdomain')
            relytrust = row.get('rely_trust')
    # if os.environ['activate'] and os.environ['activate'] == str(True):
    context.oem = oem_client
    windowsclient = Windows_Client(oem_client)

    if windowsclient.gui.status_window.client_is_activated():
        pass
    else:
        if client.upper() == "GUI":
            # result = windowsclient.gui.status_window.continuesetupbutton.Click()
            # result = windowsclient.gui.login_dialog.activate(email, password)
            if activate_type.upper() == "KEYLESS":
                result = windowsclient.gui.login_dialog.keyless_activate(
                    email,
                    password,
                    encryption_type,
                    encryption_key,
                    is_exist="existing")
            elif activate_type.upper() == "KEYED":
                result = windowsclient.gui.login_dialog.key_activate(
                    productkey,
                    email,
                    password,
                    encryption_type,
                    encryption_key,
                    is_exist="existing")
                pass
            elif activate_type.upper() == "FEDID":
                context.subdomain = subdomain
                # result = windowsclient.gui.login_dialog.open_fedidpage(subdomain)
                context.execute_steps(unicode("I open fedid SignIn window"))
                # result = windowsclient.gui.login_dialog.fedid_activate(subdomain, relytrust, email, password, encryption_type, encryption_key)
                pass

        else:
            result = windowsclient.cli.activate_keyless(
                email, password, encryption_type, encryption_key)

    (result is not None).should.be(True)
Ejemplo n.º 5
0
def step_impl(context, cre):
    cre_with_oc = re.sub(r"{oemclient}", RUNNER_CONFIG.get('OEM_CLIENT'), cre)
    cre_with_oc_env = re.sub(r"{env}", RUNNER_CONFIG.get('ENVIRONMENT'),
                             cre_with_oc)
    expected_credential = MAC_CONFIG.get('CREDENTIAL').get(cre_with_oc_env)
    username = expected_credential.get('USERNAME')
    password = expected_credential.get('PASSWORD') + "suffix"
    context.username = username

    MacGUIClient().login_sh.set_credential_with(username, password)
Ejemplo n.º 6
0
def step_impl(context, resource):
    win_installer = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT',
                                                     "mozypro")).installer
    if resource == "Jenkins":
        win_installer.download_and_install(
            RUNNER_CONFIG.get('BUILD', "543"),
            RUNNER_CONFIG.get('JOB', "kalypso-release"))
    elif resource == "Mozy.com":
        win_installer.download_and_install(RUNNER_CONFIG.get('BUILD', "0"),
                                           RUNNER_CONFIG.get('JOB', "product"))
Ejemplo n.º 7
0
def step_impl(context):
    from lib.platformhelper import PlatformHelper
    if PlatformHelper.is_win():
        from apps.windows.windows_client import Windows_Client
    winclient = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT', "mozypro"))

    if winclient.gui.status_window.client_is_activated():
        winclient.controller.set_unconfigured_status()
        winclient.controller.reset_reg(RUNNER_CONFIG.get(
            'ENVIRONMENT', "QA12"))
        winclient.controller.restart_services(force=True)
def step_impl(context):
    """
    ensure that Linux Client is activate with {env}_codename pattern
    """
    from configuration.runner_config_loader import RUNNER_CONFIG
    env = RUNNER_CONFIG.get('ENVIRONMENT')
    codename = RUNNER_CONFIG.get('OEM_CLIENT')
    credential_key = "%s_%s" % (env, codename)
    step_str = 'When Linux Client is activated with "%s"' % credential_key

    context.execute_steps(unicode(step_str))
Ejemplo n.º 9
0
def step_impl(context, client, activated_type):
    oem_client = RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")
    env = RUNNER_CONFIG.get('ENVIRONMENT', "QA12")
    windowsenv = QA_Environment(oem_client)
    windowsenv.get_host(env)
    if activated_type == "fedid":
        windowsenv.set_env.set_fedid_env(env)
    elif activated_type == "autoactivate":
        windowsenv.get_autoactivate_env(env)
    elif activated_type == "assistactivate":
        windowsenv.get_assistedactivate_env(env)
Ejemplo n.º 10
0
def step_impl(context, cre):
    cre_with_oc = re.sub(r"{oemclient}", RUNNER_CONFIG.get('OEM_CLIENT'), cre)
    cre_with_oc_env = re.sub(r"{env}", RUNNER_CONFIG.get('ENVIRONMENT'),
                             cre_with_oc)
    expected_credential = MAC_CONFIG.get('CREDENTIAL').get(cre_with_oc_env)
    username = expected_credential.get('USERNAME')
    password = expected_credential.get('PASSWORD')
    pk = expected_credential.get('PERSONALKEY')

    if pk:
        MacGUIClient().login_sh.activate(username, password, keytext=pk)
    else:
        MacGUIClient().login_sh.activate(username, password)
Ejemplo n.º 11
0
def step_impl(context, type, is_exist, encryption_type, client):
    result = None

    oem_client = RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")
    env = RUNNER_CONFIG.get('ENVIRONMENT', "QA12")
    email = context.user.username
    password = context.user.password

    productkey = context.user.product_keys

    # TODO: Created from BUS Client Configuration
    encryption_type = encryption_type.lower() or "pkey"
    # encryption_type = context.encryption.type or "pkey"
    # encryption_key = context.encryption.key or "test1234"

    windowsclient = Windows_Client(oem_client)

    if windowsclient.gui.status_window.client_is_activated():
        pass
    else:
        if client.upper() == "GUI":
            if type.upper() == "KEYLESS":
                context.multiencryption = False
                result = windowsclient.gui.login_dialog.keyless_activate(
                    email,
                    password,
                    encryptiontype=encryption_type,
                    key="test1234",
                    is_exist=is_exist,
                    multiencryption=context.multiencryption)
            elif type.upper() == "KEYED":
                result = windowsclient.gui.login_dialog.key_activate(
                    productkey,
                    email,
                    password,
                    encryptiontype=encryption_type,
                    key="test1234",
                    is_exist=is_exist,
                    multiencryption=context.multiencryption)
        else:
            if type.upper() == "KEYLESS":
                result = windowsclient.cli.activate_keyless(
                    email,
                    password,
                    encryption_type=encryption_type,
                    key="test1234")
            # elif type.upper() == "KEYED":
            #     result = windowsclient.cli.activate_keyless(email, password, encryption_type="pkey", key="test1234")

    (result is not None).should.be(True)
def step_impl(context):
    winclient = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT', "mozypro"))
    result = winclient.controller.search_result_in_history()
    if result[0] == -9:
        LogHelper.info("backup is cancelled successfully")
    else:
        LogHelper.error("backup is cancelled unsuccessfully")
Ejemplo n.º 13
0
def step_impl(context):
    result = MacGUIInstaller.is_setup_assistant_launched(120)
    result.should.equal(True)

    env = RUNNER_CONFIG.get('ENVIRONMENT')
    MacController.setup_qa_env(env)
    MacController.kill_system_preference()
Ejemplo n.º 14
0
def step_impl(context):
    env = RUNNER_CONFIG.get('ENVIRONMENT') or "QA12"
    env_dict = GLOBAL_CONFIG['QA_ENVIRONMENT'].get(env)
    if env_dict is not None:
        api_key = env_dict.get('bifrost.partner.api_key')
        bifrost_host = env_dict.get('bifrost.host')
        for row in context.table:
            if row.get('name'):
                machine_name = str(row.get('name'))
            else:
                machine_name = "testmachine1"
            if row.get('user_id'):
                user_id = row.get("user_id")
            else:
                user_id = context.user.id
            if row.get('type'):
                type = str(row.get('type'))
            else:
                type = "Desktop"
            if row.get('site'):
                site = str(row.get('site'))
            else:
                site = "q12a"
            authexchange = AuthExchange(
                ('%s%s%s' % (HTTP_PROTOCOL, bifrost_host, AUTH_EXCHANGE_URL)),
                api_key)
            token = (authexchange.get_auth_exchange())
            bifrosthelper = BifrostHelper(
                ('%s%s' % (HTTP_PROTOCOL, bifrost_host)), token)
            context.machine_id = bifrosthelper.Create_New_Machine(
                user_id=user_id, name=machine_name, type=type, site=site)
            assert (context.machine_id != -1)
Ejemplo n.º 15
0
def step_impl(context, buttonname):
    time.sleep(2)
    win_cancel = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT',
                                                  "mozypro")).gui.setup_window
    if buttonname.upper() == "YES":
        win_cancel.choose_yes_on_cancel()
    elif buttonname.upper() == "NO":
        win_cancel.choose_no_on_cancel()
Ejemplo n.º 16
0
def step_impl(context):
    win_setup = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT',
                                                 "mozypro")).gui.setup_window
    if win_setup.license_agreement_checked():
        win_setup.choose_license_agreement()
    if win_setup.location_change_checked():
        win_setup.choose_location_change()
    win_setup.install_start()
Ejemplo n.º 17
0
def step_impl(context, cred):
    key_cred_oc = re.sub(r"{oemclient}", RUNNER_CONFIG.get('OEM_CLIENT'), cred)
    key_cre_oc_env = re.sub(r"{env}", RUNNER_CONFIG.get('ENVIRONMENT'),
                            key_cred_oc)
    expected_credential = MAC_CONFIG.get('AUTO_ACTIVATION').get(key_cre_oc_env)
    guid = "{" + expected_credential.get('DOMAIN_ID') + "}"
    ou = expected_credential.get('OU')
    username_prefix = expected_credential.get('USERNAME_PREFIX')
    str_time = time.strftime("%y%m%d%H%M", time.gmtime())
    username = username_prefix + str_time + "@email.com"
    context.username = username
    result = MacCliClient.auto_activation(guid, ou, username)

    activated = False
    if result.find("Saving configuration") != -1:
        activated = True
    activated.should.equal(True)
 def enter_personal_key(self):
     env = RUNNER_CONFIG.get('ENVIRONMENT') or 'QA12'
     personal_key = FRYR_CONFIG['RESTORE'][env]['PERSONAL_KEY']
     time.sleep(1)
     self.restore_manager.Edit.set_text(personal_key)
     time.sleep(1)
     self.restore_manager.child_window(title="&OK",
                                       class_name="Button").Click()
Ejemplo n.º 19
0
def step_impl(context):
    result = MacInstaller.install_from_volumes()
    result.should.equal(True)

    env = RUNNER_CONFIG.get('ENVIRONMENT')
    MacController.setup_qa_env(env)

    MacInstaller.eject_images('Mozy')
def step_impl(context):
    winclient = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT', "mozypro"))
    import time
    time.sleep(10)
    winclient.gui.restore_panel.select_restore_by_date(
        ConfigAdapter.get_output_path())
    winclient.gui.restore_panel.startrestore()
    winclient.gui.restore_panel.apply()
Ejemplo n.º 21
0
def before_scenario(context, scenario):

    testrun = RUNNER_CONFIG.get('TESTRUN') or 'testrun'
    context.log_starttime = strftime("%Y-%m-%dT%H:%M:%SZ", localtime())
    start_time = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    hostname = PlatformHelper.get_hostname()
    ip = PlatformHelper.get_ip_address()

    product = RUNNER_CONFIG.get("PRODUCT")
    build = RUNNER_CONFIG.get('BUILD')
    context.senddb = RUNNER_CONFIG.get('DATABASE_ENABLED')
    context.env = RUNNER_CONFIG.get('ENVIRONMENT')

    logger_path = os.path.join(ConfigAdapter.get_log_path(), testrun)
    tc_prefix = ConfigAdapter.get_testlink_prefix(product)

    match = filter(lambda x: x.find(tc_prefix) >= 0, scenario.tags)

    if len(match)>0:
        # differentiate scenarios in scenario outline
        if hasattr(context, 'active_outline') and type(context.active_outline) == behave.model.Row:
            suffix = match.pop()
            for example_key in context.active_outline:
                suffix += ".%s" % (example_key)
            tc_id = testrun + "_" + suffix
        else:
            tc_id = testrun + "_" + match.pop()
    else:
        #no test link project id foud
        tc_id = hashlib.md5(testrun + "_" + scenario.name.encode()).hexdigest()

    if not FileHelper.dir_exist(logger_path):
        FileHelper.create_directory(logger_path)
    logger_filename = "%s.log" % (tc_id)
    logfile = os.path.join(logger_path, logger_filename)

    client_ip = PlatformHelper.get_ip_address()

    LogHelper.create_logger(logfile, fmt=client_ip+" %(asctime)s %(levelname)s " + product+" | %(message)s |")

    tc = TestCase(testrun=testrun, start_time=start_time, hostname=hostname, product=product,
                  ip=ip, summary=scenario.name, feature=scenario.filename, tags=scenario.tags, logfile=logfile, _id=tc_id, build=build)
    context.tc = tc

    LogHelper.info("test start: " + scenario.name)
Ejemplo n.º 22
0
def step_impl(context, activate_type, username):
    oem_client = RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")
    win_cli = Windows_Cli(oem_client)
    if activate_type == "auto":
        now = int(time.time())
        timeArray = time.localtime(now)
        otherStyleTime = time.strftime("%m%d%H%M", timeArray)
        username = username + "+" + otherStyleTime + "@mozy.com"
        win_cli.activate_auto(username)
Ejemplo n.º 23
0
def step_impl(context):
    brand = RUNNER_CONFIG.get('OEM_CLIENT')
    normalize_brand = MacController.normalize_brand_name(brand)

    result = MacController.check_process_by_name(normalize_brand + 'Backup')
    result.should.equal(True)

    result = MacController.check_process_by_name(normalize_brand + ' Status')
    result.should.equal(True)
Ejemplo n.º 24
0
def step_impl(context, backupsetname, func):
    root_path = WIN_CONFIG.get('TESTDATA_PATH', "c:/testdata")
    if func == "CLI":
        Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")).cli.create_backupset(root_path, backupsetname)
    elif func.upper() == "UI":
        # TODO: Further invesigate pywinauto to support right click popup menu
        pass
    else:
        LogHelper.error("ERROR: Only support start backup from MozyUTIL or UI.")
Ejemplo n.º 25
0
def step_impl(context, operation):
    selecting = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT',
                                                 "mozypro")).gui.setup_window
    if operation.upper() == "DESELECT":
        if selecting.location_change_checked():
            selecting.choose_location_change()
    else:
        if not selecting.location_change_checked():
            selecting.choose_location_change()
Ejemplo n.º 26
0
def step_impl(context):
    #Generate dir full path
    LogHelper.info('Generate directory full path')
    root = ConfigAdapter.get_testdata_path()
    for row in context.table:
        dir_name = row.get('entity')
        full_path = os.path.join(root, dir_name)
        #remve unwanted empty string
        drill_down_list = filter(lambda x: len(x) > 0,
                                 full_path.split(os.path.sep))
        if RUNNER_CONFIG.get('PRODUCT').upper() in ('MAC', "LINUX",
                                                    'MAC_MACFRYR'):
            drill_down_list.insert(0, os.path.sep)

        # Drill down folders
        result = FreyjaPage.drill_down_folders(drill_down_list[0:-1])
        try:
            (result).should.be(True)
        except AssertionError:
            LogHelper.error("Frejya fail to Expand folder.")
            FreyjaPage.quit()
        else:
            # Select folder checkbox
            result = FreyjaPage.check_entity(full_path)
            try:
                (result).should.be(True)
            except AssertionError:
                LogHelper.error("Frejya fail to check folder checkbox.")
                FreyjaPage.quit()

            else:
                context.kpi = KPI(testcase=context.tc.name,
                                  category="Web",
                                  start_time=strftime("%Y-%m-%dT%H:%M:%SZ",
                                                      gmtime()),
                                  name="Frejya Create MZD",
                                  result="Fail",
                                  hostname=context.tc.machine_hostname,
                                  ip=context.tc.machine_ip,
                                  env=context.env)

                result = FreyjaPage.create_mzd()
                try:
                    (result).should.be(True)
                except AssertionError:
                    context.kpi.message = "Frejya fail to create MZD."
                    FreyjaPage.quit()
                else:
                    context.kpi.result = "SUCCESS"
                finally:
                    context.kpi.end_time = strftime("%Y-%m-%dT%H:%M:%SZ",
                                                    gmtime())
                    context.kpi.write_to_elasticsearch(context.senddb)
                    context.kpi = None
                    Page.quit()
Ejemplo n.º 27
0
def step_impl(context, activate_type, client):
    oem_client = RUNNER_CONFIG.get('OEM_CLIENT', "mozypro")
    env = RUNNER_CONFIG.get('ENVIRONMENT', "QA12")
    email = ""
    password = ""
    productkey = ""
    encryption_key = ""
    env = "QA12"
    for row in context.table:
        if oem_client.upper() == row.get(
                'oem').upper() and env.upper() == row.get('env').upper():
            email = row.get('email')
            password = row.get('password')
            productkey = row.get('password')
            encryption_type = row.get('encryption_type')
            encryption_key = row.get('encryption_key')
    # if os.environ['activate'] and os.environ['activate'] == str(True):
    windowsclient = Windows_Client(oem_client)

    if windowsclient.gui.status_window.client_is_activated():
        pass
    else:
        if client.upper() == "GUI":
            # result = windowsclient.gui.status_window.continuesetupbutton.Click()
            # result = windowsclient.gui.login_dialog.activate(email, password)
            if activate_type.upper() == "KEYLESS":
                result = windowsclient.gui.login_dialog.keyless_activate(
                    email, password, encryption_type, encryption_key)
            elif activate_type.upper() == "KEY":
                result = windowsclient.gui.login_dialog.key_activate(
                    productkey, encryption_type, encryption_key)
                pass
            elif activate_type.upper() == "FEDID":
                result = windowsclient.gui.login_dialog.fedid_activate(
                    productkey, encryption_type, encryption_key)
                pass

        else:
            result = windowsclient.cli.activate_keyless(
                email, password, encryption_type, encryption_key)

    (result is not None).should.be(True)
Ejemplo n.º 28
0
def step_impl(context, num):
    path = "C:\\"
    count = 0
    while (count < int(num)):
        subpath = random.randrange(1, 100)
        path = path + str(subpath) + "\\"
        count += 1
    location = Windows_Client(RUNNER_CONFIG.get('OEM_CLIENT',
                                                "mozypro")).gui.setup_window
    location.set_location(path)
    time.sleep(2)
def step_impl(context, credential):
    context.execute_steps(u"""When I wait for sock ready""")
    # logic to parse credential
    cre_with_oc = re.sub(r"{oemclient}", RUNNER_CONFIG.get('OEM_CLIENT'),
                         credential)
    cre_with_oc_env = re.sub(r"{env}", RUNNER_CONFIG.get('ENVIRONMENT'),
                             cre_with_oc)
    expected_credential = LYNX_CONFIG.get('CREDENTIAL').get(cre_with_oc_env)
    username = expected_credential.get('USERNAME')
    LogHelper.debug("username: %s" % username)
    password = expected_credential.get('PASSWORD')
    pk = expected_credential.get('PERSONALKEY') or None
    context.user = UserHelper(username=username)
    to_activate = False
    if not LinuxGUIClient.account_cmd.is_activate():
        to_activate = True
    else:
        current_email = LinuxGUIClient.account_cmd.get_email()
        LogHelper.debug('%s is not the as  %s' % (current_email, username))
        if not current_email.upper() == username.upper():
            to_activate = True

    if to_activate:
        LogHelper.info("change user account")
        LinuxGUIClient.unlink_cmd.unlink()
        context.execute_steps(
            unicode('When I cleanup local state|metric database'))
        context.execute_steps(unicode('When I restart Linux Client'))
        if pk:
            result = LinuxGUIClient.activate_cmd.activate(
                email=username,
                password=password,
                customkeytext=pk,
                force_encryption_change=None)
        else:
            result = LinuxGUIClient.activate_cmd.activate(
                email=username,
                password=password,
                force_encryption_change=None)

        LogHelper.debug(result)
Ejemplo n.º 30
0
    def visit(self):
        self.dashboardpage_driver = Page.current_driver()
        env = RUNNER_CONFIG.get('ENVIRONMENT') or 'QA12'
        bushost = GLOBAL_CONFIG.get('QA_ENVIRONMENT').get(env).get('mozy.bushost') or 'www.mozypro.com'
        dashboardpage_url = "{bushost}/dashboard".format(bushost=bushost)
        if not bushost.startswith('https://'):
            dashboardpage_url = "https://{page}".format(page=dashboardpage_url)

        try:
            self.dashboardpage_driver.get(dashboardpage_url)
        except:
            self.dashboardpage_driver = Page.create_browser(force=True)
            self.dashboardpage_driver.get(dashboardpage_url)