def run_tests(repl): """Runs all of the tests.""" if repl: # Actually show errors in the repl. sys.excepthook = original_excepthook def no_thanks(exit_code): print("Tests finished with exit code %d." % exit_code) sys.exit = no_thanks proboscis.TestProgram().run_and_exit() if repl: import code code.interact()
# F401 unused imports needed for tox tests from trove.tests.api import backups # noqa from trove.tests.api import header # noqa from trove.tests.api import limits # noqa from trove.tests.api import flavors # noqa from trove.tests.api import versions # noqa from trove.tests.api import instances as rd_instances # noqa from trove.tests.api import instances_actions as rd_actions # noqa from trove.tests.api import instances_delete # noqa from trove.tests.api import instances_mysql_down # noqa from trove.tests.api import instances_resize # noqa from trove.tests.api import databases # noqa from trove.tests.api import datastores # noqa from trove.tests.api import root # noqa from trove.tests.api import root_on_create # noqa from trove.tests.api import users # noqa from trove.tests.api import user_access # noqa from trove.tests.api.mgmt import accounts # noqa from trove.tests.api.mgmt import admin_required # noqa from trove.tests.api.mgmt import hosts # noqa from trove.tests.api.mgmt import instances as mgmt_instances # noqa from trove.tests.api.mgmt import instances_actions as mgmt_actions # noqa from trove.tests.api.mgmt import storage # noqa from trove.tests.api.mgmt import malformed_json # noqa except Exception as e: print("Run tests failed: %s" % e) traceback.print_exc() raise proboscis.TestProgram().run_and_exit()
def run_main(test_importer): add_support_for_localization() # Strip non-nose arguments out before passing this to nosetests repl = False nose_args = [] conf_file = "~/test.conf" show_elapsed = True groups = [] print("RUNNING TEST ARGS : " + str(sys.argv)) extra_test_conf_lines = [] rdl_config_file = None nova_flag_file = None index = 0 while index < len(sys.argv): arg = sys.argv[index] if arg[:2] == "-i" or arg == '--repl': repl = True elif arg[:7] == "--conf=": conf_file = os.path.expanduser(arg[7:]) print("Setting TEST_CONF to " + conf_file) os.environ["TEST_CONF"] = conf_file elif arg[:8] == "--group=": groups.append(arg[8:]) elif arg == "--test-config": if index >= len(sys.argv) - 1: print('Expected an argument to follow "--test-conf".') sys.exit() conf_line = sys.argv[index + 1] extra_test_conf_lines.append(conf_line) elif arg[:11] == "--flagfile=": pass elif arg[:14] == "--config-file=": rdl_config_file = arg[14:] elif arg[:13] == "--nova-flags=": nova_flag_file = arg[13:] elif arg.startswith('--hide-elapsed'): show_elapsed = False else: nose_args.append(arg) index += 1 # Many of the test decorators depend on configuration values, so before # start importing modules we have to load the test config followed by the # flag files. from trove.tests.config import CONFIG # Find config file. if not "TEST_CONF" in os.environ: raise RuntimeError("Please define an environment variable named " + "TEST_CONF with the location to a conf file.") file_path = os.path.expanduser(os.environ["TEST_CONF"]) if not os.path.exists(file_path): raise RuntimeError("Could not find TEST_CONF at " + file_path + ".") # Load config file and then any lines we read from the arguments. CONFIG.load_from_file(file_path) for line in extra_test_conf_lines: CONFIG.load_from_line(line) if CONFIG.white_box: # If white-box testing, set up the flags. # Handle loading up RDL's config file madness. initialize_rdl_config(rdl_config_file) # Set up the report, and print out how we're running the tests. from tests.util import report from datetime import datetime report.log("Trove Integration Tests, %s" % datetime.now()) report.log("Invoked via command: " + str(sys.argv)) report.log("Groups = " + str(groups)) report.log("Test conf file = %s" % os.environ["TEST_CONF"]) if CONFIG.white_box: report.log("") report.log("Test config file = %s" % rdl_config_file) report.log("") report.log("sys.path:") for path in sys.path: report.log("\t%s" % path) # Now that all configurations are loaded its time to import everything test_importer() atexit.register(_clean_up) c = config.Config(stream=sys.stdout, env=os.environ, verbosity=3, plugins=core.DefaultPluginManager()) runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, config=c, show_elapsed=show_elapsed, known_bugs=CONFIG.known_bugs) MAIN_RUNNER = runner if repl: # Turn off the following "feature" of the unittest module in case # we want to start a REPL. sys.exit = lambda x: None proboscis.TestProgram(argv=nose_args, groups=groups, config=c, testRunner=MAIN_RUNNER).run_and_exit() sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__
self.__result.printSummary(self.__start_time, stop_time) self.config.plugins.finalize(self.__result) if self.show_elapsed: self._writeSlowTests(self.__result) def run(self, test): result = super(IntegrationTestRunner, self).run(test) self.__finished = True return result c = config.Config(stream=sys.stdout, env=os.environ, verbosity=3, plugins=core.DefaultPluginManager()) runner = IntegrationTestRunner(stream=c.stream, verbosity=c.verbosity, config=c, show_elapsed=show_elapsed) runner.init() MAIN_RUNNER = runner if repl: # Turn off the following "feature" of the unittest module in case # we want to start a REPL. sys.exit = lambda x: None proboscis.TestProgram(argv=nose_args, groups=groups, testRunner=runner).run_and_exit() sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__