コード例 #1
0
    def Perf_Check_Channel_ARI_Common(self,
                                      logfile,
                                      filter_required_fields=None,
                                      filter_fields_value=None):
        u'''
        check Channel_ARI_Common Perf log

        Examples:

        | Perf Check Channel ARI Common  | logname.log |

        filter required fields

        | Perf Check Channel ARI Common   | logname.log | ['channel','process']

        '''
        try:
            self._set_filter_required_fields(filter_required_fields)
            self._set_filter_fields_value(filter_fields_value)
            etimes = 0
            plogs = self._getlogs(logfile)
            for plog in plogs:
                s = self._check("Channel_ARI_Common", plog)
                if not s:
                    etimes += 1
            if etimes != 0:
                dlog.fail("Check Failed")
        except Exception, e:
            dlog.fail("Channel_ARI_Common error:%s" % e)
コード例 #2
0
 def Perf_Check_PaymentCard(self, logfile, *PaymentCards):
     logfile = CONTEXT.get_path(logfile)
     lines = open(logfile, 'r')
     for line in lines:
         for pc in PaymentCards:
             if pc in line:
                 dlog.fail("Perf Log Check PaymentCard Error:%s" % line)
コード例 #3
0
ファイル: stream.py プロジェクト: EmyTest/Doraemon
 def _read_stream_log(self):
     self.lines = open(self.logfile).readlines()
     for l in self.lines:
         if not self._deal_time(l):
             # print 'Stream Log Error:The beginning of line is not timestamps \n%s' % (l)
             dlog.fail(
                 'Stream Log Error:The beginning of line is not timestamps \n%s'
                 % (l))
             break
         self._deal_process(l)
コード例 #4
0
ファイル: stream.py プロジェクト: EmyTest/Doraemon
 def _deal_process(self, line):
     indexpipe = line.find('|')
     tr = line[24:indexpipe - 1].strip().split(' ')
     self.token.append(tr[0])
     if tr[-1] == 'request':
         self.requests.append(line[indexpipe + 1:].strip())
     elif tr[-1] == 'response':
         self.responses.append(line[indexpipe + 1:].strip())
     else:
         # print "Stream Log Error:missing process type \n%s"%(line)
         dlog.fail("Stream Log Error:missing process type \n%s" % (line))
コード例 #5
0
    def Perf_Clean(self, logfile):
        u'''
        Clean performance log file

        Examples:

        | Perf_Clean  | logfile |

        '''
        try:
            logfile = CONTEXT.get_path(logfile)
            if os.path.exists(logfile):
                file1 = open(logfile, 'w+')
                file1.truncate()
            else:
                dlog.fail("log file(%s) is not exist" % logfile)
        except Exception, e:
            dlog.write(e, "WARN")
コード例 #6
0
ファイル: stream.py プロジェクト: EmyTest/Doraemon
    def Stream_Log_Check_Requests_Number(self, number, logfile=None):
        u'''
        Args:
            logfile:

        Examples:
            | Stream_Log_Check_Token_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_Log_Check_Requests_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_Log_Check_Responses_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_log_Check_PaymentCard  |  434343434343 | 4545234234324 | 43234234234234
        '''
        self._deal(logfile)
        requests_len = len(self.requests)
        if requests_len == int(number):
            dlog.write('Stream Log Check Requests Number Successfully')
        else:
            dlog.fail(
                'Stream Log Check Requests Number Error:Actual Request number is %s \n%s'
                % (requests_len, self.requests))
コード例 #7
0
ファイル: stream.py プロジェクト: EmyTest/Doraemon
    def Stream_log_Check_PaymentCard(self, *PaymentCards):
        u'''
        Args:
            logfile:

        Examples:
            | Stream_Log_Check_Token_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_Log_Check_Requests_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_Log_Check_Responses_Number  |  1 | /usr/local/log/app.stream.log |
            | Stream_log_Check_PaymentCard  |  434343434343 | 4545234234324 | 43234234234234 |
        '''
        for rq in self.requests:
            for pc in PaymentCards:
                if pc in rq:
                    dlog.fail("Stream Log Check PaymentCard Error:%s" % rq)
        for rp in self.responses:
            for pc in PaymentCards:
                if pc in rp:
                    dlog.fail("Stream Log Check PaymentCard Error:%s" % rp)
        dlog.write("Stream Log Check PaymentCard Successfully")
コード例 #8
0
    def Perf_Check_Number(self, logfile, number):
        u'''
        Args:
            logfile:
            number:

        Returns:List

        Get logs

        | Perf Check Number |  /usr/local/logs/app.per.log | 10 |

        '''
        plogs = self._getlogs(logfile)
        if len(plogs) == int(number):
            dlog.write('Performance Log Check Number Successfully')
        else:
            dlog.fail(
                'Performance Log Check Number Error:Actual Number is %s' %
                len(plogs))
コード例 #9
0
    def Perf_Check_Value(self,
                         logfile,
                         key,
                         value,
                         condition=None,
                         method="equal"):
        u'''
        Performance log Check Value

        *method : equal | contain*

        _*Examples:*_

        no condition:

        | Perf Check Value  | logname.log |  request.type | BatchARIFetch |

        condition:

        | Perf Check Value  | logname.log |  message.duration.avg | 28 | {"message.duration.max":"22"} |

        '''
        status = True
        plogs = self._getlogs(logfile)
        if len(plogs) == 0:
            dlog.fail("performance log is empty")
        if condition is None:
            status = self._check_value(plogs[0], key, value, method)
        else:
            if type(condition) is unicode:
                condition = eval(condition)
            for p in plogs:
                if self._find_keyvalue_by_condition(p, condition):
                    status = self._check_value(p, key, value, method)
        if status is False:
            dlog.fail("Performance log file check failed")