Reland "Remove references to Observatory (#118577)" (#121606)

This reverts commit 275ab9c69b.
This commit is contained in:
Ben Konyi
2023-02-28 11:57:04 -05:00
committed by GitHub
parent 8fc499aaf0
commit ecd7518df5
90 changed files with 519 additions and 491 deletions

View File

@@ -100,18 +100,18 @@ class CoverageCollector extends TestWatcher {
/// has been run to completion so that all coverage data has been recorded.
///
/// The returned [Future] completes when the coverage is collected.
Future<void> collectCoverageIsolate(Uri observatoryUri) async {
_logMessage('collecting coverage data from $observatoryUri...');
Future<void> collectCoverageIsolate(Uri vmServiceUri) async {
_logMessage('collecting coverage data from $vmServiceUri...');
final Map<String, dynamic> data = await collect(
observatoryUri, libraryNames, branchCoverage: branchCoverage);
vmServiceUri, libraryNames, branchCoverage: branchCoverage);
_logMessage('($observatoryUri): collected coverage data; merging...');
_logMessage('($vmServiceUri): collected coverage data; merging...');
_addHitmap(await coverage.HitMap.parseJson(
data['coverage'] as List<Map<String, dynamic>>,
packagePath: packageDirectory,
checkIgnoredLines: true,
));
_logMessage('($observatoryUri): done merging coverage data into global coverage map.');
_logMessage('($vmServiceUri): done merging coverage data into global coverage map.');
}
/// Collects coverage for the given [Process] using the given `port`.
@@ -141,11 +141,11 @@ class CoverageCollector extends TestWatcher {
}
);
final Future<void> collectionComplete = testDevice.observatoryUri
.then((Uri? observatoryUri) {
_logMessage('collecting coverage data from $testDevice at $observatoryUri...');
final Future<void> collectionComplete = testDevice.vmServiceUri
.then((Uri? vmServiceUri) {
_logMessage('collecting coverage data from $testDevice at $vmServiceUri...');
return collect(
observatoryUri!, libraryNames, serviceOverride: serviceOverride,
vmServiceUri!, libraryNames, serviceOverride: serviceOverride,
branchCoverage: branchCoverage)
.then<void>((Map<String, dynamic> result) {
_logMessage('Collected coverage data.');

View File

@@ -17,10 +17,15 @@ class EventPrinter extends TestWatcher {
final TestWatcher? _parent;
@override
void handleStartedDevice(Uri? observatoryUri) {
void handleStartedDevice(Uri? vmServiceUri) {
_sendEvent('test.startedProcess',
<String, dynamic>{'observatoryUri': observatoryUri?.toString()});
_parent?.handleStartedDevice(observatoryUri);
<String, dynamic>{
'vmServiceUri': vmServiceUri?.toString(),
// TODO(bkonyi): remove references to Observatory
// See https://github.com/flutter/flutter/issues/121271
'observatoryUri': vmServiceUri?.toString()
});
_parent?.handleStartedDevice(vmServiceUri);
}
@override

View File

@@ -34,7 +34,7 @@ import 'test_time_recorder.dart';
import 'watcher.dart';
/// The address at which our WebSocket server resides and at which the sky_shell
/// processes will host the Observatory server.
/// processes will host the VmService server.
final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType, InternetAddress>{
InternetAddressType.IPv4: InternetAddress.loopbackIPv4,
InternetAddressType.IPv6: InternetAddress.loopbackIPv6,
@@ -46,13 +46,15 @@ typedef PlatformPluginRegistration = void Function(FlutterPlatform platform);
///
/// On systems where each [FlutterPlatform] is only used to run one test suite
/// (that is, one Dart file with a `*_test.dart` file name and a single `void
/// main()`), you can set an observatory port explicitly.
/// main()`), you can set a VM Service port explicitly.
FlutterPlatform installHook({
TestWrapper testWrapper = const TestWrapper(),
required String shellPath,
required DebuggingOptions debuggingOptions,
TestWatcher? watcher,
// TODO(bkonyi): remove after roll into google3.
bool enableObservatory = false,
bool enableVmService = false,
bool machine = false,
String? precompiledDillPath,
Map<String, String>? precompiledDillFiles,
@@ -68,7 +70,7 @@ FlutterPlatform installHook({
TestTimeRecorder? testTimeRecorder,
UriConverter? uriConverter,
}) {
assert(enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
assert(enableVmService || enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
// registerPlatformPlugin can be injected for testing since it's not very mock-friendly.
platformPluginRegistration ??= (FlutterPlatform platform) {
@@ -84,7 +86,7 @@ FlutterPlatform installHook({
debuggingOptions: debuggingOptions,
watcher: watcher,
machine: machine,
enableObservatory: enableObservatory,
enableVmService: enableVmService || enableObservatory,
host: _kHosts[serverType],
precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles,
@@ -276,7 +278,7 @@ class FlutterPlatform extends PlatformPlugin {
required this.shellPath,
required this.debuggingOptions,
this.watcher,
this.enableObservatory,
this.enableVmService,
this.machine,
this.host,
this.precompiledDillPath,
@@ -295,7 +297,7 @@ class FlutterPlatform extends PlatformPlugin {
final String shellPath;
final DebuggingOptions debuggingOptions;
final TestWatcher? watcher;
final bool? enableObservatory;
final bool? enableVmService;
final bool? machine;
final InternetAddress? host;
final String? precompiledDillPath;
@@ -357,7 +359,7 @@ class FlutterPlatform extends PlatformPlugin {
if (_testCount > 0) {
// Fail if there will be a port conflict.
if (debuggingOptions.hostVmServicePort != null) {
throwToolExit('installHook() was called with an observatory port or debugger mode enabled, but then more than one test suite was run.');
throwToolExit('installHook() was called with a VM Service port or debugger mode enabled, but then more than one test suite was run.');
}
// Fail if we're passing in a precompiled entry-point.
if (precompiledDillPath != null) {
@@ -424,7 +426,7 @@ class FlutterPlatform extends PlatformPlugin {
processManager: globals.processManager,
logger: globals.logger,
shellPath: shellPath,
enableObservatory: enableObservatory!,
enableVmService: enableVmService!,
machine: machine,
debuggingOptions: debuggingOptions,
host: host,
@@ -512,13 +514,13 @@ class FlutterPlatform extends PlatformPlugin {
await Future.any<void>(<Future<void>>[
testDevice.finished,
() async {
final Uri? processObservatoryUri = await testDevice.observatoryUri;
if (processObservatoryUri != null) {
globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri');
final Uri? processVmServiceUri = await testDevice.vmServiceUri;
if (processVmServiceUri != null) {
globals.printTrace('test $ourTestCount: VM Service uri is available at $processVmServiceUri');
} else {
globals.printTrace('test $ourTestCount: Observatory uri is not available');
globals.printTrace('test $ourTestCount: VM Service uri is not available');
}
watcher?.handleStartedDevice(processObservatoryUri);
watcher?.handleStartedDevice(processVmServiceUri);
final StreamChannel<String> remoteChannel = await remoteChannelFuture;
globals.printTrace('test $ourTestCount: connected to test device, now awaiting test result');

View File

@@ -36,7 +36,7 @@ class FlutterTesterTestDevice extends TestDevice {
required this.logger,
required this.shellPath,
required this.debuggingOptions,
required this.enableObservatory,
required this.enableVmService,
required this.machine,
required this.host,
required this.testAssetDirectory,
@@ -45,8 +45,8 @@ class FlutterTesterTestDevice extends TestDevice {
required this.compileExpression,
required this.fontConfigManager,
required this.uriConverter,
}) : assert(!debuggingOptions.startPaused || enableObservatory),
_gotProcessObservatoryUri = enableObservatory
}) : assert(!debuggingOptions.startPaused || enableVmService),
_gotProcessVmServiceUri = enableVmService
? Completer<Uri?>() : (Completer<Uri?>()..complete());
/// Used for logging to identify the test that is currently being executed.
@@ -57,7 +57,7 @@ class FlutterTesterTestDevice extends TestDevice {
final Logger logger;
final String shellPath;
final DebuggingOptions debuggingOptions;
final bool enableObservatory;
final bool enableVmService;
final bool? machine;
final InternetAddress? host;
final String? testAssetDirectory;
@@ -67,7 +67,7 @@ class FlutterTesterTestDevice extends TestDevice {
final FontConfigManager fontConfigManager;
final UriConverter? uriConverter;
final Completer<Uri?> _gotProcessObservatoryUri;
final Completer<Uri?> _gotProcessVmServiceUri;
final Completer<int> _exitCode = Completer<int>();
Process? _process;
@@ -89,7 +89,7 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printTrace('test $id: test harness socket server is running at port:${_server!.port}');
final List<String> command = <String>[
shellPath,
if (enableObservatory) ...<String>[
if (enableVmService) ...<String>[
// Some systems drive the _FlutterPlatform class in an unusual way, where
// only one test file is processed at a time, and the operating
// environment hands out specific ports ahead of time in a cooperative
@@ -99,12 +99,12 @@ class FlutterTesterTestDevice extends TestDevice {
//
// I mention this only so that you won't be tempted, as I was, to apply
// the obvious simplification to this code and remove this entire feature.
'--observatory-port=${debuggingOptions.enableDds ? 0 : debuggingOptions.hostVmServicePort }',
'--vm-service-port=${debuggingOptions.enableDds ? 0 : debuggingOptions.hostVmServicePort }',
if (debuggingOptions.startPaused) '--start-paused',
if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
]
else
'--disable-observatory',
'--disable-vm-service',
if (host!.type == InternetAddressType.IPv6) '--ipv6',
if (icudtlPath != null) '--icu-data-file-path=$icudtlPath',
'--enable-checked-mode',
@@ -154,11 +154,11 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printTrace('test $id: Started flutter_tester process at pid ${_process!.pid}');
// Pipe stdout and stderr from the subprocess to our printStatus console.
// We also keep track of what observatory port the engine used, if any.
// We also keep track of what VM Service port the engine used, if any.
_pipeStandardStreamsToConsole(
process: _process!,
reportObservatoryUri: (Uri detectedUri) async {
assert(!_gotProcessObservatoryUri.isCompleted);
reportVmServiceUri: (Uri detectedUri) async {
assert(!_gotProcessVmServiceUri.isCompleted);
assert(debuggingOptions.hostVmServicePort == null ||
debuggingOptions.hostVmServicePort == detectedUri.port);
@@ -194,12 +194,11 @@ class FlutterTesterTestDevice extends TestDevice {
if (debuggingOptions.startPaused && !machine!) {
logger.printStatus('The test process has been started.');
logger.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
logger.printStatus('You can now connect to it using vmService. To connect, load the following Web site in your browser:');
logger.printStatus(' $forwardingUri');
logger.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
}
_gotProcessObservatoryUri.complete(forwardingUri);
_gotProcessVmServiceUri.complete(forwardingUri);
},
);
@@ -207,8 +206,8 @@ class FlutterTesterTestDevice extends TestDevice {
}
@override
Future<Uri?> get observatoryUri {
return _gotProcessObservatoryUri.future;
Future<Uri?> get vmServiceUri {
return _gotProcessVmServiceUri.future;
}
@override
@@ -293,7 +292,7 @@ class FlutterTesterTestDevice extends TestDevice {
void _pipeStandardStreamsToConsole({
required Process process,
required Future<void> Function(Uri uri) reportObservatoryUri,
required Future<void> Function(Uri uri) reportVmServiceUri,
}) {
for (final Stream<List<int>> stream in <Stream<List<int>>>[
process.stderr,
@@ -310,9 +309,9 @@ class FlutterTesterTestDevice extends TestDevice {
if (match != null) {
try {
final Uri uri = Uri.parse(match[1]!);
await reportObservatoryUri(uri);
await reportVmServiceUri(uri);
} on Exception catch (error) {
logger.printError('Could not parse shell observatory port message: $error');
logger.printError('Could not parse shell VM Service port message: $error');
}
} else {
logger.printStatus('Shell: $line');

View File

@@ -84,7 +84,7 @@ class TestGoldenComparator {
}
final List<String> command = <String>[
shellPath!,
'--disable-observatory',
'--disable-vm-service',
'--non-interactive',
'--packages=${_fileSystem.path.join('.dart_tool', 'package_config.json')}',
output,

View File

@@ -35,7 +35,7 @@ class IntegrationTestTestDevice implements TestDevice {
ApplicationPackage? _applicationPackage;
final Completer<void> _finished = Completer<void>();
final Completer<Uri> _gotProcessObservatoryUri = Completer<Uri>();
final Completer<Uri> _gotProcessVmServiceUri = Completer<Uri>();
/// Starts the device.
///
@@ -62,19 +62,19 @@ class IntegrationTestTestDevice implements TestDevice {
if (!launchResult.started) {
throw TestDeviceException('Unable to start the app on the device.', StackTrace.current);
}
final Uri? observatoryUri = launchResult.observatoryUri;
if (observatoryUri == null) {
throw TestDeviceException('Observatory is not available on the test device.', StackTrace.current);
final Uri? vmServiceUri = launchResult.vmServiceUri;
if (vmServiceUri == null) {
throw TestDeviceException('The VM Service is not available on the test device.', StackTrace.current);
}
// No need to set up the log reader because the logs are captured and
// streamed to the package:test_core runner.
_gotProcessObservatoryUri.complete(observatoryUri);
_gotProcessVmServiceUri.complete(vmServiceUri);
globals.printTrace('test $id: Connecting to vm service');
final FlutterVmService vmService = await connectToVmService(
observatoryUri,
vmServiceUri,
logger: globals.logger,
compileExpression: compileExpression,
).timeout(
@@ -116,7 +116,7 @@ class IntegrationTestTestDevice implements TestDevice {
}
@override
Future<Uri> get observatoryUri => _gotProcessObservatoryUri.future;
Future<Uri> get vmServiceUri => _gotProcessVmServiceUri.future;
@override
Future<void> kill() async {

View File

@@ -30,7 +30,7 @@ abstract class FlutterTestRunner {
List<String> plainNames = const <String>[],
String? tags,
String? excludeTags,
bool enableObservatory = false,
bool enableVmService = false,
bool ipv6 = false,
bool machine = false,
String? precompiledDillPath,
@@ -68,7 +68,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
List<String> plainNames = const <String>[],
String? tags,
String? excludeTags,
bool enableObservatory = false,
bool enableVmService = false,
bool ipv6 = false,
bool machine = false,
String? precompiledDillPath,
@@ -197,7 +197,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
shellPath: shellPath,
debuggingOptions: debuggingOptions,
watcher: watcher,
enableObservatory: enableObservatory,
enableVmService: enableVmService,
machine: machine,
serverType: serverType,
precompiledDillPath: precompiledDillPath,

View File

@@ -21,8 +21,8 @@ abstract class TestDevice {
/// or raw source file.
Future<StreamChannel<String>> start(String entrypointPath);
/// Should complete with null if the observatory is not enabled.
Future<Uri?> get observatoryUri;
/// Should complete with null if the VM Service is not enabled.
Future<Uri?> get vmServiceUri;
/// Terminates the test device.
Future<void> kill();

View File

@@ -8,9 +8,9 @@ import 'test_device.dart';
abstract class TestWatcher {
/// Called after the test device starts.
///
/// If startPaused was true, the caller needs to resume in Observatory to
/// If startPaused was true, the caller needs to resume in DevTools to
/// start running the tests.
void handleStartedDevice(Uri? observatoryUri) { }
void handleStartedDevice(Uri? vmServiceUri) { }
/// Called after the tests finish but before the test device exits.
///