def test_get_dispatcher_with_dump(self): #get the dump of dispatchers self.send_message( messages.KZorpGetDispatcherMessage(None), message_handler=self._get_dispatchers_message_handler, dump=True) self._check_ndim_params(self._dispatchers)
def check_dispatcher_num(self, num_dispatchers = 0, in_transaction = True): self._dumped_dispatchers = [] if in_transaction == True: self.start_transaction() self.send_message(messages.KZorpGetDispatcherMessage(None), message_handler = self._dump_dispatcher_handler, dump = True) if in_transaction == True: self.end_transaction() self.assertEqual(num_dispatchers, len(self._dumped_dispatchers))
def test_get_4k_dispatcher(self): services = ['A_A'] _iface_num = 300 _iface_list = [] _iface_string = "abcdefghijklmno" for i in range(_iface_num): _iface_list.append(_iface_string) dispatchers = [{ 'name': 'n_dimension_4k', 'num_rules': 1, 'rules': [{ 'rule_id': 1, 'service': 'A_A', 'entry_nums': { messages.KZNL_ATTR_N_DIMENSION_IFACE: _iface_num, messages.KZNL_ATTR_N_DIMENSION_PROTO: 1, messages.KZNL_ATTR_N_DIMENSION_SRC_PORT: 2, messages.KZNL_ATTR_N_DIMENSION_DST_PORT: 1, messages.KZNL_ATTR_N_DIMENSION_SRC_IP: 2, messages.KZNL_ATTR_N_DIMENSION_SRC_ZONE: 3, messages.KZNL_ATTR_N_DIMENSION_DST_IP: 2, messages.KZNL_ATTR_N_DIMENSION_DST_ZONE: 1, messages.KZNL_ATTR_N_DIMENSION_IFGROUP: 1 }, 'entry_values': { messages.KZNL_ATTR_N_DIMENSION_IFACE: _iface_list, messages.KZNL_ATTR_N_DIMENSION_PROTO: [socket.IPPROTO_TCP], messages.KZNL_ATTR_N_DIMENSION_SRC_PORT: [(2, 3), (4, 5)], messages.KZNL_ATTR_N_DIMENSION_DST_PORT: [(5, 6)], messages.KZNL_ATTR_N_DIMENSION_SRC_IP: ['1.2.3.4', '2.3.4.5/24'], messages.KZNL_ATTR_N_DIMENSION_SRC_ZONE: ['ZZZ', 'ZZ', 'Z'], messages.KZNL_ATTR_N_DIMENSION_DST_IP: ['3.4.5.6/16', '4.5.6.7/8'], messages.KZNL_ATTR_N_DIMENSION_DST_ZONE: 'AAA', messages.KZNL_ATTR_N_DIMENSION_IFGROUP: [1] }, }] }] self.setup_service_dispatcher(services, dispatchers, False, False) self.send_message( messages.KZorpGetDispatcherMessage("n_dimension_4k"), message_handler=self._get_dispatchers_message_handler) self._check_dispatcher_params(self._add_dispatcher_messages[0], dispatchers[0]) self._check_ndim_params(dispatchers)
def test_get_dispatcher_by_name(self): #get a not existent dispatcher res = self.send_message( messages.KZorpGetDispatcherMessage('nonexistentdispatchername'), assert_on_error=False) self.assertEqual(res, -errno.ENOENT)