fix: wait for DHCP before WireGuard startup and record PCIe benchmark
This commit is contained in:
1 parent
3c7ba8ba49
commit
b7e7fb05b6
7 files changed
+299
-5
No files matched your search
+26
-1
@@ -1,10 +1,11 @@
|
||||
import json
|
||||
import errno
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
from network.config import parse_config,ConfigError
|
||||
from network.native import Manager
|
||||
from network.native import Manager,wait_for_lan
|
||||
|
||||
CONF='''[Interface]
|
||||
PrivateKey = AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
|
||||
@@ -18,6 +19,30 @@ Endpoint = vpn.example.test:51820
|
||||
PersistentKeepalive = 25
|
||||
'''
|
||||
class NativeTests(unittest.TestCase):
|
||||
def test_start_waits_for_configured_lan_address(self):
|
||||
policy=dict(lan_address='192.0.2.11',lan_interface='lan0')
|
||||
devices=json.dumps([{'ifname':'lan0','addr_info':[{'local':'192.0.2.11'}]}])
|
||||
with patch('network.native.run',side_effect=['[]',devices]),patch('network.native.time.sleep') as sleep:
|
||||
wait_for_lan(policy);sleep.assert_called_once_with(1)
|
||||
def test_start_wait_is_bounded(self):
|
||||
with patch('network.native.run',return_value='[]'),patch('network.native.time.monotonic',side_effect=[0,61]):
|
||||
with self.assertRaisesRegex(ValueError,'LAN-Adresse'):wait_for_lan(dict(lan_address='192.0.2.11',lan_interface='lan0'))
|
||||
def test_bind_error_distinguishes_missing_address(self):
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
m=self.manager(t)
|
||||
with patch('network.native.Listener',side_effect=OSError(errno.EADDRNOTAVAIL,'missing')):
|
||||
with self.assertRaisesRegex(ValueError,'Netzwerkadresse'):m.reconcile()
|
||||
def test_failed_connection_preserves_autostart(self):
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
m=self.manager(t);m.dispatch(dict(action='import',config=CONF))
|
||||
from network.native import save
|
||||
save(Path(t)/'enabled.json',True)
|
||||
def command(args,check=True):
|
||||
if args[:2]==['wg','setconf']:raise ValueError('synthetic failure')
|
||||
return '[]' if '-j' in args else ''
|
||||
with patch('network.native.run',side_effect=command),patch.object(m,'reconcile'):
|
||||
with self.assertRaises(ValueError):m.connect()
|
||||
self.assertTrue(json.loads((Path(t)/'enabled.json').read_text()));self.assertFalse(m.enabled)
|
||||
def manager(self,root):
|
||||
with patch.object(Manager,'reconcile'):return Manager(root,dict(lan_address='192.0.2.11',gui_port=8108,ports=[8108,8120]))
|
||||
def test_dual_stack_repeated_dns(self):
|
||||
|
||||
Reference in new issue
Block a user