[flutter_driver] make timeline request in chunks (#58430)

Work-around large timeline data killing devicelab machines by requesting data in 1 second intervals and combining at the end. Non-breaking change to the driver API.
This commit is contained in:
Jonah Williams
2020-06-01 13:58:44 -07:00
committed by GitHub
parent f4d26a3b85
commit cd7dfd0a0a
2 changed files with 118 additions and 2 deletions

View File

@@ -538,6 +538,12 @@ void main() {
return null;
});
when(mockPeer.sendRequest('getVMTimelineMicros'))
.thenAnswer((Invocation invocation) async {
log.add('getVMTimelineMicros');
return <String, Object>{};
});
when(mockPeer.sendRequest('setVMTimelineFlags', argThat(equals(<String, dynamic>{'recordedStreams': '[all]'}))))
.thenAnswer((Invocation invocation) async {
log.add('startTracing');
@@ -568,8 +574,10 @@ void main() {
}, retainPriorEvents: true);
expect(log, const <String>[
'getVMTimelineMicros',
'startTracing',
'action',
'getVMTimelineMicros',
'stopTracing',
'download',
]);
@@ -583,13 +591,77 @@ void main() {
expect(log, const <String>[
'clear',
'getVMTimelineMicros',
'startTracing',
'action',
'getVMTimelineMicros',
'stopTracing',
'download',
]);
expect(timeline.events.single.name, 'test event');
});
test('with time interval', () async {
int count = 0;
when(mockPeer.sendRequest('getVMTimelineMicros'))
.thenAnswer((Invocation invocation) async {
log.add('getVMTimelineMicros');
return <String, Object>{
if (count++ == 0)
'timestamp': 0
else
'timestamp': 1000001,
};
});
when(mockPeer.sendRequest('getVMTimeline', argThat(equals(<String, dynamic>{
'timeOriginMicros': 0,
'timeExtentMicros': 999999
}))))
.thenAnswer((Invocation invocation) async {
log.add('download 1');
return <String, dynamic>{
'traceEvents': <dynamic>[
<String, String>{
'name': 'test event 1',
},
],
};
});
when(mockPeer.sendRequest('getVMTimeline', argThat(equals(<String, dynamic>{
'timeOriginMicros': 1000000,
'timeExtentMicros': 999999,
}))))
.thenAnswer((Invocation invocation) async {
log.add('download 2');
return <String, dynamic>{
'traceEvents': <dynamic>[
<String, String>{
'name': 'test event 2',
},
],
};
});
final Timeline timeline = await driver.traceAction(() async {
log.add('action');
});
expect(log, const <String>[
'clear',
'getVMTimelineMicros',
'startTracing',
'action',
'getVMTimelineMicros',
'stopTracing',
'download 1',
'download 2',
]);
expect(timeline.events.map((TimelineEvent event) => event.name), <String>[
'test event 1',
'test event 2',
]);
});
});
group('traceAction with timeline streams', () {
@@ -598,6 +670,12 @@ void main() {
bool startTracingCalled = false;
bool stopTracingCalled = false;
when(mockPeer.sendRequest('getVMTimelineMicros'))
.thenAnswer((Invocation invocation) async {
log.add('getVMTimelineMicros');
return <String, Object>{};
});
when(mockPeer.sendRequest('setVMTimelineFlags', argThat(equals(<String, dynamic>{'recordedStreams': '[Dart, GC, Compiler]'}))))
.thenAnswer((Invocation invocation) async {
startTracingCalled = true;