Skip to content

Process: add wait_line and fix delta_only buffer offset - #4654

Open
mcgov (mcgov) wants to merge 3 commits into
mainfrom
mcgov/stack-1-process-wait-line
Open

Process: add wait_line and fix delta_only buffer offset#4654
mcgov (mcgov) wants to merge 3 commits into
mainfrom
mcgov/stack-1-process-wait-line

Conversation

@mcgov

Copy link
Copy Markdown
Collaborator

Part 1 of 9 of a stacked series that reworks the DPDK SRIOV hot plug tests. This one only touches lisa/util/process.py.

  • Add Process.wait_line, which consumes captured output line by line and hands each complete line to a caller supplied predicate, so tests can match on structured content (for example all key=value pairs of a uevent line) instead of the single substring search wait_output does.
  • Fix wait_output's delta_only bookkeeping. The offset was advanced to the end of the whole buffer on a match, so any output that arrived after the matched keyword was skipped by the next call. It now advances to the end of the matched keyword, and on timeout uses the length of the last buffer that was actually searched.

Key Test Cases:
verify_dpdk_sriov_rescind_failover_send_only|verify_dpdk_build_netvsc|smoke_test

Impacted LISA Features:
Sriov, NetworkInterface, SerialConsole

Tested Azure Marketplace Images:

  • canonical 0001-com-ubuntu-server-jammy 22_04-lts latest

Add Process.wait_line, which consumes captured output line by line and
hands each complete line to a caller supplied predicate. This allows
matching on structured content (for example all key=value pairs of a
uevent line) instead of the single substring search wait_output does.

Also fix wait_output's delta_only bookkeeping: the offset was advanced
to the end of the buffer on a match, so output that arrived after the
matched keyword was skipped by the next call. Advance it to the end of
the matched keyword instead, and on timeout use the length of the last
buffer that was actually searched.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 5d5f58ad-b9df-4420-ad37-22caee78e925

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a line-oriented waiting helper to Process and adjusts wait_output(delta_only=...) offset bookkeeping to better support incremental consumption of process output (used by the DPDK SRIOV hot-plug test rework).

Changes:

  • Added Process.wait_line(...) to consume captured output by complete lines and evaluate a caller-supplied predicate per line.
  • Updated Process.wait_output(...) delta_only offset advancement to move to the end of the matched keyword (and track the last searched buffer length for timeouts).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lisa/util/process.py
Comment thread lisa/util/process.py
Comment thread lisa/util/process.py Outdated
@LiliDeng

Copy link
Copy Markdown
Collaborator

AI Test Case Selection

Selected 1 test case(s): smoke_test

Marketplace image: canonical 0001-com-ubuntu-server-jammy 22_04-lts-gen2 latest

Result: Succeeded

View full logs in Azure DevOps

Add log line change for stdout -> 'output'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mcgov <6216084+mcgov@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

lisa/util/process.py:646

  • wait_output calls self.log_buffer.getvalue() twice per loop iteration (once for find() and once for len()). If new output is appended between those calls, last_search_len can become longer than the buffer that was actually searched, so on timeout log_buffer_offset may skip over output that was never searched (reintroducing the delta_only bug this PR is trying to fix). Capture the buffer once and use it for both operations.
            find_pos = self.log_buffer_offset if delta_only else 0
            buffer = self.log_buffer.getvalue()
            found_at_index = buffer.find(keyword, find_pos)

lisa/util/process.py:611

  • wait_line only evaluates complete newline-terminated lines. If the process exits without emitting a trailing newline, any remaining output after the last \n is never checked against the predicate, so a valid final line can be missed. Consider treating the remaining buffered text as a final line once the process is no longer running.
            if not is_running:
                # the process ended, and its remaining output is consumed.
                break

Copilot AI review requested due to automatic review settings August 12, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants