mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] rubnbot_merge: avoid triggering every cron on every test
Since every cron runs on a fresh database, on the first `run_crons` every single cron in the db will run even though almost none of them is relevant. Aside from the slight inefficiency, this creates unnecessary extra garbage in the test logs. By setting the `nextcall` of all crons to infinity in the template we avoid this issue, only triggered crons (or the crons whose nextcall we set ourselves) will trigger during calls. This requires adjusting the branch cleanup cron slightly: it didn't correctly handle the initial run (`lastcall` being false).
This commit is contained in:
parent
157657af49
commit
78cc8835ce
@ -326,6 +326,7 @@ class DbDict(dict):
|
||||
f.write(db)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
subprocess.run(['psql', db, '-c', "UPDATE ir_cron SET nextcall = 'infinity'"])
|
||||
|
||||
return db
|
||||
|
||||
|
@ -9,10 +9,11 @@ class BranchCleanup(models.TransientModel):
|
||||
_description = "cleans up scratch refs for deactivated branches"
|
||||
|
||||
def _run(self):
|
||||
deactivated = self.env['runbot_merge.branch'].search([
|
||||
('active', '=', False),
|
||||
('write_date', '>=', self.env.context['lastcall']),
|
||||
])
|
||||
domain = [('active', '=', False)]
|
||||
if lastcall := self.env.context['lastcall']:
|
||||
domain.append(('write_date', '>=', lastcall))
|
||||
deactivated = self.env['runbot_merge.branch'].search(domain)
|
||||
|
||||
_logger.info(
|
||||
"deleting scratch (tmp and staging) refs for branches %s",
|
||||
', '.join(b.name for b in deactivated)
|
||||
|
Loading…
Reference in New Issue
Block a user