Skip to content

Commit

Permalink
(PE-19049,PE-18718,PE-18799) Provide a test method for meep classific…
Browse files Browse the repository at this point in the history
…ation

so we can adjust tests and setup steps that need to work either with old
pe node groups, or with meep.

Ultimately the test is just based on version boundary. But while we are
validating meep classification, we need to be able to toggle around a
temporary feature flag: the pe_infrastructure::use_meep_for_classification
parameter.

The function checks to see if this has been passed into
beaker via the hosts file answers hash. These are answers which
beaker-answers would include in the pe.conf it generates.

It can also be set from an ENV['PE_USE_MEEP_FOR_CLASSIFICATION']
variable. This will make it easier to setup temporary ci jobs.

The answer file setting will take precedence over the environment
variable.
  • Loading branch information
jpartlow committed Feb 23, 2017
1 parent 7dce71c commit 6b9c618
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
33 changes: 33 additions & 0 deletions lib/beaker-pe/install/pe_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module PEUtils

# Version of PE when we switched from legacy installer to MEEP.
MEEP_CUTOVER_VERSION = '2016.2.0'
# Version of PE when we switched to using meep for classification
# instead of PE node groups
MEEP_CLASSIFICATION_VERSION = '2017.2.0'
# PE-18799 temporary default used for meep classification check while
# we navigate the switchover.
# PE-18718 switch flag to true once beaker-pe, beaker-answers,
# beaker-pe-large-environments and pe_acceptance_tests are ready
DEFAULT_MEEP_CLASSIFICATION = false

# @!macro [new] common_opts
# @param [Hash{Symbol=>String}] opts Options to alter execution.
Expand Down Expand Up @@ -633,6 +641,31 @@ def install_via_msi?(host)
(host['platform'] =~ /windows/ && (version_is_less(host['pe_ver'], '2016.4.0') && !version_is_less(host['pe_ver'], '3.99'))) || (host['platform'] =~ /windows-2008r2/ && (version_is_less(host['pe_ver'], '2016.4.3') && !version_is_less(host['pe_ver'], '3.99')))
end

# True if version is greater than or equal to MEEP_CLASSIFICATION_VERSION
# (PE-18718) AND the temporary feature flag is true.
#
# The temporary feature flag is pe_modules_next and can be set in
# the :answers hash given in beaker's host.cfg, inside a feature_flags
# hash. It will also be picked up from the environment as
# PE_MODULES_NEXT. (See register_feature_flags!())
#
# The :answers hash value will take precedence over the env variable.
#
# @param version String the current PE version
# @param opts Hash options hash to inspect for :answers
# @return Boolean true if version and flag allows for meep classification
# feature.
def use_meep_for_classification?(version, opts)
# PE-19470 remove vv
register_feature_flags!(opts)

temporary_flag = feature_flag?('pe_modules_next', opts)
temporary_flag = DEFAULT_MEEP_CLASSIFICATION if temporary_flag.nil?
# ^^

!version_is_less(version, MEEP_CLASSIFICATION_VERSION) && temporary_flag
end

# For PE 3.8.5 to PE 2016.1.2 they have an expired gpg key. This method is
# for deb nodes to ignore the gpg-key expiration warning
def ignore_gpg_key_warning_on_hosts(hosts, opts)
Expand Down
79 changes: 78 additions & 1 deletion spec/beaker-pe/install/pe_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ class ClassMixedWithDSLInstallUtils
include Beaker::DSL::Patterns
include Beaker::DSL::PE

attr_accessor :hosts, :metadata
attr_accessor :hosts, :metadata, :options

def initialize
@metadata = {}
@options = {}
end

# Because some the methods now actually call out to the `step` method, we need to
Expand Down Expand Up @@ -391,6 +392,82 @@ def slice_installer_options(host)
end
end

describe 'use_meep_for_classification?' do
let(:feature_flag) { nil }
let(:environment_feature_flag) { nil }
let(:answers) do
{
:answers => {
'feature_flags' => {
'pe_modules_next' => feature_flag,
},
},
}
end
let(:options) do
feature_flag.nil? ?
opts :
opts.merge(answers)
end
let(:host) { unixhost }

before(:each) do
subject.options = options
if !environment_feature_flag.nil?
ENV['PE_MODULES_NEXT'] = environment_feature_flag
end
end

after(:each) do
ENV.delete('PE_MODULES_NEXT')
end

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }

context 'feature flag false' do
let(:feature_flag) { false }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
end

context 'feature flag true' do
let(:feature_flag) { true }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }
end

context 'environment feature flag true' do
let(:environment_feature_flag) { 'true' }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }

context 'answers feature flag false' do
let(:feature_flag) { false }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }
end
end

context 'environment feature flag false' do
let(:environment_feature_flag) { 'false' }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(false) }

context 'answers feature flag true' do
let(:feature_flag) { true }

it { expect(subject.use_meep_for_classification?('2017.1.0', options)).to eq(false) }
it { expect(subject.use_meep_for_classification?('2017.2.0', options)).to eq(true) }
end
end
end

describe 'generate_installer_conf_file_for' do
let(:master) { hosts.first }

Expand Down

0 comments on commit 6b9c618

Please sign in to comment.