test_07_oem.py 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import time
  2. import pytest
  3. import rostest.util as u
  4. from rostest.util import SSH
  5. @pytest.fixture(scope="module")
  6. def qemu(request):
  7. q = u.run_qemu(request, run_args=['--append', 'rancher.state.dev=x'])
  8. u.flush_out(q.stdout)
  9. return q
  10. def test_oem(qemu):
  11. try:
  12. SSH(qemu).check_call('''
  13. set -x
  14. set -e
  15. sudo mkfs.ext4 -L RANCHER_OEM /dev/vda
  16. sudo mount /dev/vda /mnt
  17. cat > /tmp/oem-config.yml << EOF
  18. #cloud-config
  19. rancher:
  20. upgrade:
  21. url: 'foo'
  22. EOF
  23. sudo cp /tmp/oem-config.yml /mnt
  24. sudo umount /mnt
  25. sudo reboot
  26. '''.strip())
  27. except:
  28. pass
  29. time.sleep(3)
  30. SSH(qemu).check_call('''
  31. set -x
  32. if [ ! -e /usr/share/ros/oem/oem-config.yml ]; then
  33. echo Failed to find /usr/share/ros/oem/oem-config.yml
  34. exit 1
  35. fi
  36. FOO="$(sudo ros config get rancher.upgrade.url)"
  37. if [ "$FOO" != "foo" ]; then
  38. echo rancher.upgrade.url is not foo
  39. exit 1
  40. fi
  41. '''.strip())