def test_validate_chronos_valid_instance( mock_path_to_soa_dir_service, mock_load_chronos_job_config, mock_list_all_instances_for_service, mock_list_clusters, mock_get_services_for_cluster, capfd, ): fake_service = 'fake-service' fake_instance = 'fake-instance' fake_cluster = 'penguin' mock_chronos_job = mock.Mock(autospec=True) mock_chronos_job.get_parents.return_value = None mock_chronos_job.validate.return_value = (True, []) mock_path_to_soa_dir_service.return_value = ('fake_soa_dir', fake_service) mock_list_clusters.return_value = [fake_cluster] mock_list_all_instances_for_service.return_value = [fake_instance] mock_get_services_for_cluster.return_value = [(fake_service, fake_instance) ] mock_load_chronos_job_config.return_value = mock_chronos_job assert validate_chronos('fake_service_path') output, _ = capfd.readouterr() assert valid_chronos_instance(fake_cluster, fake_instance) in output
def test_validate_chronos_valid_instance( mock_stdout, mock_path_to_soa_dir_service, mock_load_chronos_job_config, mock_list_all_instances_for_service, mock_list_clusters, mock_get_services_for_cluster ): fake_service = 'fake-service' fake_instance = 'fake-instance' fake_cluster = 'penguin' mock_chronos_job = mock.Mock(autospec=True) mock_chronos_job.get_parents.return_value = None mock_chronos_job.validate.return_value = (True, []) mock_path_to_soa_dir_service.return_value = ('fake_soa_dir', fake_service) mock_list_clusters.return_value = [fake_cluster] mock_list_all_instances_for_service.return_value = [fake_instance] mock_get_services_for_cluster.return_value = [(fake_service, fake_instance)] mock_load_chronos_job_config.return_value = mock_chronos_job assert validate_chronos('fake_service_path') output = mock_stdout.getvalue() assert valid_chronos_instance(fake_cluster, fake_instance) in output
def test_validate_chronos_valid_instance( mock_stdout, mock_path_to_soa_dir_service, mock_load_chronos_job_config, mock_list_all_instances_for_service, mock_list_clusters ): fake_service = 'test-service' fake_instance = 'fake-instance' fake_job_name = 'test' fake_cluster = 'penguin' fake_monitoring_info = {'fake_monitoring_info': 'fake_monitoring_value'} fake_config_dict = { 'bounce_method': 'graceful', 'cmd': '/bin/sleep 40', 'epsilon': 'PT30M', 'retries': 5, 'cpus': 5.5, 'mem': 1024.4, 'disabled': True, 'schedule': 'R/2015-03-25T19:36:35Z/PT5M', 'schedule_time_zone': 'Zulu', 'monitoring': fake_monitoring_info, } fake_branch_dict = { 'desired_state': 'start', 'docker_image': 'paasta-%s-%s' % (fake_service, fake_cluster), } fake_chronos_job_config = ChronosJobConfig(fake_service, fake_job_name, fake_config_dict, fake_branch_dict) mock_path_to_soa_dir_service.return_value = ('fake_soa_dir', 'fake_service') mock_list_clusters.return_value = [fake_cluster] mock_list_all_instances_for_service.return_value = [fake_instance] mock_load_chronos_job_config.return_value = fake_chronos_job_config assert validate_chronos('fake_service_path') == 0 output = mock_stdout.getvalue() assert valid_chronos_instance(fake_cluster, fake_instance) in output
def test_validate_chronos_valid_instance( mock_stdout, mock_path_to_soa_dir_service, mock_load_chronos_job_config, mock_list_all_instances_for_service, mock_list_clusters ): fake_instance = 'fake-instance' fake_cluster = 'penguin' mock_chronos_job = mock.Mock(autospec=True) mock_chronos_job.validate.return_value = (True, []) mock_path_to_soa_dir_service.return_value = ('fake_soa_dir', 'fake_service') mock_list_clusters.return_value = [fake_cluster] mock_list_all_instances_for_service.return_value = [fake_instance] mock_load_chronos_job_config.return_value = mock_chronos_job assert validate_chronos('fake_service_path') == 0 output = mock_stdout.getvalue() assert valid_chronos_instance(fake_cluster, fake_instance) in output