From 9694ea7fd553efa250448b2e42fcd8a81a2fdbe5 Mon Sep 17 00:00:00 2001 From: Aarti Kriplani Date: Fri, 22 Mar 2013 09:54:35 +0530 Subject: xenapi: Added logging for sparse copy After 300 seconds(default), logs how many bytes have been written already, and how many are left, so as to be able to track progress of the long running task. Implements blueprint log-progress-of-sparse-copy Change-Id: I289ab978ec4b31f1015c783111c01a460de33f09 --- nova/tests/virt/xenapi/test_vm_utils.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/virt/xenapi/test_vm_utils.py b/nova/tests/virt/xenapi/test_vm_utils.py index 3f7de1521..f2a75d899 100644 --- a/nova/tests/virt/xenapi/test_vm_utils.py +++ b/nova/tests/virt/xenapi/test_vm_utils.py @@ -24,6 +24,7 @@ from nova.compute import flavors from nova import context from nova import db from nova import exception +from nova.openstack.common import timeutils from nova import test from nova.tests.virt.xenapi import stubs from nova import utils @@ -364,6 +365,26 @@ class ResizeHelpersTestCase(test.TestCase): vm_utils._resize_part_and_fs("fake", 0, 20, 10) + def test_log_progress_if_required(self): + self.mox.StubOutWithMock(vm_utils.LOG, "debug") + vm_utils.LOG.debug(_("Sparse copy in progress, " + "%(complete_pct).2f%% complete. " + "%(left) bytes left to copy"), + {"complete_pct": 50.0, "left": 1}) + current = timeutils.utcnow() + timeutils.set_time_override(current) + timeutils.advance_time_seconds(vm_utils.PROGRESS_INTERVAL_SECONDS + 1) + self.mox.ReplayAll() + vm_utils._log_progress_if_required(1, current, 2) + + def test_log_progress_if_not_required(self): + self.mox.StubOutWithMock(vm_utils.LOG, "debug") + current = timeutils.utcnow() + timeutils.set_time_override(current) + timeutils.advance_time_seconds(vm_utils.PROGRESS_INTERVAL_SECONDS - 1) + self.mox.ReplayAll() + vm_utils._log_progress_if_required(1, current, 2) + def test_resize_part_and_fs_down_fails_disk_too_big(self): self.mox.StubOutWithMock(vm_utils, "_repair_filesystem") self.mox.StubOutWithMock(utils, 'execute') -- cgit