def git_repo_check(service): git_url = get_git_url(service) cmd = "git ls-remote %s" % git_url returncode, _ = _run(cmd, timeout=5) if returncode == 0: print PaastaCheckMessages.GIT_REPO_FOUND else: print PaastaCheckMessages.git_repo_missing(git_url)
def git_repo_check(service): git_url = get_git_url(service) cmd = 'git ls-remote %s' % git_url returncode, _ = _run(cmd, timeout=5) if returncode == 0: print PaastaCheckMessages.GIT_REPO_FOUND else: print PaastaCheckMessages.git_repo_missing(git_url)
def service_dir_check(service): """Check whether directory service exists in /nail/etc/services :param service: string of service name we wish to inspect """ try: validate_service_name(service) print PaastaCheckMessages.service_dir_found(service) except NoSuchService: print PaastaCheckMessages.service_dir_missing(service)
def service_dir_check(service): """Check whether directory service exists in /nail/etc/services :param service: string of service name we wish to inspect """ try: validate_service_name(service) print PaastaCheckMessages.service_dir_found(service) except NoSuchService: print PaastaCheckMessages.service_dir_missing(service)
def sensu_check(service, service_path): """Check whether monitoring.yaml exists in service directory, and that the team name is declared. :param service: name of service currently being examined :param service_path: path to loction of monitoring.yaml file""" if is_file_in_dir("monitoring.yaml", service_path): print PaastaCheckMessages.SENSU_MONITORING_FOUND team = get_team(service=service, overrides={}) if team is None: print PaastaCheckMessages.SENSU_TEAM_MISSING else: print PaastaCheckMessages.sensu_team_found(team) else: print PaastaCheckMessages.SENSU_MONITORING_MISSING
def sensu_check(service, service_path): """Check whether monitoring.yaml exists in service directory, and that the team name is declared. :param service: name of service currently being examined :param service_path: path to loction of monitoring.yaml file""" if is_file_in_dir('monitoring.yaml', service_path): print PaastaCheckMessages.SENSU_MONITORING_FOUND team = get_team(service=service, overrides={}) if team is None: print PaastaCheckMessages.SENSU_TEAM_MISSING else: print PaastaCheckMessages.sensu_team_found(team) else: print PaastaCheckMessages.SENSU_MONITORING_MISSING
def smartstack_check(service, service_path): """Check whether smartstack.yaml exists in service directory, and the proxy ports are declared. Print appropriate message depending on outcome. :param service: name of service currently being examined :param service_path: path to loction of smartstack.yaml file""" if is_file_in_dir("smartstack.yaml", service_path): print PaastaCheckMessages.SMARTSTACK_YAML_FOUND instances = get_all_namespaces_for_service(service) if len(instances) > 0: for namespace, config in get_all_namespaces_for_service(service, full_name=False): if "proxy_port" in config: print PaastaCheckMessages.smartstack_port_found(namespace, config.get("proxy_port")) else: print PaastaCheckMessages.SMARTSTACK_PORT_MISSING else: print PaastaCheckMessages.SMARTSTACK_PORT_MISSING
def test_check_service_dir_check_pass(mock_stdout, mock_validate_service_name): mock_validate_service_name.return_value = None service = 'fake_service' expected_output = \ "%s\n" % PaastaCheckMessages.service_dir_found(service) service_dir_check(service) output = mock_stdout.getvalue() assert output == expected_output
def test_check_service_dir_check_fail(mock_stdout, mock_validate_service_name): service = 'fake_service' mock_validate_service_name.side_effect = NoSuchService(service) expected_output = "%s\n" \ % PaastaCheckMessages.service_dir_missing(service) service_dir_check(service) output = mock_stdout.getvalue() assert output == expected_output
def test_check_service_dir_check_fail(mock_stdout, mock_validate_service_name): service = 'fake_service' mock_validate_service_name.side_effect = NoSuchService(service) expected_output = "%s\n" \ % PaastaCheckMessages.service_dir_missing(service) service_dir_check(service) output = mock_stdout.getvalue() assert output == expected_output
def test_check_service_dir_check_pass(mock_stdout, mock_validate_service_name): mock_validate_service_name.return_value = None service = 'fake_service' expected_output = \ "%s\n" % PaastaCheckMessages.service_dir_found(service) service_dir_check(service) output = mock_stdout.getvalue() assert output == expected_output
def smartstack_check(service, service_path): """Check whether smartstack.yaml exists in service directory, and the proxy ports are declared. Print appropriate message depending on outcome. :param service: name of service currently being examined :param service_path: path to loction of smartstack.yaml file""" if is_file_in_dir('smartstack.yaml', service_path): print PaastaCheckMessages.SMARTSTACK_YAML_FOUND instances = get_all_namespaces_for_service(service) if len(instances) > 0: for namespace, config in get_all_namespaces_for_service(service, full_name=False): if 'proxy_port' in config: print PaastaCheckMessages.smartstack_port_found( namespace, config.get('proxy_port')) else: print PaastaCheckMessages.SMARTSTACK_PORT_MISSING else: print PaastaCheckMessages.SMARTSTACK_PORT_MISSING
def test_check_sensu_check_pass(mock_stdout, mock_get_team, mock_is_file_in_dir): # monitoring.yaml exists and team is found mock_is_file_in_dir.return_value = "/fake/path" team = 'team-service-infra' mock_get_team.return_value = team expected_output = "%s\n%s\n" % (PaastaCheckMessages.SENSU_MONITORING_FOUND, PaastaCheckMessages.sensu_team_found(team)) sensu_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output mock_get_team.assert_called_once_with(service='fake_service', overrides={})
def test_check_sensu_check_pass(mock_stdout, mock_get_team, mock_is_file_in_dir): # monitoring.yaml exists and team is found mock_is_file_in_dir.return_value = "/fake/path" team = 'team-service-infra' mock_get_team.return_value = team expected_output = "%s\n%s\n" % (PaastaCheckMessages.SENSU_MONITORING_FOUND, PaastaCheckMessages.sensu_team_found(team)) sensu_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output mock_get_team.assert_called_once_with(service='fake_service', overrides={})
def test_check_smartstack_check_pass(mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = 'main' smartstack_dict = {'smartstack': {instance: {'proxy_port': port}}} mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found( instance, port)) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output
def test_check_smartstack_check_pass(mock_stdout, mock_is_file_in_dir, mock_read_service_info): # smartstack.yaml exists and port is found mock_is_file_in_dir.return_value = True port = 80 instance = 'main' smartstack_dict = { 'smartstack': { instance: { 'proxy_port': port } } } mock_read_service_info.return_value = smartstack_dict expected_output = "%s\n%s\n" \ % (PaastaCheckMessages.SMARTSTACK_YAML_FOUND, PaastaCheckMessages.smartstack_port_found( instance, port)) smartstack_check('fake_service', 'path') output = mock_stdout.getvalue() assert output == expected_output