From 2d34ec796913191f5f3d5c235e07acf565f36724 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 6 Oct 2016 17:56:01 +0200 Subject: [PATCH] MT#21751 recentcalls rename set_by_uuid to set_by_key * rename set_by_uuid to set_by_key as key can be anything now * save uuid as an additional parameter inside the key entry Change-Id: Ic63e11855d96931b2676b991d012197c35d8ca2f --- ngcp/recentcalls.lua | 15 +++++++++------ tests/ngcp_recentcalls.lua | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ngcp/recentcalls.lua b/ngcp/recentcalls.lua index 80ab044..59d3380 100644 --- a/ngcp/recentcalls.lua +++ b/ngcp/recentcalls.lua @@ -68,24 +68,27 @@ end return client end - function NGCPRecentCalls:set_by_uuid(uuid, callid, start_time, + function NGCPRecentCalls:set_by_key(key, + callid, uuid, start_time, duration, caller, callee, source) if not self._test_connection(self.central) then self.central = self._connect(self.config.central) end - local res = self.central:hmset(uuid, "callid", callid, + local res = self.central:hmset(key, + "callid", callid, + "uuid", uuid, "start_time", start_time, "duration", duration, "caller", caller, "callee", callee, "source", source) if res then - self.central:expire(uuid, self.config.expire) + self.central:expire(key, self.config.expire) end - sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n", - uuid, tostring(res), - callid, + sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s uuid: %s start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n", + key, tostring(res), + callid, uuid, start_time, duration, caller, callee, source, diff --git a/tests/ngcp_recentcalls.lua b/tests/ngcp_recentcalls.lua index b050ebc..70ac209 100644 --- a/tests/ngcp_recentcalls.lua +++ b/tests/ngcp_recentcalls.lua @@ -67,9 +67,10 @@ TestNGCPRecentCalls = {} --class assertIs(prev, self.central) end - function TestNGCPRecentCalls:test_set_by_uuid() + function TestNGCPRecentCalls:test_set_by_key() local ttl = 7200 + local key = "431110001" local uuid = "9bcb88b6-541a-43da-8fdc-816f5557ff93" local callid = "12345-67890" local start_time = "1439911398" @@ -79,7 +80,8 @@ TestNGCPRecentCalls = {} --class local source = "SIPWISE_1" self.central:ping() ;mc :returns(true) - self.central:hmset(uuid, "callid", callid, + self.central:hmset(key, "callid", callid, + "uuid", uuid, "start_time", start_time, "duration", duration, "caller", caller, @@ -88,7 +90,8 @@ TestNGCPRecentCalls = {} --class self.central:expire(uuid, ttl) ;mc :returns(1) mc:replay() - local res = self.rcalls:set_by_uuid(uuid, callid, + local res = self.rcalls:set_by_key(key, + callid, uuid, start_time, duration, caller, callee, source)