Sync time on cfg01 node before tempest
- sync time again on all the nodes including cfg01
- check if the services 'maas-rackd' and 'maas-regiond' are
present on the node. if yes - disable the services while
time is synchronized
- execute salt_actions.sync_time() also before the tempest
is started
- remove the class override_ntp_virtual because it disables
the ntp client on cfg01.
Closes-Bug: #PROD-30114
Change-Id: Ibb731ae14f573a3d7471da2cbe9f55754d79c4ff
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index 9b321cb..68fb5e6 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -276,16 +276,35 @@
return result['return']
@utils.retry(3, exception=libpepper.PepperException)
- def sync_time(self, tgt='* and not cfg01*'):
+ def sync_time(self, tgt='*'):
LOG.info("NTP time sync on the salt minions '{0}'".format(tgt))
# Force authentication update on the next API access
# because previous authentication most probably is not valid
# before or after time sync.
self.__api = None
if not settings.SKIP_SYNC_TIME:
+ cmd = ('service ntp stop;'
+ 'if systemctl is-active --quiet maas-rackd; then'
+ ' systemctl stop maas-rackd; RACKD=true;'
+ 'else'
+ ' RACKD=false;'
+ 'fi;'
+ 'if systemctl is-active --quiet maas-regiond; then'
+ ' systemctl stop maas-regiond; REGIOND=true;'
+ 'else'
+ ' REGIOND=false;'
+ 'fi;'
+ 'if [ -x /usr/sbin/ntpdate ]; then'
+ ' ntpdate -s ntp.ubuntu.com;'
+ 'else'
+ ' ntpd -gq;'
+ 'fi;'
+ 'service ntp start;'
+ 'if $RACKD; then systemctl start maas-rackd; fi;'
+ 'if $REGIOND; then systemctl start maas-regiond; fi;')
self.run_state(
tgt,
- 'cmd.run', 'service ntp stop; if [ -x /usr/sbin/ntpdate ]; then ntpdate -s ntp.ubuntu.com; else ntpd -gq ; fi; service ntp start') # noqa
+ 'cmd.run', cmd) # noqa
new_time_res = self.run_state(tgt, 'cmd.run', 'date')
for node_name, time in sorted(new_time_res[0]['return'][0].items()):
LOG.info("{0}: {1}".format(node_name, time))