def tearDown(self): sessRec = DepiMcastSessionRecord() sessRec.delete_all()
def tearDownClass(cls): # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all() stop_test_redis()
def setUp(self): sessRec = DepiMcastSessionRecord() sessRec.delete_all()
def setUpClass(cls): setup_logging("GCP", "gcp.log") setup_test_redis() # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all()
def setUp(self): setup_test_redis() # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all()
def test_recvRpdInfo(self): # db support # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all() sessRec = DepiMcastSessionRecord() test_count = 2 for test_session in range(0, test_count): sessRec.updateDepiMcastSessionKey(IpAddrType=1, GroupIpAddr="10.79.31.1", SrcIpAddr="10.90.31.1", SessionId=test_session) sessRec.JoinTime = time.time() sessRec.write() print("######test_recvRpdInfo######") rcp_msg = t_RcpMessage() rcp_msg.RcpDataResult = t_RcpMessage.RCP_RESULT_OK rcp_msg.RcpMessageType = t_RcpMessage.RPD_CONFIGURATION print("=====test case1: payload operation read, # no read count, no key=====") data = config() data.RpdInfo.DepiMcastSession.add() rcp_msg.RpdDataMessage.RpdData.CopyFrom(data) rcp_msg.RpdDataMessage.RpdDataOperation = 2 payload = rcp_msg.SerializeToString() msg = HalMessage("HalConfig", SrcClientID="testRpdFM", SeqNum=322, CfgMsgType=MsgTypeRpdInfo, CfgMsgPayload=payload) return_str = self.hal_client.recvRpdInfo(msg.msg) config_data = t_RcpMessage() config_data.ParseFromString(msg.msg.CfgMsgPayload) recv_rcp_msg = config_data.RpdDataMessage.RpdData self.assertEqual(len(recv_rcp_msg.RpdInfo.DepiMcastSession), 2) self.assertEqual(config_data.RcpDataResult, t_RcpMessage.RCP_RESULT_OK) print("=====test case2: payload operation read, # read with keylist=====") data = config() for sessionId in range(0, 3): req = data.RpdInfo.DepiMcastSession.add() req.IpAddrType = 1 req.GroupIpAddr = "10.79.31.1" req.SrcIpAddr = "10.90.31.1" req.SessionId = sessionId + 1 rcp_msg.RpdDataMessage.RpdData.CopyFrom(data) rcp_msg.RpdDataMessage.RpdDataOperation = 2 payload = rcp_msg.SerializeToString() msg = HalMessage("HalConfig", SrcClientID="testRpdFM", SeqNum=322, CfgMsgType=MsgTypeRpdInfo, CfgMsgPayload=payload) return_str = self.hal_client.recvRpdInfo(msg.msg) config_data = t_RcpMessage() config_data.ParseFromString(msg.msg.CfgMsgPayload) recv_rcp_msg = config_data.RpdDataMessage.RpdData for item in recv_rcp_msg.RpdInfo.DepiMcastSession: print item self.assertEqual(len(recv_rcp_msg.RpdInfo.DepiMcastSession), 3) self.assertEquals(config_data.RcpDataResult, t_RcpMessage.RCP_RESULT_OK) print("=====test case3: payload operation read, # read with readcount=====") data = config() data.ReadCount = 3 req = data.RpdInfo.DepiMcastSession.add() req.IpAddrType = 1 req.GroupIpAddr = "10.79.31.1" req.SrcIpAddr = "10.90.31.1" req.SessionId = 0 rcp_msg.RpdDataMessage.RpdData.CopyFrom(data) rcp_msg.RpdDataMessage.RpdDataOperation = 2 payload = rcp_msg.SerializeToString() msg = HalMessage("HalConfig", SrcClientID="testRpdFM", SeqNum=322, CfgMsgType=MsgTypeRpdInfo, CfgMsgPayload=payload) return_str = self.hal_client.recvRpdInfo(msg.msg) config_data = t_RcpMessage() config_data.ParseFromString(msg.msg.CfgMsgPayload) recv_rcp_msg = config_data.RpdDataMessage.RpdData for item in recv_rcp_msg.RpdInfo.DepiMcastSession: print item self.assertEqual(len(recv_rcp_msg.RpdInfo.DepiMcastSession), 2) self.assertEquals(config_data.RcpDataResult, t_RcpMessage.RCP_RESULT_OK)
def tearDown(self): # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all()
def setUp(self): # clear db records sessRec = DepiMcastSessionRecord() sessRec.delete_all()