diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8f205dd..96b4d7e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -209,9 +209,7 @@ jobs: FLUTTER: flutter SUITES: dart QLOGDIR: ${{ runner.temp }}/qlog/dart - # DEBUG -v: flutter test once launched the app and then waited 13 minutes without connecting to it; verbose - # output shows what it waits on. - run: ./run_integration_tests.sh ios "${{ steps.simulator.outputs.udid }}" -v + run: ./run_integration_tests.sh ios "${{ steps.simulator.outputs.udid }}" - name: Upload logs if: always() timeout-minutes: 2 @@ -354,8 +352,7 @@ jobs: env: FLUTTER: flutter SUITES: dart - # DEBUG -v: shows what flutter test waits on when it doesn't connect to the app (see Record logcat). - run: ./run_integration_tests.sh android emulator-5554 -v + run: ./run_integration_tests.sh android emulator-5554 # Runs after a failed Dart suite too, but not when the emulator never came up. - name: Native bridge tests (instrumented) if: ${{ !cancelled() && steps.emulator.outcome == 'success' }} diff --git a/android/src/androidTest/kotlin/com/agtonomy/connect_native_http/CronetBridgeTest.kt b/android/src/androidTest/kotlin/com/agtonomy/connect_native_http/CronetBridgeTest.kt index d7a6d3d..8aba6e4 100644 --- a/android/src/androidTest/kotlin/com/agtonomy/connect_native_http/CronetBridgeTest.kt +++ b/android/src/androidTest/kotlin/com/agtonomy/connect_native_http/CronetBridgeTest.kt @@ -89,8 +89,10 @@ class CronetBridgeTest { )) } + // Each case opens a fresh connection to the host through the emulator, which once took 3 s to come up on CI (the + // request reached the server just as a 3 s wait gave up). 10 s, like the Dart cases, still fails a real hang fast. private fun await(callId: Int, vararg types: String): Map { - val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(3) + val deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(10) while (true) { events.firstOrNull { it["callId"] == callId && it["type"] in types }?.let { return it } val left = deadline - System.nanoTime() diff --git a/example/integration_test/eliza_test.dart b/example/integration_test/eliza_test.dart index 1a581bd..c41cadc 100644 --- a/example/integration_test/eliza_test.dart +++ b/example/integration_test/eliza_test.dart @@ -141,19 +141,34 @@ void main() { // on the same CI runner are both slow (a QUIC connection took 66 ms to set up, and the server answered its first // packet 130 ms after it was sent), so the first call's QUIC attempt loses URLSession's race to TCP. The cases then // start on a warm app and server. The protocol it got is logged, not checked. + // + // A few attempts, each on a fresh client whose call a deadline cancels: on a freshly booted simulator, trustd can + // stall every certificate check for a while (once while it updated its pinning database from a trust data update). + // Three 8 s attempts stay inside the test framework's 30 s default timeout. setUpAll(() async { if (serverUrl.isEmpty) { return; // setUp reports it. } - final warmup = await Harness.create(serverUrl, http3Origins: {Uri.parse(serverUrl)}); - try { - await warmup.eliza - .say(SayRequest(sentence: 'warm up'), onHeader: warmup.recordHeaders) - .timeout(const Duration(seconds: 10)); - debugPrint('warm-up call went over ${warmup.serverProtocols.single}'); - } finally { - await warmup.native.close(); + const attempts = 3; + final errors = []; + for (var attempt = 1; attempt <= attempts; attempt++) { + final warmup = await Harness.create(serverUrl, http3Origins: {Uri.parse(serverUrl)}); + try { + await warmup.eliza.say( + SayRequest(sentence: 'warm up'), + signal: TimeoutSignal(const Duration(seconds: 8)), + onHeader: warmup.recordHeaders, + ); + debugPrint('warm-up call $attempt went over ${warmup.serverProtocols.single}'); + return; + } on ConnectException catch (e) { + debugPrint('warm-up call $attempt failed: $e'); + errors.add(e); + } finally { + await warmup.native.close(); + } } + fail('no warm-up call succeeded in $attempts attempts: $errors'); }); setUp(() async {