-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create testruns model in timeseries app
- Loading branch information
1 parent
f7dae7d
commit 2fdefc4
Showing
7 changed files
with
369 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
shared/django_apps/timeseries/migrations/0015_testrun_testrun_flags_hash_test_id_unique.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 15:02 | ||
|
||
import django.contrib.postgres.fields | ||
import django_prometheus.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
( | ||
"timeseries", | ||
"0014_remove_measurement_timeseries_measurement_flag_unique_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Testrun", | ||
fields=[ | ||
("timestamp", models.DateTimeField(primary_key=True, serialize=False)), | ||
("repo_id", models.BigIntegerField()), | ||
("test_id", models.BinaryField()), | ||
("flags_hash", models.BinaryField(null=True)), | ||
("testsuite", models.TextField(null=True)), | ||
("classname", models.TextField(null=True)), | ||
("name", models.TextField(null=True)), | ||
("computed_name", models.TextField(null=True)), | ||
("outcome", models.TextField()), | ||
("duration_seconds", models.FloatField(null=True)), | ||
("failure_message", models.TextField(null=True)), | ||
("framework", models.TextField(null=True)), | ||
("filename", models.TextField(null=True)), | ||
("commit_sha", models.TextField(null=True)), | ||
("branch", models.TextField(null=True)), | ||
( | ||
"flags", | ||
django.contrib.postgres.fields.ArrayField( | ||
base_field=models.TextField(), null=True, size=None | ||
), | ||
), | ||
("upload_id", models.BigIntegerField(null=True)), | ||
], | ||
bases=( | ||
django_prometheus.models.ExportModelOperationsMixin( | ||
"timeseries.testrun" | ||
), | ||
models.Model, | ||
), | ||
), | ||
migrations.RunSQL( | ||
"ALTER TABLE timeseries_testrun DROP CONSTRAINT timeseries_testrun_pkey;", | ||
reverse_sql="", | ||
), | ||
migrations.RunSQL( | ||
"SELECT create_hypertable('timeseries_testrun', 'timestamp');", | ||
reverse_sql="", | ||
), | ||
] |
42 changes: 42 additions & 0 deletions
42
shared/django_apps/timeseries/migrations/0016_auto_20250206_1513.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 15:13 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
# cant create this views in a transaction | ||
atomic = False | ||
|
||
dependencies = [ | ||
("timeseries", "0015_testrun_testrun_flags_hash_test_id_unique"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
""" | ||
create materialized view timeseries_testrun_branch_summary_1day | ||
with (timescaledb.continuous) as | ||
select | ||
repo_id, | ||
branch, | ||
testsuite, | ||
classname, | ||
name, | ||
min(computed_name) as computed_name, | ||
COUNT(DISTINCT CASE WHEN outcome = 'failure' OR outcome = 'flaky_fail' THEN commit_sha ELSE NULL END) AS cwf, | ||
time_bucket(interval '1 days', timestamp) as timestamp_bin, | ||
last(duration_seconds, timestamp) as last_duration_seconds, | ||
avg(duration_seconds) as avg_duration_seconds, | ||
COUNT(*) FILTER (WHERE outcome = 'pass') AS pass_count, | ||
COUNT(*) FILTER (WHERE outcome = 'failure') AS fail_count, | ||
COUNT(*) FILTER (WHERE outcome = 'skip') AS skip_count, | ||
COUNT(*) FILTER (WHERE outcome = 'flaky_fail') AS flaky_fail_count, | ||
MAX(timestamp) AS updated_at, | ||
array_agg(DISTINCT flags) filter(where flags <> '{}') as flags | ||
from timeseries_testrun | ||
group by | ||
repo_id, testsuite, classname, name, branch, timestamp_bin; | ||
""", | ||
reverse_sql="drop materialized view timeseries_testrun_branch_summary_1day;", | ||
), | ||
] |
41 changes: 41 additions & 0 deletions
41
shared/django_apps/timeseries/migrations/0017_auto_20250206_1656.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 16:56 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
# cant create this views in a transaction | ||
atomic = False | ||
|
||
dependencies = [ | ||
("timeseries", "0016_auto_20250206_1513"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
""" | ||
create materialized view timeseries_testrun_summary_1day | ||
with (timescaledb.continuous) as | ||
select | ||
repo_id, | ||
testsuite, | ||
classname, | ||
name, | ||
min(computed_name) as computed_name, | ||
COUNT(DISTINCT CASE WHEN outcome = 'failure' OR outcome = 'flaky_fail' THEN commit_sha ELSE NULL END) AS cwf, | ||
time_bucket(interval '1 days', timestamp) as timestamp_bin, | ||
last(duration_seconds, timestamp) as last_duration_seconds, | ||
avg(duration_seconds) as avg_duration_seconds, | ||
COUNT(*) FILTER (WHERE outcome = 'pass') AS pass_count, | ||
COUNT(*) FILTER (WHERE outcome = 'failure') AS fail_count, | ||
COUNT(*) FILTER (WHERE outcome = 'skip') AS skip_count, | ||
COUNT(*) FILTER (WHERE outcome = 'flaky_fail') AS flaky_fail_count, | ||
MAX(timestamp) AS updated_at, | ||
array_agg(DISTINCT flags) filter(where flags <> '{}') as flags | ||
from timeseries_testrun | ||
group by | ||
repo_id, testsuite, classname, name, timestamp_bin; | ||
""", | ||
reverse_sql="drop materialized view timeseries_testrun_summary_1day;", | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
shared/django_apps/timeseries/migrations/0018_auto_20250206_1657.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 16:57 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("timeseries", "0017_auto_20250206_1656"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
""" | ||
select add_continuous_aggregate_policy( | ||
'timeseries_testrun_branch_summary_1day', | ||
start_offset => '7 days', | ||
end_offset => '1 days', | ||
schedule_interval => INTERVAL '1 days' | ||
); | ||
""", | ||
reverse_sql="select remove_continuous_aggregate_policy('timeseries_testrun_branch_summary_1day');", | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
shared/django_apps/timeseries/migrations/0019_auto_20250206_1657.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 16:57 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("timeseries", "0018_auto_20250206_1657"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
""" | ||
select add_continuous_aggregate_policy( | ||
'timeseries_testrun_summary_1day', | ||
start_offset => '7 days', | ||
end_offset => '1 days', | ||
schedule_interval => INTERVAL '1 days' | ||
); | ||
""", | ||
reverse_sql="select remove_continuous_aggregate_policy('timeseries_testrun_summary_1day');", | ||
), | ||
] |
90 changes: 90 additions & 0 deletions
90
...ed/django_apps/timeseries/migrations/0020_testrunbranchsummary_testrunsummary_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Generated by Django 4.2.16 on 2025-02-06 16:57 | ||
import django.contrib.postgres.fields | ||
import django_prometheus.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("timeseries", "0019_auto_20250206_1657"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="TestrunBranchSummary", | ||
fields=[ | ||
( | ||
"timestamp_bin", | ||
models.DateTimeField(primary_key=True, serialize=False), | ||
), | ||
("repo_id", models.IntegerField()), | ||
("branch", models.TextField()), | ||
("name", models.TextField()), | ||
("classname", models.TextField()), | ||
("testsuite", models.TextField()), | ||
("computed_name", models.TextField()), | ||
("cwf", models.IntegerField()), | ||
("avg_duration_seconds", models.FloatField()), | ||
("last_duration_seconds", models.FloatField()), | ||
("pass_count", models.IntegerField()), | ||
("fail_count", models.IntegerField()), | ||
("skip_count", models.IntegerField()), | ||
("flaky_fail_count", models.IntegerField()), | ||
("updated_at", models.DateTimeField()), | ||
( | ||
"flags", | ||
django.contrib.postgres.fields.ArrayField( | ||
base_field=models.TextField(), null=True, size=None | ||
), | ||
), | ||
], | ||
options={ | ||
"db_table": "timeseries_testrun_branch_summary_1day", | ||
"managed": False, | ||
}, | ||
bases=( | ||
django_prometheus.models.ExportModelOperationsMixin( | ||
"timeseries.testrun_continuous_aggregate" | ||
), | ||
models.Model, | ||
), | ||
), | ||
migrations.CreateModel( | ||
name="TestrunSummary", | ||
fields=[ | ||
( | ||
"timestamp_bin", | ||
models.DateTimeField(primary_key=True, serialize=False), | ||
), | ||
("repo_id", models.IntegerField()), | ||
("name", models.TextField()), | ||
("classname", models.TextField()), | ||
("testsuite", models.TextField()), | ||
("computed_name", models.TextField()), | ||
("cwf", models.IntegerField()), | ||
("avg_duration_seconds", models.FloatField()), | ||
("last_duration_seconds", models.FloatField()), | ||
("pass_count", models.IntegerField()), | ||
("fail_count", models.IntegerField()), | ||
("skip_count", models.IntegerField()), | ||
("flaky_fail_count", models.IntegerField()), | ||
("updated_at", models.DateTimeField()), | ||
( | ||
"flags", | ||
django.contrib.postgres.fields.ArrayField( | ||
base_field=models.TextField(), null=True, size=None | ||
), | ||
), | ||
], | ||
options={ | ||
"db_table": "timeseries_testrun_summary_1day", | ||
"managed": False, | ||
}, | ||
bases=( | ||
django_prometheus.models.ExportModelOperationsMixin( | ||
"timeseries.testrun_continuous_aggregate" | ||
), | ||
models.Model, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters