From e8f1ec84fe58e5abea7fc6c4ca68b899a92d19fa Mon Sep 17 00:00:00 2001 From: Oana Tanasoiu Date: Wed, 13 May 2020 15:30:06 +0300 Subject: [PATCH] (FACT-2183) Add Solaris's uptime legacy facts --- .github/workflows/acceptance_tests.yml | 7 +++++++ lib/facts/solaris/system_uptime/days.rb | 3 ++- lib/facts/solaris/system_uptime/hours.rb | 3 ++- lib/facts/solaris/system_uptime/seconds.rb | 3 ++- lib/facts/solaris/system_uptime/uptime.rb | 3 ++- spec/facter/facts/solaris/system_uptime/days_spec.rb | 5 +++-- spec/facter/facts/solaris/system_uptime/hours_spec.rb | 5 +++-- spec/facter/facts/solaris/system_uptime/seconds_spec.rb | 5 +++-- spec/facter/facts/solaris/system_uptime/uptime_spec.rb | 5 +++-- 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/acceptance_tests.yml b/.github/workflows/acceptance_tests.yml index 5182ac32c..eedc1f666 100644 --- a/.github/workflows/acceptance_tests.yml +++ b/.github/workflows/acceptance_tests.yml @@ -57,5 +57,12 @@ jobs: sudo chmod a-w /home/runner /usr/share && sudo chmod -R a-w /usr/share/rust /home/runner/.config /home/linuxbrew + - name: Instal dhclient + if: runner.os == 'Linux' + run: sudo apt install dhcpcd5 + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v2 + - name: Run acceptance tests run: sudo -E "PATH=$PATH" ruby facter_4/.github/actions/presuite.rb diff --git a/lib/facts/solaris/system_uptime/days.rb b/lib/facts/solaris/system_uptime/days.rb index 9f736b298..64d2c5ce4 100644 --- a/lib/facts/solaris/system_uptime/days.rb +++ b/lib/facts/solaris/system_uptime/days.rb @@ -5,11 +5,12 @@ module Solaris module SystemUptime class Days FACT_NAME = 'system_uptime.days' + ALIASES = 'uptime_days' def call_the_resolver fact_value = Facter::Resolvers::Uptime.resolve(:days) - Facter::ResolvedFact.new(FACT_NAME, fact_value) + [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end end end diff --git a/lib/facts/solaris/system_uptime/hours.rb b/lib/facts/solaris/system_uptime/hours.rb index 657f7aa97..2980c7ac6 100644 --- a/lib/facts/solaris/system_uptime/hours.rb +++ b/lib/facts/solaris/system_uptime/hours.rb @@ -5,11 +5,12 @@ module Solaris module SystemUptime class Hours FACT_NAME = 'system_uptime.hours' + ALIASES = 'uptime_hours' def call_the_resolver fact_value = Facter::Resolvers::Uptime.resolve(:hours) - Facter::ResolvedFact.new(FACT_NAME, fact_value) + [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end end end diff --git a/lib/facts/solaris/system_uptime/seconds.rb b/lib/facts/solaris/system_uptime/seconds.rb index 5d8d461df..b8c77c658 100644 --- a/lib/facts/solaris/system_uptime/seconds.rb +++ b/lib/facts/solaris/system_uptime/seconds.rb @@ -5,11 +5,12 @@ module Solaris module SystemUptime class Seconds FACT_NAME = 'system_uptime.seconds' + ALIASES = 'uptime_seconds' def call_the_resolver fact_value = Facter::Resolvers::Uptime.resolve(:seconds) - Facter::ResolvedFact.new(FACT_NAME, fact_value) + [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end end end diff --git a/lib/facts/solaris/system_uptime/uptime.rb b/lib/facts/solaris/system_uptime/uptime.rb index 613e5f950..8c5b3120d 100644 --- a/lib/facts/solaris/system_uptime/uptime.rb +++ b/lib/facts/solaris/system_uptime/uptime.rb @@ -5,11 +5,12 @@ module Solaris module SystemUptime class Uptime FACT_NAME = 'system_uptime.uptime' + ALIASES = 'uptime' def call_the_resolver fact_value = Facter::Resolvers::Uptime.resolve(:uptime) - Facter::ResolvedFact.new(FACT_NAME, fact_value) + [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end end end diff --git a/spec/facter/facts/solaris/system_uptime/days_spec.rb b/spec/facter/facts/solaris/system_uptime/days_spec.rb index d8d7c0dfd..f3ff77d08 100644 --- a/spec/facter/facts/solaris/system_uptime/days_spec.rb +++ b/spec/facter/facts/solaris/system_uptime/days_spec.rb @@ -16,8 +16,9 @@ end it 'returns days since last boot' do - expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ - have_attributes(name: 'system_uptime.days', value: value) + expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ + contain_exactly(an_object_having_attributes(name: 'system_uptime.days', value: value), + an_object_having_attributes(name: 'uptime_days', value: value, type: :legacy)) end end end diff --git a/spec/facter/facts/solaris/system_uptime/hours_spec.rb b/spec/facter/facts/solaris/system_uptime/hours_spec.rb index 4e421755f..5cfee1c85 100644 --- a/spec/facter/facts/solaris/system_uptime/hours_spec.rb +++ b/spec/facter/facts/solaris/system_uptime/hours_spec.rb @@ -16,8 +16,9 @@ end it 'returns hours since last boot' do - expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ - have_attributes(name: 'system_uptime.hours', value: value) + expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ + contain_exactly(an_object_having_attributes(name: 'system_uptime.hours', value: value), + an_object_having_attributes(name: 'uptime_hours', value: value, type: :legacy)) end end end diff --git a/spec/facter/facts/solaris/system_uptime/seconds_spec.rb b/spec/facter/facts/solaris/system_uptime/seconds_spec.rb index 718d1a74a..f679a91f7 100644 --- a/spec/facter/facts/solaris/system_uptime/seconds_spec.rb +++ b/spec/facter/facts/solaris/system_uptime/seconds_spec.rb @@ -16,8 +16,9 @@ end it 'returns minutes since last boot' do - expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ - have_attributes(name: 'system_uptime.seconds', value: value) + expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ + contain_exactly(an_object_having_attributes(name: 'system_uptime.seconds', value: value), + an_object_having_attributes(name: 'uptime_seconds', value: value, type: :legacy)) end end end diff --git a/spec/facter/facts/solaris/system_uptime/uptime_spec.rb b/spec/facter/facts/solaris/system_uptime/uptime_spec.rb index bcf032839..7d10f8f51 100644 --- a/spec/facter/facts/solaris/system_uptime/uptime_spec.rb +++ b/spec/facter/facts/solaris/system_uptime/uptime_spec.rb @@ -16,8 +16,9 @@ end it 'returns total uptime since last boot' do - expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \ - have_attributes(name: 'system_uptime.uptime', value: value) + expect(fact.call_the_resolver).to be_an_instance_of(Array).and \ + contain_exactly(an_object_having_attributes(name: 'system_uptime.uptime', value: value), + an_object_having_attributes(name: 'uptime', value: value, type: :legacy)) end end end