Commit 4fc2acf0 authored by Thong Kuah's avatar Thong Kuah Committed by Douglas Barbosa Alexandre

Use string instead of IPAddr

This helps with logging and debugging of `Host` objects.
parent 7712e947
...@@ -174,7 +174,7 @@ module Gitlab ...@@ -174,7 +174,7 @@ module Gitlab
address = srv_resolver.address_for(r.host.to_s) address = srv_resolver.address_for(r.host.to_s)
next unless address next unless address
Address.new(address, r.port) Address.new(address.to_s, r.port)
end.compact end.compact
end end
......
...@@ -175,8 +175,8 @@ describe Gitlab::Database::LoadBalancing::ServiceDiscovery do ...@@ -175,8 +175,8 @@ describe Gitlab::Database::LoadBalancing::ServiceDiscovery do
context 'with an A record' do context 'with an A record' do
let(:record_type) { 'A' } let(:record_type) { 'A' }
let(:res1) { double(:resource, address: '255.255.255.0', ttl: 90) } let(:res1) { double(:resource, address: IPAddr.new('255.255.255.0'), ttl: 90) }
let(:res2) { double(:resource, address: '127.0.0.1', ttl: 90) } let(:res2) { double(:resource, address: IPAddr.new('127.0.0.1'), ttl: 90) }
it 'returns a TTL and ordered list of IP addresses' do it 'returns a TTL and ordered list of IP addresses' do
addresses = [ addresses = [
...@@ -198,8 +198,8 @@ describe Gitlab::Database::LoadBalancing::ServiceDiscovery do ...@@ -198,8 +198,8 @@ describe Gitlab::Database::LoadBalancing::ServiceDiscovery do
before do before do
expect_next_instance_of(Gitlab::Database::LoadBalancing::SrvResolver) do |resolver| expect_next_instance_of(Gitlab::Database::LoadBalancing::SrvResolver) do |resolver|
allow(resolver).to receive(:address_for).with('foo1.service.consul.').and_return('255.255.255.0') allow(resolver).to receive(:address_for).with('foo1.service.consul.').and_return(IPAddr.new('255.255.255.0'))
allow(resolver).to receive(:address_for).with('foo2.service.consul.').and_return('127.0.0.1') allow(resolver).to receive(:address_for).with('foo2.service.consul.').and_return(IPAddr.new('127.0.0.1'))
allow(resolver).to receive(:address_for).with('foo3.service.consul.').and_return(nil) allow(resolver).to receive(:address_for).with('foo3.service.consul.').and_return(nil)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment