1
0
mirror of https://github.com/rancher/os.git synced 2025-07-02 09:41:47 +00:00
os/tests/integration/rancherostest/test_system.py

46 lines
1.1 KiB
Python
Raw Normal View History

import pytest
2015-05-07 13:59:48 +00:00
import string
import subprocess
@pytest.fixture(scope="module")
def qemu(request):
2015-05-07 13:59:48 +00:00
p = subprocess.Popen('./scripts/run', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def fin():
2015-05-07 16:01:19 +00:00
print('\nTerminating QEMU!!!')
2015-05-07 13:59:48 +00:00
p.stdout.close()
p.terminate()
request.addfinalizer(fin)
return p
@pytest.mark.timeout(20)
def test_system_boot(qemu):
for ln in iter(qemu.stdout.readline, ''):
2015-05-07 16:01:19 +00:00
ros_booted_substr = string.find(ln, 'RancherOS v0.3.1-rc2 started')
if ros_booted_substr > -1:
assert True
return
2015-05-07 16:01:19 +00:00
assert False
@pytest.mark.timeout(20)
def test_run_system_container(qemu):
assert qemu.returncode is None
ssh = subprocess.Popen(
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
try:
for ln in iter(ssh.stdout.readline, ''):
print(ln)
pass
ssh.wait()
assert ssh.returncode == 0
finally:
ssh.stdout.close()
if ssh.returncode is None:
ssh.terminate()