diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2019-04-10 06:38:27 +0000 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-10 06:38:27 +0000 |
commit | c239bfcb1750794ec1bf8172dfa380dea64fe4c1 (patch) | |
tree | 2e0a95a1a741e0dc76e5f166cc29a65549aaa41e /spec/lib/gitlab | |
parent | b5af30bba6a7ffdd4b054fa9c8c9b42dd91a51d7 (diff) | |
download | gitlab-ce-c239bfcb1750794ec1bf8172dfa380dea64fe4c1.tar.gz |
Add more info logging to cluster apps
Log events so that it's easy to see
when different requests are starting.
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/kubernetes/namespace_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/kubernetes/namespace_spec.rb b/spec/lib/gitlab/kubernetes/namespace_spec.rb index e1c35c355f4..e91a755aa03 100644 --- a/spec/lib/gitlab/kubernetes/namespace_spec.rb +++ b/spec/lib/gitlab/kubernetes/namespace_spec.rb @@ -62,5 +62,32 @@ describe Gitlab::Kubernetes::Namespace do subject.ensure_exists! end + + context 'when client errors' do + let(:exception) { Kubeclient::HttpError.new(500, 'system failure', nil) } + + before do + allow(client).to receive(:get_namespace).with(name).once.and_raise(exception) + end + + it 'raises the exception' do + expect { subject.ensure_exists! }.to raise_error(exception) + end + + it 'logs the error' do + expect(subject.send(:logger)).to receive(:error).with( + hash_including( + exception: 'Kubeclient::HttpError', + status_code: 500, + namespace: 'a_namespace', + class_name: 'Gitlab::Kubernetes::Namespace', + event: :failed_to_create_namespace, + message: 'system failure' + ) + ) + + expect { subject.ensure_exists! }.to raise_error(exception) + end + end end end |