mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
test(setupntp): the ntpd backend never falls back to chrony
setupntp treats the requested backend as a preference in one direction only. A node given --backend chrony without chronyd uses ntpd, but a node given --backend ntpd without ntpd still hands over to setupntp.traditional, which writes /etc/ntp.conf and starts a daemon that is not installed. The selection cases in makentp_ntp_deps.t now also make ntpd absent. The stub for check_executes takes a list of absent commands, so a case can hide ntpd, or ntpd and chronyd together. Two cases fail: --backend ntpd and --use-ntpd both keep ntpd where only chrony is present. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -124,14 +124,20 @@ SKIP: {
|
||||
# --- the backend the management node chose must reach the node ------------
|
||||
# makentp selects the daemon from site.ntpbackend through xCAT::NTP::Backend and passes it here,
|
||||
# so a cluster told to use ntpd does not get chrony on every node that happens to have it.
|
||||
# The backend is a preference on both sides: a node that does not have the requested daemon is
|
||||
# configured with the other one, rather than handed a daemon that is not there.
|
||||
foreach my $case (
|
||||
# argv chronyd present? expected daemon
|
||||
# argv absent commands expected daemon
|
||||
[ '--backend ntpd pool.ntp.org', 'nothing', 'ntpd', 'ntpd is honoured even where chronyd is installed' ],
|
||||
[ '--backend chrony pool.ntp.org','nothing', 'chrony', 'chrony is honoured' ],
|
||||
[ 'pool.ntp.org', 'nothing', 'chrony', 'with no backend given the probe still picks chrony' ],
|
||||
[ 'pool.ntp.org', 'chronyd', 'ntpd', 'with no backend given and no chronyd it falls back' ],
|
||||
[ '--backend chrony pool.ntp.org','chronyd', 'ntpd', 'chrony requested but absent falls back rather than failing' ],
|
||||
[ '--use-ntpd pool.ntp.org', 'nothing', 'ntpd', 'the legacy --use-ntpd flag still forces ntpd' ],
|
||||
[ '--backend ntpd pool.ntp.org', 'ntpd', 'chrony', 'ntpd requested but absent falls back to chrony' ],
|
||||
[ '--use-ntpd pool.ntp.org', 'ntpd', 'chrony', 'the legacy flag falls back the same way' ],
|
||||
[ '--backend ntpd pool.ntp.org', 'ntpd chronyd', 'ntpd', 'with neither daemon present the request is kept' ],
|
||||
[ '--backend ntpd pool.ntp.org', 'ntpd systemctl', 'ntpd', 'chrony without systemctl is no fallback' ],
|
||||
) {
|
||||
my ($argv, $missing, $want, $name) = @$case;
|
||||
my $root = File::Temp::tempdir(CLEANUP => 1);
|
||||
@@ -144,7 +150,7 @@ foreach my $case (
|
||||
. "systemctl() { echo \"systemctl \$*\" >>\"$root/calls\"; return 0; }\n"
|
||||
. "timedatectl() { echo \"timedatectl \$*\" >>\"$root/calls\"; return 0; }\n"
|
||||
. "hwclock() { echo \"hwclock \$*\" >>\"$root/calls\"; return 0; }\n"
|
||||
. "check_executes() { for c in \"\$@\"; do [ \"\$c\" = \"$missing\" ] && return 1; done; return 0; }\n"
|
||||
. "check_executes() { for c in \"\$@\"; do case \" $missing \" in *\" \$c \"*) return 1;; esac; done; return 0; }\n"
|
||||
. "log_label=xcat\nset -- $argv\n";
|
||||
my $out = `bash -c 'exec 2>/dev/null; $prelude$args$select
|
||||
printf "USE_NTPD=%s\\n" "\${USE_NTPD:-}"' 2>/dev/null`;
|
||||
|
||||
Reference in New Issue
Block a user