-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken tests on head due to Dart SDK update #2392
Changes from all commits
1e4a431
cd8dc69
707d417
93f0caa
e73749e
ab82223
52cf42f
a9f41e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,83 +47,93 @@ void main() { | |
); | ||
}); | ||
|
||
test('Refuses additional connections when in single client mode', () async { | ||
final ddsWs = await WebSocket.connect( | ||
'${context.debugConnection.uri}/ws', | ||
); | ||
final completer = Completer<void>(); | ||
ddsWs.listen((event) { | ||
final response = json.decode(event as String); | ||
test( | ||
'Refuses additional connections when in single client mode', | ||
() async { | ||
final ddsWs = await WebSocket.connect( | ||
'${context.debugConnection.uri}/ws', | ||
); | ||
final completer = Completer<void>(); | ||
ddsWs.listen((event) { | ||
final response = json.decode(event as String); | ||
expect(response['id'], '0'); | ||
expect(response.containsKey('result'), isTrue); | ||
final result = response['result'] as Map<String, dynamic>; | ||
expect(result['type'], 'Success'); | ||
completer.complete(); | ||
}); | ||
|
||
const yieldControlToDDS = <String, dynamic>{ | ||
'jsonrpc': '2.0', | ||
'id': '0', | ||
'method': '_yieldControlToDDS', | ||
'params': { | ||
'uri': 'http://localhost:123', | ||
}, | ||
}; | ||
ddsWs.add(json.encode(yieldControlToDDS)); | ||
await completer.future; | ||
|
||
// While DDS is connected, expect additional connections to fail. | ||
await expectLater( | ||
WebSocket.connect('${context.debugConnection.uri}/ws'), | ||
throwsA(isA<WebSocketException>()), | ||
); | ||
|
||
// However, once DDS is disconnected, additional clients can connect again. | ||
await ddsWs.close(); | ||
expect( | ||
WebSocket.connect('${context.debugConnection.uri}/ws') | ||
.then((ws) => ws.close()), | ||
completes, | ||
); | ||
}, | ||
// TODO(elliette): Re-enable test. | ||
skip: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be enabled and fixed in #2388 |
||
); | ||
|
||
test( | ||
'Refuses to yield to dwds if existing clients found', | ||
() async { | ||
final ddsWs = await WebSocket.connect( | ||
'${context.debugConnection.uri}/ws', | ||
); | ||
|
||
// Connect to vm service. | ||
final ws = await WebSocket.connect('${context.debugConnection.uri}/ws'); | ||
|
||
final completer = Completer<Map<String, dynamic>>(); | ||
ddsWs.listen((event) { | ||
completer.complete(json.decode(event as String)); | ||
}); | ||
|
||
const yieldControlToDDS = <String, dynamic>{ | ||
'jsonrpc': '2.0', | ||
'id': '0', | ||
'method': '_yieldControlToDDS', | ||
'params': { | ||
'uri': 'http://localhost:123', | ||
}, | ||
}; | ||
|
||
// DDS should fail to start with existing vm clients. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DDS should only fail to start if there's an existing DDS instance. In the case of existing clients, the existing clients should be disconnected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Will handle that in #2388, this change just skips the existing test |
||
ddsWs.add(json.encode(yieldControlToDDS)); | ||
|
||
final response = await completer.future; | ||
expect(response['id'], '0'); | ||
expect(response.containsKey('result'), isTrue); | ||
final result = response['result'] as Map<String, dynamic>; | ||
expect(result['type'], 'Success'); | ||
completer.complete(); | ||
}); | ||
|
||
const yieldControlToDDS = <String, dynamic>{ | ||
'jsonrpc': '2.0', | ||
'id': '0', | ||
'method': '_yieldControlToDDS', | ||
'params': { | ||
'uri': 'http://localhost:123', | ||
}, | ||
}; | ||
ddsWs.add(json.encode(yieldControlToDDS)); | ||
await completer.future; | ||
|
||
// While DDS is connected, expect additional connections to fail. | ||
await expectLater( | ||
WebSocket.connect('${context.debugConnection.uri}/ws'), | ||
throwsA(isA<WebSocketException>()), | ||
); | ||
|
||
// However, once DDS is disconnected, additional clients can connect again. | ||
await ddsWs.close(); | ||
expect( | ||
WebSocket.connect('${context.debugConnection.uri}/ws') | ||
.then((ws) => ws.close()), | ||
completes, | ||
); | ||
}); | ||
|
||
test('Refuses to yield to dwds if existing clients found', () async { | ||
final ddsWs = await WebSocket.connect( | ||
'${context.debugConnection.uri}/ws', | ||
); | ||
|
||
// Connect to vm service. | ||
final ws = await WebSocket.connect('${context.debugConnection.uri}/ws'); | ||
|
||
final completer = Completer<Map<String, dynamic>>(); | ||
ddsWs.listen((event) { | ||
completer.complete(json.decode(event as String)); | ||
}); | ||
|
||
const yieldControlToDDS = <String, dynamic>{ | ||
'jsonrpc': '2.0', | ||
'id': '0', | ||
'method': '_yieldControlToDDS', | ||
'params': { | ||
'uri': 'http://localhost:123', | ||
}, | ||
}; | ||
|
||
// DDS should fail to start with existing vm clients. | ||
ddsWs.add(json.encode(yieldControlToDDS)); | ||
|
||
final response = await completer.future; | ||
expect(response['id'], '0'); | ||
expect(response.containsKey('error'), isTrue); | ||
|
||
final result = response['error'] as Map<String, dynamic>; | ||
expect(result['message'], 'Feature is disabled.'); | ||
expect( | ||
result['data'], | ||
'Existing VM service clients prevent DDS from taking control.', | ||
); | ||
|
||
await ddsWs.close(); | ||
await ws.close(); | ||
}); | ||
expect(response.containsKey('error'), isTrue); | ||
|
||
final result = response['error'] as Map<String, dynamic>; | ||
expect(result['message'], 'Feature is disabled.'); | ||
expect( | ||
result['data'], | ||
'Existing VM service clients prevent DDS from taking control.', | ||
); | ||
|
||
await ddsWs.close(); | ||
await ws.close(); | ||
}, | ||
// TODO(elliette): Re-enable test. | ||
skip: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be enabled and fixed with #2388 |
||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2388 has the actual implementation of this method, but I'm still working on getting all the tests passing on that PR.