[PATCH] [Kimchi 0/5] Kimchi testcases fixes

From: Paulo Vital <pvital@linux.vnet.ibm.com> This patchset fixes some Kimchi testcases were failling or finishing with errors in Fedora 23 host. There're 3 tests failling at this moment: 2 tests in test_edit_vm() and test_vlan_tag_bridge(). The solution for "Fix test_async_tasks testcase." depends on the WOK patch "Create utils method get_task_id()" to be applied before. Paulo Vital (5): Fix range for network of NAT and isolated types. Fix test_image_based_template testcase. Fix test_async_tasks testcase. Fix test_vm_lifecycle testcase. fix 2 test_vm_lifecycle testcase model/networks.py | 2 +- tests/test_model.py | 79 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 25 deletions(-) -- 2.5.0

From: Paulo Vital <pvital@linux.vnet.ibm.com> The calculations to create the range of IP addresses when creating a virtual network of NAT and isolated types, was discounting only 2 number of hosts when it's necessary to discount 3 to not use the broadcast address as possible address. This fix, solves the Libvirt error: "end of range 192.168.0.129 - 192.168.0.255 in network 192.168.0.1/24 is the broadcast address" Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- model/networks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/networks.py b/model/networks.py index 2856291..d0186a7 100644 --- a/model/networks.py +++ b/model/networks.py @@ -143,7 +143,7 @@ class NetworksModel(object): ip.ip = ip.ip + 1 dhcp_start = str(ip.ip + ip.numhosts / 2) - dhcp_end = str(ip.ip + ip.numhosts - 2) + dhcp_end = str(ip.ip + ip.numhosts - 3) params.update({'net': str(ip), 'dhcp': {'range': {'start': dhcp_start, 'end': dhcp_end}}}) -- 2.5.0

From: Paulo Vital <pvital@linux.vnet.ibm.com> Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_image_based_template when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error: "cannot unlink file '/var/lib/libvirt/images/base-vol.img': Success" This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index caacd91..0108015 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -250,19 +250,31 @@ class ModelTests(unittest.TestCase): @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_image_based_template(self): + + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24 + try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) + inst = model.Model(objstore_loc=self.tmp_store) with RollbackContext() as rollback: + pool = 'default' vol = 'base-vol.img' params = {'name': vol, 'capacity': 1073741824, # 1 GiB 'allocation': 1048576, # 1 MiB 'format': 'qcow2'} - task_id = inst.storagevolumes_create('default', params)['id'] - rollback.prependDefer(inst.storagevolume_delete, 'default', vol) + task_id = inst.storagevolumes_create(pool, params)['id'] + rollback.prependDefer(temporary_storagevolume_delete, pool, vol) inst.task_wait(task_id) self.assertEquals('finished', inst.task_lookup(task_id)['status']) - vol_path = inst.storagevolume_lookup('default', vol)['path'] + vol_path = inst.storagevolume_lookup(pool, vol)['path'] # Create template based on IMG file tmpl_name = "img-tmpl" -- 2.5.0

On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_image_based_template when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error:
"cannot unlink file '/var/lib/libvirt/images/base-vol.img': Success"
This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py index caacd91..0108015 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -250,19 +250,31 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_image_based_template(self): + + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24
Is there a Fedora issue for it? If so, could you add a reference for that in this comment?
+ try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) + inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback: + pool = 'default' vol = 'base-vol.img' params = {'name': vol, 'capacity': 1073741824, # 1 GiB 'allocation': 1048576, # 1 MiB 'format': 'qcow2'} - task_id = inst.storagevolumes_create('default', params)['id'] - rollback.prependDefer(inst.storagevolume_delete, 'default', vol) + task_id = inst.storagevolumes_create(pool, params)['id'] + rollback.prependDefer(temporary_storagevolume_delete, pool, vol) inst.task_wait(task_id) self.assertEquals('finished', inst.task_lookup(task_id)['status']) - vol_path = inst.storagevolume_lookup('default', vol)['path'] + vol_path = inst.storagevolume_lookup(pool, vol)['path']
# Create template based on IMG file tmpl_name = "img-tmpl"

On 12/07/2015 11:52 AM, Aline Manera wrote:
On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_image_based_template when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error:
"cannot unlink file '/var/lib/libvirt/images/base-vol.img': Success"
This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py index caacd91..0108015 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -250,19 +250,31 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_image_based_template(self): + + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24
Is there a Fedora issue for it? If so, could you add a reference for that in this comment?
I don't think so. The issue was found and resolved by Libvirt community during some tests related to snapshots operations.
+ try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) + inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback: + pool = 'default' vol = 'base-vol.img' params = {'name': vol, 'capacity': 1073741824, # 1 GiB 'allocation': 1048576, # 1 MiB 'format': 'qcow2'} - task_id = inst.storagevolumes_create('default', params)['id'] - rollback.prependDefer(inst.storagevolume_delete, 'default', vol) + task_id = inst.storagevolumes_create(pool, params)['id'] + rollback.prependDefer(temporary_storagevolume_delete, pool, vol) inst.task_wait(task_id) self.assertEquals('finished', inst.task_lookup(task_id)['status']) - vol_path = inst.storagevolume_lookup('default', vol)['path'] + vol_path = inst.storagevolume_lookup(pool, vol)['path']
# Create template based on IMG file tmpl_name = "img-tmpl"

On 12/07/2015 11:52 AM, Aline Manera wrote:
On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_image_based_template when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error:
"cannot unlink file '/var/lib/libvirt/images/base-vol.img': Success"
This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py index caacd91..0108015 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -250,19 +250,31 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_image_based_template(self): + + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24
Is there a Fedora issue for it? If so, could you add a reference for that in this comment?
There's no Fedora's bugzilla or even libvirt issue about this error. The error was found during the investigation of a different libvirt problem and them a solution was submitted to libvirt ML. I can add the reference to this patch sent to libvirt ML.
+ try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) + inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback: + pool = 'default' vol = 'base-vol.img' params = {'name': vol, 'capacity': 1073741824, # 1 GiB 'allocation': 1048576, # 1 MiB 'format': 'qcow2'} - task_id = inst.storagevolumes_create('default', params)['id'] - rollback.prependDefer(inst.storagevolume_delete, 'default', vol) + task_id = inst.storagevolumes_create(pool, params)['id'] + rollback.prependDefer(temporary_storagevolume_delete, pool, vol) inst.task_wait(task_id) self.assertEquals('finished', inst.task_lookup(task_id)['status']) - vol_path = inst.storagevolume_lookup('default', vol)['path'] + vol_path = inst.storagevolume_lookup(pool, vol)['path']
# Create template based on IMG file tmpl_name = "img-tmpl"

From: Paulo Vital <pvital@linux.vnet.ibm.com> When executed all Kimchi tests (by run_tests.sh), the test_async_tasks is falling due to wrong check of the number of the current task added to be executed. This happens because the control of the task_id is handled by a global variable in Wok, increased by 1 each time a new task is added. This patch uses the wok.utils method get_task_id() to get the current value of the task_id controlled by Wok. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 0108015..0ac36dd 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -34,7 +34,7 @@ from wok.config import config from wok.exception import InvalidOperation from wok.exception import InvalidParameter, NotFoundError, OperationFailed from wok.rollbackcontext import RollbackContext -from wok.utils import add_task +from wok.utils import add_task, get_task_id from wok.xmlutils.utils import xpath_get_text from wok.plugins.kimchi import netinfo @@ -939,14 +939,14 @@ class ModelTests(unittest.TestCase): objstore_loc=self.tmp_store) taskid = add_task('', quick_op, inst.objstore, 'Hello') inst.task_wait(taskid) - self.assertEquals(1, taskid) + self.assertEquals(get_task_id(), taskid) self.assertEquals('finished', inst.task_lookup(taskid)['status']) self.assertEquals('Hello', inst.task_lookup(taskid)['message']) taskid = add_task('', long_op, inst.objstore, {'delay': 3, 'result': False, 'message': 'It was not meant to be'}) - self.assertEquals(2, taskid) + self.assertEquals(get_task_id(), taskid) self.assertEquals('running', inst.task_lookup(taskid)['status']) self.assertEquals('OK', inst.task_lookup(taskid)['message']) inst.task_wait(taskid) -- 2.5.0

From: Paulo Vital <pvital@linux.vnet.ibm.com> Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_vm_lifecycle when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error: "cannot unlink file '/var/lib/libvirt/images/test-vol': Success" This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_model.py b/tests/test_model.py index 0ac36dd..338f04d 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -124,12 +124,23 @@ class ModelTests(unittest.TestCase): @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_lifecycle(self): + + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24 + try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) + inst = model.Model(objstore_loc=self.tmp_store) with RollbackContext() as rollback: vol_params = {'name': u'test-vol', 'capacity': 1024} task = inst.storagevolumes_create(u'default', vol_params) - rollback.prependDefer(inst.storagevolume_delete, u'default', + rollback.prependDefer(temporary_storagevolume_delete, u'default', vol_params['name']) inst.task_wait(task['id']) task = inst.task_lookup(task['id']) -- 2.5.0

On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
Libvirt of the Fedora 23 is not able to delete the storage volume in the testcase test_vm_lifecycle when testing ModelTests. This happens because Libvirt is not able to unlink/rmdir returning an error (-1) and setting errno to ENOENT, causing the error:
"cannot unlink file '/var/lib/libvirt/images/test-vol': Success"
This patch fixes the testcase by manually remove the volume file from the storage pool directory if the wok.plugins.kimchi.model.storagevolume_delete() was not capable to delete the volume.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tests/test_model.py b/tests/test_model.py index 0ac36dd..338f04d 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -124,12 +124,23 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_vm_lifecycle(self):
+ + def temporary_storagevolume_delete(pool, vol): + # Quick fix to passby the Libvirt error: + # "error: cannot unlink file '%(vol)': Success" + # in Fedora <= 23. The Libvirt fix will be present only on Fedora 24 + try: + inst.storagevolume_delete(pool, vol) + except OperationFailed as e: + path = inst.storagevolume_lookup(pool, vol)['path'] + os.remove(path) +
This function was created twice (check patch 2/5). I suggest to add it for the test class and reuse everywhere when needed.
inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback: vol_params = {'name': u'test-vol', 'capacity': 1024} task = inst.storagevolumes_create(u'default', vol_params) - rollback.prependDefer(inst.storagevolume_delete, u'default', + rollback.prependDefer(temporary_storagevolume_delete, u'default', vol_params['name']) inst.task_wait(task['id']) task = inst.task_lookup(task['id'])

From: Paulo Vital <pvital@linux.vnet.ibm.com> The vmsnapshot_revert() updates the name in the VM XML to the previous VM name (kimchi-vm), but the domain name used by libvirt to lookup this VM/domain, is the updated name (kimchi-vm-new) as proved here: https://paste.fedoraproject.org/296617/49064913/. In addition, if libvirtd is restarted, the name displayed in the 'virsh list --all' command is the updated name. This patch changed the name of the VM used to test the lifecycle. Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tests/test_model.py b/tests/test_model.py index 338f04d..d6d5530 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -157,7 +157,7 @@ class ModelTests(unittest.TestCase): params = {'name': 'kimchi-vm', 'template': '/plugins/kimchi/templates/test'} task = inst.vms_create(params) - rollback.prependDefer(inst.vm_delete, 'kimchi-vm') + rollback.prependDefer(inst.vm_delete, 'kimchi-vm-new') inst.task_wait(task['id'], 10) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -204,7 +204,7 @@ class ModelTests(unittest.TestCase): task = inst.vmsnapshots_create(u'kimchi-vm') snap_name = task['target_uri'].split('/')[-1] rollback.prependDefer(inst.vmsnapshot_delete, - u'kimchi-vm', snap_name) + u'kimchi-vm-new', snap_name) inst.task_wait(task['id']) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -227,34 +227,42 @@ class ModelTests(unittest.TestCase): result = inst.vmsnapshot_revert(u'kimchi-vm-new', params['name']) self.assertEquals(result, [u'kimchi-vm', snap['name']]) - vm = inst.vm_lookup(u'kimchi-vm') + # The vmsnapshot_revert() updates the name in the VM XML to the + # previous VM name (kimchi-vm), but the domain name used by libvirt + # to lookup this VM/domain, is the updated name (kimchi-vm-new) as + # proved here: https://paste.fedoraproject.org/296617/49064913/. + # In addition, if libvirtd is restarted, the name displayed in the + # 'virsh list --all' cmd is the updated name. + vm = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(vm['state'], snap['state']) - current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm') + current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm-new') self.assertEquals(params['name'], current_snap['name']) self.assertRaises(NotFoundError, inst.vmsnapshot_delete, - u'kimchi-vm', u'foobar') + u'kimchi-vm-new', u'foobar') # suspend and resume the VM - info = inst.vm_lookup(u'kimchi-vm') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'shutoff') - self.assertRaises(InvalidOperation, inst.vm_suspend, u'kimchi-vm') - inst.vm_start(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_suspend, + u'kimchi-vm-new') + inst.vm_start(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - inst.vm_suspend(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'paused') - self.assertRaises(InvalidParameter, inst.vm_update, u'kimchi-vm', - {'name': 'foo'}) - inst.vm_resume(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidParameter, inst.vm_update, + u'kimchi-vm-new', {'name': 'foo'}) + inst.vm_resume(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - self.assertRaises(InvalidOperation, inst.vm_resume, u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_resume, + u'kimchi-vm-new') # leave the VM suspended to make sure a paused VM can be # deleted correctly - inst.vm_suspend(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new') vms = inst.vms_get_list() self.assertFalse('kimchi-vm' in vms) -- 2.5.0

On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
The vmsnapshot_revert() updates the name in the VM XML to the previous VM name (kimchi-vm), but the domain name used by libvirt to lookup this VM/domain, is the updated name (kimchi-vm-new) as proved here: https://paste.fedoraproject.org/296617/49064913/. In addition, if libvirtd is restarted, the name displayed in the 'virsh list --all' command is the updated name.
What is the impact for the Kimchi user while doing the snapshot revert via UI? After reverting a snapshot which changes the VM name, will the user continue to be able to manage the VM after that?
This patch changed the name of the VM used to test the lifecycle.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py index 338f04d..d6d5530 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -157,7 +157,7 @@ class ModelTests(unittest.TestCase): params = {'name': 'kimchi-vm', 'template': '/plugins/kimchi/templates/test'} task = inst.vms_create(params) - rollback.prependDefer(inst.vm_delete, 'kimchi-vm') + rollback.prependDefer(inst.vm_delete, 'kimchi-vm-new') inst.task_wait(task['id'], 10) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -204,7 +204,7 @@ class ModelTests(unittest.TestCase): task = inst.vmsnapshots_create(u'kimchi-vm') snap_name = task['target_uri'].split('/')[-1] rollback.prependDefer(inst.vmsnapshot_delete, - u'kimchi-vm', snap_name) + u'kimchi-vm-new', snap_name) inst.task_wait(task['id']) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -227,34 +227,42 @@ class ModelTests(unittest.TestCase): result = inst.vmsnapshot_revert(u'kimchi-vm-new', params['name']) self.assertEquals(result, [u'kimchi-vm', snap['name']])
- vm = inst.vm_lookup(u'kimchi-vm') + # The vmsnapshot_revert() updates the name in the VM XML to the + # previous VM name (kimchi-vm), but the domain name used by libvirt + # to lookup this VM/domain, is the updated name (kimchi-vm-new) as + # proved here: https://paste.fedoraproject.org/296617/49064913/. + # In addition, if libvirtd is restarted, the name displayed in the + # 'virsh list --all' cmd is the updated name. + vm = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(vm['state'], snap['state'])
- current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm') + current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm-new') self.assertEquals(params['name'], current_snap['name'])
self.assertRaises(NotFoundError, inst.vmsnapshot_delete, - u'kimchi-vm', u'foobar') + u'kimchi-vm-new', u'foobar')
# suspend and resume the VM - info = inst.vm_lookup(u'kimchi-vm') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'shutoff') - self.assertRaises(InvalidOperation, inst.vm_suspend, u'kimchi-vm') - inst.vm_start(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_suspend, + u'kimchi-vm-new') + inst.vm_start(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - inst.vm_suspend(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'paused') - self.assertRaises(InvalidParameter, inst.vm_update, u'kimchi-vm', - {'name': 'foo'}) - inst.vm_resume(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidParameter, inst.vm_update, + u'kimchi-vm-new', {'name': 'foo'}) + inst.vm_resume(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - self.assertRaises(InvalidOperation, inst.vm_resume, u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_resume, + u'kimchi-vm-new') # leave the VM suspended to make sure a paused VM can be # deleted correctly - inst.vm_suspend(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new')
vms = inst.vms_get_list() self.assertFalse('kimchi-vm' in vms)

On 07/12/2015 11:55, Aline Manera wrote:
On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
The vmsnapshot_revert() updates the name in the VM XML to the previous VM name (kimchi-vm), but the domain name used by libvirt to lookup this VM/domain, is the updated name (kimchi-vm-new) as proved here: https://paste.fedoraproject.org/296617/49064913/. In addition, if libvirtd is restarted, the name displayed in the 'virsh list --all' command is the updated name.
What is the impact for the Kimchi user while doing the snapshot revert via UI? After reverting a snapshot which changes the VM name, will the user continue to be able to manage the VM after that?
The revert() action should return the right VM resource and the test could be able to get the new resource name to work with. The same flow while doing it using the UI
This patch changed the name of the VM used to test the lifecycle.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com> --- tests/test_model.py | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py index 338f04d..d6d5530 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -157,7 +157,7 @@ class ModelTests(unittest.TestCase): params = {'name': 'kimchi-vm', 'template': '/plugins/kimchi/templates/test'} task = inst.vms_create(params) - rollback.prependDefer(inst.vm_delete, 'kimchi-vm') + rollback.prependDefer(inst.vm_delete, 'kimchi-vm-new') inst.task_wait(task['id'], 10) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -204,7 +204,7 @@ class ModelTests(unittest.TestCase): task = inst.vmsnapshots_create(u'kimchi-vm') snap_name = task['target_uri'].split('/')[-1] rollback.prependDefer(inst.vmsnapshot_delete, - u'kimchi-vm', snap_name) + u'kimchi-vm-new', snap_name) inst.task_wait(task['id']) task = inst.task_lookup(task['id']) self.assertEquals('finished', task['status']) @@ -227,34 +227,42 @@ class ModelTests(unittest.TestCase): result = inst.vmsnapshot_revert(u'kimchi-vm-new', params['name']) self.assertEquals(result, [u'kimchi-vm', snap['name']])
- vm = inst.vm_lookup(u'kimchi-vm') + # The vmsnapshot_revert() updates the name in the VM XML to the + # previous VM name (kimchi-vm), but the domain name used by libvirt + # to lookup this VM/domain, is the updated name (kimchi-vm-new) as + # proved here: https://paste.fedoraproject.org/296617/49064913/. + # In addition, if libvirtd is restarted, the name displayed in the + # 'virsh list --all' cmd is the updated name. + vm = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(vm['state'], snap['state'])
- current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm') + current_snap = inst.currentvmsnapshot_lookup(u'kimchi-vm-new') self.assertEquals(params['name'], current_snap['name'])
self.assertRaises(NotFoundError, inst.vmsnapshot_delete, - u'kimchi-vm', u'foobar') + u'kimchi-vm-new', u'foobar')
# suspend and resume the VM - info = inst.vm_lookup(u'kimchi-vm') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'shutoff') - self.assertRaises(InvalidOperation, inst.vm_suspend, u'kimchi-vm') - inst.vm_start(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_suspend, + u'kimchi-vm-new') + inst.vm_start(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - inst.vm_suspend(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'paused') - self.assertRaises(InvalidParameter, inst.vm_update, u'kimchi-vm', - {'name': 'foo'}) - inst.vm_resume(u'kimchi-vm') - info = inst.vm_lookup(u'kimchi-vm') + self.assertRaises(InvalidParameter, inst.vm_update, + u'kimchi-vm-new', {'name': 'foo'}) + inst.vm_resume(u'kimchi-vm-new') + info = inst.vm_lookup(u'kimchi-vm-new') self.assertEquals(info['state'], 'running') - self.assertRaises(InvalidOperation, inst.vm_resume, u'kimchi-vm') + self.assertRaises(InvalidOperation, inst.vm_resume, + u'kimchi-vm-new') # leave the VM suspended to make sure a paused VM can be # deleted correctly - inst.vm_suspend(u'kimchi-vm') + inst.vm_suspend(u'kimchi-vm-new')
vms = inst.vms_get_list() self.assertFalse('kimchi-vm' in vms)
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Hi Paulo, I will apply patches 1 and 3 by now. Thanks, Aline Manera On 05/12/2015 17:22, pvital@linux.vnet.ibm.com wrote:
From: Paulo Vital <pvital@linux.vnet.ibm.com>
This patchset fixes some Kimchi testcases were failling or finishing with errors in Fedora 23 host. There're 3 tests failling at this moment: 2 tests in test_edit_vm() and test_vlan_tag_bridge().
The solution for "Fix test_async_tasks testcase." depends on the WOK patch "Create utils method get_task_id()" to be applied before.
Paulo Vital (5): Fix range for network of NAT and isolated types. Fix test_image_based_template testcase. Fix test_async_tasks testcase. Fix test_vm_lifecycle testcase. fix 2 test_vm_lifecycle testcase
model/networks.py | 2 +- tests/test_model.py | 79 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 25 deletions(-)
participants (3)
-
Aline Manera
-
Paulo Ricardo Paz Vital
-
pvital@linux.vnet.ibm.com