Skip to content

Commit e27ba56

Browse files
committed
feat(helper/models): Add platformfilter
Add filter that allows to restrict tests on specific platform. This feature required for proper bisection implementation, as some tests might be scheduled on multiple platforms. Rework a bit code to avoid null variables. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent ed2c354 commit e27ba56

2 files changed

Lines changed: 28 additions & 18 deletions

File tree

kernelci/api/helper.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -385,26 +385,26 @@ def create_job_node(self, job_config, input_node,
385385
runtime=None, platform=None):
386386
"""Create a new job node based on input and configuration"""
387387
jobfilter = input_node.get('jobfilter')
388+
platform_filter = input_node.get('platform_filter')
388389
treeid = input_node.get('treeid')
389390
submitter = input_node.get('submitter')
390-
try:
391-
job_node = {
392-
'kind': job_config.kind,
393-
'parent': input_node['id'],
394-
'name': job_config.name,
395-
'path': input_node['path'] + [job_config.name],
396-
'group': job_config.name,
397-
'artifacts': {},
398-
'jobfilter': jobfilter,
399-
'treeid': treeid,
400-
'submitter': submitter,
401-
'data': {
402-
'kernel_revision': input_node['data']['kernel_revision'],
403-
},
404-
}
405-
except KeyError as error:
406-
print(f"Missing key {error} in input node")
407-
return None
391+
job_node = {
392+
'kind': job_config.kind,
393+
'parent': input_node['id'],
394+
'name': job_config.name,
395+
'path': input_node['path'] + [job_config.name],
396+
'group': job_config.name,
397+
'artifacts': {},
398+
'treeid': treeid,
399+
'submitter': submitter,
400+
'data': {
401+
'kernel_revision': input_node['data']['kernel_revision'],
402+
},
403+
}
404+
if jobfilter:
405+
job_node['jobfilter'] = jobfilter
406+
if platform_filter:
407+
job_node['platform_filter'] = platform_filter
408408

409409
# if jobfilter not null, verify if job_config.name exist in jobfilter
410410
if jobfilter and job_config.name not in jobfilter:
@@ -434,7 +434,14 @@ def create_job_node(self, job_config, input_node,
434434
print(f"Not creating node {input_node['id']} due to runtime rules "
435435
f"for {runtime.config.name}")
436436
return None
437+
# Filter by platform if it is test job only
437438
if platform:
439+
# if platform_filter not null, verify if platform.name exist in platform_filter
440+
if platform_filter and platform.name not in platform_filter\
441+
and job_config.kind == 'job':
442+
print(f"Filtered: Platform {platform.name} not found in platform_filter "
443+
f"for node {input_node['id']}")
444+
return None
438445
job_node['data']['platform'] = platform.name
439446
if not self.should_create_node(platform.rules, job_node, input_node):
440447
print(f"Not creating node {input_node['id']} due to platform rules "

kernelci/api/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ class Node(DatabaseModel):
204204
jobfilter: Optional[List[str]] = Field(
205205
description="Restrict jobs that can be scheduled by this node"
206206
)
207+
platform_filter: Optional[List[str]] = Field(
208+
description="Restrict test jobs to be scheduled on specific platforms",
209+
)
207210
created: datetime = Field(
208211
default_factory=datetime.utcnow,
209212
description="Timestamp of node creation"

0 commit comments

Comments
 (0)