diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-16 17:25:02 +0300 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-17 17:22:47 +0300 |
commit | 6ced4d138e56a82fc460d6281ae445fb7b739636 (patch) | |
tree | 4aaf211e9781ee017d29dbddfe91aa4935b8ac0d /spec/lib/gitlab/health_checks | |
parent | 43befaf25f4f929d01a0af5ef3c2148002be7f4e (diff) |
Fix transient CI errors by increasing command execution timeouts from 1s to 30s
+ actually make local tests correctly detect wether 'timeout' or 'gtimeout' is available
Diffstat (limited to 'spec/lib/gitlab/health_checks')
-rw-r--r-- | spec/lib/gitlab/health_checks/fs_shards_check_spec.rb | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb index 45ccd3d6459..289c93ecde7 100644 --- a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb +++ b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Gitlab::HealthChecks::FsShardsCheck do + include TimeoutHelper + let(:metric_class) { Gitlab::HealthChecks::Metric } let(:result_class) { Gitlab::HealthChecks::Result } let(:repository_storages) { [:default] } @@ -103,15 +105,51 @@ describe Gitlab::HealthChecks::FsShardsCheck do end end + context 'when timeout kills fs checks' do + let(:timeout_seconds) { 1.to_s } + + before do + skip 'timeout or gtimeout not available' unless any_timeout_command_exists? + + allow(described_class).to receive(:with_timeout) { [timeout_command, timeout_seconds].concat(%w{ sleep 2 }) } + FileUtils.chmod_R(0755, tmp_dir) + end + + describe '#readiness' do + subject { described_class.readiness } + + it { is_expected.to include(result_class.new(false, 'cannot stat storage', shard: :default)) } + end + + describe '#metrics' do + subject { described_class.metrics } + + it { is_expected.to include(metric_class.new(:filesystem_accessible, 0, shard: :default)) } + it { is_expected.to include(metric_class.new(:filesystem_readable, 0, shard: :default)) } + it { is_expected.to include(metric_class.new(:filesystem_writable, 0, shard: :default)) } + + it { is_expected.to include(have_attributes(name: :filesystem_access_latency, value: be >= 0, labels: { shard: :default })) } + it { is_expected.to include(have_attributes(name: :filesystem_read_latency, value: be >= 0, labels: { shard: :default })) } + it { is_expected.to include(have_attributes(name: :filesystem_write_latency, value: be >= 0, labels: { shard: :default })) } + end + end + context 'when popen always finds required binaries' do + let(:timeout_seconds) { 30.to_s } before do - allow(Gitlab::Popen).to receive(:popen).and_wrap_original do |method, *args, &block| + skip 'timeout or gtimeout not available' unless any_timeout_command_exists? + + allow(described_class).to receive(:exec_with_timeout).and_wrap_original do |method, *args, &block| begin method.call(*args, &block) - rescue RuntimeError + rescue RuntimeError, Errno::ENOENT raise 'expected not to happen' end end + + allow(described_class).to receive(:with_timeout) do |args, &block| + [timeout_command, timeout_seconds].concat(args) + end end it_behaves_like 'filesystem checks' |