]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add ARM64 tests to repo test script.
authorErik Winkels <erik.winkels@powerdns.com>
Thu, 20 Jun 2024 14:33:19 +0000 (16:33 +0200)
committerErik Winkels <erik.winkels@powerdns.com>
Tue, 9 Jul 2024 08:57:22 +0000 (10:57 +0200)
build-scripts/docker/repo-test/README.md
build-scripts/docker/repo-test/generate-repo-files.py

index 36038b437b2e6f2175cee8dda8a564c34f60b80b..94af3ad403576a76a88fd74daa7205c2522a15c4 100644 (file)
@@ -10,6 +10,11 @@ To see the supported releases do `./generate-repo-files.py --help`.
 This tool is mainly used internally to test releases but might be useful
 for others.
 
+## Known Issues
+
+- `--test-aarch64` really only makes sense if the test script is running on
+  another platform (and so far we've assumed `x86_64` to be the default)
+
 ## Dependencies
 
 - Python 3
index f360e82c5081f52563884200b9c4377cfe07cd05..7c4f47ac5493ca66d4ea35f23cdb37712b9b335f 100755 (executable)
@@ -58,6 +58,8 @@ def init_argparser():
                         help='always show output from running a container')
     parser.add_argument('--test', action='store_true',
                         help='test the release')
+    parser.add_argument('--test-aarch64', action='store_true',
+                        help='test the release for ARM64')
     parser.add_argument('--verbose', action='store_true',
                         help='verbose output')
     parser.add_argument('--version', action='store_true',
@@ -111,7 +113,7 @@ def write_list_file (os, os_version, release):
     tpl = g_env.get_template('pdns-list.jinja2')
 
     if os in ['debian', 'ubuntu']:
-        arch = ' [arch=amd64] '
+        arch = ' [arch=amd64,arm64] '
     else:
         arch = ' '
 
@@ -170,7 +172,7 @@ def write_release_files (release):
 
 # Test Release Functions
 
-def build (dockerfile):
+def build (dockerfile, arch='x86_64'):
     # Maybe create `determine_tag` function.
     if len(str(dockerfile)) <= len(g_dockerfile):
         print('Unable to determine tag for {}'.format(dockerfile))
@@ -179,9 +181,16 @@ def build (dockerfile):
     print('Building Docker image using {}...'.format(dockerfile))
     if g_verbose:
         print('  - tag = {}'.format(tag))
-    cp = subprocess.run(['docker', 'build', '--no-cache', '--pull', '--file',
-                         dockerfile, '--tag', tag, '.'],
-                        capture_output=not(g_verbose))
+    if arch == 'x86_64':
+        cp = subprocess.run(['docker', 'build', '--no-cache', '--pull',
+                             '--file', dockerfile, '--tag', tag, '.'],
+                            capture_output=not(g_verbose))
+    # not very subtle
+    elif arch == 'aarch64':
+        cp = subprocess.run(['docker', 'build', '--platform', 'linux/arm64/v8',
+                             '--no-cache', '--pull', '--file', dockerfile,
+                             '--tag', tag, '.'],
+                            capture_output=not(g_verbose))
     # FIXME write failed output to log
     if cp.returncode != 0:
         print('Error building {}: {}'.format(tag, repr(cp.returncode)))
@@ -189,14 +198,20 @@ def build (dockerfile):
     return ( tag, cp.returncode )
 
 
-def run (tag):
+def run (tag, arch='x86_64'):
     if g_run_output:
         capture_run_output = False
     else:
         capture_run_output = not(g_verbose)
     print('Running Docker container tagged {}...'.format(tag))
-    cp = subprocess.run(['docker', 'run', tag],
-                        stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    if arch == 'x86_64':
+        cp = subprocess.run(['docker', 'run', tag],
+                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    # not very subtle
+    elif arch == 'aarch64':
+        cp = subprocess.run(['docker', 'run', '--platform', 'linux/arm64/v8',
+                             tag],
+                            stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
     version = re.search(r'(PowerDNS Authoritative Server|PowerDNS Recursor|' +
                         r'dnsdist) (\d+\.\d+\.\d+(-\w+)?)',
                         cp.stdout.decode())
@@ -224,17 +239,22 @@ def collect_dockerfiles (release):
     return files
 
 
-def test_release (release):
+def test_release (release, arch='x86_64'):
     # sorted because we want determinism
     dockerfiles = sorted(collect_dockerfiles(release))
     failed_builds = []
     failed_runs = []
     returned_versions = []
-    print('=== testing {} ==='.format(release))
+    print('=== testing {} ({}) ==='.format(release, arch))
     for df in dockerfiles:
+        if arch == 'aarch64' and str(df).endswith('centos-7'):
+            continue
+        if arch == 'aarch64' and not release in ['rec-51', 'rec-master',
+                                                 'dnsdist-19', 'dnsdist-master']:
+            continue
         if g_verbose:
             print('--- {} ---'.format(df))
-        (tag, returncode) = build(df)
+        (tag, returncode) = build(df, arch)
         if returncode != 0:
             print('Skipping running {} due to build error: {}'
                   .format(df, returncode))
@@ -243,7 +263,7 @@ def test_release (release):
             print('Skipping running {} due to undetermined tag.'.format(df))
             failed_builds.append((str(df), returncode))
         else:
-            (returncode, return_version) = run(tag)
+            (returncode, return_version) = run(tag, arch)
             # 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:
@@ -286,3 +306,6 @@ write_release_files(args.release)
 
 if args.test:
     test_release(args.release)
+
+if args.test_aarch64:
+    test_release(args.release, 'aarch64')