Skip to content

Backport metrics + DotNetty test stabilizations to v1.5 (#7798, #8273) - #8298

Merged
Aaronontheweb merged 2 commits into
akkadotnet:v1.5from
Aaronontheweb:backport/v1.5-metrics-dotnetty-test-stabilization
Jul 2, 2026
Merged

Aaronontheweb merged 2 commits into
akkadotnet:v1.5from
Aaronontheweb:backport/v1.5-metrics-dotnetty-test-stabilization

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Backport: test-stability fixes to v1.5 (#7798, #8273)

These are test-only flaky-test backports. Both fixes already landed on dev but were never on v1.5, so the flaky specs continue to fail intermittently on v1.5 PR CI (e.g. seen on #8294). This PR brings them over as two individual cherry-picks (with -x provenance), in chronological order.

What each PR stabilizes

Backported PR dev commit Files touched Stabilizes
#7798 — Fix metrics specs race conditions 3abeec261 (2025-09-04) Akka.Cluster.Metrics.Tests/Base/AkkaSpecWithCollector.cs, MetricSpec.cs, MetricsCollectorSpec.cs MetricValuesSpec.NodeMetrics_MetricValues_should_extract_expected_metrics_for_load_balancing and ..._expected_MetricValue_types_for_load_balancing — replaces the live-collector CreateTestData(202, 10.Seconds(), ...) sampling (which required ~10s of real system metrics and could deadlock/flake in CI) with deterministic CreateTestMetrics() / CreateTestMetricsVariation(), and makes MetricValuesSpec independent of the AkkaSpecWithCollector base. Also adds retry/backoff + longer timeouts to the remaining live-collector paths (CreateTestDataAsync, MetricsCollectorSpec).
#8273 — prevent ephemeral-port overflow b9f263c0f (2026-06-16) Akka.Remote.Tests/Transport/DotNettyTransportShutdownSpec.cs DotNettyTcpTransport_should_cleanly_terminate_endpoints_upon_failed_outbound_connection (Windows-only flake). Clamps the "dead port" target so boundPort + 100 can't exceed IPEndPoint.MaxPort (65535) when the OS assigns a high ephemeral port on Windows.

Hand-porting

None required. Both commits cherry-picked cleanly onto v1.5 — the touched regions on v1.5 were byte-for-byte identical to the dev pre-fix state. (The metrics test project builds against Akka.TestKit.Xunit on v1.5; the ported code compiles against it without changes, so no xUnit-namespace adaptation was needed.)

Local validation (net10.0, Linux)

  • MetricValuesSpec + MetricsCollectorSpec: Passed — 5/5 (~7s).
  • DotNettyTcpTransport_should_cleanly_terminate_endpoints_upon_failed_outbound_connection: Passed — 1/1 (~0.4s; it was a Windows-only flake, so it passes on Linux and now also can't overflow).
  • Both touched test projects build clean.

Scope

This PR is separate from #8294 (the #8031 consistent-hashing fix) and #8296 (an earlier flaky-test backport) — it does not touch those branches or their commits.

Aaronontheweb and others added 2 commits July 2, 2026 17:39
…et#7798)

- Fix MetricsCollectorSpec with platform-aware retry logic and progressive backoff
- Fix MetricValuesSpec using IAsyncLifetime pattern to avoid constructor deadlocks
- Add comprehensive timeout handling and exception recovery for CI environments
- Optimize test data generation to use single sample instead of 202 real samples
- Increase timeouts from 30s to 60s for DefaultCollector initialization timing

(cherry picked from commit 3abeec2)
…akkadotnet#8273)

DotNettyTcpTransport_should_cleanly_terminate_endpoints_upon_failed_outbound_connection
bound to port 0 (OS-assigned ephemeral) and targeted boundPort + 100 to force a
connect failure. On Windows the dynamic port range tops out at 65535, so when the
OS assigned a port in [65436, 65535], boundPort + 100 exceeded IPEndPoint.MaxPort
and the IPEndPoint ctor in AddressToSocketAddress threw ArgumentOutOfRangeException
before the connect, escaping the InvalidAssociationException assertion. Linux's
default ephemeral range caps below that band, so it only flaked on Windows.

Offset the dead port down when near the top of the range so it always stays within
0-65535 while still pointing at a port where nothing is listening.

(cherry picked from commit b9f263c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant