fix(perpatch): Sort comparison output by test name 59/40659/3
authorVratko Polak <vrpolak@cisco.com>
Tue, 9 Apr 2024 08:22:49 +0000 (10:22 +0200)
committerVratko Polak <vrpolak@cisco.com>
Tue, 9 Apr 2024 08:22:49 +0000 (10:22 +0200)
Change-Id: Id68a4e2b7514b9cf2e1f2f30b78dc0cd696a673a
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/python/model/parse.py
resources/tools/integrated/compare_perpatch.py

index b2e8da6..1e0aebf 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2023 Cisco and/or its affiliates.
+# Copyright (c) 2024 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -54,6 +54,9 @@ def parse(dirpath: str, fake_value: float = 1.0) -> Dict[str, List[float]]:
     Units are ignored, as both parent and current are tested
     with the same CSIT code so the unit should be identical.
 
     Units are ignored, as both parent and current are tested
     with the same CSIT code so the unit should be identical.
 
+    The test results are sorted by test_id,
+    as the filesystem order is not deterministic enough.
+
     The result is also cached as results.json file.
 
     :param dirpath: Path to the directory tree to examine.
     The result is also cached as results.json file.
 
     :param dirpath: Path to the directory tree to examine.
@@ -103,6 +106,7 @@ def parse(dirpath: str, fake_value: float = 1.0) -> Dict[str, List[float]]:
                 results[name] = [result_object["bandwidth"]["value"]]
             else:
                 raise RuntimeError(f"Unknown result type: {result_type}")
                 results[name] = [result_object["bandwidth"]["value"]]
             else:
                 raise RuntimeError(f"Unknown result type: {result_type}")
+    results = {test_id: results[test_id] for test_id in sorted(results)}
     with open(resultpath, "wt", encoding="utf8") as file_out:
         json.dump(results, file_out, indent=1, separators=(", ", ": "))
     return results
     with open(resultpath, "wt", encoding="utf8") as file_out:
         json.dump(results, file_out, indent=1, separators=(", ", ": "))
     return results
index 3821054..59ea7e5 100644 (file)
@@ -56,7 +56,7 @@ def main() -> int:
         parent_results = {}
         current_results = {}
         parent_results = parse(f"csit_parent/{iteration}", fake_value=2.0)
         parent_results = {}
         current_results = {}
         parent_results = parse(f"csit_parent/{iteration}", fake_value=2.0)
-        parent_names = set(parent_results.keys())
+        parent_names = list(parent_results)
         if test_names is None:
             test_names = parent_names
         if not parent_names:
         if test_names is None:
             test_names = parent_names
         if not parent_names:
@@ -64,7 +64,7 @@ def main() -> int:
             break
         assert parent_names == test_names, f"{parent_names} != {test_names}"
         current_results = parse(f"csit_current/{iteration}", fake_value=1.0)
             break
         assert parent_names == test_names, f"{parent_names} != {test_names}"
         current_results = parse(f"csit_current/{iteration}", fake_value=1.0)
-        current_names = set(current_results.keys())
+        current_names = list(current_results)
         assert (
             current_names == parent_names
         ), f"{current_names} != {parent_names}"
         assert (
             current_names == parent_names
         ), f"{current_names} != {parent_names}"