Skip to content
Snippets Groups Projects
Commit 9b3f4a27 authored by Eloi Bail's avatar Eloi Bail Committed by gerrit2
Browse files

tools: refactor automatic call test tool

Refactor of automatic call test tool
Now do ./dringctrl --help : all test name will be listed
./dringctrl --test <testName> to execute a test

Issue: #80498
Change-Id: I86d16e7d96f04f040133f16856ba9ca8a061374d
parent 6432f74f
No related branches found
No related tags found
No related merge requests found
...@@ -457,6 +457,13 @@ class DRingCtrl(Thread): ...@@ -457,6 +457,13 @@ class DRingCtrl(Thread):
account = self._valid_account(account) account = self._valid_account(account)
return [int(x) for x in self.configurationmanager.getActiveCodecList(account)] return [int(x) for x in self.configurationmanager.getActiveCodecList(account)]
def setCodecBitrate(self, account, bitrate):
""" Change bitrate for all codecs on given account"""
for codecId in self.configurationmanager.getActiveCodecList(account):
details = self.configurationmanager.getCodecDetails(account, codecId)
details['CodecInfo.bitrate'] = str(bitrate)
self.configurationmanager.setCodecDetails(account, codecId, details)
# #
# Call management # Call management
# #
...@@ -599,6 +606,11 @@ class DRingCtrl(Thread): ...@@ -599,6 +606,11 @@ class DRingCtrl(Thread):
self.callmanager.hangUpConference(confId) self.callmanager.hangUpConference(confId)
def switchInput(self, callid, inputName):
"""switch to input if exist"""
return self.callmanager.switchInput(callid, inputName)
def run(self): def run(self):
"""Processing method for this thread""" """Processing method for this thread"""
......
#!/usr/bin/env python3 #!/usr/bin/env python3
# #
# Copyright (C) 2015 Savoir-Faire Linux Inc. # Copyright (C) 2015 Savoir-faire Linux Inc.
# Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> # Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -16,18 +16,6 @@ ...@@ -16,18 +16,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Additional permission under GNU GPL version 3 section 7:
#
# If you modify this program, or any covered work, by linking or
# combining it with the OpenSSL project's OpenSSL library (or a
# modified version of that library), containing parts covered by the
# terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
# grants you additional permission to convey the resulting work.
# Corresponding Source for a non-source form of such a combination
# shall include the source code for the parts of OpenSSL used as well
# as that of the covered work.
#
import sys import sys
import os import os
...@@ -100,7 +88,7 @@ if __name__ == "__main__": ...@@ -100,7 +88,7 @@ if __name__ == "__main__":
parser.add_argument('--dtmf', help='Send DTMF', metavar='<key>') parser.add_argument('--dtmf', help='Send DTMF', metavar='<key>')
parser.add_argument('--toggleVideo', help='Launch toggle video tests', action='store_true') parser.add_argument('--toggleVideo', help='Launch toggle video tests', action='store_true')
parser.add_argument('--test', help='Launch automatic tests', action='store_true') parser.add_argument('--test', help=' '.join(str(test) for test in DRingTester().getTestName() ), metavar='<testName>')
args = parser.parse_args() args = parser.parse_args()
...@@ -179,7 +167,7 @@ if __name__ == "__main__": ...@@ -179,7 +167,7 @@ if __name__ == "__main__":
ctrl.Dtmf(args.dtmf) ctrl.Dtmf(args.dtmf)
if args.test: if args.test:
DRingTester().start(ctrl) DRingTester().start(ctrl, args.test)
if args.toggleVideo: if args.toggleVideo:
if not ctrl.videomanager: if not ctrl.videomanager:
......
...@@ -36,29 +36,52 @@ from random import shuffle ...@@ -36,29 +36,52 @@ from random import shuffle
from errors import * from errors import *
WITH_HOLD = True
WITHOUT_HOLD = False
ALL_TEST_NAME = {
'TestConfig': 'testConfig',
'LoopCallDht': 'testLoopCallDht',
'VideoBirtateDHT': 'testLoopCallDhtWithIncBitrate',
'SimultenousDHTCall' : 'testSimultaneousLoopCallDht',
'DhtCallHold' : 'testLoopCallDhtWithHold'
}
class DRingTester():
DHT_ACCOUNT_ID = ''
SIP_ACCOUNT_ID = ''
# Dht Client # Dht Client
SIP_TEST_ACCOUNT = 'sf1' SIP_TEST_ACCOUNT = 'sf1'
# Dht Client # Dht Client
DHT_TEST_ACCOUNT = '6c8d591e7c55b348338209bb6f9f638688d50034' DHT_TEST_ACCOUNT = '280ca11317ec90a939c86fbfa06532dbb8a08f8a'
# Ring Client # Ring Client
RING_TEST_ACCOUNT = '192.168.48.125' RING_TEST_ACCOUNT = '192.168.50.143'
# RING_TEST_ACCOUNT = '192.168.48.158'
# Polycom Client # Polycom Client
POLYCOM_TEST_ACCOUNT = '192.168.40.38' POLYCOM_TEST_ACCOUNT = '192.168.40.38'
FILE_TEST = '/home/eloi/Videos/Mad_Max_Fury_Road_2015_Trailer_F4_5.1-1080p-HDTN.mp4'
WITH_HOLD = True minBitrate = 400
WITHOUT_HOLD = False maxBitrate = 4000
incBitrate = 100
class DRingTester():
def testConfig(self, ctrl): def testConfig(self, ctrl):
print("**[BEGIN] test config") print("**[BEGIN] test config")
allCodecs = ctrl.getAllCodecs() allCodecs = ctrl.getAllCodecs()
if len(allCodecs) == 0: if len(allCodecs) == 0:
print("error no codec on the system") print("error no codec on the system")
return 0 return 0
print("**[SUCCESS] test config")
print("**[END] test config") print("**[END] test config")
return 1 return 1
#
# Helpers
#
def getTestName(self):
return ALL_TEST_NAME.keys()
def checkIP2IPAccount(self, ctrl): def checkIP2IPAccount(self, ctrl):
ipAccount = ctrl.getAllAccounts() ipAccount = ctrl.getAllAccounts()
...@@ -87,66 +110,117 @@ class DRingTester(): ...@@ -87,66 +110,117 @@ class DRingTester():
print("UnHolding: " + callId) print("UnHolding: " + callId)
ctrl.UnHold(callId) ctrl.UnHold(callId)
def startCallTests(self, ctrl, localAccount, destAccount, nbIteration, #
delay, withHold): # tests
print("**[BEGIN] Call Test for account:" + localAccount) #
if localAccount == 'IP2IP':
ctrl.setAccount(localAccount) # testLoopCallDht
# perform <nbIteration> DHT calls using <delay> between each call
def testLoopCallDht(self, ctrl, nbIteration, delay):
print("**[BEGIN] DHT Call Test")
count = 0
while count < nbIteration:
print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID)
callId = ctrl.Call(self.DHT_TEST_ACCOUNT)
# switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST)
time.sleep(delay)
ctrl.HangUp(callId)
count += 1
print("**[END] DHT Call Test")
# testLoopCallDhtWithHold
# perform <nbIteration> DHT calls using <delay> between each call
# perform stress hold/unhold between each call
def testLoopCallDhtWithHold(self, ctrl, nbIteration, delay):
print("**[BEGIN] DHT Call Test")
count = 0 count = 0
while count < nbIteration: while count < nbIteration:
print("[%s/%s]" % (count, nbIteration)) print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, localAccount)
ctrl.Call(destAccount) self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID)
callId = ctrl.getAllCalls()[0]
callId = ctrl.Call(self.DHT_TEST_ACCOUNT)
# switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST)
if withHold:
delayHold = 5 delayHold = 5
nbHold = delay / (delayHold * 2) nbHold = delay / (delayHold * 2)
countHold = 0 countHold = 0
while countHold < nbHold: while countHold < nbHold:
self.holdToggle(ctrl, callId, delayHold) self.holdToggle(ctrl, callId, delayHold)
countHold += 1 countHold = countHold + 1
else:
ctrl.HangUp(callId)
count += 1
print("**[END] DHT Call Test")
# testLoopCallDhtWithIncBitrate
# perform <nbIteration> DHT calls using <delay> between each call
# inc bitrate between each iteration
def testLoopCallDhtWithIncBitrate(self, ctrl, nbIteration, delay):
print("**[BEGIN] VIDEO Bitrate Test")
count = 0
currBitrate = self.minBitrate
while count < nbIteration:
print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID)
print("setting video bitrate to "+str(currBitrate))
ctrl.setCodecBitrate(self.DHT_ACCOUNT_ID, currBitrate)
callId = ctrl.Call(self.DHT_TEST_ACCOUNT)
# switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST)
time.sleep(delay) time.sleep(delay)
ctrl.HangUp(callId) ctrl.HangUp(callId)
count += 1 count += 1
print("**[END] Call Test for account:" + localAccount) currBitrate += self.incBitrate
if (currBitrate > self.maxBitrate):
currBitrate = self.minBitrate
print("**[END] VIDEO Bitrate Test")
def startSimultaneousCallTests(self, ctrl, localAccount, destAccount, # testSimultaneousLoopCallDht
nbIteration, delay, withHold, nbCalls): # perform <nbIteration> simultaneous DHT calls using <delay> between each call
print("**[BEGIN] Call Test for account:" + localAccount)
if localAccount == 'IP2IP':
ctrl.setAccount(localAccount)
def testSimultaneousLoopCallDht(self, ctrl, nbIteration, delay):
count = 0 count = 0
while count < nbIteration: while count < nbIteration:
print("[%s/%s]" % (count, nbIteration)) print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, localAccount) self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID)
# do all the calls # do all the calls
currCall = 0 currCall = 0
while currCall < nbCalls: NB_SIMULTANEOUS_CALL = 10;
ctrl.Call(destAccount) while currCall <= NB_SIMULTANEOUS_CALL:
ctrl.Call(self.DHT_TEST_ACCOUNT)
time.sleep(1) time.sleep(1)
currCall = currCall + 1 currCall = currCall + 1
# hold or wait for each call
if withHold:
delayHold = 5
nbHold = delay / (delayHold * 2)
countHold = 0
while countHold < nbHold:
for callId in ctrl.getAllCalls():
self.holdToggle(ctrl, callId, delayHold)
countHold = countHold + 1
else:
time.sleep(delay) time.sleep(delay)
# hangup each call # hangup each call
...@@ -157,31 +231,48 @@ class DRingTester(): ...@@ -157,31 +231,48 @@ class DRingTester():
print("**[END] Call Test for account:" + localAccount) print("**[END] Call Test for account:" + localAccount)
def start(self, ctrl):
# testConfig
if not (self.testConfig(ctrl)):
print(("testConfig [KO]")) # Main function
def start(self, ctrl, testName):
if not testName in ALL_TEST_NAME:
print(("wrong test name"))
return return
else:
print(("testConfig [OK]")) #getConfig
self.DHT_ACCOUNT_ID = ctrl.getAllAccounts('RING')[0]
self.SIP_ACCOUNT_ID = ctrl.getAllAccounts('SIP')[0]
TEST_NB_ITERATION = 100
TEST_DELAY = 30
getattr(self, ALL_TEST_NAME[testName])(ctrl,TEST_NB_ITERATION, TEST_DELAY)
"""
# DHT tests
dhtAccount = ctrl.getAllAccounts('RING')[0]
self.startDynamicBitrateCallTests(ctrl, dhtAccount, DHT_TEST_ACCOUNT, 100, 60, 250, 4000, 100)
self.startCallTests(ctrl, dhtAccount, DHT_TEST_ACCOUNT, 100, 60, WITHOUT_HOLD)
self.startCallTests(ctrl, dhtAccount, DHT_TEST_ACCOUNT, 100, 60, WITH_HOLD)
# RING IP2IP tests # RING IP2IP tests
self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD) self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD)
self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITH_HOLD) self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITH_HOLD)
# Polycom IP2IP tests # Polycom IP2IP tests
self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD) self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD)
self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITH_HOLD) self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITH_HOLD)
# SIP tests # SIP tests
sipAccount = ctrl.getAllAccounts('SIP')[0] sipAccount = ctrl.getAllAccounts('SIP')[0]
self.registerAccount(ctrl, sipAccount)
# self.startSimultaneousCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 10, 40, WITHOUT_HOLD,10) # self.startSimultaneousCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 10, 40, WITHOUT_HOLD,10)
self.startCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 1000, 20, WITH_HOLD) self.startCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 1000, 20, WITH_HOLD)
self.startCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD) self.startCallTests(ctrl, sipAccount, SIP_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD)
"""
# DHT tests
dhtAccount = ctrl.getAllAccounts('RING')[0]
self.registerAccount(ctrl, dhtAccount)
self.startCallTests(ctrl, dhtAccount, DHT_TEST_ACCOUNT, 10, 60, WITHOUT_HOLD)
self.startCallTests(ctrl, dhtAccount, DHT_TEST_ACCOUNT, 10, 60, WITH_HOLD)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment