Skip to content

Commit eca9969

Browse files
derekxu16Commit Queue
authored andcommitted
[VM/Service] Move test logic of http_get_vm_rpc_test from testee to main process
This should fix the tests' flakiness. Change-Id: I613e6c21babda6254579b4dc24f7d1da7647e619 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419640 Reviewed-by: Ben Konyi <[email protected]>
1 parent 2b8c0ee commit eca9969

File tree

3 files changed

+26
-35
lines changed

3 files changed

+26
-35
lines changed

pkg/vm_service/test/http_invocations/http_auth_get_vm_rpc_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import 'http_get_vm_rpc_common.dart';
77

88
void main([args = const <String>[]]) => runIsolateTests(
99
args,
10-
tests,
10+
httpGetVmRpcTests,
1111
'http_auth_get_vm_rpc_test.dart',
12-
testeeBefore: testeeBefore,
1312
);

pkg/vm_service/test/http_invocations/http_get_vm_rpc_common.dart

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,36 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:async';
6-
75
import 'package:vm_service/vm_service.dart';
86

97
import '../common/expect.dart';
108
import '../common/service_test_common.dart';
119
import 'http_request_helpers.dart';
1210

13-
Future<void> testeeBefore() async {
14-
final info = await waitForServiceInfo();
15-
final serverUri = info.serverUri!;
16-
17-
try {
18-
final result = createServiceObject(
19-
await makeHttpServiceRequest(
20-
serverUri: serverUri,
21-
method: 'getVM',
22-
),
23-
['VM'],
24-
)! as VM;
25-
Expect.equals(result.name, 'vm');
26-
Expect.isTrue(result.architectureBits! > 0);
27-
Expect.isNotNull(result.targetCPU);
28-
Expect.isNotNull(result.hostCPU);
29-
Expect.isNotNull(result.version);
30-
Expect.isNotNull(result.pid);
31-
Expect.isTrue(result.startTime! > 0);
32-
Expect.isTrue(result.isolates!.isNotEmpty);
33-
Expect.isTrue(result.isolateGroups!.isNotEmpty);
34-
} catch (e) {
35-
Expect.fail('invalid request: $e');
36-
}
37-
}
11+
final httpGetVmRpcTests = <IsolateTest>[
12+
(VmService service, _) async {
13+
final wsUri = Uri.parse(service.wsUri!);
14+
final serverUri = Uri.parse('http://${wsUri.authority}');
3815

39-
final tests = <IsolateTest>[
40-
(VmService service, IsolateRef isolateRef) async {
41-
// Just getting here means that the testee enabled the service protocol
42-
// web server.
16+
try {
17+
final result = createServiceObject(
18+
await makeHttpServiceRequest(
19+
serverUri: serverUri,
20+
method: 'getVM',
21+
),
22+
['VM'],
23+
)! as VM;
24+
Expect.equals(result.name, 'vm');
25+
Expect.isTrue(result.architectureBits! > 0);
26+
Expect.isNotNull(result.targetCPU);
27+
Expect.isNotNull(result.hostCPU);
28+
Expect.isNotNull(result.version);
29+
Expect.isNotNull(result.pid);
30+
Expect.isTrue(result.startTime! > 0);
31+
Expect.isTrue(result.isolates!.isNotEmpty);
32+
Expect.isTrue(result.isolateGroups!.isNotEmpty);
33+
} catch (e) {
34+
Expect.fail('invalid request: $e');
35+
}
4336
}
4437
];

pkg/vm_service/test/http_invocations/http_get_vm_rpc_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import 'http_get_vm_rpc_common.dart';
77

88
void main([args = const <String>[]]) => runIsolateTests(
99
args,
10-
tests,
10+
httpGetVmRpcTests,
1111
'http_get_vm_rpc_test.dart',
12-
testeeBefore: testeeBefore,
1312
useAuthToken: false,
1413
);

0 commit comments

Comments
 (0)