mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
fix(instances): a VM name of any length libvirt takes is kept
libvirt names a VM by its <name>.xml file, so a name can have up to 251 bytes. The panel's VM, removed-VM and log records held 120 characters: on PostgreSQL one longer name made the host's sync fail and the VM list answer with an error. They now hold 255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
e83bdcbd44
commit
373760f2c5
8 changed files with 68 additions and 8 deletions
|
|
@ -7,7 +7,8 @@ from django.test.utils import CaptureQueriesContext
|
|||
from accounts.models import UserInstance
|
||||
from computes.models import Compute
|
||||
from computes.utils import refresh_instance_database
|
||||
from instances.models import Instance
|
||||
from instances.models import Instance, InstanceTombstone
|
||||
from logs.models import Logs
|
||||
from computes.tests.fakes import Domain
|
||||
|
||||
|
||||
|
|
@ -41,6 +42,23 @@ class InstanceReconciliationTestCase(TestCase):
|
|||
self.assertEqual(instances[1].name, "vm-beta")
|
||||
self.assertEqual(instances[1].uuid, "22222222-2222-2222-2222-222222222222")
|
||||
|
||||
def test_a_longest_libvirt_name_is_kept_and_buried(self):
|
||||
# libvirt's limit: its <name>.xml file; PostgreSQL refused names over 120
|
||||
name = "v" * 251
|
||||
uuid = "55555555-5555-5555-5555-555555555555"
|
||||
mock_proxy = MagicMock()
|
||||
mock_proxy.wvm.listAllDomains.return_value = [Domain(name=name, uuid=uuid)]
|
||||
self.compute.__dict__["proxy"] = mock_proxy
|
||||
self.compute.__dict__["status"] = True
|
||||
|
||||
refresh_instance_database(self.compute)
|
||||
UserInstance.objects.create(instance=Instance.objects.get(uuid=uuid), user=self.user)
|
||||
mock_proxy.wvm.listAllDomains.return_value = []
|
||||
refresh_instance_database(self.compute)
|
||||
|
||||
self.assertEqual(InstanceTombstone.objects.get(uuid=uuid).name, name)
|
||||
self.assertEqual(Logs.objects.filter(instance_uuid=uuid).first().instance, name)
|
||||
|
||||
def test_domain_deleted_in_libvirt_is_deleted_from_db(self):
|
||||
inst = Instance.objects.create(
|
||||
compute=self.compute,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue