-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple test execution runs (#225)
* Drop unnecessary columns and type from previous refactor * Allow multiple test execution runs * Remove automatic approvals * Add a rerun to seed data script * Show multiple runs on frontend * Add rerun results to seed data * Edit seed script again * Refactor and add last test execution status filter * Expand the first test execution run initially * Show status icon for last run on environment expandable * Fix test case * Add test execution id to previous test results * Remove test execution id in previous results until we use it * Add to seed data * Fix bugs in previous test results and improve it's performance * Small changes * Reverse order of previous results list and add current result * Add version tooltip to current result * Group previous results by artefact version * Some code improvements * Some code improvements * Add back TestExecution status summary using latest test executions for each environment
- Loading branch information
Showing
31 changed files
with
840 additions
and
1,056 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...rations/versions/2024_10_18_1134-b234def463ad_drop_review_columns_from_test_execution_.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,55 @@ | ||
"""Drop review columns from Test Execution Table | ||
Revision ID: b234def463ad | ||
Revises: 91e7e3f437a0 | ||
Create Date: 2024-10-18 11:34:38.285303+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b234def463ad" | ||
down_revision = "91e7e3f437a0" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.drop_column("test_execution", "review_decision") | ||
op.drop_column("test_execution", "review_comment") | ||
op.execute("DROP TYPE testexecutionreviewdecision") | ||
|
||
|
||
def downgrade() -> None: | ||
te_review_decision = sa.Enum( | ||
"REJECTED", | ||
"APPROVED_INCONSISTENT_TEST", | ||
"APPROVED_UNSTABLE_PHYSICAL_INFRA", | ||
"APPROVED_FAULTY_HARDWARE", | ||
"APPROVED_CUSTOMER_PREREQUISITE_FAIL", | ||
"APPROVED_ALL_TESTS_PASS", | ||
name="testexecutionreviewdecision", | ||
) | ||
te_review_decision.create(op.get_bind()) | ||
op.add_column( | ||
"test_execution", | ||
sa.Column( | ||
"review_comment", | ||
sa.VARCHAR(), | ||
server_default=sa.text("''::character varying"), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
) | ||
op.add_column( | ||
"test_execution", | ||
sa.Column( | ||
"review_decision", | ||
postgresql.ARRAY(te_review_decision), | ||
server_default=sa.text("'{}'::testexecutionreviewdecision[]"), | ||
autoincrement=False, | ||
nullable=False, | ||
), | ||
) |
53 changes: 53 additions & 0 deletions
53
...end/migrations/versions/2024_10_21_1035-063e32aac8db_allow_multiple_testexecution_runs.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,53 @@ | ||
"""Allow multiple TestExecution runs | ||
Revision ID: 063e32aac8db | ||
Revises: b234def463ad | ||
Create Date: 2024-10-21 10:35:17.364462+00:00 | ||
""" | ||
from textwrap import dedent | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "063e32aac8db" | ||
down_revision = "b234def463ad" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.drop_constraint( | ||
"test_execution_artefact_build_id_environment_id_key", | ||
"test_execution", | ||
type_="unique", | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
remove_test_execution_runs_keeping_latest() | ||
|
||
op.create_unique_constraint( | ||
"test_execution_artefact_build_id_environment_id_key", | ||
"test_execution", | ||
["artefact_build_id", "environment_id"], | ||
) | ||
|
||
|
||
def remove_test_execution_runs_keeping_latest(): | ||
connection = op.get_bind() | ||
|
||
stmt = """\ | ||
SELECT artefact_build_id, environment_id, MAX(id), COUNT(*) | ||
FROM test_execution | ||
GROUP BY artefact_build_id, environment_id | ||
HAVING COUNT(*) > 1 | ||
""" | ||
|
||
for ab_id, e_id, max_id, _ in connection.execute(sa.text(dedent(stmt))): | ||
stmt = f"""\ | ||
DELETE FROM test_execution | ||
WHERE artefact_build_id={ab_id} AND environment_id={e_id} AND id <> {max_id} | ||
""" | ||
op.execute(dedent(stmt)) |
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
Oops, something went wrong.