From e1b921999e767a3a7fa9e6c1050232c2a126f56b Mon Sep 17 00:00:00 2001 From: Roopak Parikh Date: Mon, 23 May 2016 23:25:47 -0700 Subject: [PATCH] Fix for IAAS-5476, update for instance lease Instance lease update failed, fixing the code to call the update lease of vm instead of tenant. Added a functional test to call PUT on instance as well. Ran the functional test --- mors/mors_wsgi.py | 2 +- test/test_api.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mors/mors_wsgi.py b/mors/mors_wsgi.py index 35a1ce5..9ffe460 100644 --- a/mors/mors_wsgi.py +++ b/mors/mors_wsgi.py @@ -109,7 +109,7 @@ def add_update_vm_lease(tenant_id, instance_id): if request.method == "POST": lease_manager.add_instance_lease(get_context(), tenant_id, lease_obj) else: - lease_manager.update_tenant_lease(get_context(), tenant_id, lease_obj) + lease_manager.update_instance_lease(get_context(), tenant_id, lease_obj) return jsonify({'success': True}), 200, {'ContentType': 'application/json'} diff --git a/test/test_api.py b/test/test_api.py index 7a76459..8bbce67 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -152,8 +152,25 @@ def test_get_instance(): logger.debug(r.text) assert_equal(r.status_code, 200) - @test(depends_on=[test_get_instance]) +def test_update_instance(): + expiry = datetime.utcnow() + expiry_str = datetime.strftime(expiry, DATE_FORMAT) + r = requests.put('http://127.0.0.1:' + port + '/v1/tenant/' + tenant_id1 + '/instance/' + instance_id1, + json={"instance_uuid": instance_id1, "expiry": expiry_str}, + headers=headers) + logger.debug(r.text) + assert_equal(r.status_code, 200) + +@test(depends_on=[test_update_instance]) +def test_get_instance2(): + r = requests.get('http://127.0.0.1:' + port + '/v1/tenant/' + tenant_id1 + '/instance/' + instance_id1, + headers=headers) + logger.debug(r.text) + assert_equal(r.status_code, 200) + + +@test(depends_on=[test_get_instance2]) def test_deleted_instance(): eventlet.greenthread.sleep(50) # The instance lease should be deleted by now