Skip to content

Allow multiple test execution runs #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3d5448c
Drop unnecessary columns and type from previous refactor
omar-selo Oct 18, 2024
aa6416a
Allow multiple test execution runs
omar-selo Oct 21, 2024
1e72125
Remove automatic approvals
omar-selo Oct 21, 2024
456bb13
Add a rerun to seed data script
omar-selo Oct 21, 2024
9578ff4
Show multiple runs on frontend
omar-selo Oct 22, 2024
63e7d43
Add rerun results to seed data
omar-selo Oct 25, 2024
7ea32f4
Edit seed script again
omar-selo Oct 25, 2024
dda41ff
Refactor and add last test execution status filter
omar-selo Oct 25, 2024
0a78d04
Expand the first test execution run initially
omar-selo Oct 25, 2024
4daa23a
Show status icon for last run on environment expandable
omar-selo Oct 25, 2024
657ecdc
Fix test case
omar-selo Oct 25, 2024
28e1361
Add test execution id to previous test results
omar-selo Oct 25, 2024
de17e78
Remove test execution id in previous results until we use it
omar-selo Oct 25, 2024
e983f4b
Add to seed data
omar-selo Nov 21, 2024
7cf125f
Fix bugs in previous test results and improve it's performance
omar-selo Nov 21, 2024
f34bd5c
Small changes
omar-selo Nov 22, 2024
57c450b
Reverse order of previous results list and add current result
omar-selo Nov 22, 2024
8992fee
Add version tooltip to current result
omar-selo Nov 22, 2024
3f1720e
Group previous results by artefact version
omar-selo Nov 22, 2024
3fa79b2
Some code improvements
omar-selo Nov 26, 2024
513a19d
Some code improvements
omar-selo Nov 26, 2024
f22afa9
Add back TestExecution status summary using latest test executions fo…
omar-selo Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope everything goes well and we don't have to execute this deletion 😄

But should we perhaps at least locally try to execute this downgrade path, just to make sure it will work correctly if we have to execute it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sure hope we don't have to do that. I've tried it locally and it worked fine at least for what I've tried.

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
Loading