Skip to content

Commit 2735e27

Browse files
committed
feat: show unexistent tests on issue incidents
There can be incidents relating an issue with a nonexisting test. Since this is part of the issue incidents, it should be shown so that the incident generation is fixed.
1 parent 6e46ca9 commit 2735e27

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

backend/kernelCI_app/queries/issues.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_issue_tests(*, issue_id: str, version: Optional[int]) -> list[dict]:
6666

6767
query = f"""
6868
SELECT
69-
T.ID,
69+
INC.TEST_ID AS ID,
7070
T.STATUS,
7171
T.DURATION,
7272
T.PATH,
@@ -78,14 +78,15 @@ def get_issue_tests(*, issue_id: str, version: Optional[int]) -> list[dict]:
7878
C.GIT_REPOSITORY_URL
7979
FROM
8080
INCIDENTS INC
81-
INNER JOIN TESTS T ON (INC.TEST_ID = T.ID)
81+
LEFT JOIN TESTS T ON (INC.TEST_ID = T.ID)
8282
LEFT JOIN BUILDS B ON (T.BUILD_ID = B.ID)
8383
LEFT JOIN CHECKOUTS C ON (B.CHECKOUT_ID = C.ID)
8484
WHERE
8585
(
8686
INC.ISSUE_ID = %(issue_id)s
8787
AND {version_clause}
8888
)
89+
AND INC.TEST_ID IS NOT NULL
8990
"""
9091

9192
with connection.cursor() as cursor:

backend/kernelCI_app/typeModels/testDetails.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
from kernelCI_app.constants.general import DEFAULT_ORIGIN
55
from kernelCI_app.constants.localization import DocStrings
66

7+
from kernelCI_app.typeModels.common import make_default_validator
78
from kernelCI_app.typeModels.databases import (
9+
NULL_STATUS,
810
Origin,
11+
StatusValues,
912
Test__Id,
1013
Build__Id,
1114
Test__Status,
@@ -35,7 +38,10 @@ class TestDetailsResponse(BaseModel):
3538
field_timestamp: Timestamp = Field(validation_alias="_timestamp")
3639
id: Test__Id
3740
build_id: Build__Id
38-
status: Test__Status
41+
status: Annotated[
42+
StatusValues,
43+
make_default_validator(NULL_STATUS),
44+
]
3945
path: Test__Path
4046
log_excerpt: Test__LogExcerpt
4147
log_url: Test__LogUrl

backend/kernelCI_app/views/issueDetailsTestsView.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get(self, _request: HttpRequest, issue_id: Optional[str]) -> Response:
3939
issue_id=path_params.issue_id, version=query_params.version
4040
)
4141

42-
if not tests_data:
42+
if not tests_data or len(tests_data) == 1 and tests_data[0].get("id") is None:
4343
return create_api_error_response(
4444
error_message=ClientStrings.ISSUE_TESTS_NOT_FOUND,
4545
status_code=HTTPStatus.OK,

dashboard/src/components/BootsTable/BootsTable.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { TableHeader } from '@/components/Table/TableHeader';
5252

5353
import { TooltipDateTime } from '@/components/TooltipDateTime';
5454
import TooltipHardware from '@/components/Table/TooltipHardware';
55+
import { EMPTY_VALUE } from '@/lib/string';
5556

5657
const defaultColumns: ColumnDef<TestByCommitHash>[] = [
5758
{
@@ -141,6 +142,10 @@ export function BootsTable({
141142
(): TTestByCommitHashResponse => ({
142143
tests: testHistory
143144
? testHistory.map((e): TestByCommitHash => {
145+
if (!e.path) {
146+
e.path = EMPTY_VALUE;
147+
}
148+
144149
return {
145150
duration: e.duration?.toString() ?? '',
146151
id: e.id,

dashboard/src/components/TestsTable/TestsTable.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { usePaginationState } from '@/hooks/usePaginationState';
4141
import type { TableKeys } from '@/utils/constants/tables';
4242
import { buildHardwareArray, buildTreeBranch } from '@/utils/table';
4343

44+
import { EMPTY_VALUE } from '@/lib/string';
45+
4446
import { IndividualTestsTable } from './IndividualTestsTable';
4547
import { defaultColumns, defaultInnerColumns } from './DefaultTestsColumns';
4648

@@ -120,6 +122,9 @@ export function TestsTable({
120122
const groups: Groups = {};
121123
if (testHistory !== undefined) {
122124
testHistory.forEach(e => {
125+
if (!e.path) {
126+
e.path = EMPTY_VALUE;
127+
}
123128
const parts = e.path.split('.', 1);
124129
const group = parts.length > 0 ? parts[0] : '-';
125130
if (!(group in groups)) {
@@ -184,7 +189,7 @@ export function TestsTable({
184189
const individualTest = test.individual_tests.filter(t => {
185190
let dataIncludesPath = true;
186191
if (isValidPath) {
187-
dataIncludesPath = t.path.includes(path);
192+
dataIncludesPath = t.path?.includes(path) ?? false;
188193
}
189194
if (dataIncludesPath) {
190195
countStatus(localGroup, t.status);

dashboard/src/types/general.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export type TPathTests = {
2121

2222
export type TIndividualTest = {
2323
id: string;
24-
path: string;
24+
path?: string;
2525
status?: Status;
26-
start_time: string;
27-
duration: string;
26+
start_time?: string;
27+
duration?: string;
2828
hardware?: string[];
2929
treeBranch?: string;
3030
};
@@ -39,9 +39,9 @@ export type TreeBranchItem = {
3939
};
4040

4141
export type TestHistory = TreeBranchItem & {
42-
start_time: string;
42+
start_time?: string;
4343
status: Status;
44-
path: string;
44+
path?: string;
4545
id: string;
4646
duration?: number;
4747
environment_compatible?: string[];

dashboard/src/types/tree/TreeDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export type TestByCommitHash = {
167167
path: string | null;
168168
status: Status;
169169
duration: string;
170-
startTime: string;
170+
startTime?: string;
171171
hardware?: string[];
172172
treeBranch?: string;
173173
};

0 commit comments

Comments
 (0)