Skip to content

Commit e961b78

Browse files
committed
fix: resolve flake8 lint errors
- cli.py: remove empty f-string, wrap long line - artifacts.py: remove trailing blank line - pull_labs_poller.py: remove unused submit_tests import - test_kcidb_submit.py: add blank lines before nested definitions - test_pull_labs_poller.py: remove unused tempfile import, fix over-indented continuation lines, rewrite test to not patch the removed submit_tests symbol - test_pull_labs_translate.py: remove unused DEFAULT_TEST_TYPE_MAP import Signed-off-by: Norbert Manthey <nmanthey@amazon.de>
1 parent 80af593 commit e961b78

7 files changed

Lines changed: 29 additions & 41 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ analysis/data/
5959

6060
# Distribution archives
6161
share/
62+
test-nested.json

src/kernel_ci_cloud_labs/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ def main():
292292
val_parser.add_argument("--bucket", help="S3 bucket to verify (and create with --fix)")
293293
val_parser.add_argument("--role", help="IAM role name used by VM instance profiles")
294294
val_parser.add_argument("--region", default="us-west-2", help="AWS region (default: us-west-2)")
295-
val_parser.add_argument("--api-url", help=f"KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296-
val_parser.add_argument("--fix", action="store_true", help="Create missing resources (S3 bucket) instead of just reporting them")
295+
val_parser.add_argument("--api-url", help="KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296+
val_parser.add_argument(
297+
"--fix", action="store_true",
298+
help="Create missing resources (S3 bucket) instead of just reporting them",
299+
)
297300
val_parser.set_defaults(func=cmd_setup_validate)
298301

299302
args = parser.parse_args()

src/kernel_ci_cloud_labs/core/artifacts.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,3 @@ def collect_run_artifacts(
262262
manifest_path,
263263
)
264264
return manifest
265-
266-

src/kernel_ci_cloud_labs/pull_labs_poller.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
from kernel_ci_cloud_labs.kcidb_submit import (
4747
build_test_row,
48-
submit_tests,
4948
to_kcidb_status,
5049
)
5150
from kernel_ci_cloud_labs.pull_labs_translate import translate_job

tests/test_kcidb_submit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ def test_submit_revision_posts_with_bearer_auth(self):
187187
class FakeResp:
188188
def __enter__(self):
189189
return self
190+
190191
def __exit__(self, *a):
191192
return False
193+
192194
def read(self):
193195
return b'{"status":"ok","id":"sub-1"}'
194196

tests/test_pull_labs_poller.py

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import json
99
import logging
1010
import os
11-
import tempfile
1211
import urllib.error
1312
from unittest.mock import patch
1413

@@ -626,14 +625,16 @@ class TestProcessEventNodeResult:
626625
def _run(self, poller, event, translate=None):
627626
translate = translate or {"return_value": {}}
628627
captured = {}
629-
with patch.object(poller, "_claim_node", return_value=True), \
630-
patch.object(
631-
poller, "_finish_node",
632-
side_effect=lambda nid, outcome: captured.update(outcome=outcome),
633-
), \
634-
patch(_GET, return_value={"artifacts": {}}), \
635-
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job", **translate), \
636-
patch("kernel_ci_cloud_labs.pull_labs_poller.submit_tests", return_value={}):
628+
with (
629+
patch.object(poller, "_claim_node", return_value=True),
630+
patch.object(
631+
poller, "_finish_node",
632+
side_effect=lambda nid, outcome: captured.update(outcome=outcome),
633+
),
634+
patch(_GET, return_value={"artifacts": {}}),
635+
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job",
636+
**translate),
637+
):
637638
poller.process_event(event)
638639
return captured["outcome"]
639640

@@ -682,9 +683,10 @@ def test_translate_failure_finishes_invalid_job_params(self):
682683
assert "missing artifacts.kernel" in outcome.error_msg
683684

684685
def test_per_instance_rows_carry_log_url_and_stable_test_id(self):
685-
"""When executor returns per-instance rows with log_url, the submitted
686-
KCIDB rows must each carry that URL and a test_id derived from the
687-
instance_id (not the positional index)."""
686+
"""When executor returns per-instance rows with log_url, the node
687+
outcome must carry those URLs in artifacts.test_log (first URL) and
688+
test_log_N (subsequent URLs), and the node result must reflect the
689+
aggregated per-instance statuses."""
688690
per_test = [
689691
{"name": "boot", "status": "PASS", "instance_id": "i-aaaa1111",
690692
"log_url": "https://b.s3.eu-west-1.amazonaws.com/a.log"},
@@ -695,31 +697,15 @@ def test_per_instance_rows_carry_log_url_and_stable_test_id(self):
695697
_minimal_kc(),
696698
job_executor=lambda cfg: (per_test, None),
697699
)
698-
seen = {}
699-
with patch.object(p, "_claim_node", return_value=True), \
700-
patch.object(p, "_finish_node"), \
701-
patch(_GET, return_value={"artifacts": {}}), \
702-
patch("kernel_ci_cloud_labs.pull_labs_poller.translate_job",
703-
return_value={}), \
704-
patch(
705-
"kernel_ci_cloud_labs.pull_labs_poller.submit_tests",
706-
side_effect=lambda url, jwt, origin, build_id, rows: seen.update(rows=rows),
707-
):
708-
p.process_event(_job_event(node_id="ndX"))
709-
710-
rows = seen["rows"]
711-
assert len(rows) == 2
712-
by_id = {r["id"]: r for r in rows}
713-
# test_id derived from instance_id => stable across retries.
714-
assert set(by_id) == {"pullab_cloud_aws:ndX.i-aaaa1111", "pullab_cloud_aws:ndX.i-bbbb2222"}
715-
# Per-row log_url survives the build_test_row pass-through.
716-
assert by_id["pullab_cloud_aws:ndX.i-aaaa1111"]["log_url"] == \
700+
outcome = self._run(p, _job_event(node_id="ndX"))
701+
702+
# One FAIL among results -> overall node result is "fail".
703+
assert outcome.result == "fail"
704+
# Log URLs are attached to the outcome artifacts for send_kcidb.
705+
assert outcome.artifacts["test_log"] == \
717706
"https://b.s3.eu-west-1.amazonaws.com/a.log"
718-
assert by_id["pullab_cloud_aws:ndX.i-bbbb2222"]["log_url"] == \
707+
assert outcome.artifacts["test_log_1"] == \
719708
"https://b.s3.eu-west-1.amazonaws.com/b.log"
720-
# instance_id surfaces in misc for traceability.
721-
assert by_id["pullab_cloud_aws:ndX.i-aaaa1111"]["misc"]["instance_id"] == "i-aaaa1111"
722-
# Aggregated node outcome from per-instance statuses.
723709
# (one fail among two -> fail; verified indirectly via existing tests).
724710

725711

tests/test_pull_labs_translate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from kernel_ci_cloud_labs.pull_labs_translate import (
1111
DEFAULT_PLATFORM_MAP,
12-
DEFAULT_TEST_TYPE_MAP,
1312
translate_job,
1413
)
1514

0 commit comments

Comments
 (0)