Exemplo n.º 1
0
 def test_global_pinger_memo(self):
   fast_pinger = Pinger(timeout=self.fast_timeout_seconds, tries=2)
   slow_pinger = Pinger(timeout=self.slow_timeout_seconds, tries=2)
   self.assertEqual(
     fast_pinger.pings([self.slow_netloc])[0][1], Pinger.UNREACHABLE, msg=self.message)
   self.assertNotEqual(
     slow_pinger.pings([self.slow_netloc])[0][1], Pinger.UNREACHABLE, msg=self.message)
Exemplo n.º 2
0
 def test_pinger_timeout_config(self):
   test = Pinger(timeout=self.fast_timeout_seconds, tries=2)
   netlocs = [self.fast_netloc, self.slow_netloc]
   ping_results = dict(test.pings(netlocs))
   self.assertLess(ping_results[self.fast_netloc], self.fast_timeout_seconds)
   self.assertEqual(
     ping_results[self.slow_netloc], Pinger.UNREACHABLE, msg=self.message)
Exemplo n.º 3
0
 def test_pinger_times_correct(self):
   test = Pinger(timeout=self.slow_timeout_seconds, tries=2)
   netlocs = [self.fast_netloc, self.slow_netloc, self.unreachable_netloc]
   ping_results = dict(test.pings(netlocs))
   self.assertNotEqual(ping_results[self.slow_netloc], Pinger.UNREACHABLE)
   self.assertLess(ping_results[self.fast_netloc], ping_results[self.slow_netloc])
   self.assertEqual(ping_results[self.unreachable_netloc], Pinger.UNREACHABLE, msg=self.message)
Exemplo n.º 4
0
 def test_pinger_times_correct(self):
   test = Pinger(timeout=.5, tries=2)
   netlocs = [self.fast_netloc, self.slow_netloc, self.timeout_netloc]
   ping_results = dict(test.pings(netlocs))
   self.assertLess(ping_results[self.fast_netloc], ping_results[self.slow_netloc])
   self.assertEqual(ping_results[self.timeout_netloc], Pinger.UNREACHABLE)
Exemplo n.º 5
0
 def test_https_external_pinger(self):
   # NB(gmalmquist): I spent quite some time trying to spin up an HTTPS server and get it to work
   # with this test, but it appears to be more trouble than it's worth. If you're feeling
   # ambitious, feel free to give it a try.
   pinger = Pinger(timeout=self.slow_delay_seconds, tries=2)
   self.assertLess(pinger.ping(self.https_external_netlock), Pinger.UNREACHABLE)
Exemplo n.º 6
0
 def test_https_external_pinger(self):
     # NB(gmalmquist): I spent quite some time trying to spin up an HTTPS server and get it to work
     # with this test, but it appears to be more trouble than it's worth. If you're feeling
     # ambitious, feel free to give it a try.
     pinger = Pinger(timeout=5, tries=2)
     self.assertLess(pinger.ping('https://github.com'), Pinger.UNREACHABLE)
Exemplo n.º 7
0
 def test_pinger_timeout_config(self):
     test = Pinger(timeout=self.slow_seconds - .01, tries=2)
     netlocs = [self.fast_netloc, self.slow_netloc]
     ping_results = dict(test.pings(netlocs))
     self.assertLess(ping_results[self.fast_netloc], 1)
     self.assertEqual(ping_results[self.slow_netloc], Pinger.UNREACHABLE)