def test_bad_calculate_remote_master(mock_get_by_hostname, system_paasta_config): mock_get_by_hostname.side_effect = gaierror(42, 'bar') ips, output = utils.calculate_remote_masters('myhost', system_paasta_config) assert ips == [] assert 'ERROR while doing DNS lookup of paasta-myhost.yelp:\nbar\n' in output
def test_ok_remote_masters(mock_get_by_hostname): mock_get_by_hostname.return_value = ('myhost', [], ['1.2.3.4', '1.2.3.5']) fake_system_paasta_config = SystemPaastaConfig({}, '/fake/config') ips, output = utils.calculate_remote_masters('myhost', fake_system_paasta_config) assert output is None assert ips == ['1.2.3.4', '1.2.3.5']
def test_bad_calculate_remote_master(mock_get_by_hostname): mock_get_by_hostname.side_effect = gaierror('foo', 'bar') fake_system_paasta_config = SystemPaastaConfig({}, '/fake/config') ips, output = utils.calculate_remote_masters('myhost', fake_system_paasta_config) assert ips == [] assert 'ERROR while doing DNS lookup of paasta-myhost.yelp:\nbar\n' in output
def get_any_mesos_master(cluster): system_paasta_config = load_system_paasta_config() masters, output = calculate_remote_masters(cluster, system_paasta_config) if not masters: print 'ERROR: %s' % output sys.exit(1) mesos_master, output = find_connectable_master(masters) if not mesos_master: print 'ERROR: could not find connectable master in cluster %s\nOutput: %s' % (cluster, output) sys.exit(1) return mesos_master
def get_any_mesos_master(cluster, system_paasta_config): masters, output = calculate_remote_masters(cluster, system_paasta_config) if not masters: paasta_print('ERROR: %s' % output) sys.exit(1) mesos_master, output = find_connectable_master(masters) if not mesos_master: paasta_print( 'ERROR: could not find connectable master in cluster %s\nOutput: %s' % (cluster, output)) sys.exit(1) return mesos_master
def get_any_mesos_master(cluster, system_paasta_config): masters, output = calculate_remote_masters(cluster, system_paasta_config) if not masters: print("ERROR: %s" % output) sys.exit(1) mesos_master, output = find_connectable_master(masters) if not mesos_master: print( f"ERROR: could not find connectable master in cluster {cluster}\nOutput: {output}" ) sys.exit(1) return mesos_master
def test_ok_remote_masters(mock_get_by_hostname, system_paasta_config): mock_get_by_hostname.return_value = ('myhost', [], ['1.2.3.4', '1.2.3.5']) ips, output = utils.calculate_remote_masters('myhost', system_paasta_config) assert output is None assert ips == ['1.2.3.4', '1.2.3.5']
def test_ok_remote_masters(mock_get_by_hostname): mock_get_by_hostname.return_value = ('myhost', [], ['1.2.3.4', '1.2.3.5']) ips, output = utils.calculate_remote_masters('myhost') assert output is None assert ips == ['1.2.3.4', '1.2.3.5']
def test_bad_calculate_remote_master(mock_get_by_hostname): mock_get_by_hostname.side_effect = gaierror('foo', 'bar') ips, output = utils.calculate_remote_masters('myhost') assert ips == [] assert 'ERROR while doing DNS lookup of paasta-myhost.yelp:\nbar\n' in output
def test_ok_remote_masters(mock_get_by_hostname, system_paasta_config): mock_get_by_hostname.return_value = ("myhost", [], ["1.2.3.4", "1.2.3.5"]) ips, output = utils.calculate_remote_masters("myhost", system_paasta_config) assert output is None assert ips == ["1.2.3.4", "1.2.3.5"]