示例#1
0
 def _sleeptest(t):
     start = now()
     self.info("sleeping %s seconds" % (t, ))
     self.sched.sleep(t)
     elapsed = now() - start
     self.assert_approximately_equal(
         elapsed, t, 1,
         "should have slept %s secs., actual %s secs." % (t, elapsed))
示例#2
0
 def test_method(self):
     start = now()
     self.sched.add(2, 0, self._tp, (2, start))
     self.sched.add(4, 0, self._tp, (4, start))
     self.sched.add(5, 0, self._tp, (5, start))
     self.sched.add(6, 0, self._tp, (6, start))
     self.sched.add(7, 0, self._tp, (7, start))
     self.info("sleeping for 8 seconds")
     self.sched.sleep(8)
     self.assert_approximately_equal(now() - start, 8, 1)
     return self.passed("passed all assertions")
示例#3
0
 def test_method(self):
     start = now()
     self.sched.add(2, 0, self._tp, (2, start))
     self.sched.add(4, 0, self._tp, (4, start))
     self.sched.add(5, 0, self._tp, (5, start))
     self.sched.add(6, 0, self._tp, (6, start))
     self.sched.add(7, 0, self._tp, (7, start))
     self.info("sleeping for 8 seconds")
     self.sched.sleep(8)
     self.assert_approximately_equal(now() - start, 8, 1)
     return self.passed("passed all assertions")
示例#4
0
 def test_method(self):
     start = now()
     self.STOP = 0
     timeout = self.sched.add(20, callback=self._timeout)
     self.info("should timeout in 20 seconds")
     try:
         subtime = self.sched.add(30, callback=self._failed)
         while not self.STOP:
             for x in range(1000000): # busy loop
                 y=x
     finally:
         self.sched.remove(timeout)
         self.sched.remove(subtime)
     self.assert_approximately_equal(now() - start, 20, 1)
     return self.passed("timers fired correctly")
示例#5
0
 def test_method(self):
     start = now()
     self.STOP = 0
     timeout = self.sched.add(20, callback=self._timeout)
     self.info("should timeout in 20 seconds")
     try:
         subtime = self.sched.add(30, callback=self._failed)
         while not self.STOP:
             for x in range(1000000):  # busy loop
                 y = x
     finally:
         self.sched.remove(timeout)
         self.sched.remove(subtime)
     self.assert_approximately_equal(now() - start, 20, 1)
     return self.passed("timers fired correctly")
示例#6
0
 def test_method(self):
     start = now()
     #### timeout pattern
     self.STOP = 0
     timeout = self.sched.add(20, callback=self._timeout)
     self.info("should stop in 20 seconds")
     try:
         while not self.STOP:
             for x in range(1000000): # busy loop
                 y=x
     finally:
         self.sched.remove(timeout)
     ####
     self.assert_approximately_equal(now() - start, 20, 1)
     return self.passed("appropriate timeout")
示例#7
0
 def test_method(self):
     start = now()
     #### timeout pattern
     self.STOP = 0
     timeout = self.sched.add(20, callback=self._timeout)
     self.info("should stop in 20 seconds")
     try:
         while not self.STOP:
             for x in range(1000000):  # busy loop
                 y = x
     finally:
         self.sched.remove(timeout)
     ####
     self.assert_approximately_equal(now() - start, 20, 1)
     return self.passed("appropriate timeout")
示例#8
0
    def __call__(self, *args, **kw):
        cf = self.config
        if os.path.isfile(self.configfile):
            pass
        else:  #try another path
            alternate_conf_file = os.path.join(cf.conf_dir, "%s.conf" % (self.test_name))
            if os.path.isfile(alternate_conf_file):
                self.configfile = alternate_conf_file

        if os.path.isfile(self.configfile):
            print "CONF file is: %s" % self.configfile
            cf.mergefile(self.configfile)
            try:
                cf.config_ID = os.path.basename(cf.config_ID.split()[1])
            except AttributeError:
                cf.config_ID = None
            except IndexError:
                cf.config_ID = "<undefined>"
                print >>sys.stderr, 'Make sure your config file is type "ktext" in Perforce.'
        else:
            cf.config_ID = None
        # this heading displays the test name just as a PREREQUISITES entry needs.
        self._ui.add_heading(repr_test(self.test_name, args, kw), 2)
        self._report.add_heading(repr_test(self.test_name, args, kw), 2)
        if cf.config_ID:
            self.info("Configuration ID: %s" % (cf.config_ID,))
        self.starttime = timelib.now()
        self.info("STARTTIME: %s" % self.timestamp(self.starttime))
        rv = None # in case of exception
        rv = self._initialize(rv)
        if rv is not None: # an exception happened
            return rv
        # test elapsed time does not include initializer time.
        teststarttime = timelib.now()
        # run test_method
        testloops = int(cf.get("testloops", 1))
        try:
            for l in xrange(testloops):
                rv = apply(self.test_method, args, kw)
        except KeyboardInterrupt:
            if self._debug:
                ex, val, tb = sys.exc_info()
                debugger.post_mortem(ex, val, tb)
            rv = self.abort("%s: aborted by user." % self.test_name)
            self._finalize(rv)
            raise
        except TestFailError, errval:
            rv = self.failed("Caught Fail exception: %s" % (errval,))
示例#9
0
 def test_method(self):
     rtc = self.config.rtc
     # Read the RTC time/date
     tm = rtc.time_read()
     self.info("Current RTC date/time is: %s" % (tm,))
     tm.add_seconds(10)
     rtc.alarm_set(tm)
     # Read the current alarm settings
     tm = rtc.alarm_read()
     self.info("Alarm time now set to: %s" % (tm,))
     start = now()
     rtc.alarm_interrupt_on()
     self.info("Waiting 10 seconds for alarm...")
     count, status = rtc.read()
     self.info("okay. Alarm rang.")
     rtc.alarm_interrupt_off()
     self.assert_approximately_equal(now() - start, 10, 1)
     return self.passed("alarm in specified time")
示例#10
0
 def test_method(self):
     rtc = self.config.rtc
     # Read the RTC time/date
     tm = rtc.time_read()
     self.info("Current RTC date/time is: %s" % (tm, ))
     tm.add_seconds(10)
     rtc.alarm_set(tm)
     # Read the current alarm settings
     tm = rtc.alarm_read()
     self.info("Alarm time now set to: %s" % (tm, ))
     start = now()
     rtc.alarm_interrupt_on()
     self.info("Waiting 10 seconds for alarm...")
     count, status = rtc.read()
     self.info("okay. Alarm rang.")
     rtc.alarm_interrupt_off()
     self.assert_approximately_equal(now() - start, 10, 1)
     return self.passed("alarm in specified time")
示例#11
0
 def test_method(self):
     start = now()
     def _itakealongtime():
         for x in xrange(sys.maxint): # busy loop
             y=x*x/(x+20000)
     try:
         self.sched.timeout(_itakealongtime, timeout=3)
     except TimeoutError:
         return self.passed("timed out long function.")
     else:
         return self.failed("function did not timeout")
示例#12
0
文件: BurnIn.py 项目: pruan/TestDepot
 def _update_uut_db(self, info):
     """
     info is a dictionary that indicates which column we are updating.
     a field that's always updated is the last update column.
     """
     for key, val in info.items():
         if key == 'msg':
             current_msg = getattr(self.db, key)
             val += current_msg
         setattr(self.db, key, val)
     self.db.lastUpdate = datetime.datetime.fromtimestamp(timelib.now())
示例#13
0
    def test_method(self):
        start = now()

        def _itakealongtime():
            for x in xrange(sys.maxint):  # busy loop
                y = x * x / (x + 20000)

        try:
            self.sched.timeout(_itakealongtime, timeout=3)
        except TimeoutError:
            return self.passed("timed out long function.")
        else:
            return self.failed("function did not timeout")
示例#14
0
文件: qatest.py 项目: pruan/TestDepot
	def __call__(self, *args, **kw):
		# this heading displays the test name just as a PREREQUISITES entry needs.
		self._report.add_heading(repr_test(self.test_name, args, kw), 2)
		self.starttime = timelib.now()
		self.info("STARTTIME: %s" % (timelib.strftime("%a, %d %b %Y %H:%M:%S %Z", timelib.localtime(self.starttime)),))
		rv = None # in case of exception
		rv = self._initialize(rv)
		if rv is not None: # an exception happened
			return rv
		# test elapsed time does not include initializer time.
		teststarttime = timelib.now()
		# run test_method
		try:
			rv = apply(self.test_method, args, kw)
		except KeyboardInterrupt:
			if self._debug:
				ex, val, tb = sys.exc_info()
				debugger.post_mortem(ex, val, tb)
			rv = self.abort("%s: aborted by user." % self.test_name)
			self._finalize(rv)
			raise
		except TestFailError, errval:
			rv = self.failed("Caught Fail exception: %s" % (errval,))
示例#15
0
文件: qatest.py 项目: pruan/TestDepot
			raise
		except TestFailError, errval:
			rv = self.failed("Caught Fail exception: %s" % (errval,))
		except TestIncompleteError, errval:
			rv = self.abort("Caught Abort exception: %s" % (errval,))
		except AssertionError, errval:
			rv = self.failed("failed assertion: %s" % (errval,))
		except TestSuiteAbort:
			raise # pass this one up to suite
		except:
			ex, val, tb = sys.exc_info()
			if self._debug:
				debugger.post_mortem(ex, val, tb)
				tb = None
			rv = self.failed("%s: Exception occured! (%s: %s)" % (self.test_name, ex, val))
		endtime = timelib.now()
		minutes, seconds = divmod(endtime - teststarttime, 60.0)
		hours, minutes = divmod(minutes, 60.0)
		self.info("Time elapsed: %02.0f:%02.0f:%02.2f" % (hours, minutes, seconds))
		return self._finalize(rv)

	def _initialize(self, rv):
		try:
			self.initialize()
		except:
			ex, val, tb = sys.exc_info()
			self.diagnostic("%s (%s)" % (ex, val))
			if self._debug:
				debugger.post_mortem(ex, val, tb)
			rv = self.abort("Test initialization failed!")
		return rv
示例#16
0
    def run_module(self, mod):
  
        cf = self._config
        userinterface = storage.get_ui(cf)
        cf['userinterface'] = userinterface

        # ui = self._config.userinterface
        user_name = commands.getoutput('whoami')
        cf['user'] = user_name
        output = commands.getoutput("groups %s" % user_name)
        user_group = output.split(':')[0].strip()
        cf.USERGROUP = user_group
        if type(mod) is str:
            mod = self.get_module(mod)
            # find out what type of test this is.  if UI, then we need to instantiate
            # a AutoWeb instance
            cf['mod_type'] = mod.__name__.split('.')[0]

        if cf.options.tag:
            # user wants to run a collection of test (a testsuite, instantiate 
            # a TCMS object, which will be used to add_test()
            cf['tcms_obj'] = tcms_base.TCMS()

        if mod:
            cf.reportbasename = mod.__name__.replace(".", "_")
            cf.logbasename = "%s.log" % (cf.reportbasename,)
            cf['logfile'] = storage.get_logfile(cf)
            # merge any test-module specific configuration files
            modconf = os.path.join(os.path.dirname(mod.__file__), "%s.conf" % (mod.__name__.split(".")[-1],))
            user_modconf = modconf + "." + cf.OPENSHIFT_user_email
            if os.path.exists(user_modconf):
                execfile(user_modconf, cf.__dict__)
            elif os.path.exists(modconf):
                execfile(modconf, cf.__dict__)


            try:
                print "tcms_testcaserun_id: %s" %(cf.tcms_testcaserun_id)
                if os.environ.has_key("OPENSHIFT_tcms_testcaserun_id"):
                    cf.tcms_testcaserun_id = os.environ['OPENSHIFT_tcms_testcaserun_id']
            except:
                 #if rhtest is run manually from command line without launcher, which should put this into the .conf file
                cf.tcms_testcaserun_id = None
                #print "WARN: None tcms_testcaserun_id info!!!"


            if cf.tcms_testcaserun_id != None:
                import tcms
                cf['tcms_obj'] = tcms.TCMS()
            else:
                cf['tcms_obj'] = None


            starttime = timelib.now()
            cf.results_year_month_dir = os.path.join(cf.resultsdirbase, "%s" % (timelib.strftime("%Y%m/%d/")))
            # first make the YYYYMM top directory
            try:
                os.system("sudo mkdir -p %s" % (cf.results_year_month_dir))
                os.system("sudo find %s -type d -exec chmod 777 {} \;" % (cf.resultsdirbase))
            except OSError, errno:
                if errno[0] == EEXIST:
                    pass
                else:
                    raise

            rand_num = random.randint(0, 5000)
            # now make the actual test directory, added rand_num to make it more unique
            cf.resultsdir = os.path.join(
                 cf.results_year_month_dir,
                 "%s-%s-%s" % (cf.reportbasename, rand_num, timelib.strftime("%Y%m%d%H%M%S", timelib.localtime(starttime)))
            )
            try:
                os.system("sudo mkdir -p %s" % (cf.resultsdir))
                os.system("sudo find %s -type d -exec chmod 777 {} \;" % (cf.resultsdirbase))
            except OSError, errno:
                if errno[0] == EEXIST:
                    pass
                else:
                    raise
示例#17
0
文件: BurnIn.py 项目: pruan/TestDepot
    def initialize(self):
        
        #test status and parameters
        self.resetState = True
        self.resetCount = 0
        self.maxResets = self.config.maxresets
        self.passing = True
        self.debugMode = self.config.debugmode
        
        #uut type
        self.uut_type = int(self.config.uuttype)        
        
        #initialize testbed
        tb = self.config.testbed
        
        #sql database
        self.burnInTestArgs = {}
          
        #data file
        pathname = self.get_pathname(self.config.dataFileName)
        self.df = file(pathname, "w")
        
        #log file
        self.lf = self.config.logfile
        
        # Making uut list
        from copy import copy
        self.uutDict = copy(self.config.uut_dict) #dict from stratatestrunner
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n"  %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        
        #Setting up the uut
        for sn in self.uutSnList:    #only one UUT
            self.burnInTestArgs[self.uutDict[sn]["id"]] = []
            uut_slot = self.uutDict[sn]['slot']
            self.SLOT = int(uut_slot)

        # make the DB connection.
        card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
        i = 0
        while i < len(card_conn_list):
            if card_conn_list[i].tb == tb.name:
                card_conn = card_conn_list[i]
                self.db = card_conn
                break
            else:
                i += 1
        if (i >= len(card_conn_list)):
            #if environment variable IDTYPE == UUID, then use UUID for database entry id, else implicit auto-increment integer is used.
            if (("IDTYPE" in os.environ.keys()) and (os.environ["IDTYPE"]=="UUID")):
                database.TitanBurnIn(
                    id = (commands.getoutput('uuidgen -t')).strip(),
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )
            else:
                database.TitanBurnIn(
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )

            card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
            i = 0
            while i < len(card_conn_list):
                if card_conn_list[i].tb == tb.name:
                    card_conn = card_conn_list[i]
                    self.db = card_conn
                    break
                else:
                    i += 1    
        db_info = {}
        db_info['sn'] = sn
        db_info['startTime'] = datetime.datetime.fromtimestamp(timelib.now())
        db_info['endTime'] = None
        db_info['status'] = 2
        self._update_uut_db(db_info)        
       
        # keep looping until a valid response is given
        while (1):
            status = upper(self.user_input("\nDo you want to start or continue the BurnIn[s/c]?:"))
            if status == "S" or status == "C":
                break

        totalHrs, interval = self.config.totalhrs
        if status == "S":
            # if start a new burnin session, ask for how long to run range
            # (1-48) hours
            self.db.msg = ''  # clear the old meassages.
            self.db.msg += "Start Burn In Test for Line Card %s in Slot:%s ...\n" % (sn, self.SLOT)
            while (1):
                totalHrs = int(self.user_input("\nHow long do you want to run BurnIn test?[1-48]?:"))
                if totalHrs > 0 and totalHrs < 49:
                    totalHrsToRun = totalHrs
                    totalHrs = PQ(totalHrs, "h")
                    break
            self.numCheckIter = int(totalHrs/interval)
            self.info("Test to run for %s" %(totalHrs,))
            self.lf.write("Test to run for %s" %(totalHrs,))
            self.db.msg += "Test to run for %s\n" % (totalHrs,)
            self.db.currentRun = 0
            db_info['runs'] = totalHrsToRun
            self._update_uut_db(db_info)
        else:
            synctime = self.db.currentRun
            totalHrsToRun = self.db.runs
            totalHrs = PQ(totalHrsToRun, "h")
            syncTimeInHrs = PQ(synctime, "h")
            self.info("Test already ran for %s" %(syncTimeInHrs,))
            self.lf.write("\n\nTest already ran for %s" %(syncTimeInHrs,))
            previousData = self.db.msg
            for line in previousData.split("\n"):
                if line.find("Initial") >= 0:
                    self.info("Previous Run: %s" % line)
                    self.lf.write("\n\nPrevious Run: %s\n" % line)
                else:
                    if line.find("Iter") >= 0:
                        self.info("Previous Run: %s" % line)
                        self.lf.write("\n\nPrevious Run: %s\n" % line)
            
            if syncTimeInHrs > totalHrs:
                self.numCheckIter = 1
            else:
                timeLeftInHrs = PQ(round(totalHrs - syncTimeInHrs), "h")
                self.numCheckIter = int(timeLeftInHrs/interval)
                if round(totalHrs - syncTimeInHrs) <= 0:
                    self.numCheckIter = int(1)
                self.info("Test to run for %s more" %(timeLeftInHrs,))
                self.lf.write("\n\nTest to run for %s more" %(timeLeftInHrs,))
                self.db.msg += "\n\nTest to run for %s more \n" % (timeLeftInHrs,)
                db_info['runs'] = totalHrsToRun
                self._update_uut_db(db_info)
        
        # reading initial UUT params
        chn, pwr, losth, pminterval, rxpwr, rxtol = self.config.uutParams
        self.linemaxberr = self.config.lineberrlimit
        self.clientmaxberr = self.config.clientberrlimit
        
        #setting up the UUT
        self.uut_ser_dict = {}
        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s" % slot
            self.uut860 = self.config.testbed[UUT_ser]
        
        #getting initial UUT state  
        while((self.resetState == True) and (self.resetCount <= self.maxResets)):  
            
            #set up uut
            self.setup_uut()
      
            # check uut initial state
            try:
                uut_client_sync = self.uut860.get_client_sync()   
                if uut_client_sync == '0':
                    uut_client_state = ['0','1','0','1','0.0','0','0']
                else:
                    uut_client_state = ['1','0','0','0','0.0','0','0']
            except:
                uut_client_state = ['1','0','0','0','0.0','0','0']

            clientlostsync = int(uut_client_state[0])
            clientSecondsInSyncCurrent = uut_client_state[1]
            clientSecondsOutOfSyncCurrent = uut_client_state[2]
            clientSecondsSinceReset = uut_client_state[3]
            clientber = uut_client_state[4]
            clientPreFECBER = uut_client_state[5]
            clientberr = uut_client_state[6]
        
            #lost sync determination
            if (clientlostsync == 1):
                self.resetState = self.uut860.get_4011_soft_reset_status()
                if self.resetState == True:
                    self.info("UUT was reset.\n")
                    self.lf.write("\n\nUUT was reset.\n")
                    self.df.write("\n\nUUT was reset.\n")
                    self.db.msg += ("\n\nUUT was reset.\n")
                    time.sleep(30)
                    self.resetCount +=1
            else:
                self.resetState = False
        
        #failure determination
        if (self.resetCount > self.maxResets):
            self.passing = False #uut was reset
            self.failed("UUT was reset more than %s times." % self.maxResets)
        if (clientlostsync == 1) and (self.resetState == False):
            self.passing = False #uut is out of sync
            self.failed("UUT was out of sync.")        
        
        #initial status output
        self.info("Initial: LostSync: %s SecondsInSync: %s ResetCount: %s" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.lf.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.df.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.db.msg += ("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))    
  
        #update database
        self._update_uut_db(db_info)
示例#18
0
文件: BurnIn.py 项目: pruan/TestDepot
    def test_method(self):
    
        #log header setup
        startTime = time.time()
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.write("\n\nBurn In Test Results:")
        
        #starting test status                
        self.info("Starting burn in testing ...\n")
        self.lf.write("Starting burn in testing ...\n")
      
        #initialize test parameters
        uutid = self.uutDict[self.uutSnList[0]]["id"]
        totalHrs, interval = self.config.totalhrs
        numIter = self.config.numIter
        db_info = {}
        priorRun = self.db.currentRun
        i = 1
        lineSecondsInSyncTotal = 0
        clientSecondsInSyncTotal = 0
        
        while i <= self.numCheckIter:
            
            #wait time before reading
            if self.debugMode == 1:
                time.sleep(90) #debug mode
            elif self.passing == False:
                time.sleep(5) #speed up test if failing
            else:
                while(1):
                    time.sleep(60) #test mode
                    if ((time.time() - startTime)/60) >= (interval.value * i):
                        break
            
            #initial status
            tm = (time.time() - startTime)/60
            
            #read uut state
            clientberr = 0
            lineberr = 0
            
            self.resetState = True
            while((self.resetState == True) and (self.resetCount <= self.maxResets)): 
      
                try:
                    uut_client_sync = self.uut860.get_client_sync() 
                    if uut_client_sync == '0':
                        uut_client_state = ['0','1','0','1','0.0','0','0']
                        clientlostsync = 0
                        clientSecondsInSyncCurrent = int(time.time() - startTime)
                        clientSecondsOutOfSyncCurrent = 0
                        clientSecondsSinceReset = int(time.time() - startTime)
                        clientber = '0.0'
                        clientPreFECBER = '0'
                        clientberr = 0
                    else:
                        uut_client_state = ['1','0','0','0','0.0','0','0']
                        clientlostsync = int(uut_client_state[0])
                        clientSecondsInSyncCurrent = uut_client_state[1]
                        clientSecondsOutOfSyncCurrent = uut_client_state[2]
                        clientSecondsSinceReset = uut_client_state[3]
                        clientber = uut_client_state[4]
                        clientPreFECBER = uut_client_state[5]
                        clientberr = uut_client_state[6]
                except:
                    uut_client_state = ['1','0','0','0','0.0','0','0']
                    clientlostsync = int(uut_client_state[0])
                    clientSecondsInSyncCurrent = uut_client_state[1]
                    clientSecondsOutOfSyncCurrent = uut_client_state[2]
                    clientSecondsSinceReset = uut_client_state[3]
                    clientber = uut_client_state[4]
                    clientPreFECBER = uut_client_state[5]
                    clientberr = uut_client_state[6]
                        
                #lost sync determination
                if (clientlostsync == 1):
                    self.resetState = self.uut860.get_4011_soft_reset_status()
                    if self.resetState == True:
                        self.info("UUT was reset.\n")
                        self.lf.write("\n\nUUT was reset.\n")
                        self.df.write("\n\nUUT was reset.\n")
                        self.db.msg += ("\n\nUUT was reset.\n")
                        time.sleep(30)
                        self.resetCount +=1
                        self.setup_uut()
                else:
                    self.resetState = False
            
            #Status Information
            self.info("Iter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
            self.lf.write("\n\nIter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))          

            #Database Information          
            self.db.msg += ("Iter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))          
                    
            db_info['lastUpdate'] = datetime.datetime.fromtimestamp(timelib.now())
            db_info['status'] = 2
            db_info['endTime'] = None
            db_info['currentRun'] = int(priorRun + (i/4))
            self._update_uut_db(db_info)
            
            #failure determination
            if (self.resetCount > self.maxResets):
                self.passing = False #uut was reset
                self.failed("UUT was reset more than %s times." % self.maxResets)
            if (clientlostsync == 1) and (self.resetState == False):
                self.passing = False #uut is out of sync
                self.failed("UUT was out of sync.")
            if self.passing == False:
                break
                             
            #interval increment    
            i += 1

        #record errors accumulated during the test
        self.burnInTestArgs[uutid].append((lineberr, clientberr))
        
        #pass/fail determination
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.flush
        if not self.passing:
            self.db.msg += "\n\nBurn In Test failed."
            db_info['status'] = -1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            self._update_uut_db(db_info)
            return self.failed("Burn In Test failed.", uutid)
        else:
            self.db.msg += "\n\nBurn In Test passed."
            db_info['status'] = 1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            self._update_uut_db(db_info)
            return self.passed("Burn In Test passed.", uutid)
示例#19
0
	def run_module(self, mod):
		"""run_module(module)
	Runs the module. The parameter should be a module object, but if it is a
	string then a module object with that name will be imported. 
	"""
		cf = self._config
		if type(mod) is str:
			mod = self.get_module(mod)
		if mod:
			try:
				cf.module_ID = mod._ID
			except AttributeError:
				cf.module_ID = "<unknown>"
			cf.reportbasename = mod.__name__.replace(".", "_")
			cf.logbasename = "%s.log" % (cf.reportbasename,)
			# merge any test-module specific config files.
			testconf = os.path.join(os.path.dirname(mod.__file__) , "%s.conf" % (mod.__name__.split(".")[-1],))
			cf.mergefile(testconf)
			# resultsdir is where you would place any resulting data files.
			starttime = timelib.now()
			cf.resultsdir = os.path.join(
					cf.get("resultsdirbase", os.environ["HOME"]),
					"%s-%s" % (cf.reportbasename, timelib.strftime("%Y%m%d%H%M", timelib.localtime(starttime)))
			)
			# make collection dir 
			try:
				os.mkdir(cf.resultsdir)
			except OSError, errno:
				if errno[0] == EEXIST:
					pass
				else:
					raise
			# firstly, run the module-level initialize function.
			if hasattr(mod, "initialize") and callable(mod.initialize):
				if cf.flags.DEBUG:
					try:
						mod.initialize(cf)
					except:
						ex, val, tb = sys.exc_info()
						import debugger
						debugger.post_mortem(ex, val, tb)
				else:
					mod.initialize(cf)

			rpt = cf.get_report()
			cf.reportfilenames = rpt.filenames # Report file's names. save for future use.
			rpt.initialize()
			rpt.logfile(cf.logfilename)
			rpt.add_title("Test Results for module %r." % (mod.__name__, ))
			rpt.add_message("ARGUMENTS", " ".join(cf.arguments))
			note = self.get_note()
			if note:
				rpt.add_message("NOTE", note)
				self._config.comment = note
			else:
				self._config.comment = "<none>"
			self._reporturl(rpt)
			rpt.add_message("MODULESTART", timelib.strftime("%a, %d %b %Y %H:%M:%S %Z", timelib.localtime(starttime)))
			mod.run(cf) # run the test!
			rpt.add_message("MODULEEND", timelib.localtimestamp())
			rpt.finalize()
			# force close of report and logfile between modules
			cf.logfile.flush()
			del cf.report ; del cf.logfile 

			# lastly, run the module-level finalize function.
			if hasattr(mod, "finalize") and callable(mod.finalize):
				if cf.flags.DEBUG:
					try:
						mod.finalize(cf)
					except:
						ex, val, tb = sys.exc_info()
						import debugger
						debugger.post_mortem(ex, val, tb)
				else:
					mod.finalize(cf)
示例#20
0
文件: BurnIn.py 项目: pruan/TestDepot
    def test_method(self):
    
        #initial failure due to incorrect command or start up issues
        if (not self.passing):
            uutid = self.uutDict[self.uutSnList[0]]["id"]
            return self.failed("Burn In Test failed.", uutid)
    
        #log header setup
        startTime = time.time()
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.write("\n\nBurn In Test Results:")
        
        #starting test status                
        self.info("Starting burn in testing ...\n")
        self.lf.write("Starting burn in testing ...\n")
        # use to store temperature information. 
        self.temp_readings = {}  # each key is the module with
        self.temp_limits = self.config.temp_limits
        for k in self.temp_limits.keys():
            self.temp_readings[k] = []
      
        #initialize test parameters
        (min_chn, max_chn, odd_chn, even_chn, pwr, clpwr, cltxminpwr, cltxmaxpwr, losth, pminterval,
            rxpwr, rxmintol, rxmaxtol, clrxpwr, clrxmintol, clrxmaxtol, linetxmintol, linetxmaxtol) = self.config.uutParams
        uutid = self.uutDict[self.uutSnList[0]]["id"]
        totalHrs, interval = self.config.totalhrs
        numIter = self.config.numIter
        self.modTemps[uutid] = {}

        db_info = {}
        priorRun = self.db.currentRun
        i = 1
        lineSecondsInSyncTotal = 0
        clientSecondsInSyncTotal = 0
        
        while i <= (self.numCheckIter - 6):
            
            #wait time before reading
            if self.debugMode == 1:
                time.sleep(5) #debug mode
            elif self.passing == False:
                time.sleep(5) #speed up test if failing
            else:
                while(1):
                    time.sleep(60) #test mode
                    if ((time.time() - startTime)/60) >= (interval.value * i):
                        break
            
            #initial status
            tm = (time.time() - startTime)/60
            
            #read uut state
            clientberr = 0
            lineberr = 0
            
            self.resetState = True
            while((self.resetState == True) and (self.resetCount <= self.maxResets)): 
                try:
                    uut_client_sync = self.uut860.get_client_sync() 
                    self.info("mr 0x3e802 = %s" % uut_client_sync)
                    if uut_client_sync == '0':
                        uut_client_state = [0, 1, 0, 1, 0.0, 0, 0]
                        clientlostsync = 0
                        clientSecondsInSyncCurrent = int(time.time() - startTime)
                        clientSecondsOutOfSyncCurrent = 0
                        clientSecondsSinceReset = int(time.time() - startTime)
                        clientber = 0.0
                        clientPreFECBER = 0
                        clientberr = 0
                    else:
                        uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                        clientlostsync = int(uut_client_state[0])
                        clientSecondsInSyncCurrent = uut_client_state[1]
                        clientSecondsOutOfSyncCurrent = uut_client_state[2]
                        clientSecondsSinceReset = uut_client_state[3]
                        clientber = uut_client_state[4]
                        clientPreFECBER = uut_client_state[5]
                        clientberr = uut_client_state[6]
                except:
                    self.info("Got exception #2...")
                    uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                    clientlostsync = int(uut_client_state[0])
                    clientSecondsInSyncCurrent = uut_client_state[1]
                    clientSecondsOutOfSyncCurrent = uut_client_state[2]
                    clientSecondsSinceReset = uut_client_state[3]
                    clientber = uut_client_state[4]
                    clientPreFECBER = uut_client_state[5]
                    clientberr = uut_client_state[6]
                        
                #lost sync determination
                if (clientlostsync == 1):
                    self.resetState = self.uut860.get_4011_soft_reset_status()
                    if self.resetState == True:
                        self.info("UUT was reset.\n")
                        self.lf.write("\n\nUUT was reset.\n")
                        self.df.write("\n\nUUT was reset.\n")
                        self.db.msg += ("\n\nUUT was reset.\n")
                        time.sleep(30)
                        self.resetCount +=1
                        self.setup_uut()
                else:
                    self.resetState = False


            # dump the power readings
            txPwrReading = self.uutdsp.show_line_tx_pwr()                
            rxPwrReading = self.uutdsp.show_line_rx_pwr()
            clientOneTxPwrReading = self.uut860.show_client_tx_pwr(1)
            clientOneRxPwrReading = self.uut860.show_client_rx_pwr(1)
            clientTwoTxPwrReading = self.uut860.show_client_tx_pwr(2)
            clientTwoRxPwrReading = self.uut860.show_client_rx_pwr(2)
            clientThreeTxPwrReading = self.uut860.show_client_tx_pwr(3)
            clientThreeRxPwrReading = self.uut860.show_client_rx_pwr(3)
            clientFourTxPwrReading = self.uut860.show_client_tx_pwr(4)
            clientFourRxPwrReading = self.uut860.show_client_rx_pwr(4)    
            # dump the temperature readings
            #self.info("Dumping temperature sensor information.....") 
            tempReadings = self.uut860.get_raw_temps()
            if not self.uut860.check_temp_limits(tempReadings, self.temp_limits, self):
                self.passing = False
                self.error("Module Temperature check failed!")
            
            tempSummary = ""
            while (tempReadings != {}):
                sensorName, sensorReading = tempReadings.popitem()
                tempSummary = "%s  %s: %s degC" % (tempSummary, sensorName, sensorReading)
                if sensorName in self.temp_limits.keys():
                    self.temp_readings[sensorName].append(float(sensorReading))
            #self.info(self.temp_readings)
            self.modTemps[uutid] = self.temp_readings            
            # dump the alarms information
            #self.info("Dumping alarms information.....")
            #line_alarms = self.uut860.dump_line_alarms('Titan')
            #client_alarms = self.uut860.dump_client_alarms()

            # display tdc dispersion information
            tdc_disp = self.uutdsp.show_actual_dispersion()
            self.info("#### UUT TDC Dispersion: %s" % tdc_disp)
            self.lf.write("#### UUT TDC Dispersion: %s" % tdc_disp)

            #Status Information
            self.info("Iter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
            self.info("Iter: %d LineTxPwr: %.2f dBm  LineRxPwr %.2f dBm" % (i, txPwrReading, rxPwrReading))          
            self.info("Iter: %d Port1TxPwr: %.2f dBm  Port1RxPwr: %.2f dBm  Port2TxPwr: %.2f dBm  Port2RxPwr: %.2f dBm" % 
                (i, clientOneTxPwrReading, clientOneRxPwrReading, clientTwoTxPwrReading, clientTwoRxPwrReading))
            self.info("Iter: %d Port3TxPwr: %.2f dBm  Port3RxPwr: %.2f dBm  Port4TxPwr: %.2f dBm  Port4RxPwr: %.2f dBm" % 
                (i, clientThreeTxPwrReading, clientThreeRxPwrReading, clientFourTxPwrReading, clientFourRxPwrReading))
            self.lf.write("\n\nIter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
            self.lf.write("\n\nIter: %d LineTxPwr: %.2f dBm  LineRxPwr %.2f dBm\n" % (i, txPwrReading, rxPwrReading))          
            self.lf.write("\n\nIter: %d Port1TxPwr: %.2f dBm  Port1RxPwr: %.2f dBm  Port2TxPwr: %.2f dBm  Port2RxPwr: %.2f dBm\n" % 
                (i, clientOneTxPwrReading, clientOneRxPwrReading, clientTwoTxPwrReading, clientTwoRxPwrReading))
            self.lf.write("\n\nIter: %d Port3TxPwr: %.2f dBm  Port3RxPwr: %.2f dBm  Port4TxPwr: %.2f dBm  Port4RxPwr: %.2f dBm\n" % 
                (i, clientThreeTxPwrReading, clientThreeRxPwrReading, clientFourTxPwrReading, clientFourRxPwrReading)) 
            #self.info("Iter: %d Client Alarms: %s" % (i, client_alarms))
            #self.lf.write("\n\nIter: %d Client Alarms: %s\n" % (i, client_alarms))
            #self.info("Iter: %d Line Alarms: %s" % (i, line_alarms))
            #self.lf.write("\n\nIter: %d Line Alarms: %s\n" % (i, line_alarms))
            self.info("Iter: %d Temperature Sensor Readings: %s" % (i, tempSummary))
            self.lf.write("\n\nIter: %d Temperature Sensor Readings: %s\n" % (i, tempSummary))       
            
            #Database Information          
            self.db.msg += ("Iter: %d Time: %u min LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (i, tm, clientlostsync, clientSecondsInSyncCurrent, self.resetCount))          
                    
            db_info['lastUpdate'] = datetime.datetime.fromtimestamp(timelib.now())
            db_info['status'] = 2
            db_info['endTime'] = None
            db_info['currentRun'] = int(priorRun + (i/4))
            self._update_uut_db(db_info)
            
            #failure determination
            if (self.resetCount > self.maxResets):
                self.passing = False #uut was reset
                self.failed("UUT was reset more than %s times." % self.maxResets)
            if (clientlostsync == 1) and (self.resetState == False):
                self.passing = False #uut is out of sync
                self.failed("UUT was out of sync.")
                
            #check all powers
            if ((rxPwrReading < (txPwrReading + rxmintol)) or 
              (rxPwrReading > (txPwrReading + rxmaxtol)) or
              (txPwrReading < (pwr + linetxmintol)) or 
              (txPwrReading > (pwr + linetxmaxtol))):
                self.passing = False
                self.failed("Line side power is not within range.\n")
            
            #check all powers
            if ((clientOneRxPwrReading < (clientTwoTxPwrReading + clrxmintol)) or 
              (clientOneRxPwrReading > (clientTwoTxPwrReading + clrxmaxtol)) or 
              (clientTwoTxPwrReading < cltxminpwr) or 
              (clientTwoTxPwrReading > cltxmaxpwr)):
                self.passing = False
                self.failed("Client side power is not within range.\n")
            #check all powers
            if ((clientTwoRxPwrReading < (clientThreeTxPwrReading + clrxmintol)) or 
              (clientTwoRxPwrReading > (clientThreeTxPwrReading + clrxmaxtol))or 
              (clientThreeTxPwrReading < cltxminpwr) or 
              (clientThreeTxPwrReading > cltxmaxpwr)):
                self.passing = False
                self.failed("Client side power is not within range.\n")
            #check all powers
            if ((clientThreeRxPwrReading < (clientFourTxPwrReading + clrxmintol)) or 
              (clientThreeRxPwrReading > (clientFourTxPwrReading + clrxmaxtol))or 
              (clientFourTxPwrReading < cltxminpwr) or 
              (clientFourTxPwrReading > cltxmaxpwr)):
                self.passing = False
                self.failed("Client side power is not within range.\n")
            #check all powers
            if ((clientFourRxPwrReading < (clientOneTxPwrReading + clrxmintol)) or 
              (clientFourRxPwrReading > (clientOneTxPwrReading + clrxmaxtol))or 
              (clientOneTxPwrReading < cltxminpwr) or 
              (clientOneTxPwrReading > cltxmaxpwr)):
                self.passing = False
                self.failed("Client side power is not within range.\n")
 
            try:  
                uut_line_state = self.uut860.show_line_prbs()      
            except:
                self.diagnostic("Problem retrieving LINE PRBS...trying again in 30 seconds")
                time.sleep(30)
                try:
                    uut_line_state = self.uut860.show_line_prbs()      
                except:
                    self.diagnostic("2nd try failed...using default...")
                    uut_line_state = [1, 0, 0, 0, 0.0, 0, 0]


            linelostsync = int(uut_line_state[0])
            lineSecondsInSyncCurrent = uut_line_state[1]
            lineSecondsOutOfSyncCurrent = uut_line_state[2]
            lineSecondsSinceReset = uut_line_state[3]
            lineber = uut_line_state[4]
            linePreFECBER = uut_line_state[5]
            lineberr = uut_line_state[6]

            self.check_line_ber_limits(uut_line_state)

            if self.passing == False:
                break
                        # line side status check
            self.info("Resetting line prbs after 15 minutes...")
            self.uut860.reset_line_prbs()             
            #interval increment    
            i += 1
            
        #check itla
        self.check_itla()
        i += 6
        db_info['lastUpdate'] = datetime.datetime.fromtimestamp(timelib.now())
        db_info['status'] = 2
        db_info['endTime'] = None
        db_info['currentRun'] = int(priorRun + (i/4))
        self._update_uut_db(db_info)
        
        #record errors accumulated during the test
        self.burnInTestArgs[uutid].append((lineberr, clientberr))
        
        #pass/fail determination
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.flush
        if not self.passing:
            self.db.msg += "\n\nBurn In Test failed."
            db_info['status'] = -1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            self._update_uut_db(db_info)
            return self.failed("Burn In Test failed.", uutid)
        else:
            self.db.msg += "\n\nBurn In Test passed."
            db_info['status'] = 1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            self._update_uut_db(db_info)
            Diag.clean_up_logs(self.serialno, self.diag)
            return self.passed("Burn In Test passed.", uutid)
示例#21
0
文件: BurnIn.py 项目: pruan/TestDepot
    def initialize(self):
        
        #test status and parameters
        self.resetState = True
        self.resetCount = 0
        self.maxResets = self.config.maxresets
        self.passing = True
        self.abort = False
        self.debugMode = self.config.debugmode
        
        # reading initial UUT params
        (min_chn, max_chn, odd_chn, even_chn, pwr, clpwr, cltxminpwr, cltxmaxpwr, losth, pminterval,
            rxpwr, rxmintol, rxmaxtol, clrxpwr, clrxmintol, clrxmaxtol, linetxmintol, linetxmaxtol) = self.config.uutParams
        tdcType = self.config.tdcType
        self.linemaxberr = self.config.lineberrlimit
        self.clientmaxberr = self.config.clientberrlimit
        self.uut_type = int(self.config.uuttype)        
        self.tagNameList = self.config.tagNameList
        
        #initialize testbed
        tb = self.config.testbed
        
        #sql database
        self.burnInTestArgs = {}
        self.modTemps = {} 
          
        #data file
        pathname = self.get_pathname(self.config.dataFileName)
        self.df = file(pathname, "w")
        
        #log file
        self.lf = self.config.logfile
        
        # Making uut list
        from copy import copy
        self.uutDict = copy(self.config.uut_dict) #dict from stratatestrunner
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n"  %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        
        #Setting up the UUT test info
        for sn in self.uutSnList:    #only one UUT
            self.burnInTestArgs[self.uutDict[sn]["id"]] = []
            uut_slot = self.uutDict[sn]['slot']
            self.SLOT = int(uut_slot)
            self.serialno = sn
            
        #Setting up the UUT
        self.uut_ser_dict = {}
        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s" % slot
            UUT_ser_mike = "UUT_slot%s_mike" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            self.uut860 = self.uutDict[sn]['obj']
            self.uutdsp = self.uutDict[sn]['mike']
            self.dbg_obj =  self.uutDict[sn]['mike_debug'] 
            self.uut_ser_dict[UUT_ser] = self.uut860
            self.uut_ser_dict[UUT_ser_mike] = self.uutdsp
        #create logging 
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)
        self.info("Basepath: %s" % basepath)
        self.diag = {}

        # get a logger for the Mike-Debug shell
        sn_mike_debug = "%s_mike_debug" % sn
        dbg_logger, mike_debug_log_name  = Diag.getLogger(basepath, sn_mike_debug)
        self.diagnostic("Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
        self.diag[sn_mike_debug] = Diag.DiagResponse()
        self.diag[sn_mike_debug].log = dbg_logger
        self.diag[sn_mike_debug].dsp = self.dbg_obj
        self.diag[sn_mike_debug].logname = mike_debug_log_name 
        self.info("Starting mike-debug shell logging...")
        t_id  = thread.start_new_thread(Diag.dbgLogger,
            (self.diag[sn_mike_debug].log, self.dbg_obj))
        self.diag[sn_mike_debug].t_id = t_id
        self.info("Debug log started.....")
        
        # cal tag checks
        for tag_name in self.tagNameList:
            xml_obj, upload_status = self.uutdsp.read_tag_from_mike(tag_name)
            if not upload_status:
                self.error("Upload failed for tag %s" % tag_name)
                self.passing = False
                uutid = self.uutDict[self.uutSnList[0]]["id"]
                return self.failed("Tags are missing.", uutid)
            else:
                self.info("Tag: %s" % tag_name)
                self.info("%s" % xml_obj.__str__())
                xml_file_name = "%s.xml" % tag_name
                self.save_object(xml_obj, xml_file_name)

        #verify the tdc type
        uut_tdc_type = self.uutdsp.get_tdc_type()
        self.info("UUT TDC Type: %s" % (int(uut_tdc_type),))
        if (int(tdcType) != int(uut_tdc_type)):
            self.info("Part number from the command line does not match the UUT TDC Type of %s." % (uut_tdc_type,))
            while(1):
                status = upper(self.user_input("\nDo you want to (c)ontinue or (a)bort the BurnIn[c/a]?:"))
                if status == "A":
                    raise TestSuiteAbort, "Suite aborted."
                    break
                elif status == "C":
                    self.info("Operator selected to continue the test.\n")
                    break

        # make the DB connection.
        card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
        i = 0
        while i < len(card_conn_list):
            if card_conn_list[i].tb == tb.name:
                card_conn = card_conn_list[i]
                self.db = card_conn
                break
            else:
                i += 1
        if (i >= len(card_conn_list)):
            #if environment variable IDTYPE == UUID, then use UUID for database entry id, else implicit auto-increment integer is used.
            if (("IDTYPE" in os.environ.keys()) and (os.environ["IDTYPE"]=="UUID")):
                database.TitanBurnIn(
                    id = (commands.getoutput('uuidgen -t')).strip(),
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )
            else:
                database.TitanBurnIn(
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )

            card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
            i = 0
            while i < len(card_conn_list):
                if card_conn_list[i].tb == tb.name:
                    card_conn = card_conn_list[i]
                    self.db = card_conn
                    break
                else:
                    i += 1    
        db_info = {}
        db_info['sn'] = sn
        db_info['startTime'] = datetime.datetime.fromtimestamp(timelib.now())
        db_info['endTime'] = None
        db_info['status'] = 2
        self._update_uut_db(db_info)        
       
        # keep looping until a valid response is given
        while (1):
            status = upper(self.user_input("\nDo you want to start or continue the BurnIn[s/c]?:"))
            if status == "S" or status == "C":
                break

        totalHrs, interval = self.config.totalhrs
        if status == "S":
            # if start a new burnin session, ask for how long to run range
            # (1-48) hours
            self.db.msg = ''  # clear the old meassages.
            self.db.msg += "Start Burn In Test for Line Card %s in Slot:%s ...\n" % (sn, self.SLOT)
            while (1):
                totalHrs = int(self.user_input("\nHow long do you want to run BurnIn test?[2-48]?:"))
                if totalHrs > 1 and totalHrs < 49:
                    if totalHrs != 48:
                        # prompt for password.
                        password_ok = self.check_password()
                        if not password_ok:
                            return self.abort("Test Engineering password not verified!")
                    totalHrsToRun = totalHrs
                    totalHrs = PQ(totalHrs, "h")
                    break
            self.numCheckIter = int(totalHrs/interval)
            self.info("Test to run for %s" %(totalHrs,))
            self.lf.write("Test to run for %s" %(totalHrs,))
            self.db.msg += "Test to run for %s\n" % (totalHrs,)
            self.db.currentRun = 0
            db_info['runs'] = totalHrsToRun
            self._update_uut_db(db_info)
        else:
            synctime = self.db.currentRun
            totalHrsToRun = self.db.runs
            totalHrs = PQ(totalHrsToRun, "h")
            syncTimeInHrs = PQ(synctime, "h")
            self.info("Test already ran for %s" %(syncTimeInHrs,))
            self.lf.write("\n\nTest already ran for %s" %(syncTimeInHrs,))
            previousData = self.db.msg
            for line in previousData.split("\n"):
                if line.find("Initial") >= 0:
                    self.info("Previous Run: %s" % line)
                    self.lf.write("\n\nPrevious Run: %s\n" % line)
                else:
                    if line.find("Iter") >= 0:
                        self.info("Previous Run: %s" % line)
                        self.lf.write("\n\nPrevious Run: %s\n" % line)
            
            if syncTimeInHrs > totalHrs:
                self.numCheckIter = 1
            else:
                timeLeftInHrs = PQ(round(totalHrs - syncTimeInHrs), "h")
                self.numCheckIter = int(timeLeftInHrs/interval)
                if round(totalHrs - syncTimeInHrs) <= 0:
                    self.numCheckIter = int(1)
                self.info("Test to run for %s more" %(timeLeftInHrs,))
                self.lf.write("\n\nTest to run for %s more" %(timeLeftInHrs,))
                self.db.msg += "\n\nTest to run for %s more \n" % (timeLeftInHrs,)
                db_info['runs'] = totalHrsToRun
                self._update_uut_db(db_info)
        
        #getting initial UUT state
        startTime = time.time()    
        while((self.resetState == True) and (self.resetCount <= self.maxResets)):  
            
            #set up uut
            self.setup_uut()
            # check uut initial state
            try:
                uut_client_sync = self.uut860.get_client_sync() 
                self.info("mr 0x3e802 = %s" % uut_client_sync)
                if uut_client_sync == '0':
                    uut_client_state = [0, 1, 0, 1, 0.0, 0, 0]
                    clientlostsync = 0
                    clientSecondsInSyncCurrent = int(time.time() - startTime)
                    clientSecondsOutOfSyncCurrent = 0
                    clientSecondsSinceReset = int(time.time() - startTime)
                    clientber = 0.0
                    clientPreFECBER = 0
                    clientberr = 0
                else:
                    uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                    clientlostsync = int(uut_client_state[0])
                    clientSecondsInSyncCurrent = uut_client_state[1]
                    clientSecondsOutOfSyncCurrent = uut_client_state[2]
                    clientSecondsSinceReset = uut_client_state[3]
                    clientber = uut_client_state[4]
                    clientPreFECBER = uut_client_state[5]
                    clientberr = uut_client_state[6]
            except:
                self.info("Got exception!")
                uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                clientlostsync = int(uut_client_state[0])
                clientSecondsInSyncCurrent = uut_client_state[1]
                clientSecondsOutOfSyncCurrent = uut_client_state[2]
                clientSecondsSinceReset = uut_client_state[3]
                clientber = uut_client_state[4]
                clientPreFECBER = uut_client_state[5]
                clientberr = uut_client_state[6]

            #lost sync determination
            if (clientlostsync == 1):
                self.resetState = self.uut860.get_4011_soft_reset_status()
                if self.resetState == True:
                    self.info("UUT was reset.\n")
                    self.lf.write("\n\nUUT was reset.\n")
                    self.df.write("\n\nUUT was reset.\n")
                    self.db.msg += ("\n\nUUT was reset.\n")
                    time.sleep(30)
                    self.resetCount +=1
            else:
                self.resetState = False
        
        #failure determination
        if (self.resetCount > self.maxResets):
            self.passing = False #uut was reset
            self.failed("UUT was reset more than %s times." % self.maxResets)
        if (clientlostsync == 1) and (self.resetState == False):
            self.passing = False #uut is out of sync
            self.failed("UUT was out of sync.")        
        
        #initial status output
        self.info("Initial: LostSync: %s SecondsInSync: %s ResetCount: %s" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.lf.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.df.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.db.msg += ("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))    
  
        #update database
        self._update_uut_db(db_info)
示例#22
0
    def test_method(self):
    
        #log header setup
        startTime = time.time()
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.write("\n\nRubiconCheck Test Results:")
        
        #starting test status                
        self.info("Starting RubiconCheck testing ...\n")
        self.lf.write("Starting RubiconCheck testing ...\n")
      
        #initialize test parameters
        (min_chn, max_chn, odd_chn, even_chn, pwr, clpwr, cltxminpwr, cltxmaxpwr, losth, pminterval,
            rxpwr, rxmintol, rxmaxtol, clrxpwr, clrxmintol, clrxmaxtol, linetxmintol, linetxmaxtol) = self.config.uutParams
        uutid = self.uutDict[self.uutSnList[0]]["id"]
        totalHrs, interval = self.config.totalhrs
        numIter = self.config.numIter
        serno = self.config.serno
        db_info = {}
        priorRun = 0 #self.db.currentRun
        i = 1
        lineSecondsInSyncTotal = 0
        clientSecondsInSyncTotal = 0
        
        while i <= self.numCheckIter:
            
            #wait time before reading
            if self.debugMode == 1:
                time.sleep(5) #debug mode
            elif self.passing == False:
                time.sleep(5) #speed up test if failing
            else:
                while(1):
                    time.sleep(60) #test mode
                    if ((time.time() - startTime)/60) >= (interval.value * i):
                        break
            
            #initial status
            tm = (time.time() - startTime)/60
            
            #read uut state
            clientberr = 0
            lineberr = 0
            
            self.resetState = True
            lber = self.uut860.BER
            if lber != PQ(0.0,'BER'):
                self.error("Line BER not 0.0!")
                self.passing = False
            
            cberr, client_status = self.client_analyzer.get_ber("10gbelan")
            status_10gbelan, failed_params = self.check_10gbelan_status(cberr, client_status)
                                
            if not status_10gbelan:
                self.error("Client_Status: %s, Failed on: %s" % (status_10gbelan, failed_params))
                self.passing = False
            else:
                self.info("No client error detected")
            
            self.info("iteration: %s, Line BER: %s, Client BER: %s" % (i,
                lber, cberr))

            db_info['lastUpdate'] = datetime.datetime.fromtimestamp(timelib.now())
            db_info['status'] = 2
            db_info['endTime'] = None
            db_info['currentRun'] = int(priorRun + (i/4))
            try:
                dbuut = list(database.UUTBuild.select(database.UUTBuild.q.UutSN==serno))[0]
                self.info("%s" % dbutt)
            except:
                pass

            # dump the alarms information
            self.info("Dumping alarms information.....")
            line_alarms = self.uut860.dump_line_alarms('Titan')
            client_alarms = self.uut860.dump_client_alarms()

            self.info("Iter: %d Client Alarms: %s" % (i, client_alarms))
            self.info("Iter: %d Line Alarms: %s" % (i, line_alarms))
            
            if self.passing == False:
                break
                             
            #interval increment    
            i += 1

        #record errors accumulated during the test
        self.burnInTestArgs[uutid].append((lineberr, clientberr))
        
        #pass/fail determination
        self.df.write( "\nTime Stamp: %s" 
                        % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
        self.df.flush
        if not self.passing:
            db_info['status'] = -1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            return self.failed("RubiconCheck Test failed.")
        else:
            db_info['status'] = 1
            db_info['endTime'] = datetime.datetime.fromtimestamp(timelib.now())
            return self.passed("RubiconCheck Test passed.")
示例#23
0
    def test_method(self):
        errorCount = 0
        card_type = None
        cf = self.config
        login_info = self.config.login_info
        ftp_addr = self.config.ftp_addr
        spn_info = database.get_spn_info(self.config)
        # the following dictionary is ONLY for Ciena rebranding.
        self.data_args = {}
        self.data_args["process_id"] = ""
        self.data_args["serial_number"] = ""
        self.data_args["operator"] = "SLCOperator"
        self.data_args["tdate"] = time.strftime("%Y-%m-%d")
        self.data_args["start_time"] = self.timestamp(self.starttime)
        self.data_args["stop_time"] = ""
        self.data_args["comments"] = ""
        self.data_args["approved"] = "Approved"
        self.data_args["ciena_pn"] = spn_info.copr
        self.data_args["ciena_clei"] = spn_info.clei
        self.data_args["spn"] = self.config.ser_no
        self.data_args["test_status"] = "PASS"

        rebranding = database.BrandingSnLinkage
        self.info("Retrieved SPN info...%s" % spn_info)
        self.info("Please select the customer: ")
        ui = self.config.userinterface
        # look into the BrandingSnLinkage table to find a match to ser_no
        # given
        ser_no = self.config.ser_no
        # now get and display customer code, prompt user to select the type of customer.
        customers = database.get_customers(self.config)
        customer_list, customer_dict = build_customer_list(customers)
        customer = ui.choose(customer_list)

        if customer != "Ciena":
            self.data_args["operator"] = "OpnextOperator"
            self.data_args["serial_number"] = self.config.ser_no

        db_conn = database.check_branding_tbl(cf, ser_no)
        if (db_conn.uploaded) and (customer == "Ciena"):
            self.info("Upload not needed")
            pass
        else:
            customer_sn = db_conn.customer_sn
            customer_id = db_conn.customer_id

            if customer == "Ciena":
                self.data_args["serial_number"] = db_conn.customer_sn
                self.info("Updating Branding databse...")
                self.endtime = timelib.now()
                self.data_args["stop_time"] = self.timestamp(timelib.now())
                upload_req = CienaSoapUpload()  # CienaSoap()
                self.info("Logging Into Ciena's system...")
                login_res = upload_req.Login
                self.info("Getting Process ID...")
                res_id = upload_req.GetAvailableProcesses
                process_id = get_single_xml_value(res_id, "ID")
                self.data_args["process_id"] = process_id
                data_args = self.data_args
                self.diagnostic("DATA posted to Ciena's website: %s" % data_args)
                # TestDataWithTheSystem
                test_res1 = upload_req.SaveDataToTheSystem(
                    process_id=data_args["process_id"],
                    serial_number=data_args["serial_number"],
                    operator=data_args["operator"],
                    tdate=data_args["tdate"],
                    start_time=data_args["start_time"],
                    stop_time=data_args["stop_time"],
                    comments=data_args["comments"],
                    approved=data_args["approved"],
                    ciena_pn=data_args["ciena_pn"],
                    ciena_clei=data_args["ciena_clei"],
                    spn=data_args["spn"],
                    test_status=data_args["test_status"],
                )
            else:  # generic template
                # for generic customer, we write out the results to a xml
                # template structure.
                data_args = self.data_args
                data_args["cust_id"] = customer_id
                del data_args["ciena_pn"]
                data_args["pn"] = self.config.part_no
                data_args["clei"] = data_args["ciena_clei"]
                data_args["copr"] = spn_info.copr
                del data_args["ciena_clei"]
                del data_args["tdate"]
                t = GenericResultsTemplate()
                results_xml = t.results_data_tpl % (
                    data_args["cust_id"],
                    data_args["serial_number"],
                    data_args["operator"],
                    data_args["start_time"],
                    data_args["stop_time"],
                    data_args["test_status"],
                    data_args["approved"],
                    data_args["clei"],
                    data_args["copr"],
                    data_args["pn"],
                )

                # save the xml result to a directory
                filename = self.save_object(results_xml, "results.xml")
                f_obj = file(filename, "r")
                user_info = login_info[customer]
                ftp_path = upload_via_ericsson_ftp(f_obj, customer_sn, user_info)
                self.info("Result XML stored in '%s'" % ftp_path)
            uploaded_status = 1
            uploaded_time = datetime.datetime.fromtimestamp(timelib.now())
            database.update_branding_tbl(
                self.config,
                self.config.ser_no,
                self.config.part_no,
                customer_sn,
                customer_id,
                uploaded_status,
                uploaded_time,
            )

        return self.passed("DataUpload test passed.")
示例#24
0
    def run_module(self, mod):
        """run_module(module)
    Runs the module. The parameter should be a module object, but if it is a
    string then a module object with that name will be imported. 
    """
        cf = self._config
        ui = self._config.userinterface
        # user to choose one.
        user_name = commands.getoutput('whoami')
        output = commands.getoutput("groups %s" % user_name)
        user_group = output.split(':')[1].strip()
        cf.flags.USERGROUP = user_group
        if cf.flags.USERGROUP.startswith('opsusers'):
            ui.info("network is in '%s'" % cf.baseurl)
            if 'stratalight' in cf.baseurl:    
                run_modes = ['MFG', 'NPI', 'RMA', 'GRR']
            else:
                run_modes = ['MFG', 'RMA']
        else:
            run_modes = ['MFG', 'NPI', 'RMA', 'DEV', 'DEBUG', 'ENG', 'GRR']

        if cf.has_key('mode'):
            mode = cf.mode.upper()
            if mode not in run_modes:
                ui.error("Run mode specified is not predefined, please choose one of the follow")
                cf.run_mode = ui.choose(run_modes)
            else:
                cf.run_mode = mode
        else:
            # don't default to anything.  List out the options to the user.
            ui.error("Run mode missing, please choose one of the following")
            cf.run_mode = ui.choose(run_modes)

        while cf.run_mode is None:
            cf.run_mode = ui.choose(run_modes)

        # XXX: hardcode it for now.
        if type(mod) is str:
            # get the .pyc module specified.
            mod = self.get_module(mod)

        # always true...assign properties module_ID and multiModule.
        if mod:  
            try:
                version_full_name = file(os.path.join(os.environ["STRATATEST_HOME"], "etc", "VERSION")).read()
                # remove trailing space and Manufacturing_Test_ from the full
                # name
                cf.module_ID = version_full_name.strip()
            except AttributeError:
                cf.module_ID = "<unknown>"
            
            try:
                cf.multiModule = mod._MULTI
            except AttributeError:
                cf.multiModule = False
    
            try:
                cf.upgrade   = mod._UPGRADE
            except AttributeError:
                cf.upgrade = False

            try:
                cf._IGNORE_SN_CHECK = mod._IGNORE_SN_CHECK
            except AttributeError:
                cf._IGNORE_SN_CHECK = False

            try:
                cf._FORCE_CHECK_PERMISSION = mod._FORCE_CHECK_PERMISSION
            except AttributeError:
                cf._FORCE_CHECK_PERMISSION = False

            cf.reportbasename = mod.__name__.replace(".", "_")
            cf.logbasename = "%s.log" % (cf.reportbasename,)
            # merge any test-module specific config files.
            modconf = os.path.join(os.path.dirname(mod.__file__) , "%s.conf" % (mod.__name__.split(".")[-1],))
            cf.conf_dir = os.path.dirname(modconf)
            cf.mergefile(modconf)
            # the "resultsdir" is where you would place any resulting data files.
            starttime = timelib.now()
            cf.results_year_month_dir = os.path.join(
                cf.get("resultsdirbase", "/var/tmp"),
                "%s" % (timelib.strftime("%Y%m")),
            )
            # first make the YYYYMM top directory
            try:
                os.mkdir(cf.results_year_month_dir)
                os.chmod(cf.results_year_month_dir, 0777)
            except OSError, errno:
                if errno[0] == EEXIST:
                    pass
                else:
                    raise

            if cf.multiModule:
                import random
                rand_num = random.randint(0, 5000)
            else:
                rand_num = cf.ser_no
            # now make the actual test directory
            cf.resultsdir = os.path.join(
                 cf.results_year_month_dir,
                 "%s-%s-%s" % (cf.reportbasename, rand_num, timelib.strftime("%Y%m%d%H%M%S", timelib.localtime(starttime)))
            )            
            try:
                os.mkdir(cf.resultsdir)
            except OSError, errno:
                if errno[0] == EEXIST:
                    pass
                else:
                    raise
示例#25
0
 def _tp(self, set, starttime):
     elapsed = now() - starttime
     self.assert_approximately_equal(elapsed, set, 1)
     self.info("%.2f elapsed for %s sec delay" % (elapsed, set))
示例#26
0
文件: qatest.py 项目: pruan/TestDepot
	def datapoint(self, val):
		"""Adds data to the list of collected data.  A time stamp is added."""
		self.datapoints.extend((timelib.now(), val))
示例#27
0
 def _tp(self, set, starttime):
     elapsed = now() - starttime
     self.assert_approximately_equal(elapsed, set, 1)
     self.info("%.2f elapsed for %s sec delay" % (elapsed, set))
示例#28
0
    def test_method(self):
        errorCount = 0
        card_type = None
        card_slot = self.config.default_card_slot
        cf = self.config
        expected_card_type = self.config.default_card_type
        cardInfoTagList = self.config.cardInfoTagList
        if expected_card_type != 'SC_MFG':
            cardInfoObjList = [CARD_INFO]
        else:
            cardInfoObjList = [SC_MFG]
        spn_info = database.get_spn_info(self.config)
        if spn_info is None:
            raise TestSuiteAbort, "No entry for part_no '%s' found ins SPN database!" % self.config.part_no
        # the following dictionary is ONLY for Ciena rebranding.
        self.data_args = {}
        self.data_args['process_id']= ''
        self.data_args['serial_number'] = ''
        self.data_args['operator'] = 'SLCOperator'
        self.data_args['tdate'] = time.strftime("%Y-%m-%d")
        self.data_args['start_time'] = self.timestamp(self.starttime)
        self.data_args['stop_time'] = ''
        self.data_args['comments'] = ''
        self.data_args['approved'] = 'Approved'
        self.data_args['ciena_pn'] = spn_info.copr
        self.data_args['ciena_clei'] = spn_info.clei
        self.data_args['spn'] = self.config.ser_no
        self.data_args['test_status'] = 'PASS'
        

        self.info("Retrieved SPN info...%s" %  spn_info)
        self.info("Please select the customer: ")
        ui = self.config.userinterface
        # now get and display customer code, prompt user to select the type of customer.
        customers = database.get_customers(self.config)
        customer_list, customer_dict = build_customer_list(customers)
        customer = ui.choose(customer_list)

        # depending of the customer, we get the serial number differently
        customer_sn = get_sn_by_customer_id(self, spn_info, customer)
        if customer_sn:
            setattr(spn_info, 'sn', customer_sn)
            self.data_args['serial_number'] = customer_sn
        else:
            if customer == 'Ciena':
                raise TestSuiteAbort, "Unable to retrieve serial number from Ciena webservice!"
            else:
                # set the customer_sn same as given
                customer_sn = self.config.ser_no
            #customer_sn = ui.user_input("Please enter Customer ReBranding serial number: ")
            #setattr(spn_info, 'sn', customer_sn)
        
        if spn_info is None:
            if self.config.has_key('sopr'):
                self.failed("Unable to find match for sopr '%s' in SPN database" % cf.sopr)
            else:
                self.failed("Unable to find match for pn '%s' in SPN database" % cf.part_no)
            errorCount += 1
        else:
            #self.Zircon.bp_clear()   # clear buffer
            required_fields = self.config.required_fields
            if self.config.flags.IGNORE:
                required_fields = []  # ignore required_fields
                self.diagnostic("Warning: required fields from SPN are being ignored!")
                errorCount += 1
            spn_card_type = spn_info.card_type
            if spn_card_type.strip() != expected_card_type.strip():
                return self.error("Card type mismatch, expected: %s, got %s" % (expected_card_type, spn_card_type))
            else:
                card_type = expected_card_type

            for field in required_fields:
                val = getattr(spn_info, field)
                if val is None:
                    return self.error("Required field '%s' is empty in SPN databse, please correct it first!" % field)
            if card_type != 'SC_MFG':
                res = self.Zircon.bp_start(card_type, card_slot)
                if not res:
                    errorCount += 1
                    self.error("ERROR: problem with starting bp")
                    self.diagnostic(res)

            for obj, tag in zip(cardInfoObjList, cardInfoTagList):
                tagXf = obj()
                # display the info that will be stored into the EEPROM.
                # prompt if user accepts it or not.  If not, then display each in
                # turn
                cardInfoXmlTag = self.display_card_info(tag, tagXf, spn_info, required_fields)
                while 1:
                    ans = upper(self.user_input("Do you accept these values [y/n]:"))
                    if ans == 'N':
                        cardInfoXmlTag = self.enter_card_info_tag(tag, tagXf, spn_info, required_fields)
                        break
                    elif ans == 'Y':
                        break
                    else:
                        pass
            self.info("Writing data into EEPROM, please wait...")
            if card_type != 'SC_MFG':
                self.info("Clearing buffer...")
                self.Zircon.bp_clear()   # clear buffer
                self.Zircon.bp_data(cardInfoXmlTag) # write data
            else:
                self.Zircon.download(cardInfoXmlTag, True) # write data
                
            self.info("Verifying EEPROM contents...")
            if card_type != 'SC_MFG':
                res = self.Zircon.upload_card_info(card_type, card_slot)
            else:
                res = self.Zircon.upload_sc_mfg()

            self.info(res)
            rv = cmp_xml_tag(tagXf, res)
            # output the CARD_INFO XML tag to a file.
            self.save_object(res, self.config.MfgTagFileName)

            if rv:
                self.failed("Failed on verify on tag '%s'" % rv)
                errorCount += 1
            else:
                self.passed("EEPROM Contents verified successfully!")
            # XXX: do a final comparison agaist SPN database.  Fail test if
            # tagXf does not compare against required_fileds
            cmp_res = self.cmp_tag_vs_spn(tagXf, spn_info, required_fields)
            if not cmp_res:
                errorCount += 1
                self.failed("Data in EEPROM does not match SPN...")
        uploaded_status = 0
        if errorCount:
            return self.failed("ReBranding test failed.")
        else:
            self.info("Updating Branding databse...")
            self.endtime = timelib.now()
            customer_id = customer_dict[customer]
            utime = timelib.now()
            uploaded_time = datetime.datetime.fromtimestamp(utime)
##            if customer == 'Ciena':
##                self.data_args['stop_time'] = self.timestamp(timelib.now())
##                upload_req = CienaSoapUpload()#CienaSoap()
##                self.info("Logging Into Ciena's system...")
##                login_res = upload_req.Login
##                self.info("Getting Process ID...")
##                res_id = upload_req.GetAvailableProcesses
##                process_id = get_single_xml_value(res_id, 'ID')
##                self.data_args['process_id'] = process_id
##                data_args = self.data_args
##                self.diagnostic("DATA posted to Ciena's website: %s" % data_args)
##                test_res1 = upload_req.TestDataWithTheSystem(process_id=data_args['process_id'],
##                                                             serial_number=data_args['serial_number'],
##                                                             operator = data_args['operator'],
##                                                             tdate = data_args['tdate'],
##                                                             start_time = data_args['start_time'],
##                                                             stop_time = data_args['stop_time'],
##                                                             comments = data_args['comments'],
##                                                             approved = data_args['approved'],
##                                                             ciena_pn = data_args['ciena_pn'],
##                                                             ciena_clei = data_args['ciena_clei'],
##                                                             spn = data_args['spn'],
##                                                             test_status = data_args['test_status'],
##                                                             )                

        database.update_branding_tbl(self.config, self.config.ser_no,
                self.config.part_no, customer_sn,
                customer_id, uploaded_status, uploaded_time)
        
        self.diagnostic("Please remember to print out the label for %s" % customer_sn)
        return self.passed("ReBranding test passed.")
示例#29
0
 def _sleeptest(t):
     start = now()
     self.info("sleeping %s seconds" % (t,))
     self.sched.sleep(t)
     elapsed = now() - start
     self.assert_approximately_equal(elapsed, t, 1, "should have slept %s secs., actual %s secs." % (t, elapsed))
示例#30
0
    def test_method(self):

        # set things up first
        errorCount = 0
        tdcCalDataPath = self.config.tdcCalDataPath
        self.tdcCalXml = TDC_CAL()
        self.tdcSwitchXml = TDC_SWITCH_CAL()


        # dave 3/28/07
        # precheck

        try:
            tagName  = "TDC_SWITCH_MFG"
            attrName = "sn"
            res = self.accessTag(tagName, attrName)

        except (globalExceptionTagAttrBlank):
            return self.failed("Cannot proceed : %s->%s is blank" % (tagName, attrName))

        if (res):
            self.TdcHasSwitch = True
        else:
            self.TdcHasSwitch = False
        

        try:
            tagName  = "TDC_MFG"
            attrName = "sn"
            res = self.accessTag(tagName, attrName)

        except (globalExceptionTagAttrBlank):
            return self.failed("Cannot proceed: %s->%s is blank" % (tagName, attrName))
            
        if (res):
            sn = res
        else:
            return self.failed("Cannot proceed - unable to retrieve the sn of FBG")


        self.info("TDC_MFG tag provided serial number is %s" % (sn))

        snFileName = self.config.tdcFile_prefix + sn + self.config.tdFile_ext
        
        file_name = os.path.join(tdcCalDataPath, snFileName)

        self.fileNameForDb = file_name

        print "debug filename -> ", file_name
        
        if not os.path.exists(file_name):
            # prompt user for complete path of the source file
            while 1:
                self.info("ERROR: No file matching '%s' not found!" % file_name)
                file_name = self.user_input("\nPlease enter the complete file name of the calibration data file:")
                if os.path.exists(file_name):
                    break

        # Parse Teraxion Calibration Data File
        # process csv file and generate XML object
        self.gen_cal_data_from_file(file_name, sn)

        #print "%s" % self.tdcCalXml
        #return self.passed()

        # dave 3/28/07 - no Tap in/out with G+
        # now, begin calibration of TDC
        # self.genTapCalData()

        #self.info("TDC_CAL XML document: \n %s" % self.tdcCalXml)
        # store the XML data into EEPROM
        self.save_object(self.tdcCalXml, self.config.tdcCalFileName)

        self.info("Wait, writing data to the EEPROM.\n")
        download_starttime = timelib.now()
        self.info("DOWNLOAD STARTTIME: %s" % self.timestamp(download_starttime))

        res = self.UUT.download(self.tdcCalXml)

        download_endtime = timelib.now()
        self.info("DOWNLOAD ENDTIME: %s" % self.timestamp(download_endtime))
        minutes, seconds = divmod(download_endtime - download_starttime, 60.0)
        hours, minutes = divmod(minutes, 60.0)
        self.info("Time elapsed: %02.0f:%02.0f:%02.2f" % (hours, minutes, seconds))

        print "\n\ndebug uploading TDC_CAL"
        res = self.UUT.upload("TDC_CAL")

        print "debug upload res -> %s" % (res)


        if errorCount:
            return self.failed("ERROR: FBG_Cal test failed.")
        else:
            self.info("Power Cycle TDC to activate changes in EEPROM...")
            #slot = int(self.config.slot)
            #self.info("Powering off slot %s" % slot)
            #self.SHELF.power_off_slots(slot, slot)
            #self.info("Powering on slot %s" % slot)
            #self.SHELF.power_on_slots(slot, slot)
            return self.passed("FBG_Cal test passed and datafile stored at %s." % file_name)
示例#31
0
 except AssertionError, errval:
     rv = self.failed("failed assertion: %s" % (errval,))
 except TestSuiteAbort:
     ex, val, tb = sys.exc_info()
     if self._debug:
         debugger.post_mortem(ex, val, tb)
         tb = None
     rv = self.incomplete("%s: ### Abort Exception occured! (%s: %s)" % (self.test_name, ex, val))
     raise # pass this one up to suite
 except:
     ex, val, tb = sys.exc_info()
     if self._debug:
         debugger.post_mortem(ex, val, tb)
         tb = None
     rv = self.incomplete("%s: Exception occured! (%s: %s)" % (self.test_name, ex, val))
 self.endtime = timelib.now()
 minutes, seconds = divmod(self.endtime - teststarttime, 60.0)
 hours, minutes = divmod(minutes, 60.0)
 self.info("Time elapsed: %02.0f:%02.0f:%02.2f" % (hours, minutes, seconds))
 rv = self._finalize(rv)
 # if not specified in command line, then record the result by default
 if cf.flags.NORECORD:
     user_group = cf.flags.USERGROUP
     
     if user_group == 'users' or user_group == 'opsusers':
         self.error("User ('%s') does not have NORECORD Flag privilage!" % self.config.user)
         if cf.test_name == 'OvenControl':
             self.info("Skip recording because test is '%s'" % cf.test_name)
         else:
             self._record_results()
             self.info("Results written to SQL DB %s ..." % cf.DBURI)