[Kimchi-devel] [PATCH 2/5] Granular task queries test updates

Royce Lv lvroyce at linux.vnet.ibm.com
Tue Mar 3 08:34:42 UTC 2015


Reviewed-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
On 02/27/2015 10:41 AM, Christy Perez wrote:
> Signed-off-by: Christy Perez <christy at linux.vnet.ibm.com>
> ---
>   src/kimchi/mockmodel.py |  7 ++++---
>   tests/test_mockmodel.py |  3 ++-
>   tests/test_model.py     |  8 ++++----
>   tests/test_rest.py      | 11 ++++++-----
>   4 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
> index 413ac5d..d49fd0a 100644
> --- a/src/kimchi/mockmodel.py
> +++ b/src/kimchi/mockmodel.py
> @@ -244,7 +244,7 @@ def _get_volume_path(self, pool, vol):
>           return MockModel._libvirt_get_vol_path(pool, vol)
>
>       def _gen_debugreport_file(self, name):
> -        return add_task('/debugreports/%s' % name, self._create_log,
> +        return add_task('/debugreports/%s' % name, 'create', self._create_log,
>                           self.objstore, name)
>
>       def _create_log(self, cb, name):
> @@ -333,7 +333,8 @@ def _mock_packageupdate_lookup(self, pkg_name):
>           return self._mock_swupdate.pkgs[pkg_name]
>
>       def _mock_host_swupdate(self, args=None):
> -        task_id = add_task('/host/swupdate', self._mock_swupdate.doUpdate,
> +        task_id = add_task('/host/swupdate', 'update',
> +                           self._mock_swupdate.doUpdate,
>                              self.objstore)
>           return self.task_lookup(task_id)
>
> @@ -385,7 +386,7 @@ def _mock_vm_clone(self, name):
>       def _mock_vmsnapshots_create(self, vm_name, params):
>           name = params.get('name', unicode(int(time.time())))
>           params = {'vm_name': vm_name, 'name': name}
> -        taskid = add_task(u'/vms/%s/snapshots/%s' % (vm_name, name),
> +        taskid = add_task(u'/vms/%s/snapshots/%s' % (vm_name, name), 'create',
>                             self._vmsnapshots_create_task, self.objstore, params)
>           return self.task_lookup(taskid)
>
> diff --git a/tests/test_mockmodel.py b/tests/test_mockmodel.py
> index 29354aa..9fca012 100644
> --- a/tests/test_mockmodel.py
> +++ b/tests/test_mockmodel.py
> @@ -245,6 +245,7 @@ def test_packages_update(self):
>               self.assertIn('version', pkgupdate.keys())
>
>           task = model.host_swupdate()
> -        task_params = [u'id', u'message', u'status', u'target_uri']
> +        task_params = [u'description', u'id', u'message', u'status',
> +                       u'target_uri']
>           self.assertEquals(sorted(task_params), sorted(task.keys()))
>           wait_task(model.task_lookup, task['id'])
> diff --git a/tests/test_model.py b/tests/test_model.py
> index f80f1c9..1045f2d 100644
> --- a/tests/test_model.py
> +++ b/tests/test_model.py
> @@ -1053,13 +1053,13 @@ def continuous_ops(cb, params):
>
>           inst = model.Model('test:///default',
>                              objstore_loc=self.tmp_store)
> -        taskid = add_task('', quick_op, inst.objstore, 'Hello')
> +        taskid = add_task('', 'test', quick_op, inst.objstore, 'Hello')
>           inst.task_wait(taskid)
>           self.assertEquals(1, taskid)
>           self.assertEquals('finished', inst.task_lookup(taskid)['status'])
>           self.assertEquals('Hello', inst.task_lookup(taskid)['message'])
>
> -        taskid = add_task('', long_op, inst.objstore,
> +        taskid = add_task('', 'test', long_op, inst.objstore,
>                             {'delay': 3, 'result': False,
>                              'message': 'It was not meant to be'})
>           self.assertEquals(2, taskid)
> @@ -1069,13 +1069,13 @@ def continuous_ops(cb, params):
>           self.assertEquals('failed', inst.task_lookup(taskid)['status'])
>           self.assertEquals('It was not meant to be',
>                             inst.task_lookup(taskid)['message'])
> -        taskid = add_task('', abnormal_op, inst.objstore, {})
> +        taskid = add_task('', 'test', abnormal_op, inst.objstore, {})
>           inst.task_wait(taskid)
>           self.assertEquals('Exception raised',
>                             inst.task_lookup(taskid)['message'])
>           self.assertEquals('failed', inst.task_lookup(taskid)['status'])
>
> -        taskid = add_task('', continuous_ops, inst.objstore,
> +        taskid = add_task('', 'test', continuous_ops, inst.objstore,
>                             {'result': True})
>           self.assertEquals('running', inst.task_lookup(taskid)['status'])
>           inst.task_wait(taskid, timeout=10)
> diff --git a/tests/test_rest.py b/tests/test_rest.py
> index 812afb7..cb1ea7c 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -1370,9 +1370,9 @@ def _task_lookup(self, taskid):
>           return json.loads(self.request('/tasks/%s' % taskid).read())
>
>       def test_tasks(self):
> -        id1 = add_task('/tasks/1', self._async_op, model.objstore)
> -        id2 = add_task('/tasks/2', self._except_op, model.objstore)
> -        id3 = add_task('/tasks/3', self._intermid_op, model.objstore)
> +        id1 = add_task('/tasks/1', 'test', self._async_op, model.objstore)
> +        id2 = add_task('/tasks/2', 'test', self._except_op, model.objstore)
> +        id3 = add_task('/tasks/3', 'test', self._intermid_op, model.objstore)
>
>           target_uri = urllib2.quote('^/tasks/*', safe="")
>           filter_data = 'status=running&target_uri=%s' % target_uri
> @@ -1384,7 +1384,7 @@ def test_tasks(self):
>           self.assertEquals(set([id1, id2, id3]) - set(tasks_ids), set([]))
>           wait_task(self._task_lookup, id2)
>           foo2 = json.loads(self.request('/tasks/%s' % id2).read())
> -        keys = ['id', 'status', 'message', 'target_uri']
> +        keys = ['id', 'status', 'message', 'target_uri', 'description']
>           self.assertEquals(sorted(keys), sorted(foo2.keys()))
>           self.assertEquals('failed', foo2['status'])
>           wait_task(self._task_lookup, id3)
> @@ -1628,7 +1628,8 @@ def test_packages_update(self):
>
>           resp = self.request('/host/swupdate', '{}', 'POST')
>           task = json.loads(resp.read())
> -        task_params = [u'id', u'message', u'status', u'target_uri']
> +        task_params = [u'id', u'message', u'status', u'target_uri',
> +                       u'description']
>           self.assertEquals(sorted(task_params), sorted(task.keys()))
>
>           resp = self.request('/tasks/' + task[u'id'], None, 'GET')




More information about the Kimchi-devel mailing list