This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(FACT-231) Fix for tests/facts/validate_file_system_size_bytes.rb
- Loading branch information
Oana Tanasoiu
committed
May 12, 2020
1 parent
91df292
commit 691cbca
Showing
12 changed files
with
294 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Rhel | ||
module Os | ||
class Release | ||
FACT_NAME = 'os.release' | ||
ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze | ||
|
||
def call_the_resolver | ||
version = determine_release_version | ||
|
||
return Facter::ResolvedFact.new(FACT_NAME, nil) unless version | ||
|
||
[Facter::ResolvedFact.new(FACT_NAME, version), | ||
Facter::ResolvedFact.new(ALIASES.first, version['major'], :legacy), | ||
Facter::ResolvedFact.new(ALIASES.last, version['full'], :legacy)] | ||
end | ||
|
||
def determine_release_version | ||
version = Facter::Resolvers::OsRelease.resolve(:version_id) | ||
version ||= Facter::Resolvers::RedHatRelease.resolve(:version) | ||
|
||
return unless version | ||
|
||
versions = version.split('.') | ||
fact_value = {} | ||
fact_value['full'] = version | ||
fact_value['major'] = versions[0] | ||
fact_value['minor'] = versions[1].gsub(/^0([1-9])/, '\1') if versions[1] | ||
fact_value | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Facts::Rhel::Os::Release do | ||
describe '#call_the_resolver' do | ||
subject(:fact) { Facts::Rhel::Os::Release.new } | ||
|
||
before do | ||
allow(Facter::Resolvers::OsRelease).to receive(:resolve).with(:version_id).and_return(value) | ||
end | ||
|
||
context 'when os is RedHat' do | ||
let(:value) { '6.2' } | ||
let(:release) { { 'full' => '6.2', 'major' => '6', 'minor' => '2' } } | ||
|
||
it 'calls Facter::Resolvers::OsRelease with version_id' do | ||
fact.call_the_resolver | ||
expect(Facter::Resolvers::OsRelease).to have_received(:resolve).with(:version_id) | ||
end | ||
|
||
it 'returns operating system name fact' do | ||
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ | ||
contain_exactly(an_object_having_attributes(name: 'os.release', value: release), | ||
an_object_having_attributes(name: 'operatingsystemmajrelease', | ||
value: release['major'], type: :legacy), | ||
an_object_having_attributes(name: 'operatingsystemrelease', | ||
value: release['full'], type: :legacy)) | ||
end | ||
end | ||
|
||
context 'when os is Centos' do | ||
let(:value) { nil } | ||
let(:red_release) { '6.2' } | ||
let(:release) { { 'full' => '6.2', 'major' => '6', 'minor' => '2' } } | ||
|
||
before do | ||
allow(Facter::Resolvers::RedHatRelease).to receive(:resolve).with(:version).and_return(red_release) | ||
end | ||
|
||
it 'calls Facter::Resolvers::OsRelease with version_id' do | ||
fact.call_the_resolver | ||
expect(Facter::Resolvers::OsRelease).to have_received(:resolve).with(:version_id) | ||
end | ||
|
||
it 'calls Facter::Resolvers::RedHatRelease with version' do | ||
fact.call_the_resolver | ||
expect(Facter::Resolvers::RedHatRelease).to have_received(:resolve).with(:version) | ||
end | ||
|
||
it 'returns operating system name fact' do | ||
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ | ||
contain_exactly(an_object_having_attributes(name: 'os.release', value: release), | ||
an_object_having_attributes(name: 'operatingsystemmajrelease', | ||
value: release['major'], type: :legacy), | ||
an_object_having_attributes(name: 'operatingsystemrelease', | ||
value: release['full'], type: :legacy)) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
processor : 0 | ||
vendor_id : GenuineIntel | ||
cpu family : 6 | ||
model : 79 | ||
model name : Intel(R) Xeon(R) CPU E5-2697 v4 @ 2.30GHz | ||
stepping : 1 | ||
microcode : 0xb00002e | ||
cpu MHz : 2294.686 | ||
cache size : 46080 KB | ||
siblings : 4 | ||
core id : 0 | ||
cpu cores : 4 | ||
apicid : 0 | ||
initial apicid : 0 | ||
fpu : yes | ||
fpu_exception : yes | ||
cpuid level : 20 | ||
wp : yes | ||
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat flush_l1d arch_capabilities | ||
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds | ||
bogomips : 4589.37 | ||
clflush size : 64 | ||
cache_alignment : 64 | ||
address sizes : 43 bits physical, 48 bits virtual | ||
power management: | ||
|
||
processor : 1 | ||
vendor_id : GenuineIntel | ||
cpu family : 6 | ||
model : 79 | ||
model name : Intel(R) Xeon(R) CPU E5-2697 v4 @ 2.30GHz | ||
stepping : 1 | ||
microcode : 0xb00002e | ||
cpu MHz : 2294.686 | ||
cache size : 46080 KB | ||
siblings : 4 | ||
core id : 1 | ||
cpu cores : 4 | ||
apicid : 1 | ||
initial apicid : 1 | ||
fpu : yes | ||
fpu_exception : yes | ||
cpuid level : 20 | ||
wp : yes | ||
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat flush_l1d arch_capabilities | ||
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds | ||
bogomips : 4589.37 | ||
clflush size : 64 | ||
cache_alignment : 64 | ||
address sizes : 43 bits physical, 48 bits virtual | ||
power management: | ||
|
||
processor : 2 | ||
vendor_id : GenuineIntel | ||
cpu family : 6 | ||
model : 79 | ||
model name : Intel(R) Xeon(R) CPU E5-2697 v4 @ 2.30GHz | ||
stepping : 1 | ||
microcode : 0xb00002e | ||
cpu MHz : 2294.686 | ||
cache size : 46080 KB | ||
siblings : 4 | ||
core id : 2 | ||
cpu cores : 4 | ||
apicid : 2 | ||
initial apicid : 2 | ||
fpu : yes | ||
fpu_exception : yes | ||
cpuid level : 20 | ||
wp : yes | ||
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat flush_l1d arch_capabilities | ||
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds | ||
bogomips : 4589.37 | ||
clflush size : 64 | ||
cache_alignment : 64 | ||
address sizes : 43 bits physical, 48 bits virtual | ||
power management: | ||
|
||
processor : 3 | ||
vendor_id : GenuineIntel | ||
cpu family : 6 | ||
model : 79 | ||
model name : Intel(R) Xeon(R) CPU E5-2697 v4 @ 2.30GHz | ||
stepping : 1 | ||
microcode : 0xb00002e | ||
cpu MHz : 2294.686 | ||
cache size : 46080 KB | ||
siblings : 4 | ||
core id : 3 | ||
cpu cores : 4 | ||
apicid : 3 | ||
initial apicid : 3 | ||
fpu : yes | ||
fpu_exception : yes | ||
cpuid level : 20 | ||
wp : yes | ||
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt arat flush_l1d arch_capabilities | ||
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds | ||
bogomips : 4589.37 | ||
clflush size : 64 | ||
cache_alignment : 64 | ||
address sizes : 43 bits physical, 48 bits virtual | ||
power management: |