Exemple #1
0
 def test_get_progress_timing_data_before_first_increment(self):
     # No "progress counter increment" time stamp exists, the time stamp of
     # the *executing* `JobPhaseStats` record is taken instead.
     five_mins_ago = datetime.utcnow() - timedelta(minutes=5)
     jps = JobPhaseStats(oq_job=self.job, ctype="hazard",
                         job_status="executing")
     jps.start_time = five_mins_ago
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(300, actual, 5))
     self.assertEqual(99, timeout)
Exemple #2
0
 def test_get_progress_timing_data_before_first_increment(self):
     # No "progress counter increment" time stamp exists, the time stamp of
     # the *executing* `JobPhaseStats` record is taken instead.
     five_mins_ago = datetime.utcnow() - timedelta(minutes=5)
     jps = JobPhaseStats(oq_job=self.job,
                         ctype="hazard",
                         job_status="executing")
     jps.start_time = five_mins_ago
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(300, actual, 5))
     self.assertEqual(3601, timeout)
Exemple #3
0
 def test_get_progress_timing_data_with_stale_increment_ts(self):
     # The progress counter increment time stamp exists but is not used
     # since the time stamp in the *executing* `JobPhaseStats` record is
     # more recent.
     tstamp = datetime.utcnow() - timedelta(minutes=9)
     stats.pk_set(self.job.id, "lvr_ts", tstamp.strftime("%s"))
     tstamp = datetime.utcnow() - timedelta(minutes=8)
     jps = JobPhaseStats(oq_job=self.job, ctype="hazard",
                         job_status="executing")
     jps.start_time = tstamp
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(480, actual, 5))
Exemple #4
0
 def test_get_progress_timing_data_with_stale_increment_ts(self):
     # The progress counter increment time stamp exists but is not used
     # since the time stamp in the *executing* `JobPhaseStats` record is
     # more recent.
     tstamp = datetime.utcnow() - timedelta(minutes=9)
     stats.pk_set(self.job.id, "lvr_ts", tstamp.strftime("%s"))
     tstamp = datetime.utcnow() - timedelta(minutes=8)
     jps = JobPhaseStats(oq_job=self.job,
                         ctype="hazard",
                         job_status="executing")
     jps.start_time = tstamp
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(480, actual, 5))
Exemple #5
0
 def test_get_progress_timing_data_no_increment_multiple_rows(self):
     # No progress counter increment time stamp exists, the time stamp of
     # the most recent *executing* `JobPhaseStats` record is taken instead.
     jps_ts = datetime.utcnow() - timedelta(minutes=5)
     jps = JobPhaseStats(oq_job=self.job,
                         ctype="hazard",
                         job_status="executing")
     jps.start_time = jps_ts
     jps.save()
     jps_ts = datetime.utcnow() - timedelta(minutes=2)
     jps = JobPhaseStats(oq_job=self.job,
                         ctype="risk",
                         job_status="executing")
     jps.start_time = jps_ts
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(120, actual, 5))
Exemple #6
0
 def test_get_progress_timing_data_no_increment_multiple_rows(self):
     # No progress counter increment time stamp exists, the time stamp of
     # the most recent *executing* `JobPhaseStats` record is taken instead.
     jps_ts = datetime.utcnow() - timedelta(minutes=5)
     jps = JobPhaseStats(oq_job=self.job, ctype="hazard",
                         job_status="executing")
     jps.start_time = jps_ts
     jps.save()
     jps_ts = datetime.utcnow() - timedelta(minutes=2)
     jps = JobPhaseStats(oq_job=self.job, ctype="risk",
                         job_status="executing")
     jps.start_time = jps_ts
     jps.save()
     actual, timeout = stats.get_progress_timing_data(self.job)
     self.assertTrue(approx_equal(120, actual, 5))