|
27 | 27 |
|
28 | 28 | FAKE_CFG_RATE = 123
|
29 | 29 | FAKE_CFG_BURST = 321
|
| 30 | +FAKE_LABEL = 1 |
30 | 31 |
|
31 | 32 |
|
32 | 33 | class TestOVNDriverBase(base.BaseTestCase):
|
@@ -113,6 +114,7 @@ def __init__(self, name=None, **acl_dict):
|
113 | 114 | acl_defaults_dict = {
|
114 | 115 | "name": [name] if name else [],
|
115 | 116 | "action": ovn_const.ACL_ACTION_ALLOW_RELATED,
|
| 117 | + "label": FAKE_LABEL |
116 | 118 | }
|
117 | 119 | self.__dict__ = {**acl_defaults_dict, **acl_dict}
|
118 | 120 |
|
@@ -247,6 +249,19 @@ def _mock_lookup(_pg_table, acl_uuid, default):
|
247 | 249 | self.assertEqual(len(pg_dict["acls"]) - 1,
|
248 | 250 | self._nb_ovn.db_set.call_count)
|
249 | 251 |
|
| 252 | + # This test is enforcing the use of if_exists so that we don't get |
| 253 | + # unexpected errors while doing parallel operations like erasing log |
| 254 | + # objects and security groups |
| 255 | + @mock.patch.object(ovn_driver.LOG, 'info') |
| 256 | + def test__remove_acls_log_only_if_exists(self, m_info): |
| 257 | + pg_dict = self._fake_pg_dict(acls=['acl1', 'acl2', 'acl3']) |
| 258 | + |
| 259 | + def _only_if_exists(_pg_table, acl_uuid, col, val, if_exists): |
| 260 | + self.assertTrue(if_exists) |
| 261 | + |
| 262 | + self._nb_ovn.db_remove.side_effect = _only_if_exists |
| 263 | + self._log_driver._remove_acls_log([pg_dict], self._nb_ovn.transaction) |
| 264 | + |
250 | 265 | @mock.patch.object(ovn_driver.LOG, 'info')
|
251 | 266 | def test__remove_acls_log_with_log_name(self, m_info):
|
252 | 267 | pg_dict = self._fake_pg_dict(acls=['acl1', 'acl2', 'acl3', 'acl4'])
|
|
0 commit comments