test_vnf_alarm_respawn functional test is broken due to change to the Client interface

Bug #1844625 reported by Tushar Patil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-tackerclient
Fix Released
Undecided
Niraj Singh

Bug Description

Tacker functional test "test_vnf_alarm_respawn" is broken.

ft3.1: tacker.tests.functional.vnfm.test_tosca_vnf_alarm.VnfTestAlarmMonitor.test_vnf_alarm_respawn_StringException: Traceback (most recent call last):
  File "tacker/tests/functional/vnfm/test_tosca_vnf_alarm.py", line 134, in test_vnf_alarm_respawn
    'alarm and respawn-vnf')
  File "tacker/tests/functional/vnfm/test_tosca_vnf_alarm.py", line 83, in _test_vnf_tosca_alarm
    self.trigger_vnf(vnf_id, mon_policy_name, mon_policy_action)
  File "tacker/tests/functional/base.py", line 281, in trigger_vnf
    self.client.post('/vnfs/%s/triggers' % vnf, body)
AttributeError: 'Client' object has no attribute 'post'

Recently, client interface has been changed in patch [1].

class Client(ClientBase) has been changed to class Client(object) due to the introduction of VNF package support. As the endpoint URL syntax is different from the legacy one, facade design pattern was introduced which seems like broken.

In ClientBase class, post/delete/put/get/list methods are present but since Client is not inherited from ClientBase, it's giving an AttributeError error.

IMO, to support back compatibility with old client interface, we will need to add methods post/delete/put/get/list in Client class and call these methods using self.legacy_client.

Sample code:

diff --git a/tackerclient/v1_0/client.py b/tackerclient/v1_0/client.py
index 742184d..e007dfc 100644
--- a/tackerclient/v1_0/client.py
+++ b/tackerclient/v1_0/client.py
@@ -994,3 +994,9 @@ class Client(object):

     def delete_vnf_package(self, vnf_package):
         return self.vnf_package_client.delete_vnf_package(vnf_package)
+
+ def post(self, action, body=None, headers=None, params=None):
+ # Do not retry POST requests to avoid the orphan objects problem.
+ return self.legacy_client.do_request("POST", action, body=body,
+ headers=headers, params=params)
+

[1] : https://review.opendev.org/#/c/679956

Revision history for this message
Tushar Patil (tpatil) wrote :

Sample code shared in the description is incorrect.

I think it should be:-

diff --git a/tackerclient/v1_0/client.py b/tackerclient/v1_0/client.py
index 742184d..e007dfc 100644
--- a/tackerclient/v1_0/client.py
+++ b/tackerclient/v1_0/client.py
@@ -994,3 +994,9 @@ class Client(object):

     def delete_vnf_package(self, vnf_package):
         return self.vnf_package_client.delete_vnf_package(vnf_package)
+
+ def post(self, action, body=None, headers=None, params=None):
+ # Do not retry POST requests to avoid the orphan objects problem.
+ return self.legacy_client.post(action, body=body, headers=headers, params=params)
+

Changed in python-tackerclient:
assignee: nobody → Niraj Singh (nirajsingh)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-tackerclient (master)

Reviewed: https://review.opendev.org/683203
Committed: https://git.openstack.org/cgit/openstack/python-tackerclient/commit/?id=31b7690858913ab59e87ae837e45864f0610d600
Submitter: Zuul
Branch: master

commit 31b7690858913ab59e87ae837e45864f0610d600
Author: nirajsingh <email address hidden>
Date: Thu Sep 19 13:17:56 2019 +0000

    Add restFul methods to fix backward compatibility issue

    Tacker functional tests and applications using old version
    of tackerclient might be using post/get/delete/put/list
    method interfaces provided by Client in their applications.
    These interfaces were removed in the recent changes [1]
    because of which tacker tests are failing.

    Added post/delete/put/get/list methods back to the Client class.

    [1] : https://review.opendev.org/#/c/679956

    Closes-Bug: #1844625

    Change-Id: I803298dbc16dea9e58ec2a0a5fe3afe431c8532c

Changed in python-tackerclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-tackerclient (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/683831

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-tackerclient (stable/train)

Reviewed: https://review.opendev.org/683831
Committed: https://git.openstack.org/cgit/openstack/python-tackerclient/commit/?id=57692126a004315e5c09835fed24765d4ad7863a
Submitter: Zuul
Branch: stable/train

commit 57692126a004315e5c09835fed24765d4ad7863a
Author: nirajsingh <email address hidden>
Date: Thu Sep 19 13:17:56 2019 +0000

    Add restFul methods to fix backward compatibility issue

    Tacker functional tests and applications using old version
    of tackerclient might be using post/get/delete/put/list
    method interfaces provided by Client in their applications.
    These interfaces were removed in the recent changes [1]
    because of which tacker tests are failing.

    Added post/delete/put/get/list methods back to the Client class.

    [1] : https://review.opendev.org/#/c/679956

    Closes-Bug: #1844625

    Change-Id: I803298dbc16dea9e58ec2a0a5fe3afe431c8532c
    (cherry picked from commit 31b7690858913ab59e87ae837e45864f0610d600)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-tackerclient 0.16.1

This issue was fixed in the openstack/python-tackerclient 0.16.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-tackerclient 1.0.0

This issue was fixed in the openstack/python-tackerclient 1.0.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.