apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.

Home Page:https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flaky test NIOTransportServicesTests.NIOTSConnectionChannelTests testZeroLengthWritesHaveSatisfiedPromises

weissi opened this issue · comments

Expected behavior

test passes

Actual behavior

test did not pass once :)

Steps to reproduce

  1. swift test -Xswiftc -target -Xswiftc x86_64-apple-macosx10.14

SwiftNIO version/commit hash

  • swift-nio: 8d7d4cb9ca1c5e4b444f2895254a55b91e85540a
  • swift-nio-transport-services: e14a834

Swift & OS version (output of swift --version && uname -a)

$ swift -version
Apple Swift version 4.2 (swiftlang-1000.0.36 clang-1000.10.44)
Target: x86_64-apple-darwin18.0.0
$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.14
BuildVersion:	18A377a

Output

Compile CNIOSHA1 c_nio_sha1.c
Compile CNIOAtomics src/c-atomics.c
Compile CNIOLinux shim.c
Compile CNIODarwin shim.c
Compile CNIOLinux ifaddrs-android.c
Compile CNIOHTTPParser c_nio_http_parser.c
Compile CNIOZlib empty.c
Compile Swift Module 'NIOPriorityQueue' (2 sources)
Compile Swift Module 'NIOConcurrencyHelpers' (2 sources)
Compile Swift Module 'NIO' (55 sources)
Compile Swift Module 'NIOFoundationCompat' (1 sources)
Compile Swift Module 'NIOHTTP1' (9 sources)
Compile Swift Module 'NIOTLS' (3 sources)
Compile Swift Module 'NIOTransportServices' (11 sources)
/private/tmp/.nio-release-tools_wcDcXq/swift-nio-transport-services/Sources/NIOTransportServices/NIOTSListenerChannel.swift:386:9: warning: default will never be executed
        default:
        ^
/private/tmp/.nio-release-tools_wcDcXq/swift-nio-transport-services/Sources/NIOTransportServices/NIOTSConnectionChannel.swift:633:9: warning: default will never be executed
        default:
        ^
Compile Swift Module 'NIOTSHTTPServer' (1 sources)
Compile Swift Module 'NIOTSHTTPClient' (1 sources)
Compile Swift Module 'NIOTransportServicesTests' (6 sources)
Linking ./.build/x86_64-apple-macosx10.10/debug/NIOTSHTTPServer
Linking ./.build/x86_64-apple-macosx10.10/debug/NIOTSHTTPClient
Linking ./.build/x86_64-apple-macosx10.10/debug/swift-nio-transport-servicesPackageTests.xctest/Contents/MacOS/swift-nio-transport-servicesPackageTests
Test Suite 'All tests' started at 2018-10-08 6:12:31.603 pm
Test Suite 'swift-nio-transport-servicesPackageTests.xctest' started at 2018-10-08 6:12:31.603 pm
Test Suite 'NIOTSConnectionChannelTests' started at 2018-10-08 6:12:31.603 pm
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToEndpointSkipsPipeline]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToEndpointSkipsPipeline]' passed (0.090 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToHostPortSkipsPipeline]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToHostPortSkipsPipeline]' passed (0.003 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToSocketAddressTraversesPipeline]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testConnectingToSocketAddressTraversesPipeline]' passed (0.002 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testErrorsInChannelSetupAreFine]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testErrorsInChannelSetupAreFine]' passed (0.001 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingGettingReuseaddr]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingGettingReuseaddr]' passed (0.002 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingGettingReuseport]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingGettingReuseport]' passed (0.002 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingTCPOptionsWholesale]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testSettingTCPOptionsWholesale]' passed (0.003 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWatermarkSettingGetting]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWatermarkSettingGetting]' passed (0.002 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWritabilityChangesAfterChangingWatermarks]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWritabilityChangesAfterChangingWatermarks]' passed (0.002 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWritabilityChangesAfterExceedingWatermarks]' started.
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testWritabilityChangesAfterExceedingWatermarks]' passed (0.003 seconds).
Test Case '-[NIOTransportServicesTests.NIOTSConnectionChannelTests testZeroLengthWritesHaveSatisfiedPromises]' started.
Assertion failed: : file /private/tmp/.nio-release-tools_wcDcXq/swift-nio-transport-services/Sources/NIOTransportServices/NIOTSConnectionChannel.swift, line 653
Exited with signal code 4

Huh, that's an interesting assertion to have fail in that particular test:

private func dataReceivedHandler(content: Data?, context: NWConnection.ContentContext?, isComplete: Bool, error: NWError?) {
precondition(self.outstandingRead)
self.outstandingRead = false
guard self.isActive else {
// If we're already not active, we aren't going to process any of this: it's likely the result of an extra
// read somewhere along the line.
assert(content == nil)
return
}

Given that the entire point of the test is that no entity actually sends any data, I don't really understand how the data received handler can be firing with a non-nil content. I'm struggling to reproduce this, and without a repro scenario I simply cannot see any way to produce this failure mode. So I think we'll have to sit on this for a while.

@Lukasa maybe we should put content into the assertion message?

Not reproduced since.