1
0
mirror of https://github.com/rancher/os.git synced 2025-07-13 14:44:03 +00:00

test_run_system_container: fixed

This commit is contained in:
Ivan Mikushin 2015-05-07 22:27:17 +05:00
parent a753ca7930
commit 72b29cc797

View File

@ -1,6 +1,7 @@
import pytest import pytest
import string import string
import subprocess import subprocess
import time
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
@ -8,7 +9,7 @@ def qemu(request):
p = subprocess.Popen('./scripts/run', stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p = subprocess.Popen('./scripts/run', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def fin(): def fin():
print('\nTerminating QEMU!!!') print('\nTerminating QEMU')
p.stdout.close() p.stdout.close()
p.terminate() p.terminate()
@ -20,22 +21,24 @@ def qemu(request):
def test_system_boot(qemu): def test_system_boot(qemu):
for ln in iter(qemu.stdout.readline, ''): for ln in iter(qemu.stdout.readline, ''):
ros_booted_substr = string.find(ln, 'RancherOS v0.3.1-rc2 started') ros_booted_substr = string.find(ln, 'RancherOS v0.3.1-rc2 started')
print(string.strip(ln))
if ros_booted_substr > -1: if ros_booted_substr > -1:
assert True assert True
return return
assert False assert False
@pytest.mark.timeout(20) @pytest.mark.timeout(40)
def test_run_system_container(qemu): def test_run_system_container(qemu):
assert qemu.returncode is None assert qemu.returncode is None
time.sleep(1) # or else ssh will fail (WTF?!)
ssh = subprocess.Popen( ssh = subprocess.Popen(
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True, './scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
try: try:
for ln in iter(ssh.stdout.readline, ''): for ln in iter(ssh.stdout.readline, ''):
print(ln) print(string.strip(ln))
pass pass
ssh.wait() ssh.wait()
assert ssh.returncode == 0 assert ssh.returncode == 0