test_00_system.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import pytest
  2. import subprocess
  3. import rancherostest.util as u
  4. @pytest.fixture(scope="module")
  5. def qemu(request):
  6. return u.run_qemu(request)
  7. def rancheros_version():
  8. with open('./scripts/version') as f:
  9. for ln in iter(f.readline, ''):
  10. (k, _, v) = ln.partition('=')
  11. if k == 'VERSION' and v.strip() != '':
  12. return v.strip()
  13. raise RuntimeError("Could not parse RancherOS version")
  14. @pytest.mark.timeout(30)
  15. def test_system_boot(qemu):
  16. with qemu.stdout as f:
  17. for ln in iter(f.readline, ''):
  18. ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=rancheros_version()))
  19. print(str.strip(ln))
  20. if ros_booted_substr > -1:
  21. assert True
  22. return
  23. assert False
  24. @pytest.mark.timeout(60)
  25. def test_run_system_container(qemu):
  26. assert qemu is not None
  27. u.wait_for_ssh()
  28. ssh = subprocess.Popen(
  29. './scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
  30. stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
  31. with ssh, ssh.stdout as f:
  32. for ln in iter(f.readline, ''):
  33. print(str.strip(ln))
  34. assert ssh.returncode == 0