Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: telemetry/telemetry/internal/forwarders/do_nothing_forwarder_unittest.py

Issue 2346773002: Revert of "[telemetry] Wire TsProxy through telemetry's network stack." (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 from telemetry.core import exceptions 7 from telemetry.core import exceptions
8 from telemetry.internal import forwarders 8 from telemetry.internal import forwarders
9 from telemetry.internal.forwarders import do_nothing_forwarder 9 from telemetry.internal.forwarders import do_nothing_forwarder
10 10
(...skipping 10 matching lines...) Expand all
21 21
22 22
23 class TestErrorDoNothingForwarder(do_nothing_forwarder.DoNothingForwarder): 23 class TestErrorDoNothingForwarder(do_nothing_forwarder.DoNothingForwarder):
24 """Simulate a connection error.""" 24 """Simulate a connection error."""
25 25
26 def _WaitForConnectionEstablished(self, address, timeout): 26 def _WaitForConnectionEstablished(self, address, timeout):
27 raise exceptions.TimeoutException 27 raise exceptions.TimeoutException
28 28
29 29
30 class CheckPortPairsTest(unittest.TestCase): 30 class CheckPortPairsTest(unittest.TestCase):
31 def testChecksOnlyHttpHttps(self): 31 def testBasicCheck(self):
32 port_pairs = forwarders.PortPairs( 32 port_pair = forwarders.PortPair(80, 80)
33 http=forwarders.PortPair(80, 80), 33 f = TestDoNothingForwarder(port_pair)
34 https=forwarders.PortPair(443, 443),
35 dns=forwarders.PortPair(53, 53))
36 f = TestDoNothingForwarder(port_pairs)
37 expected_connected_addresses = [ 34 expected_connected_addresses = [
38 ('127.0.0.1', 80), 35 ('127.0.0.1', 80),
39 ('127.0.0.1', 443),
40 # Port 53 is skipped because it is UDP and does not support connections.
41 ]
42 self.assertEqual(expected_connected_addresses, f.connected_addresses)
43
44 def testNoDnsStillChecksHttpHttps(self):
45 port_pairs = forwarders.PortPairs(
46 http=forwarders.PortPair(5566, 5566),
47 https=forwarders.PortPair(7788, 7788),
48 dns=None)
49 f = TestDoNothingForwarder(port_pairs)
50 expected_connected_addresses = [
51 ('127.0.0.1', 5566),
52 ('127.0.0.1', 7788),
53 ] 36 ]
54 self.assertEqual(expected_connected_addresses, f.connected_addresses) 37 self.assertEqual(expected_connected_addresses, f.connected_addresses)
55 38
56 def testPortMismatchRaisesPortsMismatchError(self): 39 def testPortMismatchRaisesPortsMismatchError(self):
57 # The do_nothing_forward cannot forward from one port to another. 40 # The do_nothing_forward cannot forward from one port to another.
58 port_pairs = forwarders.PortPairs( 41 port_pair = forwarders.PortPair(80, 81)
59 http=forwarders.PortPair(80, 80),
60 https=forwarders.PortPair(8443, 443),
61 dns=None)
62 with self.assertRaises(do_nothing_forwarder.PortsMismatchError): 42 with self.assertRaises(do_nothing_forwarder.PortsMismatchError):
63 TestDoNothingForwarder(port_pairs) 43 TestDoNothingForwarder(port_pair)
64 44
65 def testConnectionTimeoutRaisesConnectionError(self): 45 def testConnectionTimeoutRaisesConnectionError(self):
66 port_pairs = forwarders.PortPairs( 46 port_pair = forwarders.PortPair(80, 80)
67 http=forwarders.PortPair(80, 80),
68 https=forwarders.PortPair(8443, 443),
69 dns=None)
70 with self.assertRaises(do_nothing_forwarder.ConnectionError): 47 with self.assertRaises(do_nothing_forwarder.ConnectionError):
71 TestErrorDoNothingForwarder(port_pairs) 48 TestErrorDoNothingForwarder(port_pair)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698