Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FACT-3436) Revert Debian ARM architecture change #2636

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions acceptance/lib/facter/acceptance/base_fact_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def debian_expected_facts(agent)
os_hardware = 'x86_64'
processor_model_pattern = /(Intel\(R\).*)|(AMD.*)/
elsif agent['platform'] =~ /aarch64/
os_arch = 'arm64'
os_arch = 'aarch64'
os_hardware = 'aarch64'
processor_model_pattern = // # FACT-3439 - facter doesn't figure out the processor type on these machines
else
Expand Down Expand Up @@ -391,7 +391,7 @@ def ubuntu_expected_facts(agent)
os_hardware = 'x86_64'
processor_model_pattern = /(Intel\(R\).*)|(AMD.*)/
elsif agent['platform'] =~ /aarch64/
os_arch = 'arm64'
os_arch = 'aarch64'
os_hardware = 'aarch64'
processor_model_pattern = // # facter doesn't figure out the processor type on these machines
else
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/facts/debian/architecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class Architecture
ALIASES = 'architecture'

def call_the_resolver
fact_value = Facter::Core::Execution.execute('dpkg --print-architecture')
fact_value = Facter::Resolvers::Uname.resolve(:machine)
fact_value = 'amd64' if fact_value == 'x86_64'
fact_value = 'i386' if /i[3456]86|pentium/.match?(fact_value)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
Expand Down
57 changes: 51 additions & 6 deletions spec/facter/facts/debian/os/architecture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,61 @@
describe '#call_the_resolver' do
subject(:fact) { Facts::Debian::Os::Architecture.new }

%w[amd64 arm64 i386].each do |arch|
it 'calls Facter::Core::Execution and returns architecture fact' do
allow(Facter::Core::Execution).to receive(:execute).and_return(arch)
context 'when resolver does not return x86_64' do
let(:value) { 'i86pc' }

before do
allow(Facter::Resolvers::Uname).to receive(:resolve).with(:machine).and_return(value)
end

it 'calls Facter::Resolvers::Uname' do
fact.call_the_resolver
expect(Facter::Resolvers::Uname).to have_received(:resolve).with(:machine)
end

it 'returns architecture fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'os.architecture', value: value),
an_object_having_attributes(name: 'architecture', value: value, type: :legacy))
end
end

context 'when os is 32-bit' do
let(:value) { 'i586' }
let(:fact_value) { 'i386' }

before do
allow(Facter::Resolvers::Uname).to receive(:resolve).with(:machine).and_return(value)
end

it 'calls Facter::Resolvers::Uname' do
fact.call_the_resolver
expect(Facter::Core::Execution).to have_received(:execute).with('dpkg --print-architecture')
expect(Facter::Resolvers::Uname).to have_received(:resolve).with(:machine)
end

it 'returns architecture fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'os.architecture', value: fact_value),
an_object_having_attributes(name: 'architecture', value: fact_value, type: :legacy))
end
end

context 'when resolver returns x86_64' do
let(:value) { 'x86_64' }

before do
allow(Facter::Resolvers::Uname).to receive(:resolve).with(:machine).and_return(value)
end

it 'calls Facter::Resolvers::Uname' do
fact.call_the_resolver
expect(Facter::Resolvers::Uname).to have_received(:resolve).with(:machine)
end

it 'returns architecture fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'os.architecture', value: arch),
an_object_having_attributes(name: 'architecture', value: arch, type: :legacy))
contain_exactly(an_object_having_attributes(name: 'os.architecture', value: 'amd64'),
an_object_having_attributes(name: 'architecture', value: 'amd64', type: :legacy))
end
end
end
Expand Down