[openstack-dev] [qa][tempest] "kwargs" of service clients for POST/PUT methods

Ken'ichi Ohmichi ken1ohmichi at gmail.com
Wed Jul 8 03:27:10 UTC 2015


Hi tempest team,

We are working for refactoring service clients in tempest for
preparing to migrate them to tempest-lib, and I found an inconsistency
between them.
So I'd like to ask opinions for considering which is the best as
library methods.

On some methods, a caller can specify whole body for sending a request
to http POST/PUT methods.
But on the others a caller can specify only part of body.

For example, a caller can specify any parameters to
update_quota_class_set() like:

tempest/services/compute/json/quota_classes_client.py
 34     def update_quota_class_set(self, quota_class_id, **kwargs):
 35         """
 36         Updates the quota class's limits for one or more resources.
 37         """
 38         post_body = json.dumps({'quota_class_set': kwargs})
 39
 40         resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,
 41                               post_body)

but update_quota_set method has each argument and a caller cannot
specify the other parameters like:

tempest/services/compute/json/quotas_client.py
 44     def update_quota_set(self, tenant_id, user_id=None,
 45                          force=None, injected_file_content_bytes=None,
 46                          metadata_items=None, ram=None, floating_ips=None,
 47                          fixed_ips=None, key_pairs=None, instances=None,
 48                          security_group_rules=None, injected_files=None,
 49                          cores=None, injected_file_path_bytes=None,
 50                          security_groups=None):
 51         """
 52         Updates the tenant's quota limits for one or more resources
 53         """
 54         post_body = {}
 55
 56         if force is not None:
 57             post_body['force'] = force
 58
 59         if injected_file_content_bytes is not None:
 60             post_body['injected_file_content_bytes'] = \
 61                 injected_file_content_bytes
 [..]
 96         post_body = json.dumps({'quota_set': post_body})
 97
 98         if user_id:
 99             resp, body = self.put('os-quota-sets/%s?user_id=%s' %
100                                   (tenant_id, user_id), post_body)
101         else:
102             resp, body = self.put('os-quota-sets/%s' % tenant_id,
103                                   post_body)

By defining all parameters on each method like update_quota_set(), it
is easy to know what parameters are available from caller/programer
viewpoint.
So I feel the later seems easy to use them as library methods.
But as the demerit, a caller cannot specify *undefined" parameters for
fuzzing tests.
Nova v2.1 API should deny a request which includes undefined
parameters, and Tempest will be able to test the behavior if the
former style.
So this is my concern point now.

I tend to prefer the later(all parameters need to be defined on each
method) because that will be useful for callers as the above.
In addition, tempest-lib should be a library for implementing
integration tests, then fuzzing tests can be out of scope.
If fuzzing tests are necessary, we will be able to implement them with
RestClient of tempest-lib without service clients.

I am on between both now, and I'd like to get feedback about this
before changing them.
Any comments are welcome :)

Thanks
Ken ohmichi



More information about the OpenStack-dev mailing list