2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-28 12:37:55 +00:00

[#1262] hammer: hardened checking installed packages

This commit is contained in:
Michal Nowikowski 2020-05-29 15:25:16 +02:00
parent 8319dd16e6
commit 90a7a60622

View File

@ -242,7 +242,7 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False
:param bool capture: if True then the command's traces are captured and returned by the function :param bool capture: if True then the command's traces are captured and returned by the function
:param bool interactive: if True then stdin and stdout are not redirected, traces handling is disabled, :param bool interactive: if True then stdin and stdout are not redirected, traces handling is disabled,
used for e.g. SSH used for e.g. SSH
:param int attemts: number of attempts to run the command if it fails :param int attempts: number of attempts to run the command if it fails
:param int sleep_time_after_attempt: number of seconds to sleep before taking next attempt :param int sleep_time_after_attempt: number of seconds to sleep before taking next attempt
""" """
log.info('>>>>> Executing %s in %s', cmd, cwd if cwd else os.getcwd()) log.info('>>>>> Executing %s in %s', cmd, cwd if cwd else os.getcwd())
@ -1632,12 +1632,12 @@ def _build_binaries_and_run_ut(system, revision, features, tarball_path, env, ch
def _check_installed_rpm_or_debs(services_list): def _check_installed_rpm_or_debs(services_list):
for svc in services_list: for svc in services_list:
execute('sudo systemctl stop %s' % svc) execute('sudo systemctl stop %s' % svc)
_, out = execute('date +"%Y-%m-%d%H:%M:%S"', capture=True) now = datetime.datetime.now()
timestamp = out.strip() timestamp = now.strftime('%Y-%m-%d%H:%M:%S')
execute('sudo systemctl start %s' % svc) execute('sudo systemctl start %s' % svc)
time.sleep(3) time.sleep(3)
cmd = "sudo journalctl --since %s -u %s | grep '_STARTED Kea'" % (timestamp, svc) cmd = "sudo journalctl --since %s -u %s | grep '_STARTED Kea'" % (timestamp, svc)
execute(cmd) execute(cmd, attempts=10, sleep_time_after_attempt=1)
def _build_rpm(system, revision, features, tarball_path, env, check_times, dry_run, def _build_rpm(system, revision, features, tarball_path, env, check_times, dry_run,
@ -1811,8 +1811,11 @@ def _build_alpine_apk(system, revision, features, tarball_path, env, check_times
time.sleep(3) time.sleep(3)
if svc == 'kea-dhcp-ddns': if svc == 'kea-dhcp-ddns':
svc = 'kea-ddns' svc = 'kea-ddns'
cmd = "sudo cat /var/log/kea/%s.log | grep '_STARTED Kea'" % svc log_path = '/var/log/kea/%s.log' % svc
execute(cmd) if revision == '3.10':
log_path = '/var/log/%s.log' % svc
cmd = "sudo cat %s | grep '_STARTED Kea'" % log_path
execute(cmd, attempts=10, sleep_time_after_attempt=1)
def _build_native_pkg(system, revision, features, tarball_path, env, check_times, dry_run, ccache_dir, def _build_native_pkg(system, revision, features, tarball_path, env, check_times, dry_run, ccache_dir,