2015-05-07 19:49:54 +05:00
|
|
|
import pytest
|
2015-05-07 18:59:48 +05:00
|
|
|
import subprocess
|
2015-05-08 14:10:17 +05:00
|
|
|
import rancherostest.util as u
|
2015-05-07 18:59:48 +05:00
|
|
|
|
|
|
|
|
2015-05-07 19:49:54 +05:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def qemu(request):
|
2015-05-08 14:10:17 +05:00
|
|
|
return u.run_qemu(request)
|
2015-05-07 19:49:54 +05:00
|
|
|
|
|
|
|
|
2015-05-08 12:51:13 +05:00
|
|
|
def rancheros_version():
|
|
|
|
with open('./scripts/version') as f:
|
|
|
|
for ln in iter(f.readline, ''):
|
|
|
|
(k, _, v) = ln.partition('=')
|
|
|
|
if k == 'VERSION' and v.strip() != '':
|
|
|
|
return v.strip()
|
|
|
|
raise RuntimeError("Could not parse RancherOS version")
|
|
|
|
|
|
|
|
|
2015-05-08 11:51:15 +05:00
|
|
|
@pytest.mark.timeout(30)
|
2015-05-07 19:49:54 +05:00
|
|
|
def test_system_boot(qemu):
|
2015-05-08 13:03:50 +05:00
|
|
|
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
|
2015-05-07 21:01:19 +05:00
|
|
|
assert False
|
|
|
|
|
|
|
|
|
2015-05-08 15:15:14 +05:00
|
|
|
@pytest.mark.timeout(60)
|
2015-05-07 21:01:19 +05:00
|
|
|
def test_run_system_container(qemu):
|
2015-05-08 16:23:12 +05:00
|
|
|
assert qemu is not None
|
2015-05-08 14:10:17 +05:00
|
|
|
u.wait_for_ssh()
|
2015-05-08 16:23:12 +05:00
|
|
|
|
2015-05-07 21:01:19 +05:00
|
|
|
ssh = subprocess.Popen(
|
|
|
|
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
|
2015-05-08 10:42:18 +05:00
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
2015-05-07 21:01:19 +05:00
|
|
|
|
2015-05-08 14:25:11 +05:00
|
|
|
with ssh, ssh.stdout as f:
|
|
|
|
for ln in iter(f.readline, ''):
|
|
|
|
print(str.strip(ln))
|
|
|
|
|
|
|
|
assert ssh.returncode == 0
|