Commit 9181210a authored by Tomáš Peterka's avatar Tomáš Peterka

WIP: fixing tests

parent 2b90fc01
......@@ -256,7 +256,7 @@ class CGroupManager(object):
self.software_gid = computer.software_gid
def allowed(self):
return os.path.exists("/sys/fs/cgroup/cpuset/cpuset.cpus"):
return os.path.exists("/sys/fs/cgroup/cpuset/cpuset.cpus")
def format(self):
"""Build CGROUP tree to fit SlapOS needs.
......@@ -408,10 +408,10 @@ class Computer(object):
self.tap_gateway_interface = tap_gateway_interface
# Used to be static attributes of the class object - didn't make sense (Marco again)
assert instance_root is not None and software_root is not None,
assert instance_root is not None and software_root is not None, \
"Computer's instance_root and software_root must not be empty!"
self.software_root = instance_root
self.instance_root = software_root
self.software_root = software_root
self.instance_root = instance_root
self.instance_storage_home = instance_storage_home
# The following properties are updated on update() method
......@@ -550,7 +550,7 @@ class Computer(object):
archive.writestr(saved_filename, xml_content, zipfile.ZIP_DEFLATED)
@classmethod
def load(cls, path_to_xml, reference, ipv6_interface, tap_gateway_interface
def load(cls, path_to_xml, reference, ipv6_interface, tap_gateway_interface,
instance_root=None, software_root=None):
"""
Create a computer object from a valid xml file.
......@@ -758,6 +758,8 @@ class Computer(object):
partition.tap.ipv4_gateway = gateway_addr_dict['addr']
partition.tap.ipv4_network = gateway_addr_dict['network']
partition.tap.createRoutes()
if alter_network and partition.tun is not None:
# create TUN interface per partition as well
partition.tun.createWithOwner(owner)
partition.tun.createRoutes()
......@@ -1219,7 +1221,7 @@ class Interface(object):
if self.isBridge():
callAndRead(['brctl', 'addif', self.name, tap.name])
else:
self.logger.warning("Interface slapos.cfg:interface_name={} is not a bridge. "
logger.warning("Interface slapos.cfg:interface_name={} is not a bridge. "
"TUN/TAP interface {} might not have internet connection."
"".format(self.name, tap.name))
......
......@@ -325,12 +325,12 @@ class SlapformatMixin(unittest.TestCase):
class TestComputer(SlapformatMixin):
def test_getAddress_empty_computer(self):
computer = slapos.format.Computer('computer')
computer = slapos.format.Computer('computer', instance_root='/instance_root', software_root='software_root')
self.assertEqual(computer.getAddress(), {'netmask': None, 'addr': None})
@unittest.skip("Not implemented")
def test_construct_empty(self):
computer = slapos.format.Computer('computer')
computer = slapos.format.Computer('computer', instance_root='/instance_root', software_root='software_root')
computer.format()
@unittest.skip("Not implemented")
......@@ -368,7 +368,8 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)",
"chmod('/software_root', 493)"],
self.test_result.bucket)
self.assertEqual(['ip addr list bridge'],
self.assertEqualCommands(
['ip addr list bridge'],
self.fakeCallAndRead.external_command_list)
@unittest.skip("Not implemented")
......@@ -462,12 +463,10 @@ class TestComputer(SlapformatMixin):
logger=self.logger, name='bridge', ipv4_local_network='127.0.0.1/16'),
partition_list=[
slapos.format.Partition(
'partition', '/part_path', slapos.format.User('testuser'), [], tap=None),
'partition', '/part_path', slapos.format.User('testuser'), [], tap=slapos.format.Tap('tap')),
])
global USER_LIST
USER_LIST = ['testuser']
partition.tap = slapos.format.Tap('tap')
computer.partition_list = [partition]
global INTERFACE_DICT
INTERFACE_DICT['bridge'] = {
socket.AF_INET: [{'addr': '192.168.242.77', 'broadcast': '127.0.0.1',
......@@ -501,8 +500,9 @@ class TestComputer(SlapformatMixin):
computer = slapos.format.Computer('computer',
instance_root='/instance_root',
software_root='/software_root',
tap_gateway_interface='eth1',
interface=slapos.format.Interface(
logger=self.logger, name='iface', ipv4_local_network='127.0.0.1/16', tap_gateway_interface='eth1'),
logger=self.logger, name='iface', ipv4_local_network='127.0.0.1/16'),
partition_list=[
slapos.format.Partition(
'partition', '/part_path', slapos.format.User('testuser'), [], tap=None),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment