def test_lagLimitExceeded(self):
     """
     If the median scheduling lag for any operation in the simulation
     exceeds 1 second, L{OperationLogger.failures} returns a list containing
     a string describing that issue.
     """
     logger = OperationLogger(outfile=StringIO())
     for lag in [100.0, 1100.0, 1200.0]:
         logger.observe(dict(
                 type='operation', phase='start', user='******',
                 label='testing', lag=lag))
     self.assertEqual(
         ["Median TESTING scheduling lag greater than 1000.0ms"],
         logger.failures())
Beispiel #2
0
 def test_lagLimitExceeded(self):
     """
     If the median scheduling lag for any operation in the simulation
     exceeds 1 second, L{OperationLogger.failures} returns a list containing
     a string describing that issue.
     """
     logger = OperationLogger(outfile=StringIO())
     for lag in [100.0, 1100.0, 1200.0]:
         logger.observe(
             dict(type='operation',
                  phase='start',
                  user='******',
                  label='testing',
                  lag=lag))
     self.assertEqual(
         ["Median TESTING scheduling lag greater than 1000.0ms"],
         logger.failures())
 def test_noFailures(self):
     """
     If the median lag is below 1 second and the failure rate is below 1%,
     L{OperationLogger.failures} returns an empty list.
     """
     logger = OperationLogger(outfile=StringIO())
     logger.observe(dict(
             type='operation', phase='start', user='******',
             label='testing', lag=0.5))
     logger.observe(dict(
             type='operation', phase='end', user='******',
             duration=0.35, label='testing', success=True))
     self.assertEqual([], logger.failures())
Beispiel #4
0
 def test_noFailures(self):
     """
     If the median lag is below 1 second and the failure rate is below 1%,
     L{OperationLogger.failures} returns an empty list.
     """
     logger = OperationLogger(outfile=StringIO())
     logger.observe(
         dict(type='operation',
              phase='start',
              user='******',
              label='testing',
              lag=0.5))
     logger.observe(
         dict(type='operation',
              phase='end',
              user='******',
              duration=0.35,
              label='testing',
              success=True))
     self.assertEqual([], logger.failures())
 def test_failureLimitExceeded(self):
     """
     If the failure rate for any operation exceeds 1%,
     L{OperationLogger.failures} returns a list containing a string
     describing that issue.
     """
     logger = OperationLogger(outfile=StringIO())
     for _ignore in range(98):
         logger.observe(dict(
                 type='operation', phase='end', user='******',
                 duration=0.25, label='testing', success=True))
     logger.observe(dict(
             type='operation', phase='end', user='******',
             duration=0.25, label='testing', success=False))
     self.assertEqual(
         ["Greater than 1% TESTING failed"],
         logger.failures())
Beispiel #6
0
 def test_failureLimitExceeded(self):
     """
     If the failure rate for any operation exceeds 1%,
     L{OperationLogger.failures} returns a list containing a string
     describing that issue.
     """
     logger = OperationLogger(outfile=StringIO())
     for _ignore in range(98):
         logger.observe(
             dict(type='operation',
                  phase='end',
                  user='******',
                  duration=0.25,
                  label='testing',
                  success=True))
     logger.observe(
         dict(type='operation',
              phase='end',
              user='******',
              duration=0.25,
              label='testing',
              success=False))
     self.assertEqual(["Greater than 1% TESTING failed"], logger.failures())
    def test_failureNoPush(self):
        """
        If there are no pushes, L{OperationLogger.failures} will/will not fail depending
        on whether the "failIfNoPush" parameter is set.
        """

        # No pushes, no param
        logger = OperationLogger(outfile=StringIO())
        for _ignore in range(98):
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='testing',
                     success=True))
        self.assertEqual([], logger.failures())

        # No pushes, have param True
        logger = OperationLogger(outfile=StringIO(), failIfNoPush=True)
        for _ignore in range(98):
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='testing',
                     success=True))
        self.assertEqual([OperationLogger._PUSH_MISSING_REASON],
                         logger.failures())

        # Pushes, have param False
        logger = OperationLogger(outfile=StringIO(), failIfNoPush=False)
        for _ignore in range(98):
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='testing',
                     success=True))
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='push',
                     success=True))
        self.assertEqual([], logger.failures())

        # Pushes, have param True
        logger = OperationLogger(outfile=StringIO(), failIfNoPush=True)
        for _ignore in range(98):
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='testing',
                     success=True))
            logger.observe(
                dict(type='operation',
                     phase='end',
                     user='******',
                     duration=0.25,
                     label='push',
                     success=True))
        self.assertEqual([], logger.failures())