From e6a6b7f3cf2d3b66c9528ebc7c4e3fa018dfa075 Mon Sep 17 00:00:00 2001 From: catborise Date: Tue, 27 Oct 2026 13:46:15 +0300 Subject: [PATCH] test(instances): the live suite expects vCPUs to wait for a shut-off VM 42a1783 refuses a vCPU change on a running VM, also on a direct request: the VM would get them only at its next start, past the quota counted now. The live data-loss test still posted vCPUs to a running VM and expected the change to be pending, so it failed on every connection type. It now expects the refusal, with its message, and the definition's vCPUs unchanged; the pending options part is as before. --- instances/tests/test_live_dataloss.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/instances/tests/test_live_dataloss.py b/instances/tests/test_live_dataloss.py index eb8700e2..3e6a0893 100644 --- a/instances/tests/test_live_dataloss.py +++ b/instances/tests/test_live_dataloss.py @@ -447,7 +447,7 @@ class LiveDataLossTestCase(TestCase): self.assertEqual((disk.find("driver").get("cache"), disk.findtext("serial")), ("none", "wvc-serial")) self.assertEqual(dom.XMLDesc(0), live) - def test_pending_options_and_cpu_changes_are_shown_and_kept_by_the_next_edit(self): + def test_pending_options_are_shown_and_kept_by_the_next_edit_and_cpus_wait_for_shut_off(self): from lxml import etree, html dom, inst = self.vm("options-pending", []) @@ -459,17 +459,19 @@ class LiveDataLossTestCase(TestCase): (form,) = html.fromstring(page).xpath("//form[@action=$a]", a=reverse(f"instances:{view}", args=[inst.id])) return dict(form.form_values()) # what the form would post - # the buttons are disabled while it runs; a direct post is pending + # the buttons are disabled while it runs; a direct post of options is pending self.post("change_options", inst, {**form("change_options"), "title": "wvc-title"}) - self.post("resizevm_cpu", inst, {**form("resizevm_cpu"), "vcpu": "2"}) - options, cpu = form("change_options"), form("resizevm_cpu") - self.assertEqual((options["title"], cpu["vcpu"]), ("wvc-title", "2")) + options = form("change_options") + self.assertEqual(options["title"], "wvc-title") self.post("change_options", inst, {**options, "description": "wvc-description"}) - self.post("resizevm_cpu", inst, {**cpu, "cur_vcpu": "1"}) + # vCPUs are refused: the VM would get them at its next start, past the quota counted now + response = self.post("resizevm_cpu", inst, {**form("resizevm_cpu"), "vcpu": "2"}) + self.assertIn("Shut off the VM to change its vCPUs", + [str(m) for m in get_messages(response.wsgi_request)]) tree = etree.fromstring(dom.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)) self.assertEqual((tree.findtext("title"), tree.findtext("description"), tree.findtext("vcpu")), - ("wvc-title", "wvc-description", "2")) + ("wvc-title", "wvc-description", "1")) self.assertEqual(dom.XMLDesc(0), live) def test_pending_boot_order_and_video_are_shown_and_a_live_only_choice_changes_nothing(self):