Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/load_balancing/resolver_spec.rb')
-rw-r--r--spec/lib/gitlab/database/load_balancing/resolver_spec.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/spec/lib/gitlab/database/load_balancing/resolver_spec.rb b/spec/lib/gitlab/database/load_balancing/resolver_spec.rb
index 0051cf50255..4af36693383 100644
--- a/spec/lib/gitlab/database/load_balancing/resolver_spec.rb
+++ b/spec/lib/gitlab/database/load_balancing/resolver_spec.rb
@@ -2,15 +2,16 @@
require 'spec_helper'
-RSpec.describe Gitlab::Database::LoadBalancing::Resolver do
+RSpec.describe Gitlab::Database::LoadBalancing::Resolver, :freeze_time, feature_category: :database do
describe '#resolve' do
let(:ip_addr) { IPAddr.new('127.0.0.2') }
context 'when nameserver is an IP' do
it 'returns an IPAddr object' do
service = described_class.new('127.0.0.2')
+ response = service.resolve
- expect(service.resolve).to eq(ip_addr)
+ expect(response.address).to eq(ip_addr)
end
end
@@ -22,12 +23,14 @@ RSpec.describe Gitlab::Database::LoadBalancing::Resolver do
allow(instance).to receive(:getaddress).with('localhost').and_return('127.0.0.2')
end
- expect(subject).to eq(ip_addr)
+ expect(subject.address).to eq(ip_addr)
end
context 'when nameserver is not in the hosts file' do
+ let(:raw_ttl) { 10 }
+
it 'looks the nameserver up in DNS' do
- resource = double(:resource, address: ip_addr)
+ resource = double(:resource, address: ip_addr, ttl: raw_ttl)
packet = double(:packet, answer: [resource])
allow_next_instance_of(Resolv::Hosts) do |instance|
@@ -38,7 +41,8 @@ RSpec.describe Gitlab::Database::LoadBalancing::Resolver do
.with('localhost', Net::DNS::A)
.and_return(packet)
- expect(subject).to eq(ip_addr)
+ expect(subject.address).to eq(ip_addr)
+ expect(subject.ttl).to eq(raw_ttl.seconds.from_now)
end
context 'when nameserver is not in DNS' do