Skip to content

Commit

Permalink
Merge pull request PowerDNS#12686 from aerique/feature/report-tested-…
Browse files Browse the repository at this point in the history
…repo-versions

Report Version when Testing Repositories
  • Loading branch information
aerique authored Apr 15, 2023
2 parents 03debda + 28e7226 commit 08a7346
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions build-scripts/docker/repo-test/generate-repo-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Modules

import argparse
import re
import subprocess
import sys

Expand All @@ -24,7 +25,7 @@

# Globals

g_version = '0.0.1'
g_version = '1.0.2'

g_verbose = False

Expand All @@ -46,7 +47,7 @@ def init_argparser():
'auth-44', 'auth-45', 'auth-46', 'auth-47',
'auth-48', 'auth-master',
# Recursor
'rec-45', 'rec-46', 'rec-47', 'rec-48',
'rec-46', 'rec-47', 'rec-48', 'rec-49',
'rec-master',
# DNSDist
'dnsdist-15', 'dnsdist-16', 'dnsdist-17',
Expand Down Expand Up @@ -142,7 +143,7 @@ def write_release_files (release):

if release in ['auth-44', 'auth-45', 'auth-46', 'auth-47', 'auth-48',
'auth-master',
'rec-45', 'rec-46', 'rec-47', 'rec-48',
'rec-46', 'rec-47', 'rec-48', 'rec-49',
'rec-master',
'dnsdist-15', 'dnsdist-16', 'dnsdist-17', 'dnsdist-18',
'dnsdist-master']:
Expand All @@ -151,8 +152,6 @@ def write_release_files (release):
write_dockerfile('el', '8', release)
write_dockerfile('debian', 'buster', release)
write_list_file('debian', 'buster', release)
write_dockerfile('ubuntu', 'bionic', release)
write_list_file('ubuntu', 'bionic', release)
write_dockerfile('ubuntu', 'focal', release)
write_list_file('ubuntu', 'focal', release)

Expand All @@ -161,19 +160,25 @@ def write_release_files (release):
write_list_file('raspbian', 'buster', release)

if release in ['auth-46', 'auth-47', 'auth-48', 'auth-master',
'rec-45', 'rec-46', 'rec-47', 'rec-48', 'rec-master',
'rec-46', 'rec-47', 'rec-48', 'rec-49', 'rec-master',
'dnsdist-16', 'dnsdist-17', 'dnsdist-18', 'dnsdist-master']:
write_dockerfile('debian', 'bullseye', release)
write_list_file('debian', 'bullseye', release)

if release in ['auth-46', 'auth-47', 'auth-master',
'rec-46', 'rec-47', 'rec-48', 'rec-49', 'rec-master',
'dnsdist-15', 'dnsdist-16', 'dnsdist-17', 'dnsdist-master']:
write_dockerfile('ubuntu', 'bionic', release)
write_list_file('ubuntu', 'bionic', release)

if release in ['auth-46', 'auth-47', 'auth-48', 'auth-master',
'rec-46', 'rec-47', 'rec-48', 'rec-master',
'rec-46', 'rec-47', 'rec-48', 'rec-49', 'rec-master',
'dnsdist-17', 'dnsdist-18', 'dnsdist-master']:
write_dockerfile('ubuntu', 'jammy', release)
write_list_file('ubuntu', 'jammy', release)

if release in ['auth-47', 'auth-48', 'auth-master',
'rec-47', 'rec-48', 'rec-master',
'rec-47', 'rec-48', 'rec-49', 'rec-master',
'dnsdist-17', 'dnsdist-18', 'dnsdist-master']:
write_dockerfile('el', '9', release)

Expand Down Expand Up @@ -205,13 +210,21 @@ def run (tag):
capture_run_output = not(g_verbose)
print('Running Docker container tagged {}...'.format(tag))
cp = subprocess.run(['docker', 'run', tag],
capture_output=capture_run_output)
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
version = re.search('(PowerDNS Authoritative Server|PowerDNS Recursor|' +
'dnsdist) (\d+\.\d+\.\d+(-\w+)?)',
cp.stdout.decode())
if g_verbose:
print(cp.stdout.decode())
# for some reason 99 is returned on `cmd --version` :shrug:
if cp.returncode != 0 and cp.returncode != 99:
# FIXME write failed output to log
print('Error running {}: {}'.format(tag, repr(cp.returncode)))
return cp.returncode
return cp.returncode
if version and version.group(2):
return cp.returncode, version.group(2)
else:
return cp.returncode, None


def collect_dockerfiles (release):
Expand All @@ -230,6 +243,7 @@ def test_release (release):
dockerfiles = sorted(collect_dockerfiles(release))
failed_builds = []
failed_runs = []
returned_versions = []
print('=== testing {} ==='.format(release))
for df in dockerfiles:
if g_verbose:
Expand All @@ -243,10 +257,13 @@ def test_release (release):
print('Skipping running {} due to undetermined tag.'.format(df))
failed_builds.append((str(df), returncode))
else:
returncode = run(tag)
# for some reason 99 is returned on `cmd --version` :shrug:
(returncode, return_version) = run(tag)
# for some reason 99 is returned on `cmd --version` :shrug:
# (not sure if this is true since using `stdout=PIPE...`)
if returncode != 0 and returncode != 99:
failed_runs.append((tag, returncode))
if return_version:
returned_versions.append((tag, return_version))
print('Test done.')
if len(failed_builds) > 0:
print('- failed builds:')
Expand All @@ -256,6 +273,12 @@ def test_release (release):
print('- failed runs:')
for fr in failed_runs:
print(' - {}'.format(fr))
if len(returned_versions) > 0:
print('- returned versions:')
for rv in returned_versions:
print(' - {}: {}'.format(rv[0], rv[1]))
else:
print('- ERROR: no returned versions (unsupported product?)')


# Main Program
Expand Down

0 comments on commit 08a7346

Please sign in to comment.