VOL-1665: BBSim Radius Authentication Test Case
BBSim specific Test Case for Radius Authentication
Consists of verifying that all 16 ONUs have authenticated
- Restart Onos AAA application whcih is know to return exception
upon executing aaa-users command
- Address comments from review
Change-Id: I5f7fb231067f77a1f2e52ecde7328f702b333fd1
diff --git a/tests/atests/common/authentication.py b/tests/atests/common/authentication.py
index b5196d7..a03f17e 100644
--- a/tests/atests/common/authentication.py
+++ b/tests/atests/common/authentication.py
@@ -36,14 +36,16 @@
self.dirs['log'] = None
self.dirs['root'] = None
self.dirs['voltha'] = None
-
+
+ self.__onuCount = None
self.__rgName = testCaseUtils.discover_rg_pod_name()
- self.__radiusName = None
- self.__radiusIp = None
-
+
def a_set_log_dirs(self, root_dir, voltha_dir, log_dir):
testCaseUtils.config_dirs(self, log_dir, root_dir, voltha_dir)
+ def a_configure(self, onu_count):
+ self.__onuCount = onu_count
+
def execute_authentication_on_rg(self):
logging.info('Running Radius Authentication from RG')
process_output = open('%s/%s' % (testCaseUtils.get_dir(self, 'log'), self.AUTHENTICATE_FILENAME), 'w')
@@ -102,28 +104,40 @@
testCaseUtils.print_log_file(self, self.AUTHENTICATE_FILENAME)
- def verify_authentication_should_have_started(self):
+ def authentication_should_have_started(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-EAP-STARTED', self.AUTHENTICATE_FILENAME)
assert statusLines, 'Authentication was not started'
- def verify_authentication_should_have_completed(self):
+ def authentication_should_have_completed(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-EAP-SUCCESS', self.AUTHENTICATE_FILENAME)
assert statusLines, 'Authentication was not completed successfully'
- def verify_authentication_should_have_disconnected(self):
+ def authentication_should_have_disconnected(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-DISCONNECTED', self.AUTHENTICATE_FILENAME)
assert statusLines, 'Authentication was not disconnected'
- def verify_authentication_should_have_terminated(self):
+ def authentication_should_have_terminated(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, 'CTRL-EVENT-TERMINATING', self.AUTHENTICATE_FILENAME)
assert statusLines, 'Authentication was not terminated'
-
-def run_test(root_dir, voltha_dir, log_dir):
+ def should_have_all_onus_authenticated(self):
+ testCaseUtils.send_command_to_onos_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_onu_auth.log', 'aaa-users')
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, 'AUTHORIZED', 'voltha_onu_auth.log')
+ lines = statusLines.splitlines()
+ auth_count = len(lines)
+ assert self.__onuCount == auth_count, 'There are only %s ONUS Authenticated' % auth_count
+
+
+def run_test(onu_count, root_dir, voltha_dir, log_dir, simtype):
auth = Authentication()
auth.a_set_log_dirs(root_dir, voltha_dir, log_dir)
- auth.execute_authentication_on_rg()
- auth.verify_authentication_should_have_started()
- auth.verify_authentication_should_have_completed()
- auth.verify_authentication_should_have_disconnected()
- auth.verify_authentication_should_have_terminated()
+ auth.a_configure(onu_count)
+ if simtype == 'ponsim':
+ auth.execute_authentication_on_rg()
+ auth.authentication_should_have_started()
+ auth.authentication_should_have_completed()
+ auth.authentication_should_have_disconnected()
+ auth.authentication_should_have_terminated()
+ elif simtype == 'bbsim':
+ auth.should_have_all_onus_authenticated()
diff --git a/tests/atests/common/auto_test.py b/tests/atests/common/auto_test.py
index 5182bdc..4dea0ab 100755
--- a/tests/atests/common/auto_test.py
+++ b/tests/atests/common/auto_test.py
@@ -31,7 +31,7 @@
import logging
DEFAULT_LOG_DIR = '/tmp/voltha_test_results'
-DEFAULT_ADAPTER = 'ponsim'
+DEFAULT_SIMTYPE = 'ponsim'
logging.basicConfig(level=logging.INFO)
@@ -66,18 +66,18 @@
return root_dir, voltha_dir, log_dir
-def adapter_init(adapter=DEFAULT_ADAPTER):
+def simtype_init(simtype=DEFAULT_SIMTYPE):
"""
- :param adapter: ponsim or bbsim
+ :param simtype: ponsim or bbsim
:return: olt_type, onu_type, olt_host_ip, onu_count
"""
- if adapter == 'ponsim':
+ if simtype == 'ponsim':
olt_type = 'ponsim_olt'
onu_type = 'ponsim_onu'
olt_host_ip = 'olt.voltha.svc'
onu_count = 1
- elif adapter == 'bbsim':
+ elif simtype == 'bbsim':
olt_type = 'openolt'
onu_type = 'brcm_openomci_onu'
olt_host_ip = 'bbsim.voltha.svc'
@@ -102,21 +102,22 @@
parser = argparse.ArgumentParser(description='VOLTHA Automated Testing')
parser.add_argument('-l', dest='logDir', default=DEFAULT_LOG_DIR,
help='log directory (default: %s).' % DEFAULT_LOG_DIR)
- parser.add_argument('-a', dest='adapter', choices=['ponsim', 'bbsim'], default=DEFAULT_ADAPTER,
- help='adapter (default: %s).' % DEFAULT_ADAPTER)
+ parser.add_argument('-a', dest='simtype', choices=['ponsim', 'bbsim'], default=DEFAULT_SIMTYPE,
+ help='simtype (default: %s).' % DEFAULT_SIMTYPE)
args = parser.parse_args()
ROOT_DIR, VOLTHA_DIR, LOG_DIR = dir_init(args.logDir)
- OLT_TYPE, ONU_TYPE, OLT_HOST_IP, ONU_COUNT = adapter_init(args.adapter)
+ OLT_TYPE, ONU_TYPE, OLT_HOST_IP, ONU_COUNT = simtype_init(args.simtype)
- volthaMngr.voltha_initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR, args.adapter)
+ volthaMngr.voltha_initialize(ROOT_DIR, VOLTHA_DIR, LOG_DIR, args.simtype)
preprovisioning.run_test(OLT_HOST_IP, 50060, OLT_TYPE, ONU_TYPE, ONU_COUNT, LOG_DIR)
discovery.run_test(OLT_HOST_IP, OLT_TYPE, ONU_TYPE, ONU_COUNT, LOG_DIR)
- if args.adapter == 'ponsim':
- authentication.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
+ authentication.run_test(ONU_COUNT, ROOT_DIR, VOLTHA_DIR, LOG_DIR, args.simtype)
+
+ if args.simtype == 'ponsim':
dhcp.run_test(ROOT_DIR, VOLTHA_DIR, LOG_DIR)
unicast.run_test(ONU_TYPE, ONU_COUNT, ROOT_DIR, VOLTHA_DIR, LOG_DIR)
diff --git a/tests/atests/common/run_robot.sh b/tests/atests/common/run_robot.sh
index 84e6bcd..17847a1 100755
--- a/tests/atests/common/run_robot.sh
+++ b/tests/atests/common/run_robot.sh
@@ -16,13 +16,13 @@
SRC_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VOLTHA_DIR="$SRC_DIR/../../.."
-echo "Run Robot Framework TEST. Log: $1, Adapter: ${2:-ponsim}"
+echo "Run Voltha Test Automation Suite. Log: $1, Simtype: ${2:-ponsim}"
cd ${VOLTHA_DIR}
source env.sh
if [[ "${2:-ponsim}" == "ponsim" ]]
then
- robot -d $1 -v LOG_DIR:$1/voltha_test_results -v ADAPTER:ponsim ./tests/atests/robot/voltha_automated_test_suite.robot
+ robot -d $1 -v LOG_DIR:$1/voltha_test_results -v SIMTYPE:ponsim ./tests/atests/robot/voltha_automated_test_suite.robot
elif [[ "${2}" == "bbsim" ]]
then
- robot -d $1 -v LOG_DIR:$1/voltha_test_results -v ADAPTER:bbsim -e ponsim ./tests/atests/robot/voltha_automated_test_suite.robot
+ robot -d $1 -v LOG_DIR:$1/voltha_test_results -v SIMTYPE:bbsim -e ponsim ./tests/atests/robot/voltha_automated_test_suite.robot
fi
\ No newline at end of file
diff --git a/tests/atests/common/volthaMngr.py b/tests/atests/common/volthaMngr.py
index f94322d..84e937f 100755
--- a/tests/atests/common/volthaMngr.py
+++ b/tests/atests/common/volthaMngr.py
@@ -23,6 +23,7 @@
import subprocess
import testCaseUtils
import logging
+import time
class VolthaMngr(object):
@@ -31,7 +32,7 @@
This class implements voltha startup/shutdown callable helper functions
"""
- DEFAULT_ADAPTER = 'ponsim'
+ DEFAULT_SIMTYPE = 'ponsim'
def __init__(self):
self.dirs = dict()
@@ -45,24 +46,24 @@
def v_set_log_dirs(self, root_dir, voltha_dir, log_dir):
testCaseUtils.config_dirs(self, log_dir, root_dir, voltha_dir)
- def start_all_pods(self, adapter=DEFAULT_ADAPTER):
- proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'start', adapter],
+ def start_all_pods(self, simtype=DEFAULT_SIMTYPE):
+ proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'start', simtype],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = proc1.communicate()[0]
print(output)
proc1.stdout.close()
- def stop_all_pods(self, adapter=DEFAULT_ADAPTER):
- proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'stop', adapter],
+ def stop_all_pods(self, simtype=DEFAULT_SIMTYPE):
+ proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'stop', simtype],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = proc1.communicate()[0]
print(output)
proc1.stdout.close()
- def reset_kube_adm(self, adapter=DEFAULT_ADAPTER):
- proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'clear', adapter],
+ def reset_kube_adm(self, simtype=DEFAULT_SIMTYPE):
+ proc1 = subprocess.Popen([testCaseUtils.get_dir(self, 'root') + '/build.sh', 'clear', simtype],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = proc1.communicate()[0]
@@ -129,6 +130,20 @@
'http://localhost:30120/onos/v1/network/configuration/apps/ -d @%s/tests/atests/build/aaa_json'
% testCaseUtils.get_dir(self, 'voltha'))
+ def activate_aaa_app_in_onos(self):
+ logging.info('Activating AAA Application on Onos')
+ testCaseUtils.send_command_to_onos_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_aaa_application_activate.log', 'app activate aaa')
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, 'Activated', 'voltha_aaa_application_activate.log')
+ assert statusLines, 'AAA Application failed to be Activated'
+
+ def deactivate_aaa_app_in_onos(self):
+ logging.info('Deactivating AAA Application on Onos')
+ testCaseUtils.send_command_to_onos_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_aaa_application_deactivate.log', 'app deactivate aaa')
+ statusLines = testCaseUtils.get_fields_from_grep_command(self, 'Deactivated', 'voltha_aaa_application_deactivate.log')
+ assert statusLines, 'AAA Application failed to be Deactivated'
+
def get_all_running_pods():
allRunningPods = []
@@ -152,15 +167,18 @@
return allRunningPods
-def voltha_initialize(root_dir, voltha_dir, log_dir, adapter):
+def voltha_initialize(root_dir, voltha_dir, log_dir, simtype):
voltha = VolthaMngr()
voltha.v_set_log_dirs(root_dir, voltha_dir, log_dir)
- voltha.stop_all_pods(adapter)
- voltha.reset_kube_adm(adapter)
- voltha.start_all_pods(adapter)
+ voltha.stop_all_pods(simtype)
+ voltha.reset_kube_adm(simtype)
+ voltha.start_all_pods(simtype)
voltha.alter_onos_net_cfg()
voltha.collect_pod_logs()
voltha.discover_freeradius_pod_name()
voltha.discover_freeradius_ip_addr()
voltha.prepare_current_freeradius_ip()
voltha.alter_freeradius_ip_in_onos_aaa_application_configuration()
+ voltha.deactivate_aaa_app_in_onos()
+ time.sleep(5)
+ voltha.activate_aaa_app_in_onos()