From 9bae67c3a7421895c25fdb8aaeeeb75f3cd10a0a Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Thu, 17 Oct 2024 14:15:35 -0700 Subject: [PATCH] WIP - add new_failure field to TextLogError and update when we have a new failure. --- tests/log_parser/test_tasks.py | 1 + tests/webapp/api/test_jobs_api.py | 2 ++ treeherder/etl/artifact.py | 6 ++++++ treeherder/model/error_summary.py | 1 + .../0033_textlogerror_new_failure.py | 21 +++++++++++++++++++ treeherder/model/models.py | 1 + 6 files changed, 32 insertions(+) create mode 100644 treeherder/model/migrations/0033_textlogerror_new_failure.py diff --git a/tests/log_parser/test_tasks.py b/tests/log_parser/test_tasks.py index eefeffb11f2..920348cec83 100644 --- a/tests/log_parser/test_tasks.py +++ b/tests/log_parser/test_tasks.py @@ -59,6 +59,7 @@ def test_create_error_summary( "line_number", "counter", "failure_new_in_rev", + "text_log_error_id", ] ) for failure_line in bug_suggestions: diff --git a/tests/webapp/api/test_jobs_api.py b/tests/webapp/api/test_jobs_api.py index 7b1fb6e3b35..90ba1ac8b4b 100644 --- a/tests/webapp/api/test_jobs_api.py +++ b/tests/webapp/api/test_jobs_api.py @@ -222,12 +222,14 @@ def test_text_log_errors(client, test_job): "job": 1, "line": "failure 1", "line_number": 101, + "new_failure": False, }, { "id": 2, "job": 1, "line": "failure 2", "line_number": 102, + "new_failure": False, }, ] diff --git a/treeherder/etl/artifact.py b/treeherder/etl/artifact.py index 7facdd002d5..611630071ef 100644 --- a/treeherder/etl/artifact.py +++ b/treeherder/etl/artifact.py @@ -43,6 +43,12 @@ def store_text_log_summary_artifact(job, text_log_summary_artifact): # classify job as `new failure` - for filtering, etc. job.failure_classification_id = 6 job.save() + # for every log_errors (TLE object) there is a corresponding bugs/suggestion + for tle in log_errors: + if tle.id == suggestion["text_log_error_id"]: + tle.new_failure = True + tle.save() + break def store_job_artifacts(artifact_data): diff --git a/treeherder/model/error_summary.py b/treeherder/model/error_summary.py index f346ddd2162..d3312f0fecb 100644 --- a/treeherder/model/error_summary.py +++ b/treeherder/model/error_summary.py @@ -193,6 +193,7 @@ def bug_suggestions_line( "line_number": err.line_number, "counter": counter, "failure_new_in_rev": failure_new_in_rev, + "text_log_error_id": err.id, }, line_cache diff --git a/treeherder/model/migrations/0033_textlogerror_new_failure.py b/treeherder/model/migrations/0033_textlogerror_new_failure.py new file mode 100644 index 00000000000..fcf45af4847 --- /dev/null +++ b/treeherder/model/migrations/0033_textlogerror_new_failure.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.13 on 2024-10-21 13:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "model", + "0032_rename_failureline_job_guid_repository_failure_lin_job_gui_b67c6d_idx_and_more", + ), + ] + + operations = [ + migrations.AddField( + model_name="textlogerror", + name="new_failure", + field=models.BooleanField(default=False), + ), + ] diff --git a/treeherder/model/models.py b/treeherder/model/models.py index 3a59e563659..49e77d6a83d 100644 --- a/treeherder/model/models.py +++ b/treeherder/model/models.py @@ -1219,6 +1219,7 @@ class TextLogError(models.Model): job = models.ForeignKey(Job, on_delete=models.CASCADE, related_name="text_log_error", null=True) line = models.TextField() line_number = models.PositiveIntegerField() + new_failure = models.BooleanField(default=False) # TODO delete this field and unique_together once backfill of jobs in TextLogError table has been completed step = models.ForeignKey(