isolate test_db_find_column_type_list

As per the recent gate failures (see bug), it appears
OVSLibTestCase.test_db_find_column_type_list is not isolated
and thus its usage of ovsdb's db_list() and db_find() occasionally
obtain different results.

This patch adds the db_list() and db_find() operations within the
test case to run in a transaction so that we get a single snapshot
of the db results.

In addition this patch undoes the changes from patch set 1 as the
initial changes do not appear to address the issue at hand.

Change-Id: I312076edb6e11f21347831843758894e11d6f56c
Closes-Bug: #1592546
This commit is contained in:
Boden R 2016-07-21 15:07:41 +05:30
parent 190ead3118
commit 319bc525b4
1 changed files with 12 additions and 8 deletions

View File

@ -380,16 +380,20 @@ class OVSLibTestCase(base.BaseOVSLinuxTestCase):
port_name = base.get_rand_name(prefix=net_helpers.PORT_PREFIX)
br.add_port(port_name)
self.ovs.set_db_attribute('Port', port_name, 'tag', 42)
tags = self.ovs.ovsdb.db_list('Port', columns=['tag']).execute()
# wrap list/find in transaction so we get a single isolated snapshot
with self.ovs.ovsdb.transaction(check_error=True) as txn:
tags = txn.add(self.ovs.ovsdb.db_list('Port', columns=['tag']))
len_0_list = txn.add(self.ovs.ovsdb.db_find(
'Port', ('tag', '!=', []), columns=['tag']))
single_value = txn.add(self.ovs.ovsdb.db_find(
'Port', ('tag', '=', 42), columns=['tag']))
# Make sure that there is data to query.
# It should be, but let's be a little paranoid here as otherwise
# the test has no sense
tags_present = [t for t in tags if t['tag'] != []]
tags_present = [t for t in tags.result if t['tag'] != []]
self.assertTrue(tags_present)
tags_42 = [t for t in tags_present if t['tag'] == 42]
single_value = self.ovs.ovsdb.db_find(
'Port', ('tag', '=', 42), columns=['tag']).execute()
self.assertEqual(tags_42, single_value)
len_0_list = self.ovs.ovsdb.db_find(
'Port', ('tag', '!=', []), columns=['tag']).execute()
self.assertItemsEqual(tags_present, len_0_list)
self.assertEqual(tags_42, single_value.result)
self.assertItemsEqual(len_0_list.result, tags_present)