test_10_network_from_url.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_10/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. SCRIPT
  24. sudo bash test-merge
  25. '''.strip())
  26. def test_network_dns_conf(qemu):
  27. SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
  28. set -x -e
  29. cat /etc/resolv.conf | grep "search mydomain.com example.com"
  30. cat /etc/resolv.conf | grep "nameserver 208.67.222.123"
  31. cat /etc/resolv.conf | grep "nameserver 208.67.220.123"
  32. SCRIPT
  33. sudo bash test-merge
  34. '''.strip())
  35. def test_network_dns_ros_set(qemu):
  36. SSH(qemu).check_call('''
  37. set -x -e
  38. sudo ros config set rancher.network.dns.search '[a,b]'
  39. if [ "$(sudo ros config get rancher.network.dns.search)" == "- a
  40. - b
  41. " ]; then
  42. sudo ros config get rancher.network.dns.search
  43. exit 1
  44. fi
  45. '''.strip())