1
0
mirror of https://github.com/rancher/os.git synced 2025-09-25 04:37:02 +00:00

revive integration tests

This commit is contained in:
Ivan Mikushin
2015-09-01 19:11:02 +05:00
parent e9371a67cb
commit e94f8d8a1f
11 changed files with 32 additions and 59 deletions

View File

@@ -1,10 +1,11 @@
import os
import pytest
import subprocess
@pytest.fixture(scope="session", autouse=True)
def chdir_to_project_root():
os.chdir('../..')
print('\nChdir to project root dir')
print('\nChdir to project root dir: ' + subprocess.check_output('pwd'))
os.chmod('./tests/integration/assets/test.key', 0o600)
print('Also, `chmod 600 tests/integration/assets/test.key` to make ssh happy')

View File

@@ -10,7 +10,7 @@ def qemu(request):
def rancheros_version():
with open('./scripts/version') as f:
for ln in iter(f.readline, ''):
for ln in f:
(k, _, v) = ln.partition('=')
if k == 'VERSION' and v.strip() != '':
return v.strip()
@@ -19,13 +19,14 @@ def rancheros_version():
@pytest.mark.timeout(30)
def test_system_boot(qemu):
with qemu.stdout as f:
for ln in iter(f.readline, ''):
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=rancheros_version()))
print(str.strip(ln))
if ros_booted_substr > -1:
assert True
return
version = rancheros_version()
print('parsed version: ' + version)
for ln in u.iter_lines(qemu.stdout):
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=version))
print(str.strip(ln))
if ros_booted_substr > -1:
assert True
return
assert False
@@ -38,8 +39,8 @@ def test_run_system_container(qemu):
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
with ssh, ssh.stdout as f:
for ln in iter(f.readline, ''):
print(str.strip(ln))
for ln in u.iter_lines(ssh.stdout):
print(str.strip(ln))
ssh.wait()
assert ssh.returncode == 0

View File

@@ -3,6 +3,9 @@ import subprocess
import time
def iter_lines(s):
return iter(s.readline, '')
def run_qemu(request, run_args=[]):
subprocess.check_call('rm -f ./state/empty-hd.img', shell=True)
print('\nrm ./state/*')