drm/ci: add helper script update-xfails.py
Subsystems (3)
RFC PATCH 1/1 drm/ci: add helper script update-xfails.py
Add helper script that given a gitlab pipeline url, analise which are the failures and flakes and update the xfails folder accordingly.
Example:
Trigger a pipeline in gitlab infrastructure, than re-try a few jobs more than once (so we can have data if failues are consistent across jobs with the same name or if they are flakes) and execute:
update-xfails.py https://gitlab.freedesktop.org/helen.fornazier/linux/-/pipelines/970661
git diff should show you that it updated files in xfails folder.
---
Hello,
This script is being very handy for me, so I suppose it could be handy to others, since I'm publishing it in the xfails folder.
Let me know your thoughts.
Regards,
Helen
--- drivers/gpu/drm/ci/xfails/requirements.txt | 16 ++ drivers/gpu/drm/ci/xfails/update-xfails.py | 161 +++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 drivers/gpu/drm/ci/xfails/requirements.txt create mode 100755 drivers/gpu/drm/ci/xfails/update-xfails.py
drivers/gpu/drm/ci/xfails/requirements.txt new file +16 -0
@@ -0,0 +1,16 @@ +git+https://gitlab.freedesktop.org/gfx-ci/ci-collate@4a5bb602855f2bd4fc1ecf43db19e84a906f4258 + +# ci-collate dependencies +certifi==2023.7.22 +charset-normalizer==3.2.0 +idna==3.4 +pip==23.2.1 +python-gitlab==3.15.0 +requests==2.31.0 +requests-toolbelt==1.0.0 +ruamel.yaml==0.17.32 +ruamel.yaml.clib==0.2.7 +setuptools==68.0.0 +tenacity==8.2.3 +urllib3==2.0.4 +wheel==0.41.1
drivers/gpu/drm/ci/xfails/update-xfails.py new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.34.1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Helen,
Quoted 7 lines · Helen Koike
Hello,
This script is being very handy for me, so I suppose it could be handy
to others, since I'm publishing it in the xfails folder.Let me know your thoughts.
I have two suggestions and one comment. Before that, I would like to highlight the importance of tools like that to help with repetitive tedious work, it is great to have this script.
Quoted 4 lines
+def
get_xfails_file_path(canonical_name, suffix):
+ name =canonical_name.replace(":", "-")
+script_dir= os.path.dirname(os.path.abspath(__file__)) + returnos.path.join(script_dir, f"{name}-{suffix}.txt")
I appreciate the correspondence between job name and expectation file names.
Quoted 5 lines
+def
get_unit_test_name_and_results(unit_test):
+ if "Artifact results/failures.csv not found" inunit_test:
+ return None, None
+unit_test_name,unit_test_result= unit_test.strip().split(",") + returnunit_test_name,unit_test_result
Suggestion: it is not managing empty lines or comments. By now, there aren't, but they could be found.
Quoted 38 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +12
-0+def main(namespace, project, pipeline_id): + xfails = ( + Collate(namespace=namespace, project=project) + .from_pipeline(pipeline_id) + .get_artifact("results/failures.csv") + ) + + split_unit_test_from_collate(xfails) + + for job_name in xfails.keys(): + canonical_name = get_canonical_name(job_name) + fails_txt_path = get_xfails_file_path(canonical_name,"fails")
+flakes_txt_path=get_xfails_file_path(canonical_name, "flakes")drivers/gpu/drm/ci/xfails/update-xfails.py new file +7
-0+ + fails_txt = read_file(fails_txt_path) + flakes_txt = read_file(flakes_txt_path) + + for job_id in xfails[job_name].keys(): + for unit_test in xfails[job_name][job_id]: + unit_test_name, unit_test_result =
get_unit_test_name_and_results(unit_test)drivers/gpu/drm/ci/xfails/update-xfails.py new file +5
-0+ + if not unit_test_name: + continue + + if is_test_present_on_file(flakes_txt,
unit_test_name):
+remove_unit_test_if_present(flakes_txt, unit_test_name, flakes_txt_path)
+ print("WARNING: unit test is on flakes list but a job failed due to it, "
+ "is your tree up to date?",
+unit_test_name, "DROPPED FROM",os.path.basename(flakes_txt_path))
+
+ ifunit_test_result== "UnexpectedPass":
Quoted 8 lines
+
remove_unit_test_if_present(fails_txt, unit_test_name, fails_txt_path)
+ # flake result
+ if notis_unit_test_present_in_other_jobs(unit_test, xfails[job_name]):
+add_unit_test_if_not_present(flakes_txt, unit_test_name, flakes_txt_path)
+ continue
Suggestion: Sometimes tests fails with different status ("Fail" to "Crash" for example) and the expectations should be updated with the newer status.
Quoted 9 lines
+
+ # flake result
+ if notis_unit_test_present_in_other_jobs(unit_test, xfails[job_name]):
+add_unit_test_if_not_present(flakes_txt, unit_test_name, flakes_txt_path)
+ continue
+
+ # consistent result
Quoted 8 lines
+ add_unit_test_or_update_result_to_fails_if_present(fails_txt,
unit_test,
+fails_txt_path)
+
+save_file(fails_txt, fails_txt_path)
+save_file(flakes_txt, flakes_txt_path)
Regards,
- --
Sergi Blanch Torné
Senior Software Engineer
Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQQwWRK68l+taJfhwqAto5bHyTm9RwUCZRPuvgAKCRAto5bHyTm9 R7wIAP4hr5ddBZ9+3R4n2KJA5DOc6JE1oRjabB7A2pkZFl1BxwEAyX83yMaqJE8T RXrhZ3oyQbUIyCbZhLNOP6OiZ6bchQc=
=Pr1y
-----END PGP SIGNATURE-----
Hi Sergi,
Thanks for your comments.
Quoted 23 lines · Sergi Blanch Torne
Hi Helen,
Quoted 7 lines · Helen Koike
Hello,
This script is being very handy for me, so I suppose it could be handy
to others, since I'm publishing it in the xfails folder.Let me know your thoughts.
I have two suggestions and one comment. Before that, I would like to highlight the importance of tools like that to help with repetitive tedious work, it is great to have this script.
drivers/gpu/drm/ci/xfails/update-xfails.py line 17
Quoted 4 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +4
-0+def get_xfails_file_path(canonical_name, suffix): + name = canonical_name.replace(":", "-") + script_dir = os.path.dirname(os.path.abspath(__file__)) + return os.path.join(script_dir, f"{name}-{suffix}.txt")I appreciate the correspondence between job name and expectation file names.
Quoted 8 lines
drivers/gpu/drm/ci/xfails/update-xfails.py line 24
Quoted 5 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +5
-0+def get_unit_test_name_and_results(unit_test): + if "Artifact results/failures.csv not found" in unit_test: + return None, None + unit_test_name, unit_test_result = unit_test.strip().split(",") + return unit_test_name, unit_test_resultSuggestion: it is not managing empty lines or comments. By now, there aren't, but they could be found.
Indeed.
Quoted 43 lines
Quoted 43 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +12
-0+def main(namespace, project, pipeline_id): + xfails = ( + Collate(namespace=namespace, project=project) + .from_pipeline(pipeline_id) + .get_artifact("results/failures.csv") + ) + + split_unit_test_from_collate(xfails) + + for job_name in xfails.keys(): + canonical_name = get_canonical_name(job_name) + fails_txt_path = get_xfails_file_path(canonical_name,"fails")
+flakes_txt_path= get_xfails_file_path(canonical_name,
"flakes")drivers/gpu/drm/ci/xfails/update-xfails.py new file +7
-0+ + fails_txt = read_file(fails_txt_path) + flakes_txt = read_file(flakes_txt_path) + + for job_id in xfails[job_name].keys(): + for unit_test in xfails[job_name][job_id]: + unit_test_name, unit_test_result =
get_unit_test_name_and_results(unit_test)drivers/gpu/drm/ci/xfails/update-xfails.py new file +5
-0+ + if not unit_test_name: + continue + + if is_test_present_on_file(flakes_txt,
unit_test_name):
+ remove_unit_test_if_present(flakes_txt,unit_test_name,flakes_txt_path)
+ print("WARNING: unit test is on flakes list but
a job failed due to it, "(quoted diff) +2
-0+ "is your tree up to date?", + unit_test_name, "DROPPED FROM",
os.path.basename(flakes_txt_path))drivers/gpu/drm/ci/xfails/update-xfails.py new file +3
-0+ + if unit_test_result == "UnexpectedPass": + remove_unit_test_if_present(fails_txt,
unit_test_name,fails_txt_path)(quoted diff) +2
-0+ # flake result + if not
Quoted 8 lines
Quoted 4 lines
is_unit_test_present_in_other_jobs(unit_test, xfails[job_name]):
+ add_unit_test_if_not_present(flakes_txt,unit_test_name,flakes_txt_path)
+ continueSuggestion: Sometimes tests fails with different status ("Fail" to "Crash" for example) and the expectations should be updated with the newer status.
The status is only present in the fails and not in the flakes list, so I update it with add_unit_test_or_update_result_to_fails_if_present() function below, make sense?
Regards,
Helen
Quoted 21 lines
Quoted 15 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +3
-0+ + # flake result + if not is_unit_test_present_in_other_jobs(unit_test,xfails[job_name]):
+ add_unit_test_if_not_present(flakes_txt,unit_test_name,flakes_txt_path)drivers/gpu/drm/ci/xfails/update-xfails.py new file +4
-0+ continue + + # consistent result +add_unit_test_or_update_result_to_fails_if_present(fails_txt,
unit_test,
+fails_txt_path)drivers/gpu/drm/ci/xfails/update-xfails.py line 144
Quoted 3 lines
drivers/gpu/drm/ci/xfails/update-xfails.py new file +3
-0+ + save_file(fails_txt, fails_txt_path) + save_file(flakes_txt, flakes_txt_path)Regards,
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi Helen,
Quoted 7 lines · Helen Koike
Quoted 7 lines
Quoted 6 lines
+def
get_unit_test_name_and_results(unit_test):
+ if "Artifact results/failures.csv not found" inunit_test:
+ return None, None
+unit_test_name,unit_test_result= unit_test.strip().split(",")
+ returnunit_test_name,unit_test_result
Quoted 5 lines
Quoted 3 lines
Suggestion: it is not managing empty lines or comments. By now, there
aren't, but they could be found.Indeed.
Just add a new if statement to discard if the strings start with # or strip the line and check the length. Perhaps we can think of other assertions to sanitise the string.
Quoted 9 lines
Quoted 4 lines
Suggestion: Sometimes tests fails with different status ("Fail" to "Crash" for example) and the expectations should be updated with the
newer status.The status is only present in the fails and not in the flakes list, so I
update it withadd_unit_test_or_update_result_to_fails_if_present()function below, make sense?
Absolutely, sorry that I didn't see this was a process included in the last if statement. If it is present in the fails' file (that includes the test name and its state) you do exactly what's necessary: add if not present, update if it was already in the file.
Quoted 1 line
Regards,
- --
Sergi Blanch Torné
Senior Software Engineer
Collabora Ltd.
Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718
-----BEGIN PGP SIGNATURE-----
iHUEARYIAB0WIQQwWRK68l+taJfhwqAto5bHyTm9RwUCZRUnAgAKCRAto5bHyTm9 R53NAP9T2OCiwbnEjv+H0CQg/eK1xGe7yS/3cqjaPFRvvZPp1wD/V1H9NuhpRR6M 8+QZgbsS/swSPdwYABtcz+75CKpuJwo=
=XRRO
-----END PGP SIGNATURE-----