def runTest(self): ig_port = self.swports(1) eg_port = ig_port entity = self.add_to_t_mtr_0(ig_port, eg_port) # read single entry rentity = self.read_one(entity) self.assertProtoEqual(rentity, entity) wildcard_entity = p4runtime_pb2.Entity() wildcard_entity.table_entry.table_id = entity.table_entry.table_id # wildcard read -> one entry rentity = self.read_one(wildcard_entity) self.assertProtoEqual(rentity, entity) # add second entry ig_port = self.swports(2) eg_port = ig_port entity2 = self.add_to_t_mtr_0(ig_port, eg_port) # wildcard read -> 2 entries rit = self.read(wildcard_entity) try: rentity1 = next(rit) rentity2 = next(rit) except StopIteration: self.fail( "Insufficient number of entries returned by wildcard read") # we make no assumptions regarding the order in which entries are # returned self.assertIn(entity, [rentity1, rentity2]) self.assertIn(entity2, [rentity1, rentity2])
def runTest(self): ig_port = self.swports(1) eg_port = ig_port mbr_id = ig_port entity = self.add_member_to_action_sel(mbr_id, eg_port) rentity = self.read_one(entity) self.assertProtoEqual(rentity, entity) wildcard_entity = p4runtime_pb2.Entity() act_prof_id = entity.action_profile_member.action_profile_id wildcard_entity.action_profile_member.action_profile_id = act_prof_id # wildcard read -> one member rentity = self.read_one(wildcard_entity) self.assertProtoEqual(rentity, entity) # add second member ig_port = self.swports(2) eg_port = ig_port mbr_id = ig_port entity2 = self.add_member_to_action_sel(mbr_id, eg_port) # wildcard read -> 2 members rit = self.read(wildcard_entity) try: rentity1 = next(rit) rentity2 = next(rit) except StopIteration: self.fail( "Insufficient number of members returned by wildcard read") # we make no assumptions regarding the order in which members are # returned self.assertIn(entity, [rentity1, rentity2]) self.assertIn(entity2, [rentity1, rentity2])
def gen_entities(): for i in itertools.count(): x = p4runtime_pb2.Entity() counter_entry = x.counter_entry counter_entry.counter_id = 302055013 counter_entry.index.index = i counter_entry.data.packet_count = 100 yield x
def runTest(self): mbrs = [] def add_member(idx): ig_port = self.swports(idx) eg_port = ig_port mbr_id = ig_port self.add_member_to_action_sel(mbr_id, eg_port) mbrs.append(mbr_id) for i in range(8): add_member(i) grp_id = 1000 entity = self.add_group_to_action_sel(grp_id, mbrs=mbrs[1:4]) rentity = self.read_one(entity) self.assertProtoEqual(rentity, entity) wildcard_entity = p4runtime_pb2.Entity() act_prof_id = entity.action_profile_group.action_profile_id wildcard_entity.action_profile_group.action_profile_id = act_prof_id # wildcard read -> one group rentity = self.read_one(wildcard_entity) self.assertProtoEqual(rentity, entity) # add second group ig_port = self.swports(2) grp_id = 2000 entity2 = self.add_group_to_action_sel(grp_id, mbrs=mbrs[2:7]) # wildcard read -> 2 groups rit = self.read(wildcard_entity) try: rentity1 = next(rit) rentity2 = next(rit) except StopIteration: self.fail( "Insufficient number of groups returned by wildcard read") # we make no assumptions regarding the order in which groups are # returned self.assertIn(entity, [rentity1, rentity2]) self.assertIn(entity2, [rentity1, rentity2])