Skip to content

Commit

Permalink
Remove review information from TestExecution db table
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo committed Oct 9, 2024
1 parent 79a68ff commit 0a043ca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
ORDER BY id
"""

reverse_copy_cmd = """
UPDATE test_execution te
SET review_comment = aber.review_comment,
review_decision = aber.review_decision::TEXT[]::testexecutionreviewdecision[]
FROM artefact_build_environment_review aber
WHERE te.environment_id = aber.environment_id
AND te.artefact_build_id = aber.artefact_build_id
"""


def upgrade() -> None:
op.create_table(
Expand Down Expand Up @@ -76,7 +85,44 @@ def upgrade() -> None:

op.execute(copy_cmd)

op.drop_column("test_execution", "review_comment")
op.drop_column("test_execution", "review_decision")
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_decision",
postgresql.ARRAY(te_review_decision),
server_default=sa.text("'{}'::testexecutionreviewdecision[]"),
autoincrement=False,
nullable=False,
),
)
op.add_column(
"test_execution",
sa.Column(
"review_comment",
sa.VARCHAR(),
server_default=sa.text("''::character varying"),
autoincrement=False,
nullable=False,
),
)

op.execute(reverse_copy_cmd)

op.drop_table("artefact_build_environment_review")
op.execute("DROP TYPE artefactbuildenvironmentreviewdecision")
12 changes: 0 additions & 12 deletions backend/test_observer/data_access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from test_observer.data_access.models_enums import (
ArtefactBuildEnvironmentReviewDecision,
ArtefactStatus,
TestExecutionReviewDecision,
TestExecutionStatus,
TestResultStatus,
)
Expand Down Expand Up @@ -354,22 +353,11 @@ class TestExecution(Base):
status: Mapped[TestExecutionStatus] = mapped_column(
default=TestExecutionStatus.NOT_STARTED
)
review_decision: Mapped[list[TestExecutionReviewDecision]] = mapped_column(
ARRAY(Enum(TestExecutionReviewDecision)),
default=[],
)
review_comment: Mapped[str] = mapped_column(default="")

checkbox_version: Mapped[str | None] = mapped_column(
String(200), nullable=True, default=None
)

@property
def is_approved(self) -> bool:
return (len(self.review_decision) > 0) and (
TestExecutionReviewDecision.REJECTED not in self.review_decision
)

@property
def has_failures(self) -> bool:
return any(tr.status == TestResultStatus.FAILED for tr in self.test_results)
Expand Down
11 changes: 0 additions & 11 deletions backend/test_observer/data_access/models_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ class TestExecutionStatus(str, Enum):
ENDED_PREMATURELY = "ENDED_PREMATURELY"


class TestExecutionReviewDecision(str, Enum):
__test__ = False

REJECTED = "REJECTED"
APPROVED_INCONSISTENT_TEST = "APPROVED_INCONSISTENT_TEST"
APPROVED_UNSTABLE_PHYSICAL_INFRA = "APPROVED_UNSTABLE_PHYSICAL_INFRA"
APPROVED_CUSTOMER_PREREQUISITE_FAIL = "APPROVED_CUSTOMER_PREREQUISITE_FAIL"
APPROVED_FAULTY_HARDWARE = "APPROVED_FAULTY_HARDWARE"
APPROVED_ALL_TESTS_PASS = "APPROVED_ALL_TESTS_PASS"


class ArtefactBuildEnvironmentReviewDecision(str, Enum):
REJECTED = "REJECTED"
APPROVED_INCONSISTENT_TEST = "APPROVED_INCONSISTENT_TEST"
Expand Down

0 comments on commit 0a043ca

Please sign in to comment.