Fix the failing py26 tests on jenkins

While all our tests were passing on our dev machines, the python 2.6
tests were failing in the Stackforge Jenkins environment.

The reason seems to boil down to database queries returning items in a
different order when no explicit ordering was specified. Our tests were
relying on one ordering which coused them to fail.

This fixes the two failing tests we had, but there may be more out
there, passing by a happy coincidence.

Change-Id: I444394a7e73677313ff749525c978f6954fe4509
Signed-off-by: Tomas Sedovic <tsedovic@redhat.com>
This commit is contained in:
Tomas Sedovic 2013-08-30 11:49:34 +02:00
parent c0a723455a
commit 03fa57a7c5

View File

@ -83,10 +83,15 @@ class TestDbFlavors(db_base.DbTestCase):
pecan_rc.flavors = [utils.get_test_flavor(name='xyz', value='123'),
utils.get_test_flavor(name='abc', value='456')]
db_rc = self.db.create_resource_class(pecan_rc)
# we cannot rely on the order of the db_rc.flavors items
if db_rc.flavors[0].name == 'xyz':
xyz_flavor = db_rc.flavors[0]
else:
xyz_flavor = db_rc.flavors[1]
#now update one of the flavors:
updated_flav = self.db.update_resource_class_flavor(
db_rc.id,
db_rc.flavors[1].id,
xyz_flavor.id,
utils.get_test_flavor(name='xyz', value='999'))
#retrieve updated rc and assert:
updated_rc = self.db.get_resource_class(db_rc.id)
@ -116,8 +121,13 @@ class TestDbFlavors(db_base.DbTestCase):
pecan_rc.flavors = [utils.get_test_flavor(name='xyz', value='123'),
utils.get_test_flavor(name='abc', value='456')]
db_rc = self.db.create_resource_class(pecan_rc)
# we cannot rely on the order of the db_rc.flavors items
if db_rc.flavors[0].name == 'abc':
abc_flavor = db_rc.flavors[0]
else:
abc_flavor = db_rc.flavors[1]
#retrieve a specific flavor
flav = self.db.get_flavor(db_rc.flavors[0].id)
flav = self.db.get_flavor(abc_flavor.id)
self.__check_flavor_capacities([flav], ['abc'], ['456'])
#cleanup
self.db.delete_resource_class(db_rc.id)