@@ -82,7 +82,7 @@ void main() {
82
82
restoreVmServiceConnectionFunction ();
83
83
});
84
84
85
- test ('end-to-end with three vm connections and flutter view query' , () async {
85
+ test ('end-to-end with one vm connection and flutter view query' , () async {
86
86
int port = 0 ;
87
87
Future <PortForwarder > fakePortForwardingFunction (
88
88
String address,
@@ -102,54 +102,76 @@ void main() {
102
102
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
103
103
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
104
104
// Adds some extra junk to make sure the strings will be cleaned up.
105
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
106
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
105
+ fakeRunner.iqueryResponse = < String > [
106
+ '[' ,
107
+ ' {' ,
108
+ ' "data_source": "Inspect",' ,
109
+ ' "metadata": {' ,
110
+ ' "filename": "fuchsia.inspect.Tree",' ,
111
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_aot_runner#meta/flutter_runner.cm",' ,
112
+ ' "timestamp": 12345678901234' ,
113
+ ' },' ,
114
+ ' "moniker": "core/session-manager/session\: session/flutter_runner",' ,
115
+ ' "payload": {' ,
116
+ ' "root": {' ,
117
+ ' "vm_service_port": "12345",' ,
118
+ ' "16859221": {' ,
119
+ ' "empty_tree": "this semantic tree is empty"' ,
120
+ ' },' ,
121
+ ' "build_info": {' ,
122
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
123
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
124
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
125
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
126
+ ' },' ,
127
+ ' "vm": {' ,
128
+ ' "dst_status": 1,' ,
129
+ ' "get_profile_status": 0,' ,
130
+ ' "num_get_profile_calls": 1,' ,
131
+ ' "num_intl_provider_errors": 0,' ,
132
+ ' "num_on_change_calls": 0,' ,
133
+ ' "timezone_content_status": 0,' ,
134
+ ' "tz_data_close_status": -1,' ,
135
+ ' "tz_data_status": -1' ,
136
+ ' }' ,
137
+ ' }' ,
138
+ ' },' ,
139
+ ' "version": 1' ,
140
+ ' }' ,
141
+ ' ]'
142
+ ];
107
143
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247' ;
108
144
fakeRunner.interface = 'eno1' ;
109
145
110
146
final FuchsiaRemoteConnection connection =
111
147
await FuchsiaRemoteConnection .connectWithSshCommandRunner (fakeRunner);
112
148
113
- // [fakePortForwardingFunction] will have returned three different
149
+ // [fakePortForwardingFunction] will have returned one
114
150
// forwarded ports, incrementing the port each time by one. (Just a sanity
115
151
// check that the forwarding port was called).
116
- expect (forwardedPorts.length, 3 );
117
- expect (forwardedPorts[0 ].remotePort, 123 );
118
- expect (forwardedPorts[1 ].remotePort, 456 );
119
- expect (forwardedPorts[2 ].remotePort, 789 );
152
+ expect (forwardedPorts.length, 1 );
153
+ expect (forwardedPorts[0 ].remotePort, 12345 );
120
154
expect (forwardedPorts[0 ].port, 0 );
121
- expect (forwardedPorts[1 ].port, 1 );
122
- expect (forwardedPorts[2 ].port, 2 );
123
155
124
156
// VMs should be accessed via localhost ports given by
125
157
// [fakePortForwardingFunction].
126
158
expect (uriConnections[0 ],
127
- Uri (scheme: 'ws' , host: '[::1]' , port: 0 , path: '/ws' ));
128
- expect (uriConnections[1 ],
129
- Uri (scheme: 'ws' , host: '[::1]' , port: 1 , path: '/ws' ));
130
- expect (uriConnections[2 ],
131
- Uri (scheme: 'ws' , host: '[::1]' , port: 2 , path: '/ws' ));
159
+ Uri (scheme: 'ws' , host: '[::1]' , port: 0 , path: '/ws' ));
132
160
133
161
final List <FlutterView > views = await connection.getFlutterViews ();
134
162
expect (views, isNot (null ));
135
- expect (views.length, 3 );
163
+ expect (views.length, 1 );
136
164
// Since name can be null, check for the ID on all of them.
137
165
expect (views[0 ].id, 'flutterView0' );
138
- expect (views[1 ].id, 'flutterView1' );
139
- expect (views[2 ].id, 'flutterView2' );
140
166
141
167
expect (views[0 ].name, equals (null ));
142
- expect (views[1 ].name, 'file://flutterBinary1' );
143
- expect (views[2 ].name, 'file://flutterBinary2' );
144
168
145
169
// Ensure the ports are all closed after stop was called.
146
170
await connection.stop ();
147
171
expect (forwardedPorts[0 ].stopped, true );
148
- expect (forwardedPorts[1 ].stopped, true );
149
- expect (forwardedPorts[2 ].stopped, true );
150
172
});
151
173
152
- test ('end-to-end with three vms and remote open port' , () async {
174
+ test ('end-to-end with one vm and remote open port' , () async {
153
175
int port = 0 ;
154
176
Future <PortForwarder > fakePortForwardingFunction (
155
177
String address,
@@ -170,53 +192,72 @@ void main() {
170
192
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
171
193
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
172
194
// Adds some extra junk to make sure the strings will be cleaned up.
173
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
174
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
195
+ fakeRunner.iqueryResponse = < String > [
196
+ '[' ,
197
+ ' {' ,
198
+ ' "data_source": "Inspect",' ,
199
+ ' "metadata": {' ,
200
+ ' "filename": "fuchsia.inspect.Tree",' ,
201
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_aot_runner#meta/flutter_runner.cm",' ,
202
+ ' "timestamp": 12345678901234' ,
203
+ ' },' ,
204
+ ' "moniker": "core/session-manager/session\: session/flutter_runner",' ,
205
+ ' "payload": {' ,
206
+ ' "root": {' ,
207
+ ' "vm_service_port": "12345",' ,
208
+ ' "16859221": {' ,
209
+ ' "empty_tree": "this semantic tree is empty"' ,
210
+ ' },' ,
211
+ ' "build_info": {' ,
212
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
213
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
214
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
215
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
216
+ ' },' ,
217
+ ' "vm": {' ,
218
+ ' "dst_status": 1,' ,
219
+ ' "get_profile_status": 0,' ,
220
+ ' "num_get_profile_calls": 1,' ,
221
+ ' "num_intl_provider_errors": 0,' ,
222
+ ' "num_on_change_calls": 0,' ,
223
+ ' "timezone_content_status": 0,' ,
224
+ ' "tz_data_close_status": -1,' ,
225
+ ' "tz_data_status": -1' ,
226
+ ' }' ,
227
+ ' }' ,
228
+ ' },' ,
229
+ ' "version": 1' ,
230
+ ' }' ,
231
+ ' ]'
232
+ ];
175
233
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247' ;
176
234
fakeRunner.interface = 'eno1' ;
177
235
final FuchsiaRemoteConnection connection =
178
236
await FuchsiaRemoteConnection .connectWithSshCommandRunner (fakeRunner);
179
237
180
- // [fakePortForwardingFunction] will have returned three different
181
- // forwarded ports, incrementing the port each time by one. (Just a sanity
182
- // check that the forwarding port was called).
183
- expect (forwardedPorts.length, 3 );
184
- expect (forwardedPorts[0 ].remotePort, 123 );
185
- expect (forwardedPorts[1 ].remotePort, 456 );
186
- expect (forwardedPorts[2 ].remotePort, 789 );
238
+ expect (forwardedPorts.length, 1 );
239
+ expect (forwardedPorts[0 ].remotePort, 12345 );
187
240
expect (forwardedPorts[0 ].port, 0 );
188
- expect (forwardedPorts[1 ].port, 1 );
189
- expect (forwardedPorts[2 ].port, 2 );
190
241
191
242
// VMs should be accessed via the alternate address given by
192
243
// [fakePortForwardingFunction].
193
244
expect (uriConnections[0 ],
194
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 0 , path: '/ws' ));
195
- expect (uriConnections[1 ],
196
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 1 , path: '/ws' ));
197
- expect (uriConnections[2 ],
198
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 2 , path: '/ws' ));
245
+ Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 0 , path: '/ws' ));
199
246
200
247
final List <FlutterView > views = await connection.getFlutterViews ();
201
248
expect (views, isNot (null ));
202
- expect (views.length, 3 );
249
+ expect (views.length, 1 );
203
250
// Since name can be null, check for the ID on all of them.
204
251
expect (views[0 ].id, 'flutterView0' );
205
- expect (views[1 ].id, 'flutterView1' );
206
- expect (views[2 ].id, 'flutterView2' );
207
252
208
253
expect (views[0 ].name, equals (null ));
209
- expect (views[1 ].name, 'file://flutterBinary1' );
210
- expect (views[2 ].name, 'file://flutterBinary2' );
211
254
212
255
// Ensure the ports are all closed after stop was called.
213
256
await connection.stop ();
214
257
expect (forwardedPorts[0 ].stopped, true );
215
- expect (forwardedPorts[1 ].stopped, true );
216
- expect (forwardedPorts[2 ].stopped, true );
217
258
});
218
259
219
- test ('end-to-end with three vms and ipv4' , () async {
260
+ test ('end-to-end with one vm and ipv4' , () async {
220
261
int port = 0 ;
221
262
Future <PortForwarder > fakePortForwardingFunction (
222
263
String address,
@@ -236,8 +277,44 @@ void main() {
236
277
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
237
278
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
238
279
// Adds some extra junk to make sure the strings will be cleaned up.
239
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
240
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
280
+ fakeRunner.iqueryResponse = < String > [
281
+ '[' ,
282
+ ' {' ,
283
+ ' "data_source": "Inspect",' ,
284
+ ' "metadata": {' ,
285
+ ' "filename": "fuchsia.inspect.Tree",' ,
286
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_aot_runner#meta/flutter_runner.cm",' ,
287
+ ' "timestamp": 12345678901234' ,
288
+ ' },' ,
289
+ ' "moniker": "core/session-manager/session\: session/flutter_runner",' ,
290
+ ' "payload": {' ,
291
+ ' "root": {' ,
292
+ ' "vm_service_port": "12345",' ,
293
+ ' "16859221": {' ,
294
+ ' "empty_tree": "this semantic tree is empty"' ,
295
+ ' },' ,
296
+ ' "build_info": {' ,
297
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
298
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
299
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
300
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
301
+ ' },' ,
302
+ ' "vm": {' ,
303
+ ' "dst_status": 1,' ,
304
+ ' "get_profile_status": 0,' ,
305
+ ' "num_get_profile_calls": 1,' ,
306
+ ' "num_intl_provider_errors": 0,' ,
307
+ ' "num_on_change_calls": 0,' ,
308
+ ' "timezone_content_status": 0,' ,
309
+ ' "tz_data_close_status": -1,' ,
310
+ ' "tz_data_status": -1' ,
311
+ ' }' ,
312
+ ' }' ,
313
+ ' },' ,
314
+ ' "version": 1' ,
315
+ ' }' ,
316
+ ' ]'
317
+ ];
241
318
fakeRunner.address = '196.168.1.4' ;
242
319
243
320
final FuchsiaRemoteConnection connection =
@@ -246,39 +323,25 @@ void main() {
246
323
// [fakePortForwardingFunction] will have returned three different
247
324
// forwarded ports, incrementing the port each time by one. (Just a sanity
248
325
// check that the forwarding port was called).
249
- expect (forwardedPorts.length, 3 );
250
- expect (forwardedPorts[0 ].remotePort, 123 );
251
- expect (forwardedPorts[1 ].remotePort, 456 );
252
- expect (forwardedPorts[2 ].remotePort, 789 );
326
+ expect (forwardedPorts.length, 1 );
327
+ expect (forwardedPorts[0 ].remotePort, 12345 );
253
328
expect (forwardedPorts[0 ].port, 0 );
254
- expect (forwardedPorts[1 ].port, 1 );
255
- expect (forwardedPorts[2 ].port, 2 );
256
329
257
330
// VMs should be accessed via the ipv4 loopback.
258
331
expect (uriConnections[0 ],
259
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 0 , path: '/ws' ));
260
- expect (uriConnections[1 ],
261
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 1 , path: '/ws' ));
262
- expect (uriConnections[2 ],
263
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 2 , path: '/ws' ));
332
+ Uri (scheme: 'ws' , host: '127.0.0.1' , port: 0 , path: '/ws' ));
264
333
265
334
final List <FlutterView > views = await connection.getFlutterViews ();
266
335
expect (views, isNot (null ));
267
- expect (views.length, 3 );
336
+ expect (views.length, 1 );
268
337
// Since name can be null, check for the ID on all of them.
269
338
expect (views[0 ].id, 'flutterView0' );
270
- expect (views[1 ].id, 'flutterView1' );
271
- expect (views[2 ].id, 'flutterView2' );
272
339
273
340
expect (views[0 ].name, equals (null ));
274
- expect (views[1 ].name, 'file://flutterBinary1' );
275
- expect (views[2 ].name, 'file://flutterBinary2' );
276
341
277
342
// Ensure the ports are all closed after stop was called.
278
343
await connection.stop ();
279
344
expect (forwardedPorts[0 ].stopped, true );
280
- expect (forwardedPorts[1 ].stopped, true );
281
- expect (forwardedPorts[2 ].stopped, true );
282
345
});
283
346
284
347
test ('env variable test without remote addr' , () async {
@@ -287,22 +350,17 @@ void main() {
287
350
}
288
351
289
352
// Should fail as no env variable has been passed.
290
- expect (failingFunction,
291
- throwsA (isA <FuchsiaRemoteConnectionError >()));
353
+ expect (failingFunction, throwsA (isA <FuchsiaRemoteConnectionError >()));
292
354
});
293
355
});
294
356
}
295
357
296
358
class FakeSshCommandRunner extends Fake implements SshCommandRunner {
297
- List <String >? findResponse;
298
- List <String >? lsResponse;
359
+ List <String >? iqueryResponse;
299
360
@override
300
361
Future <List <String >> run (String command) async {
301
- if (command.startsWith ('/bin/find' )) {
302
- return findResponse! ;
303
- }
304
- if (command.startsWith ('/bin/ls' )) {
305
- return lsResponse! ;
362
+ if (command.startsWith ('iquery --format json show' )) {
363
+ return iqueryResponse! ;
306
364
}
307
365
throw UnimplementedError (command);
308
366
}
0 commit comments