Index: runtime/observatory/tests/service/tcp_socket_service_test.dart |
diff --git a/runtime/observatory/tests/service/tcp_socket_service_test.dart b/runtime/observatory/tests/service/tcp_socket_service_test.dart |
deleted file mode 100644 |
index 5b3777271fc072926d7323ced77c7a6eab685c9f..0000000000000000000000000000000000000000 |
--- a/runtime/observatory/tests/service/tcp_socket_service_test.dart |
+++ /dev/null |
@@ -1,157 +0,0 @@ |
-// 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 'dart:async'; |
-import 'dart:convert'; |
-import 'dart:io' as io; |
-import 'package:observatory/service_io.dart'; |
-import 'package:unittest/unittest.dart'; |
-import 'test_helper.dart'; |
- |
-Future setupTCP() async { |
- // Note that we don't close after us, by design we leave the sockets opens |
- // to allow us to query them from the other isolate. |
- var serverSocket = await io.ServerSocket.bind('127.0.0.1', 0); |
- serverSocket.listen((s) { |
- s.transform(UTF8.decoder).listen(print); |
- s.close(); |
- }); |
- var socket = await io.Socket.connect("127.0.0.1", serverSocket.port); |
- socket.write("foobar"); |
- socket.write("foobar"); |
- await socket.flush(); |
- |
- var socket2 = await io.Socket.connect("127.0.0.1", serverSocket.port); |
- socket2.write("foobarfoobar"); |
- await socket2.flush(); |
-} |
- |
-var tcpTests = [ |
- // Initial. |
- (Isolate isolate) async { |
- var result = await isolate.invokeRpcNoUpgrade('__getOpenSockets', {}); |
- expect(result['type'], equals('_opensockets')); |
- // We expect 3 sockets to be open (in this order): |
- // The server socket accepting connections, on port X |
- // The accepted connection on the client, on port Y |
- // The client connection, on port X |
- expect(result['data'].length, equals(5)); |
- // The first socket will have a name like listening:127.0.0.1:X |
- // The second will have a name like 127.0.0.1:Y |
- // The third will have a name like 127.0.0.1:X |
- expect(result['data'][0]['name'].startsWith('listening:127.0.0.1'), isTrue); |
- expect(result['data'][1]['name'].startsWith('127.0.0.1:'), isTrue); |
- expect(result['data'][2]['name'].startsWith('127.0.0.1:'), isTrue); |
- |
- var listening = await isolate.invokeRpcNoUpgrade( |
- '__getSocketByID', { 'id' : result['data'][0]['id'] }); |
- expect(listening['id'], equals(result['data'][0]['id'])); |
- expect(listening['listening'], isTrue); |
- expect(listening['socket_type'], equals('TCP')); |
- expect(listening['port'], greaterThanOrEqualTo(1024)); |
- expect(listening['last_read'], greaterThan(0)); |
- expect(listening['total_read'], equals(2)); |
- expect(listening['last_write'], equals(0)); |
- expect(listening['total_written'], equals(0)); |
- expect(listening['write_count'], equals(0)); |
- expect(listening['read_count'], equals(0)); |
- expect(listening['remote_host'], equals('NA')); |
- expect(listening['remote_port'], equals('NA')); |
- |
- var client = await isolate.invokeRpcNoUpgrade( |
- '__getSocketByID', { 'id' : result['data'][1]['id'] }); |
- expect(client['id'], equals(result['data'][1]['id'])); |
- |
- var server = await isolate.invokeRpcNoUpgrade( |
- '__getSocketByID', { 'id' : result['data'][2]['id'] }); |
- expect(server['id'], equals(result['data'][2]['id'])); |
- |
- // We expect the client to be connected on the port and |
- // host of the listening socket. |
- expect(client['remote_port'], equals(listening['port'])); |
- expect(client['remote_host'], equals(listening['host'])); |
- // We expect the third socket (accepted server) to be connected to the |
- // same port and host as the listening socket (the listening one). |
- expect(server['port'], equals(listening['port'])); |
- expect(server['host'], equals(listening['host'])); |
- |
- expect(client['listening'], isFalse); |
- expect(server['listening'], isFalse); |
- |
- expect(client['socket_type'], equals('TCP')); |
- expect(server['socket_type'], equals('TCP')); |
- |
- // We are using no reserved ports. |
- expect(client['port'], greaterThanOrEqualTo(1024)); |
- expect(server['port'], greaterThanOrEqualTo(1024)); |
- |
- // The client and server "mirror" each other in reads and writes, and the |
- // timestamps are in correct order. |
- expect(client['last_read'], equals(0)); |
- expect(server['last_read'], greaterThan(0)); |
- expect(client['total_read'], equals(0)); |
- expect(server['total_read'], equals(12)); |
- expect(client['read_count'], equals(0)); |
- // We did not flush after first write, so only one read. |
- // This may be fragile -> should we just make sure it is bigger than 1? |
- expect(server['read_count'], equals(1)); |
- |
- expect(client['last_write'], greaterThan(0)); |
- expect(server['last_write'], equals(0)); |
- expect(client['total_written'], equals(12)); |
- expect(server['total_written'], equals(0)); |
- expect(client['write_count'], equals(2)); |
- expect(server['write_count'], equals(0)); |
- |
- // Order |
- expect(server['last_read'], greaterThan(client['last_write'])); |
- |
- var second_client = await isolate.invokeRpcNoUpgrade( |
- '__getSocketByID', { 'id' : result['data'][3]['id'] }); |
- expect(second_client['id'], equals(result['data'][3]['id'])); |
- var second_server = await isolate.invokeRpcNoUpgrade( |
- '__getSocketByID', { 'id' : result['data'][4]['id'] }); |
- expect(second_server['id'], equals(result['data'][4]['id'])); |
- |
- // We expect the client to be connected on the port and |
- // host of the listening socket. |
- expect(second_client['remote_port'], equals(listening['port'])); |
- expect(second_client['remote_host'], equals(listening['host'])); |
- // We expect the third socket (accepted server) to be connected to the |
- // same port and host as the listening socket (the listening one). |
- expect(second_server['port'], equals(listening['port'])); |
- expect(second_server['host'], equals(listening['host'])); |
- |
- expect(second_client['listening'], isFalse); |
- expect(second_server['listening'], isFalse); |
- |
- expect(second_client['socket_type'], equals('TCP')); |
- expect(second_server['socket_type'], equals('TCP')); |
- |
- // We are using no reserved ports. |
- expect(second_client['port'], greaterThanOrEqualTo(1024)); |
- expect(second_server['port'], greaterThanOrEqualTo(1024)); |
- |
- // The client and server "mirror" each other in reads and writes, and the |
- // timestamps are in correct order. |
- expect(second_client['last_read'], equals(0)); |
- expect(second_server['last_read'], greaterThan(0)); |
- expect(second_client['total_read'], equals(0)); |
- expect(second_server['total_read'], equals(12)); |
- expect(second_client['read_count'], equals(0)); |
- expect(second_server['read_count'], equals(1)); |
- |
- expect(second_client['last_write'], greaterThan(0)); |
- expect(second_server['last_write'], equals(0)); |
- expect(second_client['total_written'], equals(12)); |
- expect(second_server['total_written'], equals(0)); |
- expect(second_client['write_count'], equals(1)); |
- expect(second_server['write_count'], equals(0)); |
- |
- // Order |
- expect(server['last_read'], greaterThan(client['last_write'])); |
- }, |
-]; |
- |
-main(args) async => runIsolateTests(args, tcpTests, testeeBefore:setupTCP); |