Skip to content

Commit

Permalink
feat(helper/models): Add platformfilter
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nuclearcat committed Oct 14, 2024
1 parent ed2c354 commit f254a7e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
41 changes: 23 additions & 18 deletions kernelci/api/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,26 +385,26 @@ def create_job_node(self, job_config, input_node,
runtime=None, platform=None):
"""Create a new job node based on input and configuration"""
jobfilter = input_node.get('jobfilter')
platform_filter = input_node.get('platformfilter')
treeid = input_node.get('treeid')
submitter = input_node.get('submitter')
try:
job_node = {
'kind': job_config.kind,
'parent': input_node['id'],
'name': job_config.name,
'path': input_node['path'] + [job_config.name],
'group': job_config.name,
'artifacts': {},
'jobfilter': jobfilter,
'treeid': treeid,
'submitter': submitter,
'data': {
'kernel_revision': input_node['data']['kernel_revision'],
},
}
except KeyError as error:
print(f"Missing key {error} in input node")
return None
job_node = {
'kind': job_config.kind,
'parent': input_node['id'],
'name': job_config.name,
'path': input_node['path'] + [job_config.name],
'group': job_config.name,
'artifacts': {},
'treeid': treeid,
'submitter': submitter,
'data': {
'kernel_revision': input_node['data']['kernel_revision'],
},
}
if jobfilter:
job_node['jobfilter'] = jobfilter
if platform_filter:
job_node['platformfilter'] = platform_filter

# if jobfilter not null, verify if job_config.name exist in jobfilter
if jobfilter and job_config.name not in jobfilter:
Expand Down Expand Up @@ -435,6 +435,11 @@ def create_job_node(self, job_config, input_node,
f"for {runtime.config.name}")
return None
if platform:
# if platformfilter not null, verify if platform.name exist in platformfilter
if platform_filter and platform.name not in platform_filter:
print(f"Filtered: Platform {platform.name} not found in platformfilter "
f"for node {input_node['id']}")
return None
job_node['data']['platform'] = platform.name
if not self.should_create_node(platform.rules, job_node, input_node):
print(f"Not creating node {input_node['id']} due to platform rules "
Expand Down
4 changes: 4 additions & 0 deletions kernelci/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class Node(DatabaseModel):
jobfilter: Optional[List[str]] = Field(
description="Restrict jobs that can be scheduled by this node"
)
platform_filter: Optional[List[str]] = Field(
description="Restrict test jobs to be scheduled on specific platforms",
alias='platformfilter'
)
created: datetime = Field(
default_factory=datetime.utcnow,
description="Timestamp of node creation"
Expand Down

0 comments on commit f254a7e

Please sign in to comment.