Skip to content

Commit

Permalink
Allow multiple test execution runs (#225)
Browse files Browse the repository at this point in the history
* 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
omar-selo authored Nov 26, 2024
1 parent 2aacca2 commit 9e29680
Show file tree
Hide file tree
Showing 31 changed files with 840 additions and 1,056 deletions.
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,
),
)
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))
140 changes: 136 additions & 4 deletions backend/scripts/seed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
environment="rpi2",
ci_link="http://example1",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
name="core22",
version="20230531",
revision=1,
track="22",
store="ubuntu",
arch="armhf",
execution_stage="beta",
environment="rpi2",
ci_link="http://example13",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
name="core22",
version="20230531",
revision=1,
track="22",
store="ubuntu",
arch="armhf",
execution_stage="beta",
environment="rpi2",
ci_link="http://example14",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
name="core22",
Expand Down Expand Up @@ -154,6 +178,17 @@
environment="dragonboard",
ci_link="http://example7",
),
StartTestExecutionRequest(
family=FamilyName.DEB,
name="linux-raspi",
version="5.15.0.73.70",
series="jammy",
repo="main",
arch="arm64",
execution_stage="updates",
environment="rpi400",
ci_link="http://example9",
),
StartTestExecutionRequest(
family=FamilyName.DEB,
name="linux-raspi",
Expand All @@ -168,13 +203,24 @@
StartTestExecutionRequest(
family=FamilyName.DEB,
name="linux-raspi",
version="5.15.0.73.70",
version="5.15.0.73.71",
series="jammy",
repo="main",
arch="arm64",
execution_stage="updates",
execution_stage="proposed",
environment="rpi400",
ci_link="http://example9",
ci_link="http://example15",
),
StartTestExecutionRequest(
family=FamilyName.DEB,
name="linux-raspi",
version="5.15.0.73.71",
series="jammy",
repo="main",
arch="arm64",
execution_stage="proposed",
environment="rpi400",
ci_link="http://example16",
),
]

Expand All @@ -184,7 +230,7 @@
test_results=[
C3TestResult(
name="docker/compose-and-basic_armhf",
status=C3TestResultStatus.PASS,
status=C3TestResultStatus.FAIL,
category="Docker containers",
comment="",
io_log=dedent(
Expand Down Expand Up @@ -270,6 +316,44 @@
),
],
),
EndTestExecutionRequest(
ci_link="http://example13",
test_results=[
C3TestResult(
name="docker/compose-and-basic_armhf",
status=C3TestResultStatus.PASS,
category="Docker containers",
comment="",
io_log="",
),
C3TestResult(
name="after-suspend-audio/alsa-loopback-automated",
status=C3TestResultStatus.FAIL,
category="Audio tests",
comment="",
io_log="",
),
],
),
EndTestExecutionRequest(
ci_link="http://example10",
test_results=[
C3TestResult(
name="docker/compose-and-basic_armhf",
status=C3TestResultStatus.PASS,
category="Docker containers",
comment="",
io_log="",
),
C3TestResult(
name="after-suspend-audio/alsa-loopback-automated",
status=C3TestResultStatus.FAIL,
category="Audio tests",
comment="",
io_log="",
),
],
),
EndTestExecutionRequest(
ci_link="http://example2",
test_results=[
Expand All @@ -289,6 +373,54 @@
),
],
),
EndTestExecutionRequest(
ci_link="http://example8",
test_results=[
C3TestResult(
name="test",
status=C3TestResultStatus.FAIL,
category="",
comment="",
io_log="",
),
],
),
EndTestExecutionRequest(
ci_link="http://example15",
test_results=[
C3TestResult(
name="test",
status=C3TestResultStatus.FAIL,
category="",
comment="",
io_log="",
),
],
),
EndTestExecutionRequest(
ci_link="http://example16",
test_results=[
C3TestResult(
name="test",
status=C3TestResultStatus.PASS,
category="",
comment="",
io_log="",
),
],
),
EndTestExecutionRequest(
ci_link="http://example9",
test_results=[
C3TestResult(
name="test",
status=C3TestResultStatus.PASS,
category="",
comment="",
io_log="",
),
],
),
]

TEST_CASE_ISSUE_REQUESTS = [
Expand Down
Loading

0 comments on commit 9e29680

Please sign in to comment.