def test_record_job_stop_time(self):
        """
        Test that job stop time is recorded properly.
        """
        stats = CalcStats(
            oq_calculation=self.job, start_time=datetime.utcnow(),
            num_sites=10)
        stats.save(using='job_superv')

        supervisor.record_job_stop_time(self.job.id)

        # Fetch the stats and check for the stop_time
        stats = CalcStats.objects.get(oq_calculation=self.job.id)
        self.assertTrue(stats.stop_time is not None)
Exemple #2
0
    def _record_initial_stats(self):
        '''
        Report initial job stats (such as start time) by adding a
        uiapi.calc_stats record to the db.
        '''
        calc_stats = CalcStats(oq_calculation=self.oq_calculation)
        calc_stats.start_time = datetime.utcnow()
        calc_stats.num_sites = len(self.sites_to_compute())

        calc_mode = CALCULATION_MODE[self['CALCULATION_MODE']]
        if jobconf.HAZARD_SECTION in self.sections:
            if calc_mode != 'scenario':
                calc_stats.realizations = self["NUMBER_OF_LOGIC_TREE_SAMPLES"]

        calc_stats.save()