From 51d70ead0b6740b5cc7464bc3cb00aae6c57fc54 Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Mon, 21 Feb 2022 14:16:15 +0100 Subject: [PATCH] Acceptance Test for systemd-resolved --- .../{systemd_spec.rb => default_spec.rb} | 2 ++ spec/acceptance/resolved_spec.rb | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) rename spec/acceptance/{systemd_spec.rb => default_spec.rb} (84%) create mode 100644 spec/acceptance/resolved_spec.rb diff --git a/spec/acceptance/systemd_spec.rb b/spec/acceptance/default_spec.rb similarity index 84% rename from spec/acceptance/systemd_spec.rb rename to spec/acceptance/default_spec.rb index c402179c..3b264f76 100644 --- a/spec/acceptance/systemd_spec.rb +++ b/spec/acceptance/default_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'spec_helper_acceptance' + describe 'systemd' do it_behaves_like 'an idempotent resource' do let(:manifest) do diff --git a/spec/acceptance/resolved_spec.rb b/spec/acceptance/resolved_spec.rb new file mode 100644 index 00000000..39dc4bc3 --- /dev/null +++ b/spec/acceptance/resolved_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'systemd' do + context 'configure systemd resolved' do + it 'works idempotently with no errors' do + pp = <<-PUPPET + class{'systemd': + manage_resolved => true, + manage_resolv_conf => false, + } + PUPPET + apply_manifest(pp, catch_failures: true) + # RedHat 9 installs package first run before fact $facts['internal_services'] is set + apply_manifest(pp, catch_failures: true) if (Puppet::Util::Package.versioncmp(fact('os.release.major'), '9') >= 0) && (fact('os.family') == 'RedHat') + apply_manifest(pp, catch_changes: true) + end + + # RedHat 7 does not have systemd-resolved available at all. + describe service('systemd-resolved'), unless: (fact('os.release.major') == '7' and fact('os.family') == 'RedHat') do + it { is_expected.to be_running } + it { is_expected.to be_enabled } + end + end +end