Skip to content
Snippets Groups Projects
Commit bc8615c0 authored by Eloi Bail's avatar Eloi Bail Committed by Guillaume Roguez
Browse files

tools: use config file for dringctrl.py

Use a config file (test_config.ini) to configure test environnement
test_config.ini is provided as example

Issue: #80498
Change-Id: If0613d2264412af50e42f0a0eb151ecf741cbab4
parent 9b3f4a27
Branches
Tags
No related merge requests found
#
# Copyright (C) 2015 Savoir-faire Linux Inc.
# Author: Eloi Bail <eloi.bail@savoirfairelinux.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
[dht]
testAccount = <ringID>
[sip]
testAccount = <sip account>
[ip2ip]
testAccount = <ip>
[video]
minBitrate = 400
maxBitrate = 4000
incBitrate = 100
inputFile = <absolut path to file>
[iteration]
nbIteration = 100
delay = 60
...@@ -31,16 +31,12 @@ ...@@ -31,16 +31,12 @@
import sys import sys
import os import os
import time import time
import configparser
from threading import Thread from threading import Thread
from random import shuffle from random import shuffle
from errors import * from errors import *
WITH_HOLD = True
WITHOUT_HOLD = False
ALL_TEST_NAME = { ALL_TEST_NAME = {
'TestConfig': 'testConfig', 'TestConfig': 'testConfig',
'LoopCallDht': 'testLoopCallDht', 'LoopCallDht': 'testLoopCallDht',
...@@ -51,21 +47,15 @@ ALL_TEST_NAME = { ...@@ -51,21 +47,15 @@ ALL_TEST_NAME = {
class DRingTester(): class DRingTester():
DHT_ACCOUNT_ID = '' # init to default values
SIP_ACCOUNT_ID = '' dhtAccountId = ''
# Dht Client sipAccountId = ''
SIP_TEST_ACCOUNT = 'sf1' dhtTestAccount = ''
# Dht Client sipTestAccount = ''
DHT_TEST_ACCOUNT = '280ca11317ec90a939c86fbfa06532dbb8a08f8a' inputFile = ''
# Ring Client minBitrate = 0
RING_TEST_ACCOUNT = '192.168.50.143' maxBitrate = 0
# Polycom Client incBitrate = 0
POLYCOM_TEST_ACCOUNT = '192.168.40.38'
FILE_TEST = '/home/eloi/Videos/Mad_Max_Fury_Road_2015_Trailer_F4_5.1-1080p-HDTN.mp4'
minBitrate = 400
maxBitrate = 4000
incBitrate = 100
def testConfig(self, ctrl): def testConfig(self, ctrl):
print("**[BEGIN] test config") print("**[BEGIN] test config")
...@@ -124,18 +114,19 @@ class DRingTester(): ...@@ -124,18 +114,19 @@ class DRingTester():
while count < nbIteration: while count < nbIteration:
print("[%s/%s]" % (count, nbIteration)) print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID) self.setRandomActiveCodecs(ctrl, self.dhtAccountId)
callId = ctrl.Call(self.DHT_TEST_ACCOUNT) callId = ctrl.Call(self.dhtTestAccount)
# switch to file input # switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST) ctrl.switchInput(callId,'file://'+self.inputFile)
time.sleep(delay) time.sleep(delay)
ctrl.HangUp(callId) ctrl.HangUp(callId)
count += 1 count += 1
print("**[SUCCESS] DHT Call Test")
print("**[END] DHT Call Test") print("**[END] DHT Call Test")
# testLoopCallDhtWithHold # testLoopCallDhtWithHold
...@@ -143,18 +134,18 @@ class DRingTester(): ...@@ -143,18 +134,18 @@ class DRingTester():
# perform stress hold/unhold between each call # perform stress hold/unhold between each call
def testLoopCallDhtWithHold(self, ctrl, nbIteration, delay): def testLoopCallDhtWithHold(self, ctrl, nbIteration, delay):
print("**[BEGIN] DHT Call Test") print("**[BEGIN] DHT Call Test With Hold")
count = 0 count = 0
while count < nbIteration: while count < nbIteration:
print("[%s/%s]" % (count, nbIteration)) print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID) self.setRandomActiveCodecs(ctrl, self.dhtAccountId)
callId = ctrl.Call(self.DHT_TEST_ACCOUNT) callId = ctrl.Call(self.dhtTestAccount)
# switch to file input # switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST) ctrl.switchInput(callId,'file://'+self.inputFile)
delayHold = 5 delayHold = 5
nbHold = delay / (delayHold * 2) nbHold = delay / (delayHold * 2)
...@@ -168,7 +159,8 @@ class DRingTester(): ...@@ -168,7 +159,8 @@ class DRingTester():
ctrl.HangUp(callId) ctrl.HangUp(callId)
count += 1 count += 1
print("**[END] DHT Call Test") print("**[SUCCESS] DHT Call Test With Hold")
print("**[END] DHT Call Test With Hold")
# testLoopCallDhtWithIncBitrate # testLoopCallDhtWithIncBitrate
...@@ -184,14 +176,14 @@ class DRingTester(): ...@@ -184,14 +176,14 @@ class DRingTester():
while count < nbIteration: while count < nbIteration:
print("[%s/%s]" % (count, nbIteration)) print("[%s/%s]" % (count, nbIteration))
self.setRandomActiveCodecs(ctrl, self.DHT_ACCOUNT_ID) self.setRandomActiveCodecs(ctrl, self.dhtAccountId)
print("setting video bitrate to "+str(currBitrate)) print("setting video bitrate to "+str(currBitrate))
ctrl.setCodecBitrate(self.DHT_ACCOUNT_ID, currBitrate) ctrl.setCodecBitrate(self.dhtAccountId, currBitrate)
callId = ctrl.Call(self.DHT_TEST_ACCOUNT) callId = ctrl.Call(self.dhtTestAccount)
# switch to file input # switch to file input
ctrl.switchInput(callId,'file://'+self.FILE_TEST) ctrl.switchInput(callId,'file://'+self.inputFile)
time.sleep(delay) time.sleep(delay)
...@@ -202,22 +194,24 @@ class DRingTester(): ...@@ -202,22 +194,24 @@ class DRingTester():
if (currBitrate > self.maxBitrate): if (currBitrate > self.maxBitrate):
currBitrate = self.minBitrate currBitrate = self.minBitrate
print("**[SUCESS] VIDEO Bitrate Test")
print("**[END] VIDEO Bitrate Test") print("**[END] VIDEO Bitrate Test")
# testSimultaneousLoopCallDht # testSimultaneousLoopCallDht
# perform <nbIteration> simultaneous DHT calls using <delay> between each call # perform <nbIteration> simultaneous DHT calls using <delay> between each call
def testSimultaneousLoopCallDht(self, ctrl, nbIteration, delay): def testSimultaneousLoopCallDht(self, ctrl, nbIteration, delay):
print("**[BEGIN] Simultaneous 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, self.DHT_ACCOUNT_ID) self.setRandomActiveCodecs(ctrl, self.dhtAccountId)
# do all the calls # do all the calls
currCall = 0 currCall = 0
NB_SIMULTANEOUS_CALL = 10; NB_SIMULTANEOUS_CALL = 10;
while currCall <= NB_SIMULTANEOUS_CALL: while currCall <= NB_SIMULTANEOUS_CALL:
ctrl.Call(self.DHT_TEST_ACCOUNT) ctrl.Call(self.dhtTestAccount)
time.sleep(1) time.sleep(1)
currCall = currCall + 1 currCall = currCall + 1
...@@ -229,7 +223,8 @@ class DRingTester(): ...@@ -229,7 +223,8 @@ class DRingTester():
count += 1 count += 1
print("**[END] Call Test for account:" + localAccount) print("**[SUCESS] Simultaneous DHT call test")
print("**[END] Simultaneous DHT call test")
...@@ -243,36 +238,22 @@ class DRingTester(): ...@@ -243,36 +238,22 @@ class DRingTester():
return return
#getConfig #getConfig
self.DHT_ACCOUNT_ID = ctrl.getAllAccounts('RING')[0] self.dhtAccountId = ctrl.getAllAccounts('RING')[0]
self.SIP_ACCOUNT_ID = ctrl.getAllAccounts('SIP')[0] self.sipAccountId = ctrl.getAllAccounts('SIP')[0]
TEST_NB_ITERATION = 100
TEST_DELAY = 30
getattr(self, ALL_TEST_NAME[testName])(ctrl,TEST_NB_ITERATION, TEST_DELAY) config = configparser.ConfigParser()
config.read('test_config.ini')
self.dhtTestAccount = str(config['dht']['testAccount'])
self.sipTestAccount = str(config['sip']['testAccount'])
self.inputFile = str(config['video']['inputFile'])
self.minBitrate = int(config['video']['minBitrate'])
self.maxBitrate = int(config['video']['maxBitrate'])
self.incBitrate = int(config['video']['incBitrate'])
testNbIteration = config['iteration']['nbIteration']
delay = config['iteration']['delay']
TEST_NB_ITERATION = 100
TEST_DELAY = 30
""" getattr(self, ALL_TEST_NAME[testName])(ctrl,int(testNbIteration), int(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
self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD)
self.startCallTests(ctrl, 'IP2IP', RING_TEST_ACCOUNT, 1000, 20, WITH_HOLD)
# Polycom IP2IP tests
self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITHOUT_HOLD)
self.startCallTests(ctrl, 'IP2IP', POLYCOM_TEST_ACCOUNT, 1000, 20, WITH_HOLD)
# SIP tests
sipAccount = ctrl.getAllAccounts('SIP')[0]
# 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, WITHOUT_HOLD)
"""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment