From bc33cad99936d44929bb6884a0d96e8cc85ceb02 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 5 Aug 2019 11:56:01 -0400 Subject: [PATCH] add test for connection failure analytics --- lbry/tests/unit/stream/test_stream_manager.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lbry/tests/unit/stream/test_stream_manager.py b/lbry/tests/unit/stream/test_stream_manager.py index 77aaef6d2..be558af87 100644 --- a/lbry/tests/unit/stream/test_stream_manager.py +++ b/lbry/tests/unit/stream/test_stream_manager.py @@ -152,6 +152,7 @@ class TestStreamManager(BlobExchangeTestBase): self.assertEqual(event['event'], 'Time To First Bytes') self.assertEqual(event['properties']['tried_peers_count'], 1) self.assertEqual(event['properties']['active_peer_count'], 1) + self.assertEqual(event['properties']['connection_failures_count'], 0) self.assertEqual(event['properties']['use_fixed_peers'], True) self.assertEqual(event['properties']['added_fixed_peers'], True) self.assertEqual(event['properties']['fixed_peer_delay'], self.client_config.fixed_peer_delay) @@ -159,6 +160,21 @@ class TestStreamManager(BlobExchangeTestBase): await self._test_time_to_first_bytes(check_post, after_setup=after_setup) + async def test_tcp_connection_failure_analytics(self): + self.client_config.download_timeout = 3.0 + + def after_setup(): + self.server.stop_server() + + def check_post(event): + self.assertEqual(event['event'], 'Time To First Bytes') + self.assertIsNone(event['properties']['head_blob_duration']) + self.assertIsNone(event['properties']['sd_blob_duration']) + self.assertFalse(event['properties']['added_fixed_peers']) + self.assertEqual(event['properties']['connection_failures_count'], 1) + + await self._test_time_to_first_bytes(check_post, DownloadSDTimeout, after_setup=after_setup) + async def test_override_fixed_peer_delay_dht_disabled(self): self.client_config.reflector_servers = [(self.server_from_client.address, self.server_from_client.tcp_port - 1)] self.client_config.components_to_skip = ['dht', 'hash_announcer']