Esempio n. 1
0
def main(orderid):

    curorder = ixchorder(orderid)
    if not curorder.isInited():
        sys.exit(0)
    print "\ndut_IP:  ", dut["IP"], type(dut["IP"])
    try:
        dut_ip_sub = re.search(r"(\d{1,3}.\d{1,3}.\d{1,3})", dut["IP"]).group(1)
    except:
        print "the DUT IP is not set correctly"
        dut_ip_sub = "192.168.1"
        # dut_ip_sub='%s.%s'%(re.search(r'(\d{1,3}.\d{1,3}.\d{1,3})',dut['IP']).group(1),77)

    print "dut_ip_sub", dut_ip_sub
    curorder.order_exec = {
        "testorderid": curorder.orderid,
        "plan_start": "0000-00-00 00:00:00",
        "plan_stop": "0000-00-00 00:00:00",
        "starttime": curorder.stime.strftime("%Y-%m-%d %H:%M:%S"),
        "finishtime": "------",
        "progress": 0,
        "status": 1,
        "testcasestatus": "0_0_0",
        "log": "",
        "testerid": 11,
    }
    curorder.order_exec_id = TMS.addexetable(curorder.order_exec)
    if not curorder.order_exec_id:
        print "Can not connected with TMS server, created exec_order table"
        sys.exit(1)
    else:
        print " The execute table is built"
        # curorder.totalcasecount=totaltrytimes*curorder.xangle*len(curorder.clientlist)*curorder.totalcases/3
        # print 'fo.log-----------------------------------------',fo.log
    logfilename = "%s%slogfile.txt" % (curorder.backupdir, os.sep)
    testlogfile = open(logfilename, "w", 0)
    # fo=Getstdout()
    sout = stdsplit(testlogfile, curorder.order_exec_id)
    sys.stdout = sout

    curorder.start()
    # atestcasestatus='%s_%s_%s'%(curorder.passedcasecount,curorder.failedcasecount,curorder.totalcasecount)
    # TMS.updateprogress(100.0,datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),fo.log,atestcasestatus,curorder.order_exec_id,0)

    atestcasestatus = "%s_%s_%s" % (curorder.passedcasecount, curorder.failedcasecount, curorder.totalcasecount)
    # print '\n-------------------------time',datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    # TMS.updateprogress(100.0,datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),fo.log,atestcasestatus,curorder.order_exec_id,1)
    TMS.updateprogress(
        100.0,
        datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        curorder.errorlog,
        atestcasestatus,
        curorder.order_exec_id,
        0,
    )
Esempio n. 2
0
    def start(order):

        """
		print 'order.client',order.clientlist,'\norder.client_location',order.client_location,'\norder.clientIP',order.clientIP

		for curclient in order.clientlist:
			curclientinfo=order.clientIP[curclient]
			print 'curclient:',curclient,'radio',curclient,'clientID',curclientinfo['clientid'],'A:',curclientinfo['A'],'E:',curclientinfo['E']
		"""
        atestcasestatus = "%s_%s_%s" % (order.passedcasecount, order.failedcasecount, order.totalcasecount)
        TMS.updateprogress(
            (order.passedcasecount + order.failedcasecount) / float(order.totalcasecount) * 100,
            "------",
            order.errorlog,
            atestcasestatus,
            order.order_exec_id,
            1,
        )

        # TMS2.updateprogress((order.passedcasecount+order.failedcasecount)/float(order.totalcasecount)*100,datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),order.errorlog,atestcasestatus,order.order_exec_id)

        order.run(order.remainingcases)
Esempio n. 3
0
    def __init__(order, orderid):
        global dut
        print "the test order %s is initing..." % orderid
        order.orderid = orderid
        order.failedcases = {}
        order.passedcases = []
        order.remainingcases = []
        order.anglelist = [0, 45, 90, 135, 180, 225, 270, 315]
        # order.anglelist=[0,90,180,270]
        order.angleinterval = "45"
        order.turntableip = ""
        order.stime = datetime.datetime.now()
        order.starttime = order.stime.strftime("%Y_%m_%d_%H_%M_%S")
        order.endtime = ""
        order.tester = "test"
        order.testerid = 11
        order.testtype = "vw"
        order.clientlist = []
        order.client_location = []
        order.clientIP = {}
        order.xangle = ""
        order.conf_name = "config_file"
        order.passedcasecount = 0
        order.failedcasecount = 0
        order.totalcasecount = 0
        order.errorlog = ""
        order.attenuationlist = ""

        order.totalcasecount, dut["sn"], dut["swbuild_id"], dut[
            "product_id"
        ], order.testbed, order.testplan, order.clientlist, order.client_location, order.xangle, order.attenuationlist, order.clientIP, dut[
            "APModel"
        ], dut[
            "APSWVersion"
        ], order.caselist, dut[
            "IP"
        ], dut[
            "NumTxAntennas"
        ], dut[
            "NumTxAntennas5G"
        ] = TMS.get_ota_order(
            orderid
        )
        print dut["sn"]
        print order.attenuationlist, type(order.attenuationlist)
        if order.attenuationlist:
            order.attenuationlist = map(int, order.attenuationlist.split(","))
        print "\n---order.attenuationlist:", order.attenuationlist, "len:", len(order.attenuationlist)

        if order.xangle == "all":
            print "Use the default 8 angles"
        else:
            order.anglelist = map(int, order.xangle.split(","))

        print "xangle", order.xangle, "anglelist:", order.anglelist

        order.totalcases = len(order.caselist)
        if not order.totalcasecount:
            order.totalcasecount = order.totalcases
        order.totalcases = len(order.caselist)

        order.remainingcases = order.caselist[:]
        order.backupfilename = "%s_%s_%s_on_%s" % (dut["APModel"], dut["APSWVersion"], order.orderid, order.starttime)
        print "APSWVersion", dut["APSWVersion"]
        # order.backupfilename='testorder_%s_%s_%s_%s_on_%s'%(order.orderid,dut['APModel'],dut['APSWVersion'],order.starttime)
        backupdir = "resultbackup%s%s" % (os.sep, order.backupfilename)
        order.backupdir = re.sub(r"\s+", "_", backupdir)
        # print order.backupdir
        # winbackupdir='c:\\ixch'+order.backupdir
        # print winbackupdir
        os.mkdir(order.backupdir, 0755)

        # os.mkdir(winbackupdir)
        if order.testbed != 8 and order.testbed != 9 and order.testbed != 10:
            # what is ths for ixia or OTA
            print "Please choose the correct testbed, it should be the OTA Fisk or OTA chamber"
            sys.exit(1)
        else:
            conn = MySQLdb.connect(
                host=iccase.tms["ip"], user=iccase.tms["username"], passwd=iccase.tms["password"], db="performancetest"
            )
            cursor = conn.cursor()
            sql1 = "SELECT config_file,turntable FROM testbed WHERE id = %s" % order.testbed
            cursor.execute(sql1)
            order.conf_name, order.turntableip = cursor.fetchone()
            print "the config anme is ", order.conf_name, "the turntableip is ", order.turntableip
            conn.close()
            if order.turntableip:
                order.iturntable = turntable(order.anglelist, order.angleinterval, order.turntableip)
Esempio n. 4
0
    def run(order, toruncases):
        # order.starttime=datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
        print "\n---------------------------------The test order %s begins at %s-----------------------" % (
            order.orderid,
            order.starttime,
        )
        print "Thread %s is running\n" % threading.current_thread().name
        numangle = len(order.anglelist)
        for crcase in toruncases[:]:
            # print 'rem:',curorder.remainingcases,'total:',curorder.caselist
            active_status = TMS.getrunningstatus(order.orderid)
            if not active_status:
                print "The test order %s has been stop by the server"
                break
            match = re.search(r"^(\d{1,4})\s(\d+)", crcase)
            if not match:
                print "Not matched, the format of testcase is not correct, can not generate the tclfile"
                order.failedcases[crcase] = "The test case is not in database"
                # order.remainingcases.remove(crcase)

            else:
                # order.remainingcases.remove(crcase)
                order.passedcases.append(crcase)
                print match.group(1), match.group(2)
                if order.attenuationlist:
                    cur_case = iccase(match.group(1), match.group(2), order.conf_name, len(order.attenuationlist))
                else:
                    cur_case = iccase(match.group(1), match.group(2), order.conf_name)
                    # print order.clientIP
                if cur_case.isInited():
                    for curclient in order.clientlist:
                        print "curclient:", curclient

                        if ":" in curclient:
                            if cur_case.radio != "Dual":
                                print "The current case radio is different, skip this client-------------------\n"
                            else:
                                print "the Dual band test"
                                curclient_1 = curclient.split(":")[0]
                                curclient_2 = curclient.split(":")[1]
                                curclient_1info = order.clientIP[curclient_1]
                                curclient_2info = order.clientIP[curclient_2]
                                cur_case.clientID = curclient_1info["clientid"]
                                # cur_case.location=['A','B','C','D','E']
                                # curclient_1info['radio']=='2.4GHz':
                                cur_case.endpoint_2G["A"] = curclient_1info["A"]
                                # if order.testbed == 8:
                                cur_case.endpoint_2G["B"] = curclient_1info["B"]
                                cur_case.endpoint_2G["C"] = curclient_1info["C"]
                                cur_case.endpoint_2G["D"] = curclient_1info["D"]
                                cur_case.endpoint_2G["E"] = curclient_1info["E"]

                                cur_case.endpoint_5G["A"] = curclient_2info["A"]
                                # if order.testbed == 8:
                                cur_case.endpoint_5G["B"] = curclient_2info["B"]
                                cur_case.endpoint_5G["C"] = curclient_2info["C"]
                                cur_case.endpoint_5G["D"] = curclient_2info["D"]
                                cur_case.endpoint_5G["E"] = curclient_2info["E"]
                                cur_case.creatclonefile()

                                if numangle != 0:
                                    for iangle in range(numangle):
                                        # print order.anglelist
                                        cur_case.xangle = order.anglelist[iangle]

                                        print cur_case.xangle
                                        if order.turntableip:
                                            setangle_success = order.iturntable.setangle(cur_case.xangle)
                                        else:
                                            setangle_success = 1
                                        time.sleep(10)
                                        if not setangle_success:
                                            print " Failed to set the turntable angle, the system exit"
                                            break

                                            # print 'order.client:',order.client
                                        asucess = cur_case.go(curclient, order.client_location, order.attenuationlist)
                                        if not asucess:
                                            order.failedcasecount += 1
                                            print "failed once", order.failedcasecount

                                        else:
                                            order.passedcasecount += 1
                                            print "passed", order.passedcasecount
                                        cur_case.uploadresult(order, dut, tms_server)
                                        # print cur_case.result_pdf,'\n',cur_case.result_csv,'\n',cur_case.result_tst
                                        cur_case.dealresult(order.backupdir, cur_case.xangle)
                                        order.errorlog += " end :%s    \n" % datetime.datetime.now().strftime(
                                            "%H:%M:%S"
                                        )
                                        atestcasestatus = "%s_%s_%s" % (
                                            order.passedcasecount,
                                            order.failedcasecount,
                                            order.totalcasecount,
                                        )
                                        # atestcasestatus='%s_%s_%s'%(len(order.passedcases),len(order.failedcases),order.totalcases-len(order.failedcases)-len(order.failedcases))
                                        TMS.updateprogress(
                                            (order.passedcasecount + order.failedcasecount)
                                            / float(order.totalcasecount)
                                            * 100,
                                            "------",
                                            order.errorlog,
                                            atestcasestatus,
                                            order.order_exec_id,
                                            1,
                                        )
                                        # for angleindex in range(order.xangle):
                                        # cur_case.xangle=ixchorder.iturntable.angle[angleindex]
                                        #

                                        # print " Failed to set the turntable angle, the system exit"
                                        # sys.exit(0)

                                else:
                                    print iangle, [0, 90, 180, 270][iangle]
                                    sys.exit(0)

                        else:

                            curclientinfo = order.clientIP[curclient]
                            if cur_case.radio != curclientinfo["radio"]:
                                print "The current case radio is different, skip this client-------------------\n"
                            else:
                                print "\n-----radio", cur_case.radio, curclientinfo["radio"], "clientID", curclientinfo[
                                    "clientid"
                                ], "\n clientIP", curclientinfo["A"], "------"
                                cur_case.clientID = curclientinfo["clientid"]
                                # if order.testbed ==9 or order.testbed==10:
                                # cur_case.location=['A','B','C','D','E']
                                # elif order.testbed ==8:
                                # cur_case.location=['A','B','C','D','E']
                                # else:
                                # print "wrong testbed"
                                # sys.exit(0)

                                if cur_case.radio == "2.4GHz":
                                    cur_case.endpoint_2G["A"] = curclientinfo["A"]
                                    # if order.testbed == 8:
                                    cur_case.endpoint_2G["B"] = curclientinfo["B"]
                                    cur_case.endpoint_2G["C"] = curclientinfo["C"]
                                    cur_case.endpoint_2G["D"] = curclientinfo["D"]
                                    cur_case.endpoint_2G["E"] = curclientinfo["E"]
                                elif cur_case.radio == "5GHz":
                                    # cur_case.endpoint_5G['base']='192.168.8.205'
                                    cur_case.endpoint_5G["A"] = curclientinfo["A"]
                                    # if order.testbed == 8:
                                    cur_case.endpoint_5G["B"] = curclientinfo["B"]
                                    cur_case.endpoint_5G["C"] = curclientinfo["C"]
                                    cur_case.endpoint_5G["D"] = curclientinfo["D"]
                                    cur_case.endpoint_5G["E"] = curclientinfo["E"]
                                else:
                                    print "not supported"
                                cur_case.creatclonefile()
                                if numangle != 0:
                                    for iangle in range(numangle):
                                        print "iangle", iangle
                                        cur_case.xangle = order.anglelist[iangle]
                                        if order.turntableip:
                                            setangle_success = order.iturntable.setangle(cur_case.xangle)
                                        else:
                                            setangle_success = 1
                                        time.sleep(10)
                                        if not setangle_success:
                                            print " Failed to set the turntable angle, the system exit"
                                            break

                                            # print 'order.client:',order.client
                                            # cur_case.go(curclient, order.client_location)
                                        print "\n-----debug:", curclient, order.client_location
                                        #'0',['0,1']
                                        asucess = cur_case.go(curclient, order.client_location, order.attenuationlist)
                                        if not asucess:
                                            order.failedcasecount += 1
                                            print "failed once", order.failedcasecount

                                        else:
                                            order.passedcasecount += 1
                                            print "passed", order.passedcasecount
                                        cur_case.uploadresult(order, dut, tms_server)
                                        # print cur_case.result_pdf,'\n',cur_case.result_csv,'\n',cur_case.result_tst
                                        cur_case.dealresult(order.backupdir, cur_case.xangle)
                                        # print fo.log
                                        # order.errorlog+=fo.log
                                        # print order.errorlog
                                        order.errorlog += " end :%s    \n" % datetime.datetime.now().strftime(
                                            "%H:%M:%S"
                                        )

                                        atestcasestatus = "%s_%s_%s" % (
                                            order.passedcasecount,
                                            order.failedcasecount,
                                            order.totalcasecount,
                                        )
                                        # atestcasestatus='%s_%s_%s'%(len(order.passedcases),len(order.failedcases),order.totalcases-len(order.failedcases)-len(order.failedcases))
                                        TMS.updateprogress(
                                            (order.passedcasecount + order.failedcasecount)
                                            / float(order.totalcasecount)
                                            * 100,
                                            "------",
                                            order.errorlog,
                                            atestcasestatus,
                                            order.order_exec_id,
                                            1,
                                        )
                                        # for angleindex in range(order.xangle):
                                        # cur_case.xangle=ixchorder.iturntable.angle[angleindex]
                                        #

                                        # print " Failed to set the turntable angle, the system exit"
                                        # sys.exit(0)

                                else:
                                    print iangle, [0, 90, 180, 270][iangle]
                                    sys.exit(0)

                                    # print ixchorder.iturntable[0]

                                    # print curclientinfo  case.location=['A','B','C','D','E'] case.clientID='2'

                                    # print 'curclient:',curclient,'radio',curclient,'clientID',curclientinfo['clientid'],'A:',curclientinfo['A'],'E:',curclientinfo['E']

                                    # case_i.dealresult(dut,'./tmpresult','./tmpresult')
                                    # case_i.uploadresult(testorder,dut,tms_server)
                    print "Failinfo", cur_case.Failinfo
                    if not cur_case.Failinfo:
                        print "pass"
                    else:
                        print "fail"
                else:
                    print "the case failed"