-
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.
Merge branch 'main' into integration-test-fix
- Loading branch information
Showing
15 changed files
with
426 additions
and
381 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
backend/migrations/versions/2023_06_20_1000-b33ee8dd41b1_use_nulls_not_distinct.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,33 @@ | ||
"""Use nulls not distinct | ||
Revision ID: b33ee8dd41b1 | ||
Revises: 6a80dad01d24 | ||
Create Date: 2023-06-20 10:00:07.676129+00:00 | ||
""" | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b33ee8dd41b1" | ||
down_revision = "6a80dad01d24" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute( | ||
"ALTER TABLE artefact_build " | ||
"DROP CONSTRAINT IF EXISTS artefact_build_artefact_id_architecture_revision_key" | ||
", ADD CONSTRAINT unique_artefact_build " | ||
"UNIQUE NULLS NOT DISTINCT (artefact_id, architecture, revision);" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.execute( | ||
"ALTER TABLE artefact_build " | ||
"DROP CONSTRAINT IF EXISTS unique_artefact_build" | ||
", ADD CONSTRAINT artefact_build_artefact_id_architecture_revision_key " | ||
"UNIQUE (artefact_id, architecture, revision);" | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Empty file.
12 changes: 0 additions & 12 deletions
12
backend/test_observer/controllers/test_execution/models.py
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
backend/test_observer/controllers/test_execution/test_execution.py
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
backend/test_observer/controllers/test_executions/models.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 |
---|---|---|
@@ -1,8 +1,39 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# All rights reserved. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Written by: | ||
# Omar Selo <[email protected]> | ||
|
||
|
||
from pydantic import BaseModel | ||
|
||
from test_observer.data_access.models_enums import TestExecutionStatus | ||
|
||
|
||
class StartTestExecutionRequest(BaseModel): | ||
family: str | ||
name: str | ||
version: str | ||
revision: int | None = None | ||
source: dict | ||
arch: str | ||
execution_stage: str | ||
environment: str | ||
|
||
|
||
class TestExecutionsPatchRequest(BaseModel): | ||
c3_link: str | ||
jenkins_link: str | ||
|
80 changes: 78 additions & 2 deletions
80
backend/test_observer/controllers/test_executions/test_executions.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 |
---|---|---|
@@ -1,14 +1,90 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# All rights reserved. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Written by: | ||
# Omar Selo <[email protected]> | ||
# Nadzeya Hutsko <[email protected]> | ||
|
||
|
||
from fastapi import APIRouter, Depends | ||
from sqlalchemy.orm import Session | ||
|
||
from test_observer.data_access.models import TestExecution | ||
from test_observer.data_access.models import ( | ||
TestExecution, | ||
Stage, | ||
Artefact, | ||
ArtefactBuild, | ||
Environment, | ||
) | ||
from test_observer.data_access.models_enums import TestExecutionStatus | ||
from test_observer.data_access.repository import get_or_create | ||
from test_observer.data_access.setup import get_db | ||
|
||
from .models import TestExecutionsPatchRequest | ||
from .models import TestExecutionsPatchRequest, StartTestExecutionRequest | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.put("/start-test") | ||
def start_test_execution( | ||
request: StartTestExecutionRequest, db: Session = Depends(get_db) | ||
): | ||
stage = ( | ||
db.query(Stage) | ||
.filter( | ||
Stage.name == request.execution_stage, | ||
Stage.family.has(name=request.family), | ||
) | ||
.one() | ||
) | ||
|
||
artefact = get_or_create( | ||
db, | ||
Artefact, | ||
name=request.name, | ||
version=request.version, | ||
source=request.source, | ||
stage_id=stage.id, | ||
) | ||
|
||
environment = get_or_create( | ||
db, | ||
Environment, | ||
name=request.environment, | ||
architecture=request.arch, | ||
) | ||
|
||
artefact_build = get_or_create( | ||
db, | ||
ArtefactBuild, | ||
architecture=request.arch, | ||
revision=request.revision, | ||
artefact_id=artefact.id, | ||
) | ||
|
||
test_execution = get_or_create( | ||
db, | ||
TestExecution, | ||
environment_id=environment.id, | ||
artefact_build_id=artefact_build.id, | ||
status=TestExecutionStatus.IN_PROGRESS, | ||
) | ||
return {"id": test_execution.id} | ||
|
||
|
||
@router.patch("/{id}") | ||
def patch_test_execution( | ||
id: int, | ||
|
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
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
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.