mirror of
https://github.com/rancher/os.git
synced 2025-07-31 22:47:16 +00:00
tests cleanup
This commit is contained in:
parent
69970ed8ed
commit
94c7eca88e
@ -1,3 +1,5 @@
|
||||
from __future__ import print_function
|
||||
import itertools as it
|
||||
import pytest
|
||||
import subprocess
|
||||
import rancherostest.util as u
|
||||
@ -9,11 +11,12 @@ def qemu(request):
|
||||
|
||||
|
||||
def rancheros_version():
|
||||
with open('./scripts/version') as f:
|
||||
for ln in f:
|
||||
(k, _, v) = ln.partition('=')
|
||||
if k == 'VERSION' and v.strip() != '':
|
||||
return v.strip()
|
||||
with open('./build.conf') as f:
|
||||
for v in it.ifilter(u.non_empty,
|
||||
it.imap(u.parse_value('VERSION'),
|
||||
it.ifilter(u.non_empty,
|
||||
it.imap(u.strip_comment('#'), u.iter_lines(f))))):
|
||||
return v
|
||||
raise RuntimeError("Could not parse RancherOS version")
|
||||
|
||||
|
||||
@ -21,12 +24,14 @@ def rancheros_version():
|
||||
def test_system_boot(qemu):
|
||||
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
|
||||
|
||||
def has_ros_started_substr(s):
|
||||
return str.find(s, 'RancherOS {v} started'.format(v=version)) > -1
|
||||
|
||||
for _ in it.ifilter(has_ros_started_substr,
|
||||
it.imap(u.with_effect(print), u.iter_lines(qemu.stdout))):
|
||||
assert True
|
||||
return
|
||||
assert False
|
||||
|
||||
|
||||
@ -40,7 +45,7 @@ def test_run_system_container(qemu):
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
for ln in u.iter_lines(ssh.stdout):
|
||||
print(str.strip(ln))
|
||||
print(ln)
|
||||
ssh.wait()
|
||||
|
||||
assert ssh.returncode == 0
|
||||
|
@ -1,10 +1,36 @@
|
||||
import itertools as it
|
||||
import pytest
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
def iter_lines(s):
|
||||
return iter(s.readline, '')
|
||||
return it.imap(str.rstrip, iter(s.readline, ''))
|
||||
|
||||
|
||||
def strip_comment(prefix):
|
||||
return lambda s: s.partition(prefix)[0].strip()
|
||||
|
||||
|
||||
def non_empty(s):
|
||||
return s != ''
|
||||
|
||||
|
||||
def parse_value(var):
|
||||
def get_value(s):
|
||||
(k, _, v) = s.partition('=')
|
||||
(k, v) = (k.strip(), v.strip())
|
||||
if k == var:
|
||||
return v
|
||||
return ''
|
||||
return get_value
|
||||
|
||||
|
||||
def with_effect(p):
|
||||
def effect(s):
|
||||
p(s)
|
||||
return s
|
||||
return effect
|
||||
|
||||
|
||||
def run_qemu(request, run_args=[]):
|
||||
|
Loading…
Reference in New Issue
Block a user