def test_get_pod_name_failed(self, mock_logger_info): with mock.patch.dict(os.environ, {}, clear=True): self.assertEqual(functest_utils.get_pod_name(), "unknown-pod") mock_logger_info.assert_called_once_with("Unable to retrieve " "the POD name from " "environment. Using " "pod name 'unknown-pod'")
def main(): cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO start_time = time.time() ret = functest_utils.execute_command(cmd, logger, exit_on_error=False) stop_time = time.time() duration = round(stop_time - start_time, 1) if ret == 0: logger.info("doctor OK") test_status = 'OK' else: logger.info("doctor FAILED") test_status = 'NOK' details = { 'timestart': start_time, 'duration': duration, 'status': test_status, } pod_name = functest_utils.get_pod_name(logger) scenario = functest_utils.get_scenario(logger) version = functest_utils.get_version(logger) build_tag = functest_utils.get_build_tag(logger) status = "FAIL" if details['status'] == "OK": status = "PASS" logger.info("Pushing Doctor results: TEST_DB_URL=%(db)s pod_name=%(pod)s " "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % { 'db': TEST_DB_URL, 'pod': pod_name, 'v': version, 's': scenario, 'c': status, 'b': build_tag, 'd': details, }) functest_utils.push_results_to_db("doctor", "doctor-notification", logger, start_time, stop_time, status, details)
def main(): cmd = 'cd %s/tests && ./run.sh' % DOCTOR_REPO start_time = time.time() ret = functest_utils.execute_command(cmd, logger, exit_on_error=False) stop_time = time.time() duration = round(stop_time - start_time, 1) if ret: logger.info("doctor OK") test_status = 'OK' else: logger.info("doctor FAILED") test_status = 'NOK' details = { 'timestart': start_time, 'duration': duration, 'status': test_status, } pod_name = functest_utils.get_pod_name(logger) scenario = functest_utils.get_scenario(logger) version = functest_utils.get_version(logger) build_tag = functest_utils.get_build_tag(logger) status = "failed" if details['status'] == "OK": status = "passed" logger.info("Pushing Doctor results: TEST_DB_URL=%(db)s pod_name=%(pod)s " "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % { 'db': TEST_DB_URL, 'pod': pod_name, 'v': version, 's': scenario, 'c': status, 'b': build_tag, 'd': details, }) functest_utils.push_results_to_db("doctor", "doctor-notification", logger, start_time, stop_time, status, details)
def main(): cmd = ('%s/tests/run.sh' % COPPER_REPO) start_time = time.time() ret = functest_utils.execute_command(cmd, logger, exit_on_error=False) stop_time = time.time() duration = round(stop_time - start_time, 1) if ret == 0: logger.info("COPPER PASSED") test_status = 'PASS' else: logger.info("COPPER FAILED") test_status = 'FAIL' details = { 'timestart': start_time, 'duration': duration, 'status': test_status, } pod_name = functest_utils.get_pod_name(logger) scenario = functest_utils.get_scenario(logger) version = functest_utils.get_version(logger) build_tag = functest_utils.get_build_tag(logger) logger.info("Pushing COPPER results: TEST_DB_URL=%(db)s pod_name=%(pod)s " "version=%(v)s scenario=%(s)s criteria=%(c)s details=%(d)s" % { 'db': TEST_DB_URL, 'pod': pod_name, 'v': version, 's': scenario, 'c': details['status'], 'b': build_tag, 'd': details, }) functest_utils.push_results_to_db("COPPER", "COPPER-notification", logger, start_time, stop_time, details['status'], details)
def load_config(): """ Load connectivity settings from yaml. Load connectivity settings to Energy recording API Use functest global config yaml file (see functest_utils.get_functest_config) """ # Singleton pattern for energy_recorder_api static member # Load only if not previouly done if EnergyRecorder.energy_recorder_api is None: environment = ft_utils.get_pod_name() # API URL energy_recorder_uri = ft_utils.get_functest_config( "energy_recorder.api_url") assert energy_recorder_uri assert environment energy_recorder_uri += "/recorders/environment/" energy_recorder_uri += urllib.quote_plus(environment) EnergyRecorder.logger.debug("API recorder at: " + energy_recorder_uri) # Creds user = ft_utils.get_functest_config("energy_recorder.api_user") password = ft_utils.get_functest_config( "energy_recorder.api_password") if user != "" and password != "": energy_recorder_api_auth = (user, password) else: energy_recorder_api_auth = None # Final config EnergyRecorder.energy_recorder_api = { "uri": energy_recorder_uri, "auth": energy_recorder_api_auth }
def test_get_pod_name_default(self): with mock.patch.dict(os.environ, {'NODE_NAME': 'test_node_name'}, clear=True): self.assertEqual(functest_utils.get_pod_name(), self.node_name)