diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-15 09:24:59 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-15 09:24:59 +0300 |
commit | 5190ef57a3c5a4333020a5281904e56c00519e91 (patch) | |
tree | 1141906cc5e931b8177926f54deb83d30bba62f6 /spec/services/clusters | |
parent | c1828eaed56159998d1eaafdaa135f1b3480549b (diff) |
Ensure CheckIngressIpAddressService obtains exclusive lease per ingress controller (#42643)
Diffstat (limited to 'spec/services/clusters')
-rw-r--r-- | spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb | 19 |
1 files changed, 19 insertions, 0 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 5d99196fbe6..6c81acfcf84 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 @@ -16,9 +16,14 @@ describe Clusters::Applications::CheckIngressIpAddressService do end 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) } before do allow(application.cluster).to receive(:kubeclient).and_return(kubeclient) + allow(Gitlab::ExclusiveLease) + .to receive(:new) + .with("check_ingress_ip_address_service:#{application.id}", timeout: 3.seconds.to_i) + .and_return(exclusive_lease) end describe '#execute' do @@ -52,6 +57,20 @@ describe Clusters::Applications::CheckIngressIpAddressService do end 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 + expect(kubeclient).not_to receive(:get_service) + + service.execute(1) + end + end + context 'when there is already an external_ip' do let(:application) { create(:clusters_applications_ingress, :installed, external_ip: '001.111.002.111') } |