コード例 #1
0
    def testErrorlog(self):
        """
        This test validates if watchMswErrors() works fine.

        Instantiating the class will create the files.
        Then add a newline to the msw error log file.
        Now, watchMswErrors() should detect the new addition

        """
        # instantiate the class
        myMswInfo = msw.MSWInfo('mymsw')
        errorWatch = MswErrorWatch(myMswInfo)

        # Put the content in errorlog file at MSW
        message = "MswErrorWatch: dummyline to test Error log feature"
        mswcmd = "echo %s > %s" % (message, errorWatch.mswlogpath)
        errorWatch.mymsw.ssh.sendline(mswcmd)

        #creating dummy result
        myresult = Result(Result.TEST, "DUMMY 1", annotations={})

        # find error log difference
        errorWatch.watchMswErrors(myresult, False)

        # Assertions
        self.assertEqual(myresult.get('MSW fault'), 'MSW reported error')
コード例 #2
0
ファイル: control.py プロジェクト: AkankshaGovil/Automation
 def SetUp(self, context, result):
     """
     Create an object of class msw.MSWInfo to contain MSW state 
     information, and place it in the test context.
     """
     context['bkupinfo'] = msw.MSWInfo(self.bkupmsw)
     context['userpcapfilter'] = self.userpcapfilter
コード例 #3
0
    def __init__(self):
        """
        Create resource list for watching.
        Create null lists for holding the snapshot data at
        a later point of time.
        """
        # Connect to primary MSW
        self.primaryMsw = msw.MSWInfo('mymsw')

        # bkup MSW might be there or may not be there!!
        try:
            self.backupMsw  = msw.MSWInfo('bkupmsw')
        except:
            self.bkupexists = False
        else:
            self.bkupexists = True

        # Connect to logging started earlier
        self.log = logging.getLogger('nextestlog')

        # Create instances of all resouces and put them in resourceList
        self.resourceList = []
        self.resourceList.append(VportsResource('/tmp/'))
        self.resourceList.append(CallcacheResource('/usr/local/nextone/bin/'))
        
        # Information log
        self.log.info("ResourceWatch: Resource list created")

        # Create a null preconditionList
        self.precampaignList = []
        
        # Create a null postconditionList
        self.postcampaignList = []

        # Create null lists for bkup MSW
        if self.bkupexists:
            self.bkupPrecampaignList  =[]
            self.bkupPostcampaignList =[]
コード例 #4
0
    def testCallCache(self):
        """
        testCallCache tests the snapshot capability of CallcacheResource
        and the result format of the 'cli call cache' command
        """
        myserver = msw.MSWInfo('mymsw')
        # instantiate the class
        callObject  = CallcacheResource('/usr/local/nextone/bin/')

        # get call cache snapshot
        callDict = callObject.getSnapshot(ResourceTest.myserver)

        # Assertions
        self.assertNotEqual(callDict['active calls'], None)
        self.assertNotEqual(callDict['call legs'], None)
コード例 #5
0
    def testVports(self):
        """
        testVports tests the snapshot capability of VportsResource
        and the result format of the 'cli lstat' command
        """
        myserver = msw.MSWInfo('mymsw')
        # instantiate the class
        vportObject = VportsResource('/tmp/')

        # get vport snapshot
        vportDict = vportObject.getSnapshot(ResourceTest.myserver)

        # Assertions
        self.assertNotEqual(vportDict['avlbl vports'], None)
        self.assertNotEqual(vportDict['used vports'], None)
        self.assertNotEqual(vportDict['media avlbl vports'], None)
        self.assertNotEqual(vportDict['media used vports'], None)
コード例 #6
0
ファイル: target.py プロジェクト: AkankshaGovil/Automation
    def RunTest(self, descriptor, context):
        """Run the test given by 'test_id'.

        'descriptor' -- The 'TestDescriptor' for the test.

        'context' -- The 'Context' in which to run the test.

        Derived classes may override this method."""

        # Create the result.
        result = Result(Result.TEST, descriptor.GetId())
        try:
            #38747
            scm = context['nextest.scm_configuration']
            # Augment the context appropriately.
            context = Context(context)
            context[context.TMPDIR_CONTEXT_PROPERTY] \
                = self._GetTemporaryDirectory()
            context[context.DB_PATH_CONTEXT_PROPERTY] \
                = descriptor.GetDatabase().GetPath()
            # Set up any required resources.
            self.__SetUpResources(descriptor, context)
            # Make the ID of the test available.
            context[context.ID_CONTEXT_PROPERTY] = descriptor.GetId()
            # Note the start time.
            result[Result.START_TIME] = qm.common.format_time_iso()

            # 38747 If SCM configuration is ON and the swap flag is enabled
            # continue the remaining tests on the backup by swapping the mysmw and bkupmsw
            # objects and also in /etc/hosts file. Stop the corewatcher on the master and start the
            # corewatcher on the backup in order to monitor for core on the backup
            if scm and self.__engine.swap:
                if context.has_key('userConfig.to_addr'):
                    toaddr = context['userConfig.to_addr']
                    toaddrs = string.split(toaddr, ',')
                    if ((toaddr == '') or (string.count(toaddr, '@') == 0)):
                        self.log.info("ERROR : Entered to address %s is wrong,\
                             " % toaddr)
                if context.has_key('userConfig.from_addr'):
                    fromaddr = context['userConfig.from_addr']
                    if ((fromaddr == '')
                            or (string.count(fromaddr, '@') == 0)):
                        self.log.info(
                            "ERROR : Entered from address %s is wrong,\
                             " % fromaddr)
                if context.has_key('userConfig.mail_server'):
                    mailserver = context['userConfig.mail_server']
                    if (mailserver == ''):
                        self.log.info(
                            "ERROR : Entered mailserver name %s is wrong,\
                             " % mailserver)
                # Added the code for ticket 34247
                if context.has_key('userConfig.login'):
                    login = context['userConfig.login']
                    if (login == ''):
                        self.log.info(
                            "ERROR : Entered  login name %s is wrong,\
                             " % login)
                if context.has_key('userConfig.passwd'):
                    passwd = context['userConfig.passwd']
                    if (passwd == ''):
                        self.log.info(
                            "ERROR : Entered passwd value  %s is wrong,\
                             " % passwd)

                if ((toaddr == '') or (fromaddr == '') or (mailserver == '')
                        or (login == '') or (passwd == '')):
                    toaddr = None
                    fromaddr = None
                    mailserver = None
                    login = None
                    passwd = None
                stopOnCore = 'True'
                if context.has_key('userConfig.stop_on_core'):
                    stopOnCore = context['userConfig.stop_on_core']

                #if restartSCM is found in the script, then reverting back the original
                #/etc/hosts file and stopping the corewatcher on the bkup. Start the
                #corewatcher on the master to monitor the core on the master
                tempStr = str(descriptor.GetClass())
                if tempStr.__contains__('ExecTest'):
                    contStr = descriptor.GetItem().source
                else:
                    contStr = descriptor.GetItem().testsource
                if contStr.__contains__('restartSCM'):
                    self.__engine.swap = False
                    # Restore /etc/hosts
                    if self.__engine.hostsFile:
                        self.__engine.hostsFile = False
                        os.system('sudo cp /etc/hosts_scm /etc/hosts')
                        os.system('sudo rm -rf /etc/hosts_scm')

                # Modify /etc/hosts only once!
                # Modified the /etc/hosts file to continue the remaining tests
                # in bkup until the iserver restart is performed during the presence
                # of core
                if self.__engine.swap:
                    if not self.__engine.hostsFile:
                        modifyHostsFile()
                        self.__engine.hostsFile = True
                    #43909 Added code to revert back the original /etc/hosts file
                    #when core is found from active secondary MSX
                    else:
                        if self.__engine.revertBack:
                            self.__engine.swap = False
                            os.system('sudo cp /etc/hosts_scm /etc/hosts')
                            os.system('sudo rm -rf /etc/hosts_scm')
                            self.__engine.hostsFile = False
                            self.__engine.bkupObj = None
                            self.__engine.revertBack = False

                    # Swapping the MSW and MSWInfo object during the presence of core
                    if not self.__engine.bkupObj:
                        self.__engine.bkupCtrl = msw.MSWInfo('mymsw')
                        cont = {'mswinfo': self.__engine.bkupCtrl}
                        self.__engine.bkupObj = SSH(['root@mymsw'], ctxt=cont)
                    context['msw'] = self.__engine.bkupObj
                    context['mswinfo'] = self.__engine.bkupCtrl
            # Run the test.
            try:
                # Pass on the information on whether the previous script restarted MSW or not
                context['msw_restart'] = self.__engine.msw_restart
                descriptor.Run(context, result)

                # 39583 - Check whether the script restarts only if H323 call has been made
                # msw_restart - Variable used to store previous script information
                # hValNotChecked - Used to indicate if the first H323 script after the iserver restart has been
                # executed or not
                tempStr = str(descriptor.GetClass())
                if tempStr.__contains__('call.CallTest'):
                    if context[
                            'hValNotChecked'] or not self.__engine.msw_restart:
                        if tempStr.__contains__('ExecTest'):
                            contStr = descriptor.GetItem().source
                        else:
                            contStr = descriptor.GetItem().testsource

                        src = contStr.lower()
                        chk1 = src.__contains__(
                            'iserver all stop') or src.__contains__(
                                'ftest') or src.__contains__('checkiserver')
                        chk2 = src.__contains__(
                            'checkscmstatus') or src.__contains__(
                                'restartscm') or src.__contains__(
                                    '.initialize')
                        if chk1 or chk2:
                            self.__engine.msw_restart = True
                        else:
                            self.__engine.msw_restart = False
            finally:
                # Note the end time.
                result[Result.END_TIME] = qm.common.format_time_iso()
        except KeyboardInterrupt:
            result.NoteException(cause="Interrupted by user.")
            # We received a KeyboardInterrupt, indicating that the
            # user would like to exit QMTest.  Ask the execution
            # engine to stop.
            if self.__engine:
                self.__engine.RequestTermination()
        except qm.platform.SignalException, e:
            # Note the exception.
            result.NoteException(cause=str(e))
            # If we get a SIGTERM, propagate it so that QMTest
            # terminates.
            if e.GetSignalNumber() == signal.SIGTERM:
                # Record the result so that the traceback is
                # available.
                self._RecordResult(result)
                # Ask the execution engine to stop running tests.
                if self.__engine:
                    self.__engine.RequestTermination()
                # Re-raise the exception.
                raise