flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.59k stars 327 forks source link

flaky-test: inspector_controller_test teardown. #323

Closed jacob314 closed 3 weeks ago

jacob314 commented 5 years ago

It appears the final teardown call can sometimes flake causing test failures. Potentially this is related to the tests performing a hot restart exposing an edge case in ServiceExtensionManager.

01:15 +23 -1: test/inspector_controller_test.dart: inspector controller tests initial state [E]
  Bad state: StreamSink is closed
  dart:_http                                           _WebSocketImpl.add
  package:vm_service_lib/vm_service_lib_io.dart 24:53  vmServiceConnectUri.<fn>
  package:vm_service_lib/vm_service_lib.dart 784:5     VmService._call
  package:vm_service_lib/vm_service_lib.dart 757:14    VmService.callServiceExtension
  package:devtools/src/vm_service_wrapper.dart 72:36   VmServiceWrapper.callServiceExtension
  package:devtools/src/service_manager.dart 494:37     ServiceExtensionManager._restoreExtensionFromDevice
  ===== asynchronous gap ===========================
  dart:async                                           _AsyncAwaitCompleter.completeError
  package:devtools/src/service_manager.dart            ServiceExtensionManager._restoreExtensionFromDevice
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  package:devtools/src/service_manager.dart            ServiceExtensionManager._onFrameEventReceived
  package:devtools/src/service_manager.dart 366:15     ServiceExtensionManager._handleExtensionEvent
  ===== asynchronous gap ===========================
  dart:async                                           _StreamImpl.listen
  package:devtools/src/service_manager.dart 167:10     ServiceConnectionManager.vmServiceOpened
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  package:devtools/src/service_manager.dart            ServiceConnectionManager.vmServiceOpened
  test/support/flutter_test_environment.dart 73:28     FlutterTestEnvironment.setupEnvironment
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  test/support/flutter_test_environment.dart           FlutterTestEnvironment.setupEnvironment
  test/inspector_controller_test.dart 337:17           main.<fn>.<fn>

  This test failed after it had already completed. Make sure to use [expectAsync]
  or the [completes] matcher when testing async code.
  dart:_http                                           _WebSocketImpl.add
  package:vm_service_lib/vm_service_lib_io.dart 24:53  vmServiceConnectUri.<fn>
  package:vm_service_lib/vm_service_lib.dart 784:5     VmService._call
  package:vm_service_lib/vm_service_lib.dart 757:14    VmService.callServiceExtension
  package:devtools/src/vm_service_wrapper.dart 72:36   VmServiceWrapper.callServiceExtension
  package:devtools/src/service_manager.dart 494:37     ServiceExtensionManager._restoreExtensionFromDevice
  ===== asynchronous gap ===========================
  dart:async                                           _AsyncAwaitCompleter.completeError
  package:devtools/src/service_manager.dart            ServiceExtensionManager._restoreExtensionFromDevice
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  package:devtools/src/service_manager.dart            ServiceExtensionManager._onFrameEventReceived
  package:devtools/src/service_manager.dart 366:15     ServiceExtensionManager._handleExtensionEvent
  ===== asynchronous gap ===========================
  dart:async                                           _StreamImpl.listen
  package:devtools/src/service_manager.dart 167:10     ServiceConnectionManager.vmServiceOpened
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  package:devtools/src/service_manager.dart            ServiceConnectionManager.vmServiceOpened
  test/support/flutter_test_environment.dart 73:28     FlutterTestEnvironment.setupEnvironment
  ===== asynchronous gap ===========================
  dart:async                                           _asyncThenWrapperHelper
  test/support/flutter_test_environment.dart           FlutterTestEnvironment.setupEnvironment
  test/inspector_controller_test.dart 337:17           main.<fn>.<fn>
DanTup commented 5 years ago

I think the inspector controller tests hotReload test itself is flaky, not just the teardown:

01:15 +21: test/inspector_controller_test.dart: inspector controller tests hotReload
05:15 +21 -1: test/inspector_controller_test.dart: inspector controller tests hotReload [E]
  TimeoutException after 0:04:00.000000: Test timed out after 4 minutes.
  package:test_api  Invoker._onRun.<fn>.<fn>.<fn>

05:15 +21 -1: test/inspector_controller_test.dart: inspector controller tests (tearDownAll)
09:15 +21 -2: test/inspector_controller_test.dart: inspector controller tests (tearDownAll) [E]
  TimeoutException after 0:04:00.000000: Test timed out after 4 minutes.
  package:test_api  Invoker._onRun.<fn>.<fn>.<fn>

https://travis-ci.org/flutter/devtools/jobs/506188399#L786

I'll take a look at this.