def schema_transformer_restart(self): def mock_acl_update(*args, **kwargs): self.assertTrue(False, 'Error: Should not have updated acl entries') old_acl_update = DBBaseST._vnc_lib.access_control_list_update DBBaseST._vnc_lib.access_control_list_update = mock_acl_update test_common.reinit_schema_transformer() DBBaseST._vnc_lib.access_control_list_update = old_acl_update
def test_route_target_id_collision(self): db_checker = db_manage.DatabaseChecker( *db_manage._parse_args('check --cluster_id %s' % self._cluster_id)) zkc = db_checker._zk_client DEPRECATED_BASE_RTGT = "/".join( [x for x in db_checker.BASE_RTGT_ID_ZK_PATH.split("/") if x not in ["type0", "type1_2"]]) vn_exst_obj = self.create_virtual_network('existing_vn_%s' % self.id()) rt_exst_obj = self.wait_for_route_target(vn_exst_obj) rt_exst_id_str = "%(#)010d" % { '#': int(rt_exst_obj.get_fq_name_str().split(':')[-1])} # TestRouteTarget/id/bgp/route-target/type0/{rt_exst_id_str} node_exst_path = '%s%s%s' % ( self._cluster_id, db_checker.BASE_RTGT_ID_ZK_PATH, rt_exst_id_str) # TestRouteTarget/id/bgp/route-target/{rt_exst_id_str} node_collision_path = '%s%s%s' % ( self._cluster_id, DEPRECATED_BASE_RTGT, rt_exst_id_str) # TestRouteTarget/id/bgp/route-target rt_path = '%s%s' % (self._cluster_id, DEPRECATED_BASE_RTGT) # invariant _, zk_node_stat = zkc.get(node_exst_path) # create node in ZK zkc.create_node(node_collision_path, "6a77156f-e062-4d6b-b228-05a173b612e3") # is colliding node present rts = zkc.get_children(rt_path) self.assertIn(rt_exst_id_str, rts) # reinit ST test_common.reinit_schema_transformer() self.wait_for_route_target(vn_exst_obj) # check if initially existing node hasn't been modified _, new_zk_node_stat = db_checker._zk_client.get(node_exst_path) self.assertEqual(zk_node_stat, new_zk_node_stat) # is colliding node gone rts = zkc.get_children(rt_path) self.assertNotIn(rt_exst_id_str, rts)
def test_db_manage_zk_route_target_missing(self): vn_obj = self.create_virtual_network('vn_' + self.id(), '10.0.0.0/24') ri_fq_name = vn_obj.fq_name + [vn_obj.fq_name[-1]] rt_obj = self.wait_for_route_target(vn_obj) rt_id_str = "%(#)010d" % { '#': int(rt_obj.get_fq_name_str().split(':')[-1]) } db_checker = db_manage.DatabaseChecker( *db_manage._parse_args('check --cluster_id %s' % self._cluster_id)) db_cleaner = db_manage.DatabaseCleaner( *db_manage._parse_args('--execute clean --cluster_id %s' % self._cluster_id)) path = '%s%s%s' % (self._cluster_id, db_checker.BASE_RTGT_ID_ZK_PATH, rt_id_str) self.assertEqual( db_checker._zk_client.get(path)[0], ':'.join(ri_fq_name)) with db_checker._zk_client.patch_path(path): errors = db_checker.check_route_targets_id() error_types = [type(x) for x in errors] self.assertIn(db_manage.SchemaRTgtIdExtraError, error_types) self.assertIn(db_manage.ConfigRTgtIdExtraError, error_types) db_cleaner.clean_stale_route_target_id() errors = db_checker.check_route_targets_id() self.assertEqual([], errors) self.assertIsNone(db_checker._zk_client.exists(path)) self.assertRaises(NoIdError, self._vnc_lib.route_target_read, id=rt_obj.uuid) test_common.reinit_schema_transformer() new_rt_obj = self.wait_for_route_target(vn_obj) new_rt_id_str = "%(#)010d" % { '#': int(new_rt_obj.get_fq_name_str().split(':')[-1]) } new_path = '%s%s%s' % ( self._cluster_id, db_checker.BASE_RTGT_ID_ZK_PATH, new_rt_id_str, ) self.assertEqual( db_checker._zk_client.get(new_path)[0], ':'.join(ri_fq_name))