Commit 7bcfc6fe authored by Jérome Perrin's avatar Jérome Perrin

tests: make each test use a different partition_id

This can hide problems when tests are not isolated correctly.
parent 6d95ac41
......@@ -332,7 +332,7 @@ print(request('software_release', 'instance').getInstanceParameterDict()['parame
@contextmanager
def _test_console(self):
cp = slapos.slap.ComputerPartition('computer_id', 'partition_id')
cp = slapos.slap.ComputerPartition('computer_%s' % self.id(), 'partition_%s' % self.id())
cp._parameter_dict = {'parameter_name': 'parameter_value'}
with patch.object(slapos.slap.OpenOrder, 'request',
return_value = cp) as mock_request, \
......
......@@ -55,7 +55,7 @@ class SlapMixin(unittest.TestCase):
self.server_url = self._server_url
print('Testing against SLAP server %r' % self.server_url)
self.slap = slapos.slap.slap()
self.partition_id = 'PARTITION_01'
self.partition_id = self.id()
os.environ.pop('SLAPGRID_INSTANCE_ROOT', None)
def tearDown(self):
......@@ -224,7 +224,7 @@ class TestSlap(SlapMixin):
"""
computer_guid = self._getTestComputerId()
self.slap.initializeConnection(self.server_url)
partition_id = 'PARTITION_01'
partition_id = self.id()
def handler(url, req):
qs = parse.parse_qs(url.query)
......@@ -645,7 +645,7 @@ class TestComputerPartition(SlapMixin):
'software_type', 'myref')
def test_request_not_raises(self):
partition_id = 'PARTITION_01'
partition_id = self.id()
def handler(url, req):
qs = parse.parse_qs(url.query)
......@@ -689,7 +689,7 @@ class TestComputerPartition(SlapMixin):
self.assertIsInstance(requested_partition, slapos.slap.ComputerPartition)
def test_request_raises_later(self):
partition_id = 'PARTITION_01'
partition_id = self.id()
def handler(url, req):
qs = parse.parse_qs(url.query)
......@@ -736,8 +736,8 @@ class TestComputerPartition(SlapMixin):
requested_partition.getId)
def test_request_fullfilled_work(self):
partition_id = 'PARTITION_01'
requested_partition_id = 'PARTITION_02'
partition_id = 'PARTITION_01-%s' % self.id()
requested_partition_id = 'PARTITION_02-%s' % self.id()
computer_guid = self._getTestComputerId()
def handler(url, req):
......@@ -793,7 +793,7 @@ class TestComputerPartition(SlapMixin):
def test_request_with_slapgrid_request_transaction(self):
from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME
partition_id = 'PARTITION_01'
partition_id = self.id()
instance_root = tempfile.mkdtemp()
partition_root = os.path.join(instance_root, partition_id)
os.mkdir(partition_root)
......@@ -875,7 +875,7 @@ class TestComputerPartition(SlapMixin):
Partition
"""
computer_guid = self._getTestComputerId()
partition_id = 'PARTITION_01'
partition_id = self.id()
slap = self.slap
slap.initializeConnection(self.server_url)
......@@ -919,7 +919,7 @@ class TestComputerPartition(SlapMixin):
Asserts that calling ComputerPartition.error on new partition works
"""
computer_guid = self._getTestComputerId()
partition_id = 'PARTITION_01'
partition_id = self.id()
slap = self.slap
slap.initializeConnection(self.server_url)
......@@ -1071,7 +1071,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01'
requested_partition_id = self.id()
def handler(url, req):
from slapos.slap.slap import SoftwareInstance
......@@ -1097,7 +1097,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01'
requested_partition_id = self.id()
def handler(url, req):
from slapos.slap.slap import SoftwareInstance
......@@ -1127,7 +1127,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01'
requested_partition_id = self.id()
def handler(url, req):
from slapos.slap.slap import SoftwareInstance
......
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