Commit 36ea23a8 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 682e9b46
...@@ -328,7 +328,7 @@ class TestCliSupervisorctl(CliMixin): ...@@ -328,7 +328,7 @@ class TestCliSupervisorctl(CliMixin):
class TestCliConsole(unittest.TestCase): class TestCliConsole(unittest.TestCase):
def setUp(self): def setUp(self):
cp = slapos.slap.ComputerPartition('computer_id', 'partition_id') cp = slapos.slap.ComputerPartition('computer_id', self.id())
cp._parameter_dict = {'parameter_name': 'parameter_value'} cp._parameter_dict = {'parameter_name': 'parameter_value'}
request_patch = patch.object(slapos.slap.OpenOrder, 'request', return_value = cp) request_patch = patch.object(slapos.slap.OpenOrder, 'request', return_value = cp)
......
...@@ -53,7 +53,7 @@ class SlapMixin(unittest.TestCase): ...@@ -53,7 +53,7 @@ class SlapMixin(unittest.TestCase):
self.server_url = self._server_url self.server_url = self._server_url
print 'Testing against SLAP server %r' % self.server_url print 'Testing against SLAP server %r' % self.server_url
self.slap = slapos.slap.slap() self.slap = slapos.slap.slap()
self.partition_id = 'PARTITION_01' self.partition_id = self.id()
if os.environ.has_key('SLAPGRID_INSTANCE_ROOT'): if os.environ.has_key('SLAPGRID_INSTANCE_ROOT'):
del os.environ['SLAPGRID_INSTANCE_ROOT'] del os.environ['SLAPGRID_INSTANCE_ROOT']
...@@ -223,7 +223,7 @@ class TestSlap(SlapMixin): ...@@ -223,7 +223,7 @@ class TestSlap(SlapMixin):
""" """
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
self.slap.initializeConnection(self.server_url) self.slap.initializeConnection(self.server_url)
partition_id = 'PARTITION_01' partition_id = self.id()
def handler(url, req): def handler(url, req):
qs = urlparse.parse_qs(url.query) qs = urlparse.parse_qs(url.query)
...@@ -644,7 +644,7 @@ class TestComputerPartition(SlapMixin): ...@@ -644,7 +644,7 @@ class TestComputerPartition(SlapMixin):
'software_type', 'myref') 'software_type', 'myref')
def test_request_not_raises(self): def test_request_not_raises(self):
partition_id = 'PARTITION_01' partition_id = self.id()
def handler(url, req): def handler(url, req):
qs = urlparse.parse_qs(url.query) qs = urlparse.parse_qs(url.query)
...@@ -688,7 +688,7 @@ class TestComputerPartition(SlapMixin): ...@@ -688,7 +688,7 @@ class TestComputerPartition(SlapMixin):
self.assertIsInstance(requested_partition, slapos.slap.ComputerPartition) self.assertIsInstance(requested_partition, slapos.slap.ComputerPartition)
def test_request_raises_later(self): def test_request_raises_later(self):
partition_id = 'PARTITION_01' partition_id = self.id()
def handler(url, req): def handler(url, req):
qs = urlparse.parse_qs(url.query) qs = urlparse.parse_qs(url.query)
...@@ -735,8 +735,8 @@ class TestComputerPartition(SlapMixin): ...@@ -735,8 +735,8 @@ class TestComputerPartition(SlapMixin):
requested_partition.getId) requested_partition.getId)
def test_request_fullfilled_work(self): def test_request_fullfilled_work(self):
partition_id = 'PARTITION_01' partition_id = 'PARTITION_01-%s' % self.id()
requested_partition_id = 'PARTITION_02' requested_partition_id = 'PARTITION_02-%s' % self.id()
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
def handler(url, req): def handler(url, req):
...@@ -792,7 +792,7 @@ class TestComputerPartition(SlapMixin): ...@@ -792,7 +792,7 @@ class TestComputerPartition(SlapMixin):
def test_request_with_slapgrid_request_transaction(self): def test_request_with_slapgrid_request_transaction(self):
from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME
partition_id = 'PARTITION_01' partition_id = self.id()
instance_root = tempfile.mkdtemp() instance_root = tempfile.mkdtemp()
partition_root = os.path.join(instance_root, partition_id) partition_root = os.path.join(instance_root, partition_id)
os.mkdir(partition_root) os.mkdir(partition_root)
...@@ -874,7 +874,7 @@ class TestComputerPartition(SlapMixin): ...@@ -874,7 +874,7 @@ class TestComputerPartition(SlapMixin):
Partition Partition
""" """
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
partition_id = 'PARTITION_01' partition_id = self.id()
slap = self.slap slap = self.slap
slap.initializeConnection(self.server_url) slap.initializeConnection(self.server_url)
...@@ -918,7 +918,7 @@ class TestComputerPartition(SlapMixin): ...@@ -918,7 +918,7 @@ class TestComputerPartition(SlapMixin):
Asserts that calling ComputerPartition.error on new partition works Asserts that calling ComputerPartition.error on new partition works
""" """
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
partition_id = 'PARTITION_01' partition_id = self.id()
slap = self.slap slap = self.slap
slap.initializeConnection(self.server_url) slap.initializeConnection(self.server_url)
...@@ -1070,7 +1070,7 @@ class TestOpenOrder(SlapMixin): ...@@ -1070,7 +1070,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration # XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder() open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01' requested_partition_id = self.id()
def handler(url, req): def handler(url, req):
from slapos.slap.slap import SoftwareInstance from slapos.slap.slap import SoftwareInstance
...@@ -1096,7 +1096,7 @@ class TestOpenOrder(SlapMixin): ...@@ -1096,7 +1096,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration # XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder() open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01' requested_partition_id = self.id()
def handler(url, req): def handler(url, req):
from slapos.slap.slap import SoftwareInstance from slapos.slap.slap import SoftwareInstance
...@@ -1126,7 +1126,7 @@ class TestOpenOrder(SlapMixin): ...@@ -1126,7 +1126,7 @@ class TestOpenOrder(SlapMixin):
# XXX: Interface lack registerOpenOrder method declaration # XXX: Interface lack registerOpenOrder method declaration
open_order = self.slap.registerOpenOrder() open_order = self.slap.registerOpenOrder()
computer_guid = self._getTestComputerId() computer_guid = self._getTestComputerId()
requested_partition_id = 'PARTITION_01' requested_partition_id = self.id()
def handler(url, req): def handler(url, req):
from slapos.slap.slap import SoftwareInstance 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