Tests: fixed ruby isolation.
While alternating between running priv and unpriv tests locally, it happens that unpriv tests can't bind mount or create sub directories inside directories created by root. This patch fixes this by pointing "rootfs" to temporary directory. Now the priv and unpriv test uses the same test function.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from conftest import unit_run
|
from conftest import unit_run
|
||||||
@@ -26,7 +27,7 @@ class TestRubyIsolation(TestApplicationRuby):
|
|||||||
|
|
||||||
return check if not complete_check else check()
|
return check if not complete_check else check()
|
||||||
|
|
||||||
def test_ruby_isolation_rootfs_mount_namespace(self, is_su):
|
def test_ruby_isolation_rootfs(self, is_su):
|
||||||
isolation_features = option.available['features']['isolation'].keys()
|
isolation_features = option.available['features']['isolation'].keys()
|
||||||
|
|
||||||
if not is_su:
|
if not is_su:
|
||||||
@@ -42,34 +43,22 @@ class TestRubyIsolation(TestApplicationRuby):
|
|||||||
if 'pid' not in isolation_features:
|
if 'pid' not in isolation_features:
|
||||||
pytest.skip('pid namespace is not supported')
|
pytest.skip('pid namespace is not supported')
|
||||||
|
|
||||||
isolation = {'rootfs': option.test_dir}
|
isolation = {'rootfs': option.temp_dir}
|
||||||
|
|
||||||
if not is_su:
|
if not is_su:
|
||||||
isolation['namespaces'] = {
|
isolation['namespaces'] = {
|
||||||
'mount': True,
|
'mount': True,
|
||||||
'credential': True,
|
'credential': True,
|
||||||
'pid': True
|
'pid': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.load('status_int', isolation=isolation)
|
os.mkdir(option.temp_dir + '/ruby')
|
||||||
|
|
||||||
assert 'success' in self.conf(
|
shutil.copytree(
|
||||||
'"/ruby/status_int/config.ru"', 'applications/status_int/script',
|
option.test_dir + '/ruby/status_int',
|
||||||
|
option.temp_dir + '/ruby/status_int',
|
||||||
)
|
)
|
||||||
|
|
||||||
assert 'success' in self.conf(
|
|
||||||
'"/ruby/status_int"', 'applications/status_int/working_directory',
|
|
||||||
)
|
|
||||||
|
|
||||||
assert self.get()['status'] == 200, 'status int'
|
|
||||||
|
|
||||||
def test_ruby_isolation_rootfs(self, is_su):
|
|
||||||
if not is_su:
|
|
||||||
pytest.skip('requires root')
|
|
||||||
return
|
|
||||||
|
|
||||||
isolation = {'rootfs': option.test_dir}
|
|
||||||
|
|
||||||
self.load('status_int', isolation=isolation)
|
self.load('status_int', isolation=isolation)
|
||||||
|
|
||||||
assert 'success' in self.conf(
|
assert 'success' in self.conf(
|
||||||
|
|||||||
Reference in New Issue
Block a user