示例#1
0
    def __exec_sip_calls__(self, **kwargs):
        self._init_args(**kwargs)
        tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
        remote_dir_path = '/home/'+self.tvmc_username+'/testframework_tmp'

        tvmc_ftp.mkd(remote_dir_path)

        files_list = [self.tvm_config_file, self.caller_list, self.callee_list, self.perl_script]
        file_names = dict(zip(['config_file', 'caller_list', 'callee_list', 'perl_script'],[x.split('/')[-1] for x in files_list]))
        for fil in files_list:
            tvmc_ftp.cwd(remote_dir_path)
            tvmc_ftp.storbinary('STOR '+fil.split('/')[-1], open(fil, 'rb'))
        tvmc_ftp.quit()

        import pdb;pdb.set_trace()
        #time.sleep(180)
        tvmc_client = utils.get_ssh_conn(self.tvmc_host, self.tvmc_username, self.tvmc_password)
        interfaces = tvmutils.get_interfaces(tvmc_client)
        while len(interfaces) != num_of_test_clients():
            interfaces = tvmutils.get_interfaces(tvmc_client)
        #output, err = utils.exec_command("cli listInterfaces| tail --lines=+2 | awk '{print $1}'", client=tvmc_client)
        #interfaces = output.rstrip('\n').split('\n')
        

        import pdb;pdb.set_trace()
        cmd_perl = "perl "+remote_dir_path+'/'+file_names['perl_script']+" --config "+remote_dir_path+'/'+file_names['config_file']+' --calleelist '+remote_dir_path+'/'+file_names['callee_list']+' --callerlist '+remote_dir_path+'/'+file_names['caller_list']
        for interface_num in range(0, len(interfaces)):
            cmd_perl = cmd_perl + ' --interface '+interfaces[interface_num]
        cmd_perl = cmd_perl+"> voip_onecall.xml"
      
        cmds = [cmd_perl, "cli importTestGroup \"//\" voip_onecall.xml", "cli startTestGroup "+self.test_group, "cli listHosts|awk '{print $1, $3}'", "cli listApplications "+self.test_group+"|awk '{print $1, $3}'", "cli saveTestGroupCurrentDetailedResults "+self.test_group+" "+remote_dir_path+"/"+result_filename, "cli stopTestGroup "+self.test_group, "cli deleteTestGroup "+self.test_group]
        for cmd in cmds:
            import pdb;pdb.set_trace()
            output, err = utils.exec_command(cmd, client=tvmc_client)
            if 'awk' in cmd:
                 for line in output.rstrip().split('\n')[1:]:
                     if line.split()[1] != "Active":
                         print "Error"
                         #self.logger.warn("Error: %s not configured!!", line.split()[0])
            elif 'save' in cmd:
                 tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
                 tvmc_ftp.cwd(remote_dir_path)
                 tvmc_ftp.retrbinary('RETR '+remote_dir_path+'/'+result_filename, open(self.local_path+'/'+self.result_filename, 'wb').write)
                 tvmc_ftp.quit()
            elif 'stop' in cmd:
                 tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
                 tvmc_ftp.cwd(remote_dir_path)
		 for fil in tvmc_ftp.nlst():
                     tvmc_ftp.delete(fil)
                 tvmc_ftp.cwd('/home/'+self.tvmc_username)
                 tvmc_ftp.rmd(remote_dir_path)
                 tvmc_ftp.quit()
            elif 'start' in cmd:
                 time.sleep(100)    
            else:
                pass
示例#2
0
    def __init__(self, exeCore):
        """onboard the test framework"""
        import pdb;pdb.set_trace()
        sipp_config = {}
        self.execore = exeCore
        self.sipp_cfg = sipputils._get_sipp_config()
        self._base = self.sipp_cfg['base_number']

        args = {'network': 'sip-network', 'subnet_name': 'sip_subnet', 'cidr': self.sipp_cfg['sipp_network']}
        sip_nw_id = self.execore.createNetwork(**args)
        args = {'network': 'sip-mgmt', 'subnet_name': 'sip_mgmt_subnet', 'cidr': self.sipp_cfg['mgmt_network']}
        mgmt_nw_id = self.execore.createNetwork(**args)
        #TODO: Router ID should be from config file instead of hardcoding
        args = {'router_name': self.sipp_cfg['sipp_router'], 'external_network_name': 'public'}
        router_id = self.execore.createRouter(**args)

        self.NSD = os.path.join(self.execore.productDir,'core/tstcore/sipp/descriptor','sipp.zip')
        self.templateID = self.execore.onBoard('sipp', self.NSD)

        csObj = self.execore.createServiceRequestObject(router=self.sipp_cfg['sipp_router'], networks= {'sip-network': sip_nw_id, 'mgmt-if': mgmt_nw_id})
        csObj['name'] = 'Sipp'
        csObj['qos'] = 'Voip'
        sipp_svc = self.execore.createService(self.templateID, **csObj)

        import pdb;pdb.set_trace()
        #Need to obtain below configuration from service object
        self.sip1_ip = utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][0], 'mgmt-if')
        self.sip1_username = utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][0], 'username')
        self.sip1_password = utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][0], 'password')
        self.sip2_ip = utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][1], 'mgmt-if')
        self.sip2_username = utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][1], 'username')
        self.sip2_password= utils.getVduParameter(tvm_srv['vdus']['Sipp']['vSipp'][1], 'password')
        self._udp_ports = []
        for i in range(16376, 32767):
            self._udp_ports.append(i)

        self.sip1_client = utils.get_ssh_conn(self.sip1_ip, self.sip1_username, self.sip1_password) 
        self.sip2_client = utils.get_ssh_conn(self.sip2_ip, self.sip2_username, self.sip2_password)
        self.report = sipputils._init_report()
        self.testCaseMap = { 'TEST_SIP_WITH_RTP' : '__exec_sip_rtp__', 
                             'TEST_SIP_WITHOUT_RTP' : '__exec_sip_no_rtp'}
        super(TestCore, self).__init__()
示例#3
0
    def __exec_sip_calls__(self, **kwargs):
        self._init_args(**kwargs)
        tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
        remote_dir_path = '/home/'+self.tvmc_username+'/testframework_tmp'
        result_filename = "tvm_results_"+time.strftime("%Y%m%d-%H%M%S")+".zip"

        tvmc_ftp.mkd(remote_dir_path)

        files_list = [self.tvm_config_file, self.caller_list, self.callee_list, self.perl_script]
        file_names = dict(zip(['config_file', 'caller_list', 'callee_list', 'perl_script'],[x.split('/')[-1] for x in files_list]))
        for fil in files_list:
            tvmc_ftp.cwd(remote_dir_path)
            tvmc_ftp.storbinary('STOR '+fil.split('/')[-1], open(fil, 'rb'))
        tvmc_ftp.quit()

        tvmc_client = utils.get_ssh_conn(self.tvmc_host, self.tvmc_username, self.tvmc_password)
        interfaces = tvmutils.get_interfaces(tvmc_client)
        while len(interfaces) != 2:
            interfaces = tvmutils.get_interfaces(tvmc_client)

        cmd_perl = "perl "+remote_dir_path+'/'+file_names['perl_script']+" --config "+remote_dir_path+'/'+file_names['config_file']+' --calleelist '+remote_dir_path+'/'+file_names['callee_list']+' --callerlist '+remote_dir_path+'/'+file_names['caller_list']
        for interface_num in range(0, len(interfaces)):
            cmd_perl = cmd_perl + ' --interface '+interfaces[interface_num]
        cmd_perl = cmd_perl+"> voip_onecall.xml"
      
        cmds = [cmd_perl, "cli importTestGroup \"//\" voip_onecall.xml", "cli startTestGroup "+self.test_group, "cli saveTestGroupCurrentDetailedResults "+self.test_group+" "+remote_dir_path+"/"+result_filename, "cli stopTestGroup "+self.test_group, "cli deleteTestGroup "+self.test_group]
        for cmd in cmds:
            try:
                output, err = utils.exec_command(cmd, client=tvmc_client)
            except:
                pass
            if 'awk' in cmd:
                 for line in output.rstrip().split('\n')[1:]:
                     if line.split()[1] != "Active":
                         print "Error"
                         #self.logger.warn("Error: %s not configured!!", line.split()[0])
            elif 'save' in cmd:
                 tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
                 tvmc_ftp.cwd(remote_dir_path)
                 tvmc_ftp.retrbinary('RETR '+remote_dir_path+'/'+result_filename, open(self.local_path+'/'+result_filename, 'wb').write)
                 tvmc_ftp.quit()
            elif 'stop' in cmd:
                 tvmc_ftp = FTP(self.tvmc_host, self.tvmc_username, self.tvmc_password)
                 tvmc_ftp.cwd(remote_dir_path)
		 for fil in tvmc_ftp.nlst():
                     tvmc_ftp.delete(fil)
                 tvmc_ftp.cwd('/home/'+self.tvmc_username)
                 tvmc_ftp.rmd(remote_dir_path)
                 tvmc_ftp.quit()
            elif 'start' in cmd:
                 time.sleep(120)
            else:
                pass
        return self.__analyze_logs__(result_filename)