test_03_docker_in_persistent_console.py 895 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import time
  2. import pytest
  3. import rostest.util as u
  4. from rostest.util import SSH
  5. ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
  6. cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
  7. @pytest.fixture(scope="module")
  8. def qemu(request):
  9. q = u.run_qemu(request, ['--cloud-config', cloud_config_path])
  10. u.flush_out(q.stdout)
  11. return q
  12. nginx = {'amd64': 'nginx', 'arm': 'armhfbuild/nginx', 'arm64': 'armhfbuild/nginx'}
  13. @pytest.mark.timeout(40)
  14. def test_reboot_with_container_running(qemu):
  15. try:
  16. SSH(qemu, ssh_command).check_call('''
  17. set -ex
  18. docker run -d --restart=always %(image)s
  19. sudo reboot
  20. '''.strip() % {'image': nginx[u.arch]})
  21. except:
  22. pass
  23. time.sleep(3)
  24. v = SSH(qemu, ssh_command).check_output('''
  25. docker ps -f status=running
  26. '''.strip())
  27. assert v.find('nginx') != -1