diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/metrics_server/metrics_server_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/metrics_server/metrics_server_spec.rb')
-rw-r--r-- | spec/metrics_server/metrics_server_spec.rb | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/spec/metrics_server/metrics_server_spec.rb b/spec/metrics_server/metrics_server_spec.rb index 58577d4d633..efa716754f1 100644 --- a/spec/metrics_server/metrics_server_spec.rb +++ b/spec/metrics_server/metrics_server_spec.rb @@ -99,20 +99,22 @@ RSpec.describe MetricsServer, feature_category: :application_performance do # ru context 'for Golang server' do let(:log_enabled) { false } let(:settings) do - { - 'web_exporter' => { - 'enabled' => true, - 'address' => 'localhost', - 'port' => '8083', - 'log_enabled' => log_enabled - }, - 'sidekiq_exporter' => { - 'enabled' => true, - 'address' => 'localhost', - 'port' => '8082', - 'log_enabled' => log_enabled + Settingslogic.new( + { + 'web_exporter' => { + 'enabled' => true, + 'address' => 'localhost', + 'port' => '8083', + 'log_enabled' => log_enabled + }, + 'sidekiq_exporter' => { + 'enabled' => true, + 'address' => 'localhost', + 'port' => '8082', + 'log_enabled' => log_enabled + } } - } + ) end let(:expected_port) { target == 'puma' ? '8083' : '8082' } @@ -120,7 +122,7 @@ RSpec.describe MetricsServer, feature_category: :application_performance do # ru { 'GOGC' => '10', 'GME_MMAP_METRICS_DIR' => metrics_dir, - 'GME_PROBES' => 'self,mmap', + 'GME_PROBES' => 'self,mmap,mmap_stats', 'GME_SERVER_HOST' => 'localhost', 'GME_SERVER_PORT' => expected_port, 'GME_LOG_LEVEL' => 'quiet' @@ -175,11 +177,13 @@ RSpec.describe MetricsServer, feature_category: :application_performance do # ru context 'when TLS settings are present' do before do - %w(web_exporter sidekiq_exporter).each do |key| - settings[key]['tls_enabled'] = true - settings[key]['tls_cert_path'] = '/path/to/cert.pem' - settings[key]['tls_key_path'] = '/path/to/key.pem' - end + settings.web_exporter['tls_enabled'] = true + settings.web_exporter['tls_cert_path'] = '/path/to/cert.pem' + settings.web_exporter['tls_key_path'] = '/path/to/key.pem' + + settings.sidekiq_exporter['tls_enabled'] = true + settings.sidekiq_exporter['tls_cert_path'] = '/path/to/cert.pem' + settings.sidekiq_exporter['tls_key_path'] = '/path/to/key.pem' end it 'sets the correct environment variables' do @@ -300,12 +304,12 @@ RSpec.describe MetricsServer, feature_category: :application_performance do # ru end context 'for sidekiq' do - let(:settings) { { "sidekiq_exporter" => { "enabled" => true } } } + let(:settings) { Settingslogic.new({ "sidekiq_exporter" => { "enabled" => true } }) } before do allow(::Settings).to receive(:monitoring).and_return(settings) allow(Gitlab::Metrics::Exporter::SidekiqExporter).to receive(:instance).with( - settings['sidekiq_exporter'], gc_requests: true, synchronous: true + settings.sidekiq_exporter, gc_requests: true, synchronous: true ).and_return(exporter_double) end @@ -358,4 +362,28 @@ RSpec.describe MetricsServer, feature_category: :application_performance do # ru end end end + + describe '.name' do + subject { described_class.name(target) } + + context 'for puma' do + let(:target) { 'puma' } + + it { is_expected.to eq 'web_exporter' } + end + + context 'for sidekiq' do + let(:target) { 'sidekiq' } + + it { is_expected.to eq 'sidekiq_exporter' } + end + + context 'for invalid target' do + let(:target) { 'invalid' } + + it 'raises error' do + expect { subject }.to raise_error(RuntimeError, "Target must be one of [puma,sidekiq]") + end + end + end end |