periodic tasks called twice in unit tests

Bug #1253426 reported by aeva black
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
Low
aeva black

Bug Description

In the unit tests of ConductorManager's periodic tasks, eg,

    def test_periodic_keepalive(self):
        self.service.start()
        with mock.patch.object(self.dbapi, 'touch_conductor') as mock_touch:
            self.service.periodic_tasks(self.context)
            mock_touch.assert_called_once_with('test-host')

there seems to be an issue that, if more than one periodic_task is defined, this test will fail because dbapi.touch_conductor() will be called twice instead of once.

aeva black (tenbrae)
Changed in ironic:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Haomeng,Wang (whaom) wrote :

Devananda, I try to recreate with my local env, but not reproduced, so can you show your steps/testcase/unittest code, and I will try to reproduce and debug the root cause?

Revision history for this message
aeva black (tenbrae) wrote :

This was caused by two things and the interplay between them:
- periodic tasks may be called when the Conductor service starts, if the periodic task is defined with run_immediately=True
- a periodic task may get called (again) if the service thinks NOW > LAST_RUN + INTERVAL, which could be triggered by timeutils.set_time_override
- conversely, a method decorated as a periodic task will _not_ get run again if the service thinks that not enough time has passed, even when called directly.

I have resolved these issues in the unit tests with a recent series of patches, which also added another periodic task. I'm marking this bug as Fix Committed. For reference, here are the relevant patches which affected this:
- https://review.openstack.org/#/c/58851/
- https://review.openstack.org/#/c/56530/

Changed in ironic:
status: Triaged → Fix Committed
assignee: nobody → Devananda van der Veen (devananda)
Thierry Carrez (ttx)
Changed in ironic:
milestone: none → icehouse-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ironic:
milestone: icehouse-1 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.