← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~hyask/autopkgtest-cloud:skia/always_dump_additional_params into autopkgtest-cloud:master

 

Skia has proposed merging ~hyask/autopkgtest-cloud:skia/always_dump_additional_params into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/460240
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/always_dump_additional_params into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index 3744f06..ed85962 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -321,9 +321,7 @@ def request_matches_per_package(package, arch, release, s):
     )
 
 
-def process_output_dir(
-    dir, pkgname, code, triggers, additional_params: dict = None
-):
+def process_output_dir(dir, pkgname, code, triggers, additional_params: dict):
     """Post-process output directory"""
 
     files = set(os.listdir(dir))
@@ -353,14 +351,13 @@ def process_output_dir(
                 json.dump(d, testinfo, indent=True)
             files.add("testinfo.json")
 
-    if additional_params not in [None, {}]:
-        d = {}
-        with open(os.path.join(dir, "testinfo.json"), "r") as testinfo:
-            d = json.load(testinfo)
-        for key, val in additional_params.items():
-            d[key] = val
-        with open(os.path.join(dir, "testinfo.json"), "w") as testinfo:
-            json.dump(d, testinfo, indent=True)
+    d = {}
+    with open(os.path.join(dir, "testinfo.json"), "r") as testinfo:
+        d = json.load(testinfo)
+    for key in KEYS_FOR_ADDITIONAL_PARAMS:
+        d[key] = additional_params.get(key)
+    with open(os.path.join(dir, "testinfo.json"), "w") as testinfo:
+        json.dump(d, testinfo, indent=True)
 
     with open(os.path.join(dir, "testpkg-version"), "r") as tpv:
         testpkg_version = tpv.read().split()[1]
@@ -1250,20 +1247,17 @@ def request(msg):
         # List of key=value strings to be sent as a rabbitmq msg
         # These variables are optional additional parameters users
         # can employ when requesting a test which alters the behaviour
-        additional_parameters = []
-        # We also create it as a dict to easily insert into a json file
-        additional_parameters_for_testinfo = {}
+        additional_parameters = {}
         for key in KEYS_FOR_ADDITIONAL_PARAMS:
             if params.get(key, None) is not None:
-                additional_parameters.append("%s=%s" % (key, params[key]))
-                additional_parameters_for_testinfo[key] = params[key]
+                additional_parameters[key] = params[key]
 
         (testpkg_version, duration, requester) = process_output_dir(
             out_dir,
             pkgname,
             code,
             params.get("triggers", []),
-            additional_parameters_for_testinfo,  # embed additional parameters in testinfo.json
+            additional_parameters,  # embed additional parameters in testinfo.json
         )
 
         # If two tests for the same package with different triggers finish at the
@@ -1386,7 +1380,12 @@ def request(msg):
             "requester": requester,
             "swift_dir": swift_dir,
             "triggers": triggers,
-            "env": ",".join(additional_parameters),
+            "env": ",".join(
+                [
+                    f"{key}={value}"
+                    for key, value in additional_parameters.items()
+                ]
+            ),
         }
     )
     complete_amqp.basic_publish(

Follow ups