Fix UDP port 9100 test race; correct CompositeDiscoveryService design doc
FIX 1 — UDP 9100 binding race: SprtDiscoveryServiceTests and
CompositeDiscoveryServiceTests both use exclusive UDP 9100 binds. xunit
runs test classes concurrently by default, causing the tests to fail
intermittently with AddressAlreadyInUse. Add [Collection("udp-9100")]
attribute to both classes so they run serially instead.
FIX 2 — Design doc: CompositeDiscoveryService does NOT forward the callback
down to children; it raises the caller's callback itself after all children
finish, once per unique IP. Rewrite the relevant sentence to describe the
real behavior.
Verify: 30 tests pass (x2), build clean, no production code touched.
Claude-Session: https://claude.ai/code/session_01E6N3P4nSZLtp4BC2LXVref
This commit is contained in:
@@ -2,6 +2,7 @@ using Inspectron.Epson;
|
||||
|
||||
namespace Inspectron.Epson.Tests;
|
||||
|
||||
[Collection("udp-9100")]
|
||||
public class CompositeDiscoveryServiceTests
|
||||
{
|
||||
private sealed class StubDiscovery : IDiscoveryService
|
||||
|
||||
@@ -3,6 +3,7 @@ using Inspectron.Epson;
|
||||
|
||||
namespace Inspectron.Epson.Tests;
|
||||
|
||||
[Collection("udp-9100")]
|
||||
public class SprtDiscoveryServiceTests
|
||||
{
|
||||
// The exact 39 bytes the printer returned on the bench:
|
||||
|
||||
@@ -67,7 +67,9 @@ this service.
|
||||
|
||||
**`CompositeDiscoveryService`** - takes `IEnumerable<IDiscoveryService>`, runs
|
||||
them concurrently on the shared timeout, merges results by `IPAddress` with
|
||||
first-wins, and forwards each child's `onPrinterDiscovered` callback as it fires.
|
||||
first-wins. It does not pass the `onPrinterDiscovered` callback to its children;
|
||||
instead, it raises the caller's callback itself after all children finish,
|
||||
once per unique IP, so a printer answering two discovery protocols notifies only once.
|
||||
It absorbs a single child's failure (logs it, keeps the other children's
|
||||
results) but rethrows when every child fails, since that means discovery
|
||||
itself is broken rather than that the network simply has no printers on it.
|
||||
|
||||
Reference in New Issue
Block a user