test_14_ros_config.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import pytest
  2. import rostest.util as u
  3. from rostest.util import SSH
  4. cloud_config_path = './tests/integration/assets/test_14/cloud-config.yml'
  5. @pytest.fixture(scope="module")
  6. def qemu(request):
  7. q = u.run_qemu(request, run_args=['--cloud-config', cloud_config_path])
  8. u.flush_out(q.stdout)
  9. return q
  10. def test_ros_config_string(qemu):
  11. SSH(qemu).check_call('''
  12. set -x -e
  13. if [ "$(sudo ros config get hostname)" == "hostname3
  14. " ]; then
  15. sudo ros config get hostname
  16. exit 1
  17. fi
  18. sudo ros config set hostname rancher-test
  19. if [ "$(sudo ros config get hostname)" == "rancher-test
  20. " ]; then
  21. sudo ros config get hostname
  22. exit 1
  23. fi
  24. '''.strip())
  25. def test_ros_config_bool(qemu):
  26. SSH(qemu).check_call('''
  27. set -x -e
  28. if [ "$(sudo ros config get rancher.log)" == "true
  29. " ]; then
  30. sudo ros config get rancher.log
  31. exit 1
  32. fi
  33. sudo ros config set rancher.log false
  34. if [ "$(sudo ros config get rancher.log)" == "false
  35. " ]; then
  36. sudo ros config get rancher.log
  37. exit 1
  38. fi
  39. if [ "$(sudo ros config get rancher.debug)" == "false
  40. " ]; then
  41. sudo ros config get rancher.debug
  42. exit 1
  43. fi
  44. sudo ros config set rancher.debug true
  45. if [ "$(sudo ros config get rancher.debug)" == "true
  46. " ]; then
  47. sudo ros config get rancher.debug
  48. exit 1
  49. fi
  50. '''.strip())
  51. def test_ros_config_slice(qemu):
  52. SSH(qemu).check_call('''
  53. set -x -e
  54. sudo ros config set rancher.network.dns.search '[a,b]'
  55. if [ "$(sudo ros config get rancher.network.dns.search)" == "- a
  56. - b
  57. " ]; then
  58. sudo ros config get rancher.network.dns.search
  59. exit 1
  60. fi
  61. sudo ros config set rancher.network.dns.search '[]'
  62. if [ "$(sudo ros config get rancher.network.dns.search)" == "[]
  63. " ]; then
  64. sudo ros config get rancher.network.dns.search
  65. exit 1
  66. fi
  67. '''.strip())
  68. def test_ros_export(qemu):
  69. SSH(qemu).check_call('''
  70. set -x -e
  71. if sudo ros config export | grep "PRIVATE KEY"; then
  72. exit 1
  73. fi
  74. sudo ros config export --private | grep "PRIVATE KEY"
  75. sudo ros config export --full | grep "udev"
  76. sudo ros config export --private --full | grep "ntp"
  77. sudo ros config export --full | grep "labels"
  78. sudo ros config export --private --full | grep "PRIVATE KEY"
  79. '''.strip())