From 5d83d23cb7f7e95fedbd339405d93bc3841049ea Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 4 Mar 2013 20:35:27 -0500 Subject: Bump instance updated_at on network change. Update add-fixed-ip and remove-fixed-ip code paths to update the updated_at field of the instance, since from the user's perspective through the API, they have made a change to the instance's configuration. In that case, it makes sense to expect that the updated_at field gets changed. Fix bug 1143466. Change-Id: Icfd7d0b1b556795d94a22c1719727f8c9fc744f0 --- nova/tests/compute/test_compute.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 7869b76cc..e5a5c8b4b 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3756,6 +3756,30 @@ class ComputeTestCase(BaseTestCase): self.mox.ReplayAll() self.compute._instance_usage_audit(self.context) + def test_add_remove_fixed_ip_updates_instance_updated_at(self): + def _noop(*args, **kwargs): + pass + + self.stubs.Set(self.compute.network_api, + 'add_fixed_ip_to_instance', _noop) + self.stubs.Set(self.compute.network_api, + 'remove_fixed_ip_from_instance', _noop) + + instance = self._create_fake_instance() + updated_at_1 = instance['updated_at'] + + self.compute.add_fixed_ip_to_instance(self.context, 'fake', instance) + instance = db.instance_get_by_uuid(self.context, instance['uuid']) + updated_at_2 = instance['updated_at'] + + self.compute.remove_fixed_ip_from_instance(self.context, 'fake', + instance) + instance = db.instance_get_by_uuid(self.context, instance['uuid']) + updated_at_3 = instance['updated_at'] + + updated_ats = (updated_at_1, updated_at_2, updated_at_3) + self.assertEqual(len(updated_ats), len(set(updated_ats))) + class ComputeAPITestCase(BaseTestCase): -- cgit