From 9aa94c3f4ad186e194eb6c334ab32ff7e669d722 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Mon, 27 Mar 2023 14:15:16 -0400 Subject: [PATCH] Add a test for disabling puppet --- bats/fb-test-puppet.bats | 11 +++++++++++ bats/foreman_helper.bash | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/bats/fb-test-puppet.bats b/bats/fb-test-puppet.bats index c351c6da9..ba9b13c4d 100755 --- a/bats/fb-test-puppet.bats +++ b/bats/fb-test-puppet.bats @@ -105,3 +105,14 @@ fi puppet agent -v -o --no-daemonize grep -i "property of the Foreman project" /etc/motd } + +@test "disable puppet" { + KATELLO_VERSION=$(tKatelloVersion) + if [[ $KATELLO_VERSION != 4.[3-9]* ]]; then + skip "Disabling Puppet explicitly is only supported with Katello 4.2 or older" + fi + + if tForemanMaintainCommandAvailable 'plugin purge-puppet'; then + foreman-maintain plugin purge-puppet + fi +} diff --git a/bats/foreman_helper.bash b/bats/foreman_helper.bash index d4c7eeea3..a825675e0 100644 --- a/bats/foreman_helper.bash +++ b/bats/foreman_helper.bash @@ -139,3 +139,11 @@ tWaitForTask() { sleep $(( next_wait_time++ )) done } + +tForemanMaintainCommandAvailable() { + if tForemanMaintainAvailable ; then + if ! foreman-maintain $1 --help ; then + skip "foreman-maintain $1 is not available" + fi + fi +}