def logging_setup(config): """ Set up logging based on config """ logging.getLogger().setLevel(DEBUG_LEVELS[config["debug"]]) if config["log_dir"] != None: if os.path.exists(config["log_dir"]): import shutil shutil.rmtree(config["log_dir"]) os.makedirs(config["log_dir"]) else: if os.path.exists(config["log_file"]): os.remove(config["log_file"]) oftest.open_logfile('main')
logging.info("*** TEST RUN START: " + time.asctime()) if config["xunit"]: try: import xmlrunner # fail-fast if module missing except ImportError as ex: oftest.dataplane_instance.kill() profiler_teardown(profiler) raise ex runner = xmlrunner.XMLTestRunner(output=config["xunit_dir"], outsuffix="", verbosity=2) result = runner.run(suite) else: result = unittest.TextTestRunner(verbosity=2).run(suite) oftest.open_logfile('main') if oftest.testutils.skipped_test_count > 0: message = "Skipped %d test(s)" % oftest.testutils.skipped_test_count logging.info(message) logging.info("*** TEST RUN END : %s", time.asctime()) # Shutdown the dataplane oftest.dataplane_instance.kill() oftest.dataplane_instance = None profiler_teardown(profiler) if result.failures or result.errors: # exit(1) hangs sometimes os._exit(1) if oftest.testutils.skipped_test_count > 0 and config["fail_skipped"]:
def setUp(self): oftest.open_logfile(str(self)) logging.info("** START TEST CASE " + str(self))
def setUp(self): if config["force_ofdpa_restart"]: logging.info("Restarting OFDPA") forceOfdpaRestart(config["force_ofdpa_restart"]) oftest.open_logfile(str(self)) logging.info("** START TEST CASE " + str(self))