37ed87b038
Port the service tests and Observatory to Dart 3. Change-Id: I8a8b20d8f90acd3b5f741c93f10ba99971aa0c52 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154825 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:observatory/service_io.dart';
|
|
import 'package:test/test.dart';
|
|
import 'test_helper.dart';
|
|
|
|
import 'dart:developer';
|
|
|
|
void script() {
|
|
var counter = new Counter('a.b.c', 'description');
|
|
Metrics.register(counter);
|
|
counter.value = 1234.5;
|
|
}
|
|
|
|
var tests = <IsolateTest>[
|
|
(Isolate isolate) async {
|
|
Map metrics = await isolate.refreshNativeMetrics();
|
|
expect(metrics.length, greaterThan(1));
|
|
expect(metrics.length, greaterThan(1));
|
|
var foundOldHeapCapacity =
|
|
metrics.values.any((m) => m.name == 'heap.old.capacity');
|
|
expect(foundOldHeapCapacity, equals(true));
|
|
},
|
|
(Isolate isolate) async {
|
|
var params = {'metricId': 'metrics/native/heap.old.used'};
|
|
ServiceMetric counter =
|
|
await isolate.invokeRpc('_getIsolateMetric', params) as ServiceMetric;
|
|
expect(counter.type, equals('Counter'));
|
|
expect(counter.name, equals('heap.old.used'));
|
|
},
|
|
(Isolate isolate) async {
|
|
bool caughtException = false;
|
|
try {
|
|
await isolate.invokeRpc(
|
|
'_getIsolateMetric', {'metricId': 'metrics/native/doesnotexist'});
|
|
expect(false, isTrue, reason: 'Unreachable');
|
|
} on ServerRpcException catch (e) {
|
|
caughtException = true;
|
|
expect(e.code, equals(ServerRpcException.kInvalidParams));
|
|
expect(
|
|
e.message,
|
|
"_getIsolateMetric: invalid 'metricId' "
|
|
"parameter: metrics/native/doesnotexist");
|
|
}
|
|
expect(caughtException, isTrue);
|
|
},
|
|
];
|
|
|
|
main(args) => runIsolateTests(args, tests, testeeBefore: script);
|