Exemplo n.º 1
0
 def test_utctime_from_utcid(self):
     """Test utctime() returns utctime corresponding to utcid parameter."""
     utcid = Utility.utcid()
     utctime = Utility.utctime(utcid)
     assert isinstance(utctime, str), 'utctime is not a string'
     assert utcid == Utility.utcid(
         utctime), 'utcid -> utctime -> utcid conversion fails'
Exemplo n.º 2
0
 def dorun(self):
     """Executes a run of actions and sleep periods.
     
     Initialises runid to the current UTC ID.
     
     """
     self.runid = Utility.utcid()
     while 1:
         logger.info("Start run %s with id '%s'.", self.run, self.runid)
         for action in self.run:
             try:
                 self._doaction(action)
             except GangaRobotContinueError as e:
                 logger.warning("Continue Error in Action '%s' with message '%s'. Run continued", action, e)
             except GangaRobotBreakError as e:
                 logger.warning("Break Error in Action '%s' with message '%s'. Run ended", action, e)
                 break
             except GangaRobotFatalError as e:
                 logger.error("Fatal Error in Action '%s' with message '%s'. Run aborted", action, e)
                 raise
             except Exception as e:
                 config = getConfig('Robot')
                 if (config['ExceptionBehaviour'] == 'Continue'):
                     logger.error("Error in Action '%s' with message '%s'. Run continued", action, e)
                 elif (config['ExceptionBehaviour'] == 'Break'):
                     logger.error("Error in Action '%s' with message '%s'. Run continued", action, e)
                     break
                 else:
                     logger.error("Abort run id '%s'. Action '%s' failed with message %s.", self.runid, action, e)
                     raise
         logger.info("Finish run id '%s'.", self.runid)
         if not self.repeat: 
             break
Exemplo n.º 3
0
    def setUp(self):
        """Create test actions."""
        super(TestCore, self).setUp()
        self.runid = Utility.utcid()
        self.submitter = CoreSubmitter()
        #force submitter patterns
        self.submitter.options = {
            'CoreSubmitter_Patterns':
            ['GangaRobot/old_test/Lib/Core/test-jobs.txt']
        }
        self.finisher = CoreFinisher()
        #force finisher timeout to 5 mins
        self.finisher.options = {'BaseFinisher_Timeout': 300}

        #test extractor fakes save
        class TestCoreExtractor(CoreExtractor):
            def _saveextract(self, runnode, runid):
                self.runnode = runnode  #can be accessed in the test

        self.extractor = TestCoreExtractor()

        #test reporter fakes load and save
        class TestCoreReporter(CoreReporter):
            def _loadextract(self, runid):
                return self.runnode  #must be set in the test

            def _savereport(self, report, runid):
                self.report = report  #can be accessed in the test

        self.reporter = TestCoreReporter()
Exemplo n.º 4
0
 def dorun(self):
     """Executes a run of actions and sleep periods.
     
     Initialises runid to the current UTC ID.
     
     """
     self.runid = Utility.utcid()
     while 1:
         logger.info("Start run %s with id '%s'.", self.run, self.runid)
         for action in self.run:
             try:
                 self._doaction(action)
             except GangaRobotContinueError as e:
                 logger.warning(
                     "Continue Error in Action '%s' with message '%s'. Run continued",
                     action, e)
             except GangaRobotBreakError as e:
                 logger.warning(
                     "Break Error in Action '%s' with message '%s'. Run ended",
                     action, e)
                 break
             except GangaRobotFatalError as e:
                 logger.error(
                     "Fatal Error in Action '%s' with message '%s'. Run aborted",
                     action, e)
                 raise
             except Exception as e:
                 config = getConfig('Robot')
                 if (config['ExceptionBehaviour'] == 'Continue'):
                     logger.error(
                         "Error in Action '%s' with message '%s'. Run continued",
                         action, e)
                 elif (config['ExceptionBehaviour'] == 'Break'):
                     logger.error(
                         "Error in Action '%s' with message '%s'. Run continued",
                         action, e)
                     break
                 else:
                     logger.error(
                         "Abort run id '%s'. Action '%s' failed with message %s.",
                         self.runid, action, e)
                     raise
         logger.info("Finish run id '%s'.", self.runid)
         if not self.repeat:
             break
Exemplo n.º 5
0
 def setUp(self):
     """Create test actions."""
     super(TestCore, self).setUp()
     self.runid = Utility.utcid()
     self.submitter = CoreSubmitter()
     #force submitter patterns
     self.submitter.options = {'CoreSubmitter_Patterns':['GangaRobot/old_test/Lib/Core/test-jobs.txt']}
     self.finisher = CoreFinisher()
     #force finisher timeout to 5 mins
     self.finisher.options = {'BaseFinisher_Timeout':300}
     #test extractor fakes save
     class TestCoreExtractor(CoreExtractor):
         def _saveextract(self, runnode, runid):
             self.runnode = runnode #can be accessed in the test
     self.extractor = TestCoreExtractor()
     #test reporter fakes load and save
     class TestCoreReporter(CoreReporter):
         def _loadextract(self, runid):
             return self.runnode #must be set in the test
         def _savereport(self, report, runid):
             self.report = report #can be accessed in the test 
     self.reporter = TestCoreReporter()
Exemplo n.º 6
0
 def test_utctime_from_utcid(self):
     """Test utctime() returns utctime corresponding to utcid parameter."""
     utcid = Utility.utcid()
     utctime = Utility.utctime(utcid)
     assert isinstance(utctime, str), 'utctime is not a string'
     assert utcid == Utility.utcid(utctime), 'utcid -> utctime -> utcid conversion fails'
Exemplo n.º 7
0
 def test_utcid(self):
     """Test utcid() returns a string value when no parameter."""
     utcid = Utility.utcid()
     assert isinstance(utcid, str), 'utcid is not a string'
Exemplo n.º 8
0
 def test_utcid(self):
     """Test utcid() returns a string value when no parameter."""
     utcid = Utility.utcid()
     assert isinstance(utcid, str), 'utcid is not a string'