Skip to contentSkip to conversation

scripts: yocto_testresults_query fixes and resulttool missing tests

PATCH New [email protected] 1 participant 3 messages Feb 27, 2023

lore
Share & tools
lore
#0 lore raw

cover scripts: yocto_testresults_query fixes and resulttool missing tests

From: Alexis Lothoré <[email protected]>

Hello,
this series is a small follow-up to [1]

- add explicit error when running yocto_testresults_query.py from oe-core instead of poky. Since the tool is working with git references from poky, it will not manage to resolve SHA-1 in oe-core
- add tests for new resulttool regression features (oeselftest metadata, ptest naming fixes, ltp matching, machine matching)

[1] https://lore.kernel.org/openembedded-core/[email protected]/

Alexis Lothoré (2):
scripts/yoct_testresults_query: manage base/target revision not found oeqa/selftest/resulttool: add test for metadata filtering on
regression

 .../oeqa/selftest/cases/resulttooltests.py    | 243 ++++++++++++++++++
 scripts/yocto_testresults_query.py            |  15 +-
 2 files changed, 255 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 scripts/yoct_testresults_query: manage base/target revision not found

From: Alexis Lothoré <[email protected]>

If yocto_testresults_query.py is run from oe-core instead of poky, the script will very likely fail since poky tags do no exist in oe-core. If one or both revisions are not found, log the error and a suggestion about the reason (the script being run in oe-core instead of poky)

---
 scripts/yocto_testresults_query.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
scripts/yocto_testresults_query.py +12 -3
index 3b478822dc..3df9d6015f 100755
@@ -30,9 +30,13 @@ def create_workdir():
     return workdir
 
 def get_sha1(pokydir, revision):
-    rev = subprocess.check_output(["git", "rev-list", "-n", "1", revision], cwd=pokydir).decode('utf-8').strip()
-    logger.info(f"SHA-1 revision for {revision} in {pokydir} is {rev}")
-    return rev
+    try:
+        rev = subprocess.check_output(["git", "rev-list", "-n", "1", revision], cwd=pokydir).decode('utf-8').strip()
+        logger.info(f"SHA-1 revision for {revision} in {pokydir} is {rev}")
+        return rev
+    except subprocess.CalledProcessError:
+        logger.error(f"Can not find SHA-1 for {revision} in {pokydir}")
+        return None
 
 def fetch_testresults(workdir, sha1):
     logger.info(f"Fetching test results for {sha1} in {workdir}")
@@ -65,6 +69,11 @@ def regression(args):
     try:
         baserevision = get_sha1(poky_path, args.base)
         targetrevision = get_sha1(poky_path, args.target)
+        if not baserevision or not targetrevision:
+            logger.error("One or more revision(s) missing. You might be targeting nonexistant tags/branches, or are in wrong repository (you must use Poky and not oe-core)")
+            if not args.testresultsdir:
+                subprocess.check_call(["rm", "-rf",  workdir])
+            sys.exit(1)
         fetch_testresults(workdir, baserevision)
         fetch_testresults(workdir, targetrevision)
         report = compute_regression_report(workdir, baserevision, targetrevision)
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/2 oeqa/selftest/resulttool: add test for metadata filtering on regression

In reply to [email protected]

From: Alexis Lothoré <[email protected]>

Multiple filters have been added to resulttool to ensure that test results are compared only to relevant older tests results

Add some unit tests about added filters:
- tests should only be compared when machine matches
- tests run as oeselftest should only be compared when OESELFTEST_METADATA matches
- many ptests should match despite non-static names
- runtime tests should match with matching tests regarding ltp tests content

---
 .../oeqa/selftest/cases/resulttooltests.py    | 243 ++++++++++++++++++
 1 file changed, 243 insertions(+)
meta/lib/oeqa/selftest/cases/resulttooltests.py +243 -0
index efdfd98af3..f059991c19 100644
@@ -98,3 +98,246 @@ class ResultToolTests(OESelftestTestCase):
         resultutils.append_resultsdata(results, ResultToolTests.target_results_data, configmap=resultutils.flatten_map)
         self.assertEqual(len(results[''].keys()), 5, msg="Flattened results not correct %s" % str(results))
 
+    def test_results_without_metadata_can_be_compared(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+            "DISTRO": "mydistro",
+            "MACHINE": "qemux86",
+            "STARTTIME": 1672527600
+        }, "result": {}}
+        target_configuration = {"configuration": {
+                                "TEST_TYPE": "oeselftest",
+                                "TESTSERIES": "series1",
+                                "IMAGE_BASENAME": "image",
+                                "IMAGE_PKGTYPE": "ipk",
+                                "DISTRO": "mydistro",
+                                "MACHINE": "qemux86",
+                                "STARTTIME": 1672527600
+                                }, "result": {}}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect metadata filtering, tests without metadata should be compared")
+
+    def test_target_result_with_missing_metadata_can_not_be_compared(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+            "DISTRO": "mydistro",
+            "MACHINE": "qemux86",
+            "OESELFTEST_METADATA": {
+                "run_all_tests": True,
+                "run_tests": None,
+                "skips": None,
+                "machine": None,
+                "select_tags": ["toolchain-user", "toolchain-system"],
+                "exclude_tags": None
+            }}, "result": {}}
+        target_configuration = {"configuration": {"TEST_TYPE": "oeselftest",
+                                "TESTSERIES": "series1",
+                                                  "IMAGE_BASENAME": "image",
+                                                  "IMAGE_PKGTYPE": "ipk",
+                                                  "DISTRO": "mydistro",
+                                                  "MACHINE": "qemux86",
+                                                  "STARTTIME": 1672527600
+                                                  }, "result": {}}
+        self.assertFalse(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                         msg="incorrect metadata filtering, tests should not be compared")
+
+    def test_results_with_matching_metadata_can_be_compared(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+                             "DISTRO": "mydistro",
+                             "MACHINE": "qemux86",
+            "STARTTIME": 1672527600,
+                             "OESELFTEST_METADATA": {"run_all_tests": True,
+                                                     "run_tests": None,
+                                                     "skips": None,
+                                                     "machine": None,
+                                                     "select_tags": ["toolchain-user", "toolchain-system"],
+                                                     "exclude_tags": None}
+        }, "result": {}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+            "DISTRO": "mydistro",
+            "MACHINE": "qemux86",
+                                "STARTTIME": 1672527600,
+                                "OESELFTEST_METADATA": {"run_all_tests": True,
+                                                        "run_tests": None,
+                                                        "skips": None,
+                                                        "machine": None,
+                                                        "select_tags": ["toolchain-user", "toolchain-system"],
+                                                        "exclude_tags": None}
+                                }, "result": {}}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect metadata filtering, tests with matching metadata should be compared")
+
+    def test_results_with_mismatching_metadata_can_not_be_compared(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+            "DISTRO": "mydistro",
+            "MACHINE": "qemux86",
+            "STARTTIME": 1672527600,
+            "OESELFTEST_METADATA": {"run_all_tests": True,
+                                    "run_tests": None,
+                                    "skips": None,
+                                    "machine": None,
+                                    "select_tags": ["toolchain-user", "toolchain-system"],
+                                    "exclude_tags": None}
+        }, "result": {}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "oeselftest",
+            "TESTSERIES": "series1",
+            "IMAGE_BASENAME": "image",
+            "IMAGE_PKGTYPE": "ipk",
+            "DISTRO": "mydistro",
+            "MACHINE": "qemux86",
+                                "STARTTIME": 1672527600,
+                                "OESELFTEST_METADATA": {"run_all_tests": True,
+                                                        "run_tests": None,
+                                                        "skips": None,
+                                                        "machine": None,
+                                                        "select_tags": ["machine"],
+                                                        "exclude_tags": None}
+                                }, "result": {}}
+        self.assertFalse(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                         msg="incorrect metadata filtering, tests with mismatching metadata should not be compared")
+
+    def test_metadata_matching_is_only_checked_for_relevant_test_type(self):
+        base_configuration = {"configuration": {"TEST_TYPE": "runtime",
+                              "TESTSERIES": "series1",
+                                                "IMAGE_BASENAME": "image",
+                                                "IMAGE_PKGTYPE": "ipk",
+                                                "DISTRO": "mydistro",
+                                                "MACHINE": "qemux86",
+                                                "STARTTIME": 1672527600,
+                                                "OESELFTEST_METADATA": {"run_all_tests": True,
+                                                                        "run_tests": None,
+                                                                        "skips": None,
+                                                                        "machine": None,
+                                                                        "select_tags": ["toolchain-user", "toolchain-system"],
+                                                                        "exclude_tags": None}}, "result": {}}
+        target_configuration = {"configuration": {"TEST_TYPE": "runtime",
+                                "TESTSERIES": "series1",
+                                                  "IMAGE_BASENAME": "image",
+                                                  "IMAGE_PKGTYPE": "ipk",
+                                                  "DISTRO": "mydistro",
+                                                  "MACHINE": "qemux86",
+                                                  "STARTTIME": 1672527600,
+                                                  "OESELFTEST_METADATA": {"run_all_tests": True,
+                                                                          "run_tests": None,
+                                                                          "skips": None,
+                                                                          "machine": None,
+                                                                          "select_tags": ["machine"],
+                                                                          "exclude_tags": None}}, "result": {}}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect metadata filtering, %s tests should be compared" % base_configuration['configuration']['TEST_TYPE'])
+
+    def test_machine_matches(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"}, "result": {}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {}}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect machine filtering, identical machine tests should be compared")
+
+    def test_machine_mismatches(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86_64"
+        }, "result": {}}
+        self.assertFalse(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                         msg="incorrect machine filtering, mismatching machine tests should not be compared")
+
+    def test_can_not_compare_non_ltp_tests(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {
+            "ltpresult_foo": {
+                "STATUS": "PASSED"
+            }}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86_64"
+        }, "result": {
+            "bar": {
+                "STATUS": "PASSED"
+            }}}
+        self.assertFalse(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                         msg="incorrect ltpresult filtering, mismatching ltpresult content should not be compared")
+
+    def test_can_compare_ltp_tests(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {
+            "ltpresult_foo": {
+                "STATUS": "PASSED"
+            }}}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {
+            "ltpresult_foo": {
+                "STATUS": "PASSED"
+            }}}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect ltpresult filtering, matching ltpresult content should be compared")
+
+    def test_can_match_non_static_ptest_names(self):
+        base_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {
+            "ptestresult.lttng-tools.foo_-_bar_-_moo": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.babeltrace.bar_-_moo_-_foo": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.babletrace2.moo_-_foo_-_bar": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.curl.test_0000__foo_out_of_bar": {
+                "STATUS": "PASSED"
+            }
+        }}
+        target_configuration = {"configuration": {
+            "TEST_TYPE": "runtime",
+            "MACHINE": "qemux86"
+        }, "result": {
+            "ptestresult.lttng-tools.xxx_-_yyy_-_zzz": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.babeltrace.yyy_-_zzz_-_xxx": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.babletrace2.zzz_-_xxx_-_yyy": {
+                "STATUS": "PASSED"
+            },
+            "ptestresult.curl.test_0000__xxx_out_of_yyy": {
+                "STATUS": "PASSED"
+            }
+            }}
+        self.assertTrue(regression.can_be_compared(self.logger, base_configuration, target_configuration),
+                        msg="incorrect ptests filtering, tests shoould be compared if prefixes match")
Signature · 1 line
2.39.2