Commit 69987426 authored by Mario de la Ossa's avatar Mario de la Ossa

Update elasticsearch system check to check for new supported versions

parent f144d147
......@@ -12,6 +12,7 @@ special searches:
- [Advanced Syntax Search](../user/search/advanced_search_syntax.md)
## Version Requirements
<!-- Please remember to update ee/lib/system_check/app/elasticsearch_check.rb if this changes -->
| GitLab version | Elasticsearch version |
| -------------- | --------------------- |
......
---
title: Update elasticsearch system check to check for new supported versions
merge_request: 8683
author:
type: fixed
# frozen_string_literal: true
module SystemCheck
module App
class ElasticsearchCheck < SystemCheck::BaseCheck
set_name 'Elasticsearch version 5.1 - 5.5?'
set_name 'Elasticsearch version 5.6 - 6.x?'
set_skip_reason 'skipped (elasticsearch is disabled)'
set_check_pass -> { "yes (#{self.current_version})" }
set_check_fail -> { "no (#{self.current_version})" }
......@@ -18,7 +20,14 @@ module SystemCheck
end
def check?
self.class.current_version.major == 5 && (1..5).cover?(self.class.current_version.minor)
case self.class.current_version.major
when 5
!(1..5).cover?(self.class.current_version.minor)
when 6
true
else
false
end
end
def show_error
......
# frozen_string_literal: true
require 'spec_helper'
describe SystemCheck::App::ElasticsearchCheck do
describe '#skip?' do
context 'with elasticsearch disabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:elasticsearch_indexing?).and_return(false)
end
it 'returns true' do
expect(described_class.new.skip?).to eq(true)
end
end
context 'with elasticsearch enabled' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:elasticsearch_indexing?).and_return(true)
end
it 'returns false' do
expect(described_class.new.skip?).to eq(false)
end
end
end
describe '#check?' do
using RSpec::Parameterized::TableSyntax
subject { described_class.new.check? }
where(:version, :result) do
'2.3.0' | false
'5.3.1' | false
'5.6.0' | true
'5.6.6' | true
'6.0.0' | true
'6.3.4' | true
'7.1.0' | false
end
with_them do
before do
# `current_version` is memoized, so we must clear it out
described_class.instance_variable_set(:@current_version, nil)
allow(Gitlab::Elastic::Client).to receive(:build).and_return(double(info: { 'version' => { 'number' => version } }))
end
it { is_expected.to eq(result) }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment