1
0
mirror of https://github.com/rancher/os.git synced 2025-09-18 16:27:31 +00:00

Use a subdirectory of the state partition

This commit is contained in:
Darren Shepherd
2015-12-19 22:34:07 -07:00
parent 9c6b16928a
commit 808fbdbe1f
7 changed files with 76 additions and 13 deletions

View File

@@ -2,11 +2,12 @@ import subprocess
import os
import pytest
import rostest
@pytest.fixture(scope="session", autouse=True)
def chdir_to_project_root():
os.chdir('../..')
os.chdir(os.path.join(os.path.dirname(rostest.__file__), '../../..'))
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

@@ -0,0 +1,19 @@
import pytest
import rostest.util as u
from rostest.util import SSH
@pytest.fixture(scope="module")
def qemu(request):
q = u.run_qemu(request, run_args=['--append', 'rancher.state.directory=ros_subdir'])
u.flush_out(q.stdout)
return q
def test_system_docker_survives_custom_docker_install(qemu):
SSH(qemu).check_call('bash', '-c', '''
set -x -e
mkdir x
sudo mount $(ros dev LABEL=RANCHER_STATE) x
[ -d x/ros_subdir/home/rancher ]
'''.strip())

View File

@@ -85,3 +85,19 @@ def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu'], command=['docker
print('\nWaiting for ssh and docker... ' + str(i))
time.sleep(1)
assert qemu.returncode is None
class SSH:
def __init__(self, qemu, ssh_command=['./scripts/ssh', '--qemu']):
self._qemu = qemu
self._ssh_command = ssh_command
self._waited = False
def check_call(self, *args, **kw):
if not self._waited:
wait_for_ssh(self._qemu, ssh_command=self._ssh_command)
self._waited = True
kw['stderr'] = subprocess.STDOUT
kw['universal_newlines'] = True
return subprocess.check_call(self._ssh_command + list(args), **kw)