test_09_network.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import pytest
  2. import rostest.util as u
  3. from rostest.util import SSH
  4. pytestmark = pytest.mark.skipif(u.arch != 'amd64', reason='amd64 network setup impossible to replicate for arm64')
  5. cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
  6. net_args_arch = {'amd64': ['-net', 'nic,vlan=0,model=virtio'],
  7. 'arm64': ['-device', 'virtio-net-device']}
  8. net_args_arch['arm'] = net_args_arch['arm64']
  9. net_args = net_args_arch[u.arch]
  10. @pytest.fixture(scope="module")
  11. def qemu(request):
  12. q = u.run_qemu(request,
  13. run_args=['--cloud-config', cloud_config_path] +
  14. net_args + net_args + net_args + net_args + net_args + net_args + net_args)
  15. u.flush_out(q.stdout)
  16. return q
  17. def test_network_interfaces_conf(qemu):
  18. SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
  19. set -x -e
  20. ip link show dev br0
  21. ip link show dev br0.100 | grep br0.100@br0
  22. ip link show dev eth1.100 | grep 'master br0'
  23. ip link show dev eth6 | grep 'master bond0'
  24. ip link show dev eth7 | grep 'master bond0'
  25. [ "$(</sys/class/net/bond0/bonding/mode)" = "active-backup 1" ]
  26. SCRIPT
  27. sudo bash test-merge
  28. '''.strip())
  29. def test_network_dns_conf(qemu):
  30. SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
  31. set -x -e
  32. cat /etc/resolv.conf | grep "search mydomain.com example.com"
  33. cat /etc/resolv.conf | grep "nameserver 208.67.222.123"
  34. cat /etc/resolv.conf | grep "nameserver 208.67.220.123"
  35. SCRIPT
  36. sudo bash test-merge
  37. '''.strip())