Merge "isolate test_db_find_column_type_list"

This commit is contained in:
Jenkins 2016-08-11 01:15:41 +00:00 committed by Gerrit Code Review
commit b6d9c6c3ce
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)