Skip to content

Fix flaky endpoint tests and misleading core backtraces - #3599

Open
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_endpoint_unittest
Open

chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:fix_endpoint_unittest

Conversation

@chenBright

@chenBright chenBright commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Problem Summary:

EndPointTest.tcp_connect and EndPointTest.interrupt depended on public hosts
and network timing, causing intermittent CI failures. After an assertion
failure, the test runner could symbolize a core left by a passing death-test
child, making the failure appear to be a crash.

Observed in this CI run.

What is changed and the side effects?

Changed:

  • Replace public hosts with loopback listeners using dynamically assigned ports.
  • Verify successful connections and preservation of blocking and nonblocking
    socket modes, with and without connection deadlines.
  • Use empty pipes to test wait timeouts and successful wait completion while
    delivering signals, restoring the previous SIGURG handler afterward.
  • Clear stale cores between test binaries and symbolize only a core matching
    the failed test process's PID. Accept core.%e.%p (the CI format) and core.%p.
  • Preserve the test process's standard input and original exit status, and
    quote the program path passed to gdb.

Side effects:

  • Performance effects: No production library changes. The affected tests no
    longer depend on public network access or TCP accept-queue capacity.
  • Breaking backward compatibility: No library API or behavior changes.
    Core symbolization requires a filename containing the failed process's PID.

Check List:

  • Compiles with CMake and unit tests enabled on macOS.
  • All 21 EndPoint tests pass for 100 iterations in shuffled order.
  • All 51 shell regression checks pass across sh, bash, and dash, including
    filenames with spaces, parent/child core selection, exit status, and stdin.
  • Follow the Contributor Covenant Code of Conduct.

@chenBright
chenBright requested a lite review from Copilot October 12, 2026 09:50

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

6 open findings
What changed in this PR

This PR reduces endpoint test flakiness by removing dependencies on public hosts/network latency, and improves CI failure diagnostics by avoiding misleading backtraces from unrelated core files.

Changes:

  • Rework EndPointTest.tcp_connect/interrupt to use loopback listeners, deterministic timeouts, and EINTR retry validation.
  • Add Linux-only coverage for connect timeouts with a full accept queue.
  • Update test runner backtrace printing to trigger only on signal-based exits.
File Description
test/​run_tests.sh Only print core backtraces for signal exits to avoid misleading output from death-test cores.
test/​endpoint_unittest.cpp Replace public-host networking with local listeners; add deterministic timeout + EINTR behavior tests.

🧠 Review effort: Lite


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

Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/run_tests.sh Outdated

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.

Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/run_tests.sh
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from b9e4341 to 123e43f Compare October 12, 2026 12:13
@chenBright
chenBright requested a lite review from Copilot October 12, 2026 12:14

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.

Comment thread test/run_tests.sh Outdated
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp Outdated

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.

Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh Outdated
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from 05389e9 to 0c0b5c8 Compare October 12, 2026 15:41
@chenBright
chenBright requested a lite review from Copilot October 12, 2026 15:57

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.

Comment thread src/butil/endpoint.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/run_tests.sh Outdated

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.

Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh Outdated
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from 056d860 to 7032b63 Compare October 13, 2026 07:06
@chenBright
chenBright requested a lite review from Copilot October 13, 2026 07:35

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
2 resolved since last review

🧠 Review effort: Lite

Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread src/butil/endpoint.cpp Outdated
Comment thread test/run_tests.sh Outdated
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from 7032b63 to 8f1ccd4 Compare October 13, 2026 08:28
@chenBright
chenBright requested a lite review from Copilot October 13, 2026 10:07

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

10 open findings
4 resolved since last review

🧠 Review effort: Lite

Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp Outdated
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh
Comment thread test/run_tests.sh Outdated
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from 8f1ccd4 to 970a66f Compare October 13, 2026 11:55
@chenBright
chenBright requested a lite review from Copilot October 13, 2026 13:56

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
10 resolved since last review

🧠 Review effort: Lite

Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh
Comment thread test/endpoint_unittest.cpp Outdated

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.

Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh Outdated

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.

Comment thread test/endpoint_unittest.cpp
Comment thread test/endpoint_unittest.cpp
Comment thread test/run_tests.sh Outdated
Comment thread test/run_tests.sh
Comment thread test/run_tests.sh
@chenBright
chenBright force-pushed the fix_endpoint_unittest branch from c388265 to 62e5667 Compare October 14, 2026 05:26
@chenBright

Copy link
Copy Markdown
Contributor Author

I believe this PR is ready for a final human review. I’ve evaluated the Copilot feedback and fixed the confirmed issues. The remaining comments concern existing API design, stylistic preferences, or assumptions that do not apply to these changes.

The changes are limited to tests and the test runner, with no production code changes. The build, endpoint tests, and shell regression checks have passed.

@wwbmmm PTAL.

@chenBright
chenBright requested a review from wwbmmm October 14, 2026 05:27
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.

2 participants