def run_selenium(self):
        """ fake to run the full lifecycle flow of this deployment """

        lh.section("Runner of type {0}".format(str(self.name)), "<3")
        self.old_installer.load_config()
        self.old_installer.caclulate_file_locations()
        self.basecfg.set_directories(self.old_installer.cfg)
        if self.do_starter_test:
            lh.section("PREPARING DEPLOYMENT of {0}".format(str(self.name)), )
            self.starter_prepare_env()
            self.finish_setup()  # create the instances...
            for starter in self.starter_instances:
                # attach the PID of the starter instance:
                starter.attach_running_starter()
                # find out about its processes:
                starter.detect_instances()
            print(self.starter_instances)
            self.selenium.connect_server(self.get_frontend_instances(),
                                         '_system', self.cfg)
            self.selenium.check_old(self.old_installer.cfg)
        if self.new_installer:
            self.versionstr = "NEW[" + self.new_cfg.version + "] "

            lh.section("UPGRADE OF DEPLOYMENT {0}".format(str(self.name)), )
            self.cfg.set_directories(self.new_installer.cfg)
            self.new_cfg.set_directories(self.new_installer.cfg)

        if self.do_starter_test:
            lh.section("TESTS FOR {0}".format(str(self.name)), )
            #self.test_setup()
            #self.jam_attempt()
            #self.starter_shutdown()
        if self.selenium:
            self.selenium.disconnect()
        lh.section("Runner of type {0} - Finished!".format(str(self.name)))
Esempio n. 2
0
def main(**kwargs):
    """ main """
    kwargs['stress_upgrade'] = False
    kwargs['package_dir'] = Path(kwargs['package_dir'])
    kwargs['test_data_dir'] = Path(kwargs['test_data_dir'])
    kwargs['alluredir'] = Path(kwargs['alluredir'])

    kwargs['hb_cli_cfg'] = HotBackupCliCfg("disabled", "", "", "", "", "", "")
    kwargs['base_config'] = InstallerBaseConfig.from_dict(**kwargs)

    do_install = kwargs['mode'] in ["all", "install"]
    do_uninstall = kwargs['mode'] in ["all", "uninstall"]

    launch_dir = Path.cwd()
    if "WORKSPACE" in os.environ:
        launch_dir = Path(os.environ["WORKSPACE"])

    if not kwargs['test_data_dir'].is_absolute():
        kwargs['test_data_dir'] = launch_dir / kwargs['test_data_dir']
    if not kwargs['test_data_dir'].exists():
        kwargs['test_data_dir'].mkdir(parents=True, exist_ok=True)
    os.chdir(kwargs['test_data_dir'])

    if not kwargs['package_dir'].is_absolute():
        kwargs['package_dir'] = (launch_dir / kwargs['package_dir']).resolve()
    if not kwargs['package_dir'].exists():
        kwargs['package_dir'].mkdir(parents=True, exist_ok=True)

    init_allure(results_dir=kwargs['alluredir'],
                clean=kwargs['clean_alluredir'],
                zip_package=kwargs['zip_package'])

    lh.section("startup")

    install_config = InstallerConfig(
        kwargs['new_version'], kwargs['verbose'], kwargs['enterprise'],
        kwargs['encryption_at_rest'], kwargs['zip_package'],
        kwargs['src_testing'], kwargs['hb_cli_cfg'], kwargs['package_dir'],
        kwargs['test_data_dir'], kwargs['mode'], kwargs['publicip'],
        kwargs['interactive'], False, False)
    install_config.source = True

    inst = make_installer(install_config)

    inst.cfg.scenario = Path(kwargs['scenario'])
    runner = Testing(RunnerType.TESTING, False, inst, kwargs['selenium'],
                     kwargs['selenium_driver_args'], "bla", False, False)
    runner.do_install = do_install
    runner.do_uninstall = do_uninstall
    failed = False
    if not runner.starter_prepare_env_impl():
        failed = True

    if len(kwargs['frontends']) == 0:
        kill_all_processes()

    return 0 if not failed else 1
    def run_perf_test(self,
                      deployment_mode,
                      versions: list,
                      frontends,
                      scenario,
                      run_props: RunProperties):
        # fmt: on
        """ main """
        do_install = deployment_mode in ["all", "install"]
        do_uninstall = deployment_mode in ["all", "uninstall"]

        installers = create_config_installer_set(
            versions,
            self.base_config,
            deployment_mode,
            run_props
        )
        lh.section("configuration")
        print(
            """
        mode: {mode}
        {cfg_repr}
        """.format(
                **{"mode": str(deployment_mode), "cfg_repr": repr(installers[0][0])}
            )
        )
        inst = installers[0][1]

        split_host = re.compile(r"([a-z]*)://([0-9.:]*):(\d*)")

        if len(frontends) > 0:
            for frontend in frontends:
                print("remote")
                host_parts = re.split(split_host, frontend)
                inst.cfg.add_frontend(host_parts[1], host_parts[2], host_parts[3])
        inst.cfg.scenario = Path(scenario)
        runner = ClusterPerf(
            RunnerType.CLUSTER,
            self.abort_on_error,
            installers,
            self.selenium,
            self.selenium_driver_args,
            "perf",
            run_props,
            use_auto_certs=self.use_auto_certs
        )
        runner.do_install = do_install
        runner.do_uninstall = do_uninstall
        failed = False
        if not runner.run():
            failed = True

        if len(frontends) == 0:
            kill_all_processes()
        return failed
Esempio n. 4
0
    def progress(self, is_sub, msg, separator="x", supress_allure=False):
        """report user message, record for error handling."""
        if self.selenium:
            self.state += self.selenium.get_progress()
        if is_sub:
            if separator == "x":
                separator = "="
            lh.subsection(msg, separator)
            self.state += "   - " + msg
        else:
            if separator == "x":
                separator = "#"
            lh.section(msg, separator)
            self.state += "*** " + msg

        if not supress_allure:
            with step("Progress: " + msg):
                pass
    def __init__(self, version, verbose, package_dir, enterprise,
                 enterprise_magic, zip_package, source, httpuser, httppassvoid,
                 remote_host):
        """ main """
        lh.section("configuration")
        print("version: " + str(version))
        print("using enterpise: " + str(enterprise))
        print("using zip: " + str(zip_package))
        print("package directory: " + str(package_dir))
        print("verbose: " + str(verbose))
        self.user = httpuser
        self.passvoid = httppassvoid
        self.enterprise_magic = enterprise_magic
        if remote_host != "":
            self.remote_host = remote_host
        else:
            # dns split horizon...
            if source in ["ftp:stage1", "ftp:stage2"]:
                self.remote_host = "Nas02.arangodb.biz"
            else:
                self.remote_host = "fileserver.arangodb.com"

        lh.section("startup")
        if verbose:
            logging.info("setting debug level to debug (verbose)")
            logging.getLogger().setLevel(logging.DEBUG)

        self.package_dir = Path(package_dir)
        self.cfg = InstallerConfig(
            version,
            verbose,
            enterprise,
            False,  # don't care for enc at rest
            zip_package,
            self.package_dir,
            Path("/"),
            "",
            "127.0.0.1",
            False,
            False)
        self.inst = make_installer(self.cfg)
        self.is_nightly = self.inst.semver.prerelease == "nightly"
        self.calculate_package_names()
        self.packages = []
def run_upgrade(
    old_version,
    new_version,
    verbose,
    package_dir,
    test_data_dir,
    zip_package,
    hot_backup,
    hb_provider,
    hb_storage_path_prefix,
    interactive,
    starter_mode,
    stress_upgrade,
    abort_on_error,
    publicip,
    selenium,
    selenium_driver_args,
    run_props: RunProperties,
):
    """execute upgrade tests"""
    lh.configure_logging(verbose)

    lh.section("startup")

    for runner_type in STARTER_MODES[starter_mode]:
        if not run_props.enterprise and runner_type == RunnerType.DC2DC:
            continue
        # pylint: disable=too-many-function-args
        installers = create_config_installer_set(
            [old_version, new_version],
            verbose,
            zip_package,
            hot_backup,
            hb_provider,
            hb_storage_path_prefix,
            Path(package_dir),
            Path(test_data_dir),
            "all",  # deployment_mode
            publicip,
            interactive,
            stress_upgrade,
            run_props,
        )
        lh.section("configuration")
        print(
            """
        starter mode: {starter_mode}
        old version: {old_version}
        {cfg_repr}
        """.format(
                **{
                    "starter_mode": str(starter_mode),
                    "old_version": old_version,
                    "cfg_repr": repr(installers[1][0]),
                }
            )
        )
        runner = None
        installers[0][0].add_frontend("http", "127.0.0.1", "8529")
        runner = None
        if runner_type:
            runner = make_runner(runner_type, abort_on_error, selenium, selenium_driver_args, installers, run_props)

            if runner:
                runner.run_selenium()
Esempio n. 7
0
def run_upgrade(old_version, new_version, verbose, package_dir, test_data_dir,
                enterprise, encryption_at_rest, zip_package, interactive,
                starter_mode, stress_upgrade, publicip, selenium,
                selenium_driver_args):
    """ execute upgrade tests """
    lh.section("configuration")
    print("old version: " + str(old_version))
    print("version: " + str(new_version))
    print("using enterpise: " + str(enterprise))
    print("using zip: " + str(zip_package))
    print("package directory: " + str(package_dir))
    print("starter mode: " + str(starter_mode))
    print("public ip: " + str(publicip))
    print("interactive: " + str(interactive))
    print("verbose: " + str(verbose))

    lh.section("startup")
    if verbose:
        logging.info("setting debug level to debug (verbose)")
        logging.getLogger().setLevel(logging.DEBUG)

    if starter_mode == 'all':
        starter_mode = [
            RunnerType.LEADER_FOLLOWER, RunnerType.ACTIVE_FAILOVER,
            RunnerType.CLUSTER
        ]
        if enterprise:
            starter_mode.append(RunnerType.DC2DC)
    elif starter_mode == 'LF':
        starter_mode = [RunnerType.LEADER_FOLLOWER]
    elif starter_mode == 'AFO':
        starter_mode = [RunnerType.ACTIVE_FAILOVER]
    elif starter_mode == 'CL':
        starter_mode = [RunnerType.CLUSTER]
    elif starter_mode == 'DC':
        if enterprise:
            starter_mode = [RunnerType.DC2DC]
        else:
            starter_mode = [None]
    elif starter_mode == 'none':
        starter_mode = [None]
    else:
        raise Exception("invalid starter mode: " + starter_mode)

    for runner_type in starter_mode:

        install_config_old = InstallerConfig(old_version, verbose, enterprise,
                                             encryption_at_rest, zip_package,
                                             Path(package_dir),
                                             Path(test_data_dir), 'all',
                                             publicip, interactive,
                                             stress_upgrade)
        old_inst = make_installer(install_config_old)
        install_config_new = InstallerConfig(new_version, verbose, enterprise,
                                             encryption_at_rest, zip_package,
                                             Path(package_dir),
                                             Path(test_data_dir), 'all',
                                             publicip, interactive,
                                             stress_upgrade)
        new_inst = make_installer(install_config_new)
        install_config_old.add_frontend("http", "127.0.0.1", "8529")
        runner = None
        if runner_type:
            runner = make_runner(runner_type, selenium, selenium_driver_args,
                                 install_config_old, old_inst,
                                 install_config_new, new_inst)

            if runner:
                runner.run_selenium()
Esempio n. 8
0
def run_test(old_version, new_version, verbose, package_dir, test_data_dir,
             enterprise, encryption_at_rest, zip_package, interactive, mode,
             starter_mode, publicip, selenium, selenium_driver_args):
    """ main """
    lh.section("configuration")
    print("version: " + str(new_version))
    print("using enterpise: " + str(enterprise))
    print("using encryption at rest: " + str(encryption_at_rest))
    print("using zip: " + str(zip_package))
    print("package directory: " + str(package_dir))
    print("mode: " + str(mode))
    print("starter mode: " + str(starter_mode))
    print("public ip: " + str(publicip))
    print("interactive: " + str(interactive))
    print("verbose: " + str(verbose))

    if mode not in ['all', 'install', 'system', 'tests', 'uninstall']:
        raise Exception("unsupported mode %s!" % mode)

    do_install = mode in ["all", "install"]
    do_uninstall = mode in ["all", "uninstall"]

    lh.section("startup")
    if verbose:
        logging.info("setting debug level to debug (verbose)")
        logging.getLogger().setLevel(logging.DEBUG)

    install_config = InstallerConfig(new_version, verbose, enterprise,
                                     encryption_at_rest, zip_package,
                                     Path(package_dir), Path(test_data_dir),
                                     mode, publicip, interactive, False)

    inst = make_installer(install_config)

    if starter_mode == 'all':
        starter_mode = [
            RunnerType.LEADER_FOLLOWER, RunnerType.ACTIVE_FAILOVER,
            RunnerType.CLUSTER
        ]
        if enterprise:
            starter_mode.append(RunnerType.DC2DC)
    elif starter_mode == 'LF':
        starter_mode = [RunnerType.LEADER_FOLLOWER]
    elif starter_mode == 'AFO':
        starter_mode = [RunnerType.ACTIVE_FAILOVER]
    elif starter_mode == 'CL':
        starter_mode = [RunnerType.CLUSTER]
    elif starter_mode == 'DC':
        starter_mode = [RunnerType.DC2DC]
    elif starter_mode == 'DCendurance':
        starter_mode = [RunnerType.DC2DCENDURANCE]
    elif starter_mode == 'none':
        starter_mode = [RunnerType.NONE]
    else:
        raise Exception("invalid starter mode: " + starter_mode)

    count = 1
    for runner_type in starter_mode:
        assert runner_type
        runner = make_runner(runner_type, selenium, selenium_driver_args,
                             inst.cfg, inst, None)
        # install on first run:
        runner.do_install = (count == 1) and do_install
        # only uninstall after the last test:
        runner.do_uninstall = (count == len(starter_mode)) and do_uninstall
        failed = False
        if not runner.run():
            failed = True

        kill_all_processes()
        count += 1

    return 0 if not failed else 1
Esempio n. 9
0
def run_test(old_version, new_version, verbose, package_dir, test_data_dir,
             enterprise, encryption_at_rest, zip_package,
             interactive, mode, starter_mode, publicip, scenario, frontends,
             selenium, selenium_driver_args):
    """ main """
    lh.section("configuration")
    print("version: " + str(new_version))
    print("using enterpise: " + str(enterprise))
    print("using zip: " + str(zip_package))
    print("package directory: " + str(package_dir))
    print("mode: " + str(mode))
    print("starter mode: " + str(starter_mode))
    print("public ip: " + str(publicip))
    print("interactive: " + str(interactive))
    print("scenario: " + str(scenario))
    print("verbose: " + str(verbose))

    if mode not in ['all', 'install', 'system', 'tests', 'uninstall']:
        raise Exception("unsupported mode %s!" % mode)

    do_install = mode in ["all", "install"]
    do_uninstall = mode in ["all", "uninstall"]

    lh.section("startup")
    if verbose:
        logging.info("setting debug level to debug (verbose)")
        logging.getLogger().setLevel(logging.DEBUG)

    install_config = InstallerConfig(new_version,
                                     verbose,
                                     enterprise,
                                     encryption_at_rest,
                                     zip_package,
                                     Path(package_dir),
                                     Path(test_data_dir),
                                     mode,
                                     publicip,
                                     interactive,
                                     False)

    split_host = re.compile(r'([a-z]*)://([0-9.:]*):(\d*)')

    inst = make_installer(install_config)

    if len(frontends) > 0:
        for frontend in frontends:
            print('remote')
            host_parts = re.split(split_host, frontend)
            inst.cfg.add_frontend(host_parts[1],
                                  host_parts[2],
                                  host_parts[3])
    inst.cfg.scenario = Path(scenario)
    runner = ClusterPerf(RunnerType.CLUSTER, inst.cfg, inst, None, None, selenium, selenium_driver_args)
    runner.do_install = do_install
    runner.do_uninstall = do_uninstall
    failed = False
    if not runner.run():
        failed = True

    if len(frontends) == 0:
        kill_all_processes()

    return 0 if not failed else 1
Esempio n. 10
0
    def __init__(
        self,
        options: DownloadOptions,
        hb_cli_cfg: HotBackupCliCfg,
        version: str,
        enterprise: bool,
        zip_package: bool,
        src_testing: bool,
        source,
        existing_version_states={},
        new_version_states={},
        git_version="",
    ):
        """main"""
        lh.section("configuration")

        self.launch_dir = Path.cwd()
        if "WORKSPACE" in os.environ:
            self.launch_dir = Path(os.environ["WORKSPACE"])

        if not options.package_dir.is_absolute():
            options.package_dir = (self.launch_dir /
                                   options.package_dir).resolve()

        print("version: " + str(version))
        print("using enterpise: " + str(enterprise))
        print("using zip: " + str(zip_package))
        print("package directory: " + str(options.package_dir))
        print("verbose: " + str(options.verbose))
        self.options = options
        self.is_nightly = semver.VersionInfo.parse(
            version).prerelease == "nightly"
        self.source = source
        if not self.is_nightly and self.source == 'nightlypublic':
            self.source = 'public'
        if options.remote_host != "":
            # external DNS to wuerg around docker dns issues...
            self.remote_host = options.remote_host
        else:
            # dns split horizon...
            if source in ["ftp:stage1", "ftp:stage2"]:
                self.remote_host = "nas01.arangodb.biz"
            elif source in ["http:stage2"]:
                self.remote_host = "download.arangodb.com"
            else:
                self.remote_host = "download.arangodb.com"
        lh.section("startup")
        self.cfg = InstallerConfig(
            version=version,
            verbose=options.verbose,
            enterprise=enterprise,
            encryption_at_rest=False,
            zip_package=zip_package,
            src_testing=src_testing,
            hb_cli_cfg=hb_cli_cfg,
            package_dir=options.package_dir,
            test_dir=Path("/"),
            deployment_mode="all",
            publicip="127.0.0.1",
            interactive=False,
            stress_upgrade=False,
            ssl=False,
        )

        self.inst = make_installer(self.cfg)
        self.path_architecture = ""
        if self.is_nightly or self.cfg.semver > semver.VersionInfo.parse(
                "3.9.99"):
            machine = platform.machine()
            if machine == 'AMD64':
                machine = 'x86_64'
            self.path_architecture = machine + '/'
        self.calculate_package_names()
        self.packages = []

        self.existing_version_states = existing_version_states
        self.new_version_states = new_version_states
        self.version_content = None
        self.version_content = None
        if version.find("-nightly") >= 0:
            self.version_state_id = version + "_sourceInfo.log"
            if self.version_state_id in self.existing_version_states:
                self.version_content = self.existing_version_states[
                    self.version_state_id]
            self.fresh_content = self.get_version_info(git_version)
            self.new_version_states[self.version_state_id] = self.fresh_content
    def run_test(self,
                 deployment_mode,
                 versions: list,
                 run_props: RunProperties):
        # fmt: on
        """ main """
        results = []

        do_install = deployment_mode in ["all", "install"]
        do_uninstall = deployment_mode in ["all", "uninstall"]

        installers = create_config_installer_set(
            versions,
            self.base_config,
            deployment_mode,
            run_props
        )
        lh.section("configuration")
        print(
            """
        mode: {mode}
        {cfg_repr}
        """.format(
                **{"mode": str(deployment_mode), "cfg_repr": repr(installers[0][0])}
            )
        )

        count = 1
        for runner_type in STARTER_MODES[self.base_config.starter_mode]:
            with AllureTestSuiteContext(properties=run_props,
                                        versions=versions,
                                        parent_test_suite_name=None,
                                        auto_generate_parent_test_suite_name=True,
                                        suite_name=runner_strings[runner_type],
                                        runner_type=None,
                                        installer_type=installers[0][1].installer_type):
                with RtaTestcase(runner_strings[runner_type] + " main flow") as testcase:
                    if not run_props.supports_dc2dc() and runner_type == RunnerType.DC2DC:
                        testcase.context.status = Status.SKIPPED
                        testcase.context.statusDetails = StatusDetails(
                            message="DC2DC is not applicable to Community packages.\nDC2DC is not supported on Windows.")
                        continue
                    one_result = {
                        "testrun name": run_props.testrun_name,
                        "testscenario": runner_strings[runner_type],
                        "success": True,
                        "messages": [],
                        "progress": "",
                    }
                    runner = make_runner(
                        runner_type,
                        self.abort_on_error,
                        self.selenium,
                        self.selenium_driver_args,
                        installers,
                        run_props,
                        use_auto_certs=self.use_auto_certs,
                    )
                    # install on first run:
                    runner.do_install = (count == 1) and do_install
                    # only uninstall after the last test:
                    runner.do_uninstall = (count == len(
                        STARTER_MODES[deployment_mode])) and do_uninstall
                    try:
                        runner.run()
                        runner.cleanup()
                        testcase.context.status = Status.PASSED
                    # pylint: disable=broad-except
                    except Exception as ex:
                        one_result["success"] = False
                        one_result["messages"].append(str(ex))
                        one_result["progress"] += runner.get_progress()
                        runner.take_screenshot()
                        runner.agency_acquire_dump()
                        runner.search_for_warnings()
                        runner.quit_selenium()
                        kill_all_processes()
                        runner.zip_test_dir()
                        self.copy_packages_to_result(installers)
                        testcase.context.status = Status.FAILED
                        testcase.context.statusDetails = StatusDetails(message=str(ex),
                                                                       trace="".join(
                                                                           traceback.TracebackException.from_exception(
                                                                               ex).format()))
                        lh.section("uninstall on error")
                        installers[0][1].un_install_debug_package()
                        installers[0][1].un_install_server_package()
                        installers[0][1].cleanup_system()
                        if self.abort_on_error:
                            raise ex
                        traceback.print_exc()
                        lh.section("uninstall on error")
                        try:
                            runner.cleanup()
                        finally:
                            pass
                        results.append(one_result)
                        continue

                    if runner.ui_tests_failed:
                        failed_test_names = [f'"{row["Name"]}"' for row in
                                             runner.ui_test_results_table if
                                             not row["Result"] == "PASSED"]
                        one_result["success"] = False
                        # pylint: disable=line-too-long
                        one_result[
                            "messages"].append(
                            f'The following UI tests failed: {", ".join(failed_test_names)}. See allure report for details.')

                    kill_all_processes()
                    count += 1

        return results
    def run_upgrade(self, versions: list, run_props: RunProperties):
        """execute upgrade tests"""
        lh.section("startup")
        results = []
        for runner_type in STARTER_MODES[self.base_config.starter_mode]:
            installers = create_config_installer_set(
                versions,
                self.base_config,
                "all",
                run_props,
            )
            old_inst = installers[0][1]
            new_inst = installers[1][1]

            with AllureTestSuiteContext(
                properties=run_props,
                versions=versions,
                parent_test_suite_name=None,
                auto_generate_parent_test_suite_name=True,
                suite_name=runner_strings[runner_type],
                runner_type=None,
                installer_type=new_inst.installer_type,
            ):
                with RtaTestcase(runner_strings[runner_type] + " main flow") as testcase:
                    if not run_props.supports_dc2dc() and runner_type == RunnerType.DC2DC:
                        testcase.context.status = Status.SKIPPED
                        testcase.context.statusDetails = StatusDetails(
                            message="DC2DC is not applicable to Community packages.\nDC2DC is not supported on Windows."
                        )
                        continue
                    one_result = {
                        "testrun name": run_props.testrun_name,
                        "testscenario": runner_strings[runner_type],
                        "success": True,
                        "messages": [],
                        "progress": "",
                    }
                    try:
                        kill_all_processes()
                        runner = None
                        lh.section("configuration")
                        print(
                            """
                        starter mode: {starter_mode}
                        old version: {old_version}
                        {cfg_repr}
                        """.format(
                                **{
                                    "starter_mode": str(self.base_config.starter_mode),
                                    "old_version": str(versions[0]),
                                    "cfg_repr": repr(installers[1][0]),
                                }
                            )
                        )
                        if runner_type:
                            runner = make_runner(
                                runner_type,
                                self.abort_on_error,
                                self.selenium,
                                self.selenium_driver_args,
                                installers,
                                run_props,
                                use_auto_certs=self.use_auto_certs,
                            )
                            if runner:
                                try:
                                    runner.run()
                                    runner.cleanup()
                                    testcase.context.status = Status.PASSED
                                except Exception as ex:
                                    one_result["success"] = False
                                    one_result["messages"].append(str(ex))
                                    one_result["progress"] += runner.get_progress()
                                    runner.take_screenshot()
                                    runner.agency_acquire_dump()
                                    runner.search_for_warnings()
                                    runner.quit_selenium()
                                    kill_all_processes()
                                    runner.zip_test_dir()
                                    self.copy_packages_to_result(installers)
                                    testcase.context.status = Status.FAILED
                                    testcase.context.statusDetails = StatusDetails(
                                        message=str(ex),
                                        trace="".join(traceback.TracebackException.from_exception(ex).format()),
                                    )
                                    if self.abort_on_error:
                                        raise ex
                                    one_result["progress"] += str(ex) + "".join(
                                        traceback.TracebackException.from_exception(ex).format()
                                    )
                                    traceback.print_exc()
                                    lh.section("uninstall on error")
                                    old_inst.un_install_debug_package()
                                    old_inst.un_install_server_package()
                                    old_inst.cleanup_system()
                                    try:
                                        runner.cleanup()
                                    finally:
                                        pass
                                    results.append(one_result)
                                    continue
                                if runner.ui_tests_failed:
                                    failed_test_names = [
                                        f'"{row["Name"]}"'
                                        for row in runner.ui_test_results_table
                                        if not row["Result"] == "PASSED"
                                    ]
                                    one_result["success"] = False
                                    one_result["messages"].append(
                                        f'The following UI tests failed: {", ".join(failed_test_names)}.'
                                        + "See allure report for details."
                                    )
                        lh.section("uninstall")
                        new_inst.un_install_server_package()
                        lh.section("check system")
                        new_inst.check_uninstall_cleanup()
                        lh.section("remove residuals")
                        try:
                            old_inst.cleanup_system()
                        except Exception:
                            print("Ignoring old cleanup error!")
                        try:
                            print("Ignoring new cleanup error!")
                            new_inst.cleanup_system()
                        except Exception:
                            print("Ignoring general cleanup error!")
                    except Exception as ex:
                        print("Caught. " + str(ex))
                        one_result["success"] = False
                        one_result["messages"].append(str(ex))
                        one_result["progress"] += "\naborted outside of testcodes"
                        if self.abort_on_error:
                            print("re-throwing.")
                            raise ex
                        traceback.print_exc()
                        kill_all_processes()
                        if runner:
                            try:
                                runner.cleanup()
                            except Exception as exception:
                                print("Ignoring runner cleanup error! Exception:")
                                print(str(exception))
                                print("".join(traceback.TracebackException.from_exception(exception).format()))
                        try:
                            print("Cleaning up system after error:")
                            old_inst.un_install_debug_package()
                            old_inst.un_install_server_package()
                            old_inst.cleanup_system()
                        except Exception:
                            print("Ignoring old cleanup error!")
                        try:
                            print("Ignoring new cleanup error!")
                            new_inst.un_install_debug_package()
                            new_inst.un_install_server_package()
                            new_inst.cleanup_system()
                        except Exception:
                            print("Ignoring new cleanup error!")
                    results.append(one_result)
        return results
Esempio n. 13
0
    def run(self):
        """ run the full lifecycle flow of this deployment """
        # pylint: disable=R0915 disable=R0912
        if self.do_starter_test and not self.remote:
            self.detect_file_ulimit()

        lh.section("Runner of type {0}".format(str(self.name)), "<3")

        if self.do_install or self.do_system_test:
            lh.section("INSTALLATION for {0}".format(str(self.name)), )
            self.install(self.old_installer)

        if self.do_starter_test:
            lh.section("PREPARING DEPLOYMENT of {0}".format(str(self.name)), )
            self.starter_prepare_env()
            self.starter_run()
            self.finish_setup()
            self.make_data()
            if self.selenium:
                self.selenium.connect_server(self.get_frontend_instances(),
                                             '_system', self.cfg)
                self.selenium.check_old(self.old_installer.cfg)
            ti.prompt_user(
                self.basecfg,
                "{0}{1} Deployment started. Please test the UI!".format(
                    (self.versionstr), str(self.name)))
            if self.hot_backup:
                lh.section("TESTING HOTBACKUP")
                self.before_backup()
                # TODO generate name?
                self.backup_name = self.create_backup("thy_name_is")
                self.tcp_ping_all_nodes()
                self.create_non_backup_data()
                backups = self.list_backup()
                print(backups)
                self.upload_backup(backups[0])
                self.tcp_ping_all_nodes()
                self.delete_backup(backups[0])
                self.tcp_ping_all_nodes()
                backups = self.list_backup()
                if len(backups) != 0:
                    raise Exception("expected backup to be gone, "
                                    "but its still there: " + str(backups))
                self.download_backup(self.backup_name)
                self.tcp_ping_all_nodes()
                backups = self.list_backup()
                if backups[0] != self.backup_name:
                    raise Exception("downloaded backup has different name? " +
                                    str(backups))
                time.sleep(20)  # TODO fix
                self.restore_backup(backups[0])
                self.tcp_ping_all_nodes()
                self.after_backup()
                self.check_data_impl()
                if not self.check_non_backup_data():
                    raise Exception("data created after backup"
                                    " is still there??")
                self.create_non_backup_data()

        if self.new_installer:
            self.versionstr = "NEW[" + self.new_cfg.version + "] "

            lh.section("UPGRADE OF DEPLOYMENT {0}".format(str(self.name)), )
            if self.cfg.have_debug_package:
                print('removing *old* debug package in advance')
                self.old_installer.un_install_debug_package()

            self.new_installer.upgrade_package(self.old_installer)
            # only install debug package for new package.
            lh.subsection('installing debug package:')
            self.cfg.have_debug_package = self.new_installer.install_debug_package(
            )
            if self.cfg.have_debug_package:
                self.new_installer.gdb_test()
            self.new_installer.stop_service()
            self.cfg.set_directories(self.new_installer.cfg)
            self.new_cfg.set_directories(self.new_installer.cfg)
            self.old_installer.un_install_package_for_upgrade()

            self.upgrade_arangod_version()  #make sure to pass new version
            self.make_data_after_upgrade()
            if self.hot_backup:
                lh.section("TESTING HOTBACKUP AFTER UPGRADE")
                self.before_backup()
                backups = self.list_backup()
                print(backups)
                self.upload_backup(backups[0])
                self.tcp_ping_all_nodes()
                self.delete_backup(backups[0])
                self.tcp_ping_all_nodes()
                backups = self.list_backup()
                if len(backups) != 0:
                    raise Exception("expected backup to be gone, "
                                    "but its still there: " + str(backups))
                self.download_backup(self.backup_name)
                self.tcp_ping_all_nodes()
                backups = self.list_backup()
                if backups[0] != self.backup_name:
                    raise Exception("downloaded backup has different name? " +
                                    str(backups))
                time.sleep(20)  # TODO fix
                self.restore_backup(backups[0])
                self.tcp_ping_all_nodes()
                self.after_backup()
                if not self.check_non_backup_data():
                    raise Exception("data created after "
                                    "backup is still there??")
            self.check_data_impl()
        else:
            logging.info("skipping upgrade step no new version given")

        if self.do_starter_test:
            lh.section("TESTS FOR {0}".format(str(self.name)), )
            self.test_setup()
            self.jam_attempt()
            self.starter_shutdown()
        if self.do_uninstall:
            self.uninstall(self.old_installer
                           if not self.new_installer else self.new_installer)
        self.selenium.disconnect()
        lh.section("Runner of type {0} - Finished!".format(str(self.name)))