Skip to content
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

Add test execution review functionality #77

Merged
merged 16 commits into from
Dec 14, 2023

Conversation

andrejvelichkovski
Copy link
Contributor

@andrejvelichkovski andrejvelichkovski commented Dec 7, 2023

This PR introduces a new backend endpoint for reviewing a test execution.

Our decision was that we should have review process for both Test Execution and the whole Artefact. The artefact signoff is already implemented, but we still need to have similar implementation for Test Execution.

Implementation

As part of this PR there are a few different updates:

  • New model updates (added review_status and review_comment)
  • Updated existing PATCH endpoint for Test Execution

Database migrations

As part of this update, we need to apply one more migration to the database.

Testing

Automated tests were added and a set of manual tests were performed to verify the behaviour.

@andrejvelichkovski andrejvelichkovski marked this pull request as ready for review December 8, 2023 08:37
Copy link
Collaborator

@omar-selo omar-selo left a comment

Choose a reason for hiding this comment

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

Thanks for the work! Two main points are whether we need an additional endpoint, and whether we need a list of review statuses.

"'UNDECIDED', "
"'MARKED_AS_FAILED', "
"'APPROVED_INCONSISTENT_TEST_DEF', "
"'APPROVED_UNSTABLE_PHSYICAL_INFRA', "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"'APPROVED_UNSTABLE_PHSYICAL_INFRA', "
"'APPROVED_UNSTABLE_PHYSICAL_INFRA', "

"CREATE TYPE testexecutionreviewstatus AS "
"ENUM( "
"'UNDECIDED', "
"'MARKED_AS_FAILED', "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"'MARKED_AS_FAILED', "
"'FAILED', "

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or just REJECTED? Cause right now TestExecution already has a status field that can be FAILED. So having another review_status field that can also be FAILED would be confusing

Copy link
Contributor Author

@andrejvelichkovski andrejvelichkovski Dec 11, 2023

Choose a reason for hiding this comment

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

I also think REJECTED would be better alternative to distinguish from other status types

Copy link
Collaborator

Choose a reason for hiding this comment

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

That makes sense.


def upgrade() -> None:
op.execute(
"CREATE TYPE testexecutionreviewstatus AS "
Copy link
Collaborator

@mz2 mz2 Dec 8, 2023

Choose a reason for hiding this comment

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

Suggested change
"CREATE TYPE testexecutionreviewstatus AS "
"CREATE TYPE review_status AS "

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Are there other review statuses expected?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the Spreadsheet document I created, these were the ones added there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant this in context of renaming this type as just "review_status"

op.execute(
"CREATE TYPE testexecutionreviewstatus AS "
"ENUM( "
"'UNDECIDED', "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"'UNDECIDED', "
"'UNKNOWN', "

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually you don't need this state at all since it's to be used as a list (an empty list would be an "unknown" state)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will follow-up with removing it.

"'APPROVED_INCONSISTENT_TEST_DEF', "
"'APPROVED_UNSTABLE_PHSYICAL_INFRA', "
"'APPROVED_FAULTY_HARDWARE', "
"'APPROVED_GENERIC' "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"'APPROVED_GENERIC' "
"'APPROVED_TESTS_PASSED "

)
op.execute(
"ALTER TABLE test_execution ADD COLUMN "
"review_status testexecutionreviewstatus[] NOT NULL "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"review_status testexecutionreviewstatus[] NOT NULL "
"review_statuses review_status[] NOT NULL "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the enum name must match the enum class name in Python, according to SQLAlchemy

op.execute(
"ALTER TABLE test_execution ADD COLUMN "
"review_status testexecutionreviewstatus[] NOT NULL "
"DEFAULT '{UNDECIDED}'::testexecutionreviewstatus[]"
Copy link
Collaborator

@mz2 mz2 Dec 8, 2023

Choose a reason for hiding this comment

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

Suggested change
"DEFAULT '{UNDECIDED}'::testexecutionreviewstatus[]"
"DEFAULT '{UNKNOWN}'::review_status[]"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually on a closer thought this should be by default an empty list and you don't need an UNKNOWN state at all.

@andrejvelichkovski andrejvelichkovski marked this pull request as draft December 11, 2023 07:48
@andrejvelichkovski andrejvelichkovski marked this pull request as ready for review December 11, 2023 08:58
@andrejvelichkovski andrejvelichkovski changed the title Add test execution review endpoint Add test execution review functionality Dec 11, 2023
Copy link
Collaborator

@omar-selo omar-selo left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably also handle the case of test execution reruns. Perhaps if a rerun does occur then it might be appropriate to empty both review_status and review_comment

omar-selo
omar-selo previously approved these changes Dec 14, 2023
Copy link
Collaborator

@omar-selo omar-selo left a comment

Choose a reason for hiding this comment

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

LGTM!

@andrejvelichkovski
Copy link
Contributor Author

Forgot to handle the re-run case. Will update the code again.

Copy link
Collaborator

@omar-selo omar-selo left a comment

Choose a reason for hiding this comment

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

Looks good

@andrejvelichkovski andrejvelichkovski merged commit 09b26a3 into main Dec 14, 2023
@andrejvelichkovski andrejvelichkovski deleted the add-test-execution-review-endpoint branch December 14, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants