From 21561f3434021ad35d45c449f489802fd1dced67 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki <pawel@chojnacki.ws> Date: Mon, 22 May 2017 19:49:34 +0200 Subject: [PATCH] Correctly handle temporary folder for testing multiproces metrics --- Gemfile | 4 ++-- Gemfile.lock | 2 +- app/controllers/metrics_controller.rb | 2 +- spec/controllers/metrics_controller_spec.rb | 9 +++++++++ spec/lib/gitlab/metrics_spec.rb | 1 - 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index a6b0a20ef61..8ec2c94a2e0 100644 --- a/Gemfile +++ b/Gemfile @@ -269,9 +269,9 @@ group :metrics do gem 'method_source', '~> 0.8', require: false gem 'influxdb', '~> 0.2', require: false -# Prometheus + # Prometheus gem 'mmap2', '~> 2.2.6' - gem 'prometheus-client-mmap' + gem 'prometheus-client-mmap', '~>0.7.0.beta3' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 0b795f41783..bb574ae1834 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1000,7 +1000,7 @@ DEPENDENCIES pg (~> 0.18.2) poltergeist (~> 1.9.0) premailer-rails (~> 1.9.0) - prometheus-client-mmap + prometheus-client-mmap (~> 0.7.0.beta3) pry-byebug (~> 3.4.1) pry-rails (~> 0.3.4) rack-attack (~> 4.4.1) diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb index 18c9625c36a..4c1d04c1262 100644 --- a/app/controllers/metrics_controller.rb +++ b/app/controllers/metrics_controller.rb @@ -7,7 +7,7 @@ class MetricsController < ActionController::Base CHECKS = [ Gitlab::HealthChecks::DbCheck, Gitlab::HealthChecks::RedisCheck, - Gitlab::HealthChecks::FsShardsCheck, + Gitlab::HealthChecks::FsShardsCheck ].freeze def metrics diff --git a/spec/controllers/metrics_controller_spec.rb b/spec/controllers/metrics_controller_spec.rb index d2d4b361a62..7f2dcd3544f 100644 --- a/spec/controllers/metrics_controller_spec.rb +++ b/spec/controllers/metrics_controller_spec.rb @@ -6,8 +6,17 @@ describe MetricsController do let(:token) { current_application_settings.health_check_access_token } let(:json_response) { JSON.parse(response.body) } + around do |examples| + Dir.mktmpdir do |tmp_dir| + @metrics_multiproc_dir = tmp_dir + examples.run + end + end + before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + stub_env('prometheus_multiproc_dir', @metrics_multiproc_dir) + allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true) end describe '#metrics' do diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb index 65bd06cda08..020bdbacead 100644 --- a/spec/lib/gitlab/metrics_spec.rb +++ b/spec/lib/gitlab/metrics_spec.rb @@ -243,7 +243,6 @@ describe Gitlab::Metrics do subject { described_class.counter(:counter, 'doc') } it { is_expected.to be_a(Gitlab::Metrics::DummyMetric) } - end describe '#summary' do -- 2.30.9