mirror of
https://github.com/odoo/runbot.git
synced 2025-03-16 07:55:45 +07:00
[IMP] runbot: add the active_step_id on the ir_logging log
In order to have a more efficient ir_logging filtering, this commit adds the currrent build step id on the ir_logging line.
This commit is contained in:
parent
db52bff323
commit
27b1c2b5f4
@ -15,6 +15,7 @@ class runbot_event(models.Model):
|
||||
_order = 'id'
|
||||
|
||||
build_id = fields.Many2one('runbot.build', 'Build', index=True, ondelete='cascade')
|
||||
active_step_id = fields.Many2one('runbot.build.config.step', 'Active step', index=True)
|
||||
type = fields.Selection(TYPES, string='Type', required=True, index=True)
|
||||
|
||||
@api.model_cr
|
||||
@ -28,6 +29,7 @@ CREATE OR REPLACE FUNCTION runbot_set_logging_build() RETURNS TRIGGER AS $runbot
|
||||
BEGIN
|
||||
IF (NEW.build_id IS NULL AND NEW.dbname IS NOT NULL AND NEW.dbname != current_database()) THEN
|
||||
NEW.build_id := split_part(NEW.dbname, '-', 1)::integer;
|
||||
SELECT active_step INTO NEW.active_step_id FROM runbot_build WHERE runbot_build.id = NEW.build_id;
|
||||
END IF;
|
||||
IF (NEW.build_id IS NOT NULL) AND (NEW.type = 'server') THEN
|
||||
DECLARE
|
||||
|
@ -33,6 +33,7 @@ class TestIrLogging(common.TransactionCase):
|
||||
'branch_id': self.branch.id,
|
||||
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||
'port': '1234',
|
||||
'active_step': self.env.ref('runbot.runbot_build_config_step_test_all').id,
|
||||
})
|
||||
|
||||
build.log_counter = 10
|
||||
@ -42,6 +43,7 @@ class TestIrLogging(common.TransactionCase):
|
||||
log_line = self.IrLogging.search([('func', '=', 'test function'), ('message', '=', 'test message'), ('level', '=', 'INFO')])
|
||||
self.assertEqual(len(log_line), 1, "A build log event should have been created")
|
||||
self.assertEqual(log_line.build_id, build)
|
||||
self.assertEqual(log_line.active_step_id, self.env.ref('runbot.runbot_build_config_step_test_all'), 'The active step should be set on the log line')
|
||||
|
||||
# Test that a warn log line sets the build in warn
|
||||
self.simulate_log(build, 'test function', 'test message', level='WARNING')
|
||||
|
Loading…
Reference in New Issue
Block a user