Explain inconclusive sandbox ping checks
This commit is contained in:
parent
00ce4d6710
commit
0f1997dd0d
|
|
@ -43,13 +43,15 @@ def peer_probe(source, own_ip, peer_ip):
|
|||
capture_output=True, text=True, timeout=12)
|
||||
baseline = ping(own_ip)
|
||||
if baseline.returncode != 0:
|
||||
return 'inconclusive: client ping self-check failed'
|
||||
detail = (baseline.stderr or baseline.stdout or 'no diagnostic output').strip().replace('\n', ' ')
|
||||
return f'inconclusive: client ping self-check failed (exit {baseline.returncode}): {detail[:300]}'
|
||||
result = ping(peer_ip)
|
||||
if result.returncode == 0:
|
||||
return 'replied: VLAN isolation needs investigation'
|
||||
if result.returncode == 1:
|
||||
return 'no reply observed; not proof that all traffic is blocked'
|
||||
return 'inconclusive: peer ping failed to execute'
|
||||
detail = (result.stderr or result.stdout or 'no diagnostic output').strip().replace('\n', ' ')
|
||||
return f'inconclusive: peer ping failed to execute (exit {result.returncode}): {detail[:300]}'
|
||||
|
||||
|
||||
def client_address(guest, network):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
"""Offline checks for sandbox verification parsing."""
|
||||
import importlib.util
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
spec = importlib.util.spec_from_file_location('sandbox_verify', ROOT / 'scripts/network-sandbox-verify-host.py')
|
||||
|
|
@ -20,6 +22,13 @@ class SandboxVerifyTests(unittest.TestCase):
|
|||
with self.assertRaises(RuntimeError):
|
||||
verify.address_from_output(output, '172.29.220.0/24')
|
||||
|
||||
def test_ping_failure_explains_why_check_is_inconclusive(self):
|
||||
result = subprocess.CompletedProcess([], 1, stdout='', stderr='permission denied')
|
||||
with patch.object(verify.subprocess, 'run', return_value=result):
|
||||
message = verify.peer_probe(9110, '172.29.210.146', '172.29.220.107')
|
||||
self.assertIn('inconclusive', message)
|
||||
self.assertIn('permission denied', message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue