Пример #1
0
    def run(cls, root_path, test, base_url):
        logging.debug("run test")
        module, class_name, test_name = (test.module, test.class_name,
                                         test.test_name)
        temp_path = mkdtemp()

        try:
            logging.debug("creating venv")
            venv_path = "%s/venv" % temp_path.rstrip('/')
            virtualenv.create_environment(venv_path,
                                          site_packages=False,
                                          unzip_setuptools=True,
                                          use_distribute=True)

            logging.debug("installing funkload")
            pip = Command("%s/bin/pip" % venv_path)
            pip.install(FUNKLOAD_GIT)

            for dep in test.deps:
                logging.debug("install deps")
                pip.install(dep)

            logging.debug("creating command")
            fl_run_test = Command("%s/bin/fl-run-test" % venv_path)
            logging.debug("command created")

            logging.debug("run command: %s" %
                          ("%s/bin/fl-run-test %s %s -u %s" %
                           (venv_path, module,
                            ("%s.%s" % (class_name, test_name)), base_url)))
            result = fl_run_test(module,
                                 "%s.%s" % (class_name, test_name),
                                 u=base_url,
                                 _env={
                                     "PYTHONPATH":
                                     '$PYTHONPATH:%s' %
                                     join(root_path.rstrip('/'), "bench")
                                 },
                                 simple_fetch=True,
                                 _cwd=temp_path)
            logging.debug("command run")

            logging.debug("get result")
            exit_code = result.exit_code
            text = result.stdout + result.stderr

            with open(join(temp_path, 'funkload.log')) as fl_log:
                logging.debug("write log")
                log = fl_log.read()

        except ErrorReturnCode:
            err = sys.exc_info()[1]
            text = err.stderr
            exit_code = 1
            log = err.stderr + err.stdout
            logging.error(log)

        logging.debug("test run")
        return FunkLoadTestRunResult(exit_code, text, log)
Пример #2
0
    def run(cls, root_path, test, base_url):
        logging.debug("run test")
        module, class_name, test_name = (test.module, test.class_name, test.test_name)
        temp_path = mkdtemp()

        try:
            logging.debug("creating venv")
            venv_path = "%s/venv" % temp_path.rstrip("/")
            virtualenv.create_environment(venv_path, site_packages=False, unzip_setuptools=True, use_distribute=True)

            logging.debug("installing funkload")
            pip = Command("%s/bin/pip" % venv_path)
            pip.install(FUNKLOAD_GIT)

            for dep in test.deps:
                logging.debug("install deps")
                pip.install(dep)

            logging.debug("creating command")
            fl_run_test = Command("%s/bin/fl-run-test" % venv_path)
            logging.debug("command created")

            logging.debug(
                "run command: %s"
                % (
                    "%s/bin/fl-run-test %s %s -u %s"
                    % (venv_path, module, ("%s.%s" % (class_name, test_name)), base_url)
                )
            )
            result = fl_run_test(
                module,
                "%s.%s" % (class_name, test_name),
                u=base_url,
                _env={"PYTHONPATH": "$PYTHONPATH:%s" % join(root_path.rstrip("/"), "bench")},
                simple_fetch=True,
                _cwd=temp_path,
            )
            logging.debug("command run")

            logging.debug("get result")
            exit_code = result.exit_code
            text = result.stdout + result.stderr

            with open(join(temp_path, "funkload.log")) as fl_log:
                logging.debug("write log")
                log = fl_log.read()

        except ErrorReturnCode:
            err = sys.exc_info()[1]
            text = err.stderr
            exit_code = 1
            log = err.stderr + err.stdout
            logging.error(log)

        logging.debug("test run")
        return FunkLoadTestRunResult(exit_code, text, log)