11# SPDX-License-Identifier: Apache-2.0
22#
33# Copyright (C) 2026 Collabora Limited
4+ # pylint: disable=protected-access
45# Author: Denys Fedoryshchenko <denys.f@collabora.com>
56
67"""Unit tests for pull_labs_poller (no network, no AWS)."""
78
89import json
910import logging
1011import os
11- import tempfile
1212import urllib .error
1313from unittest .mock import patch
1414
@@ -626,14 +626,16 @@ class TestProcessEventNodeResult:
626626 def _run (self , poller , event , translate = None ):
627627 translate = translate or {"return_value" : {}}
628628 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 = {}):
629+ with (
630+ patch .object (poller , "_claim_node" , return_value = True ),
631+ patch .object (
632+ poller , "_finish_node" ,
633+ side_effect = lambda nid , outcome : captured .update (outcome = outcome ),
634+ ),
635+ patch (_GET , return_value = {"artifacts" : {}}),
636+ patch ("kernel_ci_cloud_labs.pull_labs_poller.translate_job" ,
637+ ** translate ),
638+ ):
637639 poller .process_event (event )
638640 return captured ["outcome" ]
639641
@@ -682,9 +684,10 @@ def test_translate_failure_finishes_invalid_job_params(self):
682684 assert "missing artifacts.kernel" in outcome .error_msg
683685
684686 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)."""
687+ """When executor returns per-instance rows with log_url, the node
688+ outcome must carry those URLs in artifacts.test_log (first URL) and
689+ test_log_N (subsequent URLs), and the node result must reflect the
690+ aggregated per-instance statuses."""
688691 per_test = [
689692 {"name" : "boot" , "status" : "PASS" , "instance_id" : "i-aaaa1111" ,
690693 "log_url" : "https://b.s3.eu-west-1.amazonaws.com/a.log" },
@@ -695,31 +698,15 @@ def test_per_instance_rows_carry_log_url_and_stable_test_id(self):
695698 _minimal_kc (),
696699 job_executor = lambda cfg : (per_test , None ),
697700 )
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" ] == \
701+ outcome = self ._run (p , _job_event (node_id = "ndX" ))
702+
703+ # One FAIL among results -> overall node result is "fail".
704+ assert outcome .result == "fail"
705+ # Log URLs are attached to the outcome artifacts for send_kcidb.
706+ assert outcome .artifacts ["test_log" ] == \
717707 "https://b.s3.eu-west-1.amazonaws.com/a.log"
718- assert by_id [ "pullab_cloud_aws:ndX.i-bbbb2222" ][ "log_url " ] == \
708+ assert outcome . artifacts [ "test_log_1 " ] == \
719709 "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.
723710 # (one fail among two -> fail; verified indirectly via existing tests).
724711
725712
0 commit comments