summaryrefslogtreecommitdiff
path: root/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
diff options
context:
space:
mode:
authorAndreas Kämmerle <andreas.kaemmerle@gmail.com>2018-07-03 15:30:36 +0200
committerAndreas Kämmerle <andreas.kaemmerle@gmail.com>2018-07-03 15:30:36 +0200
commite4a310113a3a5784be863151e5bcecacb23aa244 (patch)
tree79f9019b2e001a192eae3569b5746ba9c4ec9476 /spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
parentd505b48806c0880ac810374973c4b9ba802c26e8 (diff)
parentc489d53b2e2eecb22f8dc7034da142221220e89f (diff)
downloadgitlab-ce-e4a310113a3a5784be863151e5bcecacb23aa244.tar.gz
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into update-template-name-via-sentence-case
# Conflicts: # .gitlab/issue_templates/Feature proposal.md
Diffstat (limited to 'spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb')
-rw-r--r--spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb17
1 files changed, 6 insertions, 11 deletions
diff --git a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
index bf038595a4d..eb0bdb61ee3 100644
--- a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
+++ b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
@@ -1,11 +1,13 @@
require 'spec_helper'
describe Clusters::Applications::CheckIngressIpAddressService do
+ include ExclusiveLeaseHelpers
+
let(:application) { create(:clusters_applications_ingress, :installed) }
let(:service) { described_class.new(application) }
let(:kubeclient) { double(::Kubeclient::Client, get_service: kube_service) }
let(:ingress) { [{ ip: '111.222.111.222' }] }
- let(:exclusive_lease) { instance_double(Gitlab::ExclusiveLease, try_obtain: true) }
+ let(:lease_key) { "check_ingress_ip_address_service:#{application.id}" }
let(:kube_service) do
::Kubeclient::Resource.new(
@@ -22,11 +24,8 @@ describe Clusters::Applications::CheckIngressIpAddressService do
subject { service.execute }
before do
+ stub_exclusive_lease(lease_key, timeout: 15.seconds.to_i)
allow(application.cluster).to receive(:kubeclient).and_return(kubeclient)
- allow(Gitlab::ExclusiveLease)
- .to receive(:new)
- .with("check_ingress_ip_address_service:#{application.id}", timeout: 15.seconds.to_i)
- .and_return(exclusive_lease)
end
describe '#execute' do
@@ -47,13 +46,9 @@ describe Clusters::Applications::CheckIngressIpAddressService do
end
context 'when the exclusive lease cannot be obtained' do
- before do
- allow(exclusive_lease)
- .to receive(:try_obtain)
- .and_return(false)
- end
-
it 'does not call kubeclient' do
+ stub_exclusive_lease_taken(lease_key, timeout: 15.seconds.to_i)
+
subject
expect(kubeclient).not_to have_received(:get_service)