* wrap-and-sort -sat * ngcp-dlg[cnt|list]-clean both use /etc/kamailio/proxy/dlgcnt.lua.cfg Change-Id: Ib89d75c389b9357c4754e59af4727ee3803009cechanges/94/9894/11
parent
f514d07bd1
commit
a86f08672b
@ -1,4 +1,4 @@
|
|||||||
tests
|
|
||||||
tests_v
|
|
||||||
mocks
|
mocks
|
||||||
run_tests.sh
|
run_tests.sh
|
||||||
|
tests
|
||||||
|
tests_v
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
REMOVE=false
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
printf "%s [options]\n" "$(basename "$0")"
|
||||||
|
printf "\toptions\n"
|
||||||
|
printf "\t-h this help\n"
|
||||||
|
printf "\t-r remove unknown callids from redis properly\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts "rh" opt; do
|
||||||
|
case $opt in
|
||||||
|
h) usage; exit 0;;
|
||||||
|
r) REMOVE=true;;
|
||||||
|
\?) usage; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [[ $# -ne 0 ]] ; then
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ngcp-check_active -q ; then
|
||||||
|
echo "node is not active, abort" >&2
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# read kamailio.proxy.dlgcnt.pair_redis_db
|
||||||
|
REDIS_DB="$(ngcp-dlgcnt-clean -c|| echo 4)"
|
||||||
|
|
||||||
|
# full list
|
||||||
|
REDIS_CALLIDS=$(mktemp)
|
||||||
|
ngcp-redis-helper -n "$REDIS_DB" dump | egrep -v "^$" > "$REDIS_CALLIDS" || true
|
||||||
|
# 'lists:' belongs to dlglist
|
||||||
|
REDIS_CALLIDS_FILTER=$(mktemp)
|
||||||
|
egrep -v '^list:' "$REDIS_CALLIDS" > "$REDIS_CALLIDS_FILTER" || true
|
||||||
|
|
||||||
|
# list of dialogs known by kamailio
|
||||||
|
KAM_CALLIDS=$(mktemp)
|
||||||
|
ngcp-sercmd proxy dlg.list | awk -F: '/call-id:/ { print $2}' > "$KAM_CALLIDS"
|
||||||
|
|
||||||
|
while read -r i ; do
|
||||||
|
if ! grep -q "$i" "$KAM_CALLIDS" ; then
|
||||||
|
printf "CallID:[%s] unknown\n" "$i"
|
||||||
|
if $REMOVE ; then
|
||||||
|
ngcp-dlgcnt-clean "$i" || true
|
||||||
|
if grep -q "list:$i" "$REDIS_CALLIDS" ; then
|
||||||
|
ngcp-dlglist-clean "$i" || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < "$REDIS_CALLIDS_FILTER"
|
||||||
|
|
||||||
|
rm -f "$KAM_CALLIDS" "$REDIS_CALLIDS" "$REDIS_CALLIDS_FILTER"
|
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env lua5.1
|
||||||
|
--local ut = require 'ngcp.utils'.table
|
||||||
|
local NGCPDlg = require 'ngcp.dlgcnt'
|
||||||
|
local config = "/etc/kamailio/proxy/dlgcnt.lua.cfg"
|
||||||
|
|
||||||
|
-- luacheck: globals dlg_config
|
||||||
|
|
||||||
|
local function get_config()
|
||||||
|
if os.getenv('DLG_CONFIG') then
|
||||||
|
config = os.getenv('DLG_CONFIG')
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok,e = pcall(dofile,config)
|
||||||
|
if not ok then
|
||||||
|
io.stderr:write(e..'\n')
|
||||||
|
print("using defaults\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function usage()
|
||||||
|
print("ngcp-dlgcnt-clean callid")
|
||||||
|
end
|
||||||
|
|
||||||
|
if #arg ~= 1 then
|
||||||
|
io.stderr:write("wrong number of arguments\n");
|
||||||
|
usage()
|
||||||
|
os.exit(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if arg[1] == "-h" then usage(); os.exit(0); end
|
||||||
|
|
||||||
|
get_config()
|
||||||
|
|
||||||
|
local dlg = NGCPDlg:new()
|
||||||
|
|
||||||
|
if arg[1] == '-c' then
|
||||||
|
print(tostring(dlg.config.pair.db))
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
if dlg_config then
|
||||||
|
dlg.config.central.host = dlg_config.central.host
|
||||||
|
dlg.config.central.port = dlg_config.central.port
|
||||||
|
dlg.config.central.db = dlg_config.central.db
|
||||||
|
dlg.config.pair.host = dlg_config.pair.host
|
||||||
|
dlg.config.pair.port = dlg_config.pair.port
|
||||||
|
dlg.config.pair.db = dlg_config.pair.db
|
||||||
|
--print(string.format("dlg.config:%s", ut.tostring(dlg.config)))
|
||||||
|
end
|
||||||
|
|
||||||
|
dlg:del(arg[1])
|
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env lua5.1
|
||||||
|
--local ut = require 'ngcp.utils'.table
|
||||||
|
local NGCPDlgList = require 'ngcp.dlglist'
|
||||||
|
local config = "/etc/kamailio/proxy/dlgcnt.lua.cfg"
|
||||||
|
|
||||||
|
-- luacheck: globals dlg_config
|
||||||
|
|
||||||
|
local function get_config()
|
||||||
|
if os.getenv('DLG_CONFIG') then
|
||||||
|
config = os.getenv('DLG_CONFIG')
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok,e = pcall(dofile,config)
|
||||||
|
if not ok then
|
||||||
|
io.stderr:write(e..'\n')
|
||||||
|
print("using defaults\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function usage()
|
||||||
|
print("ngcp-dlglist-clean callid")
|
||||||
|
end
|
||||||
|
|
||||||
|
if #arg ~= 1 then
|
||||||
|
io.stderr:write("wrong number of arguments\n");
|
||||||
|
usage()
|
||||||
|
os.exit(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if arg[1] == "-h" then usage(); os.exit(0); end
|
||||||
|
|
||||||
|
get_config()
|
||||||
|
|
||||||
|
local dlg = NGCPDlgList.new()
|
||||||
|
if dlg_config then
|
||||||
|
dlg.config.central.host = dlg_config.central.host
|
||||||
|
dlg.config.central.port = dlg_config.central.port
|
||||||
|
dlg.config.central.db = dlg_config.central.db
|
||||||
|
dlg.config.pair.host = dlg_config.pair.host
|
||||||
|
dlg.config.pair.port = dlg_config.pair.port
|
||||||
|
dlg.config.pair.db = dlg_config.pair.db
|
||||||
|
--print(string.format("dlg.config:%s", ut.tostring(dlg.config)))
|
||||||
|
end
|
||||||
|
|
||||||
|
dlg:destroy(arg[1])
|
@ -0,0 +1,12 @@
|
|||||||
|
dlg_config = {
|
||||||
|
central = {
|
||||||
|
host = '127.2.0.1',
|
||||||
|
port = 6379,
|
||||||
|
db = 3
|
||||||
|
},
|
||||||
|
pair = {
|
||||||
|
host = '127.2.0.1',
|
||||||
|
port = 6379,
|
||||||
|
db = 4
|
||||||
|
},
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
ngcp-dlgcnt-clean f81f8a33-2dbd-1235-018c-0090fb484030-pbx_1
|
||||||
|
ngcp-dlgcnt-clean f81f8a33-2dbd-1235-018c-0090fb484030
|
||||||
|
ngcp-dlglist-clean f81f8a33-2dbd-1235-018c-0090fb484030
|
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
h_entry: 51
|
||||||
|
h_id: 3315
|
||||||
|
call-id: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
from_uri: sip:390649904073@voxbone.com
|
||||||
|
to_uri: sip:390240708163@46.29.177.34
|
||||||
|
state: 4
|
||||||
|
start_ts: 1480083143
|
||||||
|
init_ts: 1480083140
|
||||||
|
timeout: 1480126343
|
||||||
|
lifetime: 43200
|
||||||
|
dflags: 512
|
||||||
|
sflags: 0
|
||||||
|
iflags: 0
|
||||||
|
caller: {
|
||||||
|
tag: as2da8b920
|
||||||
|
contact: sip:390649904073@81.201.82.107:5060;transport=udp
|
||||||
|
cseq: 102
|
||||||
|
route_set: <sip:203.0.113.113;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:46.29.177.34;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:81.201.82.45;lr=on>
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
callee: {
|
||||||
|
tag: 2B56584B-583846C4000C078A-A5F9B700
|
||||||
|
contact: sip:390240708163@203.0.113.113:5080
|
||||||
|
cseq: 0
|
||||||
|
route_set:
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
profiles: {
|
||||||
|
}
|
||||||
|
variables: {
|
||||||
|
{
|
||||||
|
recent_calls_user_online: 1
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_caller: 390649904073
|
||||||
|
}
|
||||||
|
{
|
||||||
|
start_time: 1480083143
|
||||||
|
}
|
||||||
|
{
|
||||||
|
callee_uuid: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_key: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lua_dlg_callid: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
f81f8a33-2dbd-1235-018c-0090fb484030-pbx_1
|
||||||
|
f81f8a33-2dbd-1235-018c-0090fb484030
|
||||||
|
list:f81f8a33-2dbd-1235-018c-0090fb484030
|
@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
h_entry: 51
|
||||||
|
h_id: 3315
|
||||||
|
call-id: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
from_uri: sip:390649904073@voxbone.com
|
||||||
|
to_uri: sip:390240708163@46.29.177.34
|
||||||
|
state: 4
|
||||||
|
start_ts: 1480083143
|
||||||
|
init_ts: 1480083140
|
||||||
|
timeout: 1480126343
|
||||||
|
lifetime: 43200
|
||||||
|
dflags: 512
|
||||||
|
sflags: 0
|
||||||
|
iflags: 0
|
||||||
|
caller: {
|
||||||
|
tag: as2da8b920
|
||||||
|
contact: sip:390649904073@81.201.82.107:5060;transport=udp
|
||||||
|
cseq: 102
|
||||||
|
route_set: <sip:203.0.113.113;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:46.29.177.34;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:81.201.82.45;lr=on>
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
callee: {
|
||||||
|
tag: 2B56584B-583846C4000C078A-A5F9B700
|
||||||
|
contact: sip:390240708163@203.0.113.113:5080
|
||||||
|
cseq: 0
|
||||||
|
route_set:
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
profiles: {
|
||||||
|
}
|
||||||
|
variables: {
|
||||||
|
{
|
||||||
|
recent_calls_user_online: 1
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_caller: 390649904073
|
||||||
|
}
|
||||||
|
{
|
||||||
|
start_time: 1480083143
|
||||||
|
}
|
||||||
|
{
|
||||||
|
callee_uuid: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_key: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lua_dlg_callid: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
h_entry: 52
|
||||||
|
h_id: 3316
|
||||||
|
call-id: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107-pbx_1
|
||||||
|
from_uri: sip:390649904073@voxbone.com
|
||||||
|
to_uri: sip:390240708163@46.29.177.34
|
||||||
|
state: 4
|
||||||
|
start_ts: 1480083143
|
||||||
|
init_ts: 1480083140
|
||||||
|
timeout: 1480126343
|
||||||
|
lifetime: 43200
|
||||||
|
dflags: 512
|
||||||
|
sflags: 0
|
||||||
|
iflags: 0
|
||||||
|
caller: {
|
||||||
|
tag: as2da8b920
|
||||||
|
contact: sip:390649904073@81.201.82.107:5060;transport=udp
|
||||||
|
cseq: 102
|
||||||
|
route_set: <sip:203.0.113.113;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:46.29.177.34;r2=on;lr;ftag=as2da8b920;ngcplb=yes;socket=udp:46.29.177.34:5060>,<sip:81.201.82.45;lr=on>
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
callee: {
|
||||||
|
tag: 2B56584B-583846C4000C078A-A5F9B700
|
||||||
|
contact: sip:390240708163@203.0.113.113:5080
|
||||||
|
cseq: 0
|
||||||
|
route_set:
|
||||||
|
socket: udp:203.0.113.113:5062
|
||||||
|
}
|
||||||
|
profiles: {
|
||||||
|
}
|
||||||
|
variables: {
|
||||||
|
{
|
||||||
|
recent_calls_user_online: 1
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_caller: 390649904073
|
||||||
|
}
|
||||||
|
{
|
||||||
|
start_time: 1480083143
|
||||||
|
}
|
||||||
|
{
|
||||||
|
callee_uuid: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
recent_calls_key: 38de282f-5c5c-4d71-8a0d-b300a68d86ec
|
||||||
|
}
|
||||||
|
{
|
||||||
|
lua_dlg_callid: WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107-pbx_1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107-pbx_1
|
||||||
|
WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
||||||
|
list:WSGH2SB52VHYLPX4VQQ6N4B2ZM@81.201.82.107
|
@ -0,0 +1,194 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
import xmlrunner
|
||||||
|
import os
|
||||||
|
import io
|
||||||
|
import shutil
|
||||||
|
import copy
|
||||||
|
|
||||||
|
WORKSPACE = os.path.abspath(os.getenv('WORKSPACE', '/tmp'))
|
||||||
|
FIXTURES = os.path.join(os.getcwd(), "tests/fixtures")
|
||||||
|
FAKE_CMD_LIST = os.path.join(WORKSPACE, "cmd_list")
|
||||||
|
FAKE_BIN = os.path.join(WORKSPACE, "bin")
|
||||||
|
FAKE_PATH = "%s:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" % FAKE_BIN
|
||||||
|
|
||||||
|
|
||||||
|
def executeAndReturnOutput(command):
|
||||||
|
p = subprocess.Popen(command, stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
stdoutdata, stderrdata = p.communicate()
|
||||||
|
#print(stdoutdata, file=sys.stdout)
|
||||||
|
print(stderrdata, file=sys.stderr)
|
||||||
|
return p.returncode, stdoutdata, stderrdata
|
||||||
|
|
||||||
|
|
||||||
|
def create_prog(filename, command):
|
||||||
|
"""Create test program.
|
||||||
|
|
||||||
|
:param unicode filename: destination filename
|
||||||
|
:param unicode command: command to write to test program
|
||||||
|
"""
|
||||||
|
with io.open(filename, 'w', encoding='utf-8') as fp:
|
||||||
|
fp.write(u"#!/bin/bash\n%s\n" % (command, ))
|
||||||
|
os.fchmod(fp.fileno(), 0o755)
|
||||||
|
|
||||||
|
|
||||||
|
def setnode(active=True):
|
||||||
|
if active:
|
||||||
|
mode = 'true'
|
||||||
|
else:
|
||||||
|
mode = 'false'
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-check_active'), mode)
|
||||||
|
|
||||||
|
command = [
|
||||||
|
"env",
|
||||||
|
"PATH=%s" % FAKE_PATH,
|
||||||
|
"./scripts/ngcp-dlgcnt-check", "-r"]
|
||||||
|
|
||||||
|
FAKE_DLG_CLEAN = """
|
||||||
|
if [ $1 = -c ] ; then
|
||||||
|
echo 4
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "ngcp-dlgcnt-clean $*">> %s""" % FAKE_CMD_LIST
|
||||||
|
|
||||||
|
FAKE_REDIS_HELPER = """
|
||||||
|
if [ $1 != -n ] && [ $2 != 4 ] ; then
|
||||||
|
echo $0 $* >&2
|
||||||
|
exit 1
|
||||||
|
fi"""
|
||||||
|
|
||||||
|
|
||||||
|
class TestDlgCnt(unittest.TestCase):
|
||||||
|
|
||||||
|
def checkNotCmd(self):
|
||||||
|
self.assertFalse(os.path.exists(FAKE_CMD_LIST),
|
||||||
|
"%s found" % FAKE_CMD_LIST)
|
||||||
|
|
||||||
|
def checkCmd(self, f, f2):
|
||||||
|
self.assertTrue(os.path.exists(f), "%s not found" % f)
|
||||||
|
self.assertTrue(os.path.exists(f2), "%s not found" % f2)
|
||||||
|
res = executeAndReturnOutput(
|
||||||
|
['diff', '-uNb', f, f2])
|
||||||
|
self.assertEqual(res[0], 0, res[1])
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.command = copy.deepcopy(command)
|
||||||
|
if not os.path.exists(FAKE_BIN):
|
||||||
|
os.makedirs(FAKE_BIN)
|
||||||
|
setnode(True)
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-dlgcnt-clean'),
|
||||||
|
FAKE_DLG_CLEAN)
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-dlglist-clean'),
|
||||||
|
'echo "ngcp-dlglist-clean $*">> %s' % FAKE_CMD_LIST)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
shutil.rmtree(WORKSPACE)
|
||||||
|
|
||||||
|
def test_wrong_option(self):
|
||||||
|
self.command = ["./scripts/ngcp-dlgcnt-check", "-k"]
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 1, res[2])
|
||||||
|
self.assertRegexpMatches(res[2], 'illegal option')
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_help(self):
|
||||||
|
self.command = ["./scripts/ngcp-dlgcnt-check", "-h"]
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[2])
|
||||||
|
self.assertRegexpMatches(res[1], '\toptions\n')
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_inactive(self):
|
||||||
|
setnode(False)
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 3, res[1])
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_redisconf(self):
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"true")
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"%s; true" % FAKE_REDIS_HELPER)
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[1])
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_empty(self):
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"true")
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"true")
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[1])
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_empty_line(self):
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"echo")
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"echo")
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[1])
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_okredis(self):
|
||||||
|
FAKE_DLG = os.path.join(FIXTURES, 'okredis.dlg')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"cat %s" % (FAKE_DLG))
|
||||||
|
FAKE_REDIS = os.path.join(FIXTURES, 'okredis.redis')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"cat %s" % (FAKE_REDIS))
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[2])
|
||||||
|
self.checkNotCmd()
|
||||||
|
|
||||||
|
def test_koredis(self):
|
||||||
|
FAKE_DLG = os.path.join(FIXTURES, 'koredis.dlg')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"cat %s" % (FAKE_DLG))
|
||||||
|
FAKE_REDIS = os.path.join(FIXTURES, 'koredis.redis')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"cat %s" % (FAKE_REDIS))
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[2])
|
||||||
|
self.checkCmd(os.path.join(FIXTURES, 'koredis.cmd'),
|
||||||
|
FAKE_CMD_LIST)
|
||||||
|
|
||||||
|
def test_kodlgclean(self):
|
||||||
|
FAKE_DLG = os.path.join(FIXTURES, 'koredis.dlg')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"cat %s" % (FAKE_DLG))
|
||||||
|
FAKE_REDIS = os.path.join(FIXTURES, 'koredis.redis')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"cat %s" % (FAKE_REDIS))
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-dlgcnt-clean'),
|
||||||
|
'%s; false' % FAKE_DLG_CLEAN)
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[2])
|
||||||
|
self.checkCmd(os.path.join(FIXTURES, 'koredis.cmd'),
|
||||||
|
FAKE_CMD_LIST)
|
||||||
|
|
||||||
|
def test_kolistclean(self):
|
||||||
|
FAKE_DLG = os.path.join(FIXTURES, 'koredis.dlg')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-sercmd'),
|
||||||
|
"cat %s" % (FAKE_DLG))
|
||||||
|
FAKE_REDIS = os.path.join(FIXTURES, 'koredis.redis')
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-redis-helper'),
|
||||||
|
"cat %s" % (FAKE_REDIS))
|
||||||
|
create_prog(os.path.join(FAKE_BIN, 'ngcp-dlglist-clean'),
|
||||||
|
'echo "ngcp-dlglist-clean $*">> %s; false' % FAKE_CMD_LIST)
|
||||||
|
res = executeAndReturnOutput(self.command)
|
||||||
|
self.assertEqual(res[0], 0, res[2])
|
||||||
|
self.checkCmd(os.path.join(FIXTURES, 'koredis.cmd'),
|
||||||
|
FAKE_CMD_LIST)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(
|
||||||
|
testRunner=xmlrunner.XMLTestRunner(output=sys.stdout),
|
||||||
|
# these make sure that some options that are not applicable
|
||||||
|
# remain hidden from the help menu.
|
||||||
|
failfast=False, buffer=False, catchbreak=False)
|
Loading…
Reference in new issue