DESCRIPTION

CBQE:3685- Create a structure to encapsulate bucket creation params.
I changed cluster.py's create bucket commands to accept a dict. I also added a method inside cluster.py that takes in bucket parameters and returns a dict that contains those parameters. This dict is then passed to the create bucket commands which then passes those to the CreateBucketTask. Inside CreateBucketTask the dictionary is unpacked and the parameters are sent to the rest_client.create_bucket command. The rest of the changes are everywhere that the cluster create bucket commands are used. The conf file I changed was to fix the spelling of structure, I also fixed the affected tests method header to spell structure correctly. Finally I modified BaseTestCase to create dicts and then send them to the cluster create calls, essentially just modified BaseTestCase to work with the above changes.

UPDATE:in addition to the above changes I have refactored BaseTestCase to createa dictionary of default parameters for cluster to use.The dictionary contains keys to signify which type of bucket it is the default for.
	ex. self.base_params['sasl'] contains the sasl default params.
 I have also modified cluster's create bucket method headers again to take in a name parameter. Standard and memcached bucket creators also take in a port parameter.

UPDATE2: I made it so create_bucket_params is only in one place (cluster.py) and took out bucket_name from the bucket_params dict since it must always be unique. Otherwise minor code changes.

UPDATE3: Minor code changes, used copy.deepcopy() to create the temporary dict that is passed into bucket creation inside basetestcase. Bucket creation refactors will happen as apart of a different Jasmin Rangel push.

Change-Id: I8afc1753e3519b5692811c7a9c160530dc25c447


COMMENTS

author: Nico George
date: 2016-12-13 22:46:34.195000000

Patch Set 10: Code-Review-1

(8 comments)

Line:589, pytests/security/auditcli.py -> Here you have same code for if / else . Only difference is one parameter. Can you do like  if from_bucket:
                       tmp_server = self.master
                   else:
                       tmp_server = ...

Line:562, pytests/xdcr/xdcrbasetests.py -> See Here . If num_buckets are 10 you are calling the create_bucket_params 10 times.  I will say call it once before the loop and reuse it in the function

Line:50, pytests/sg/sgconfigtests.py -> why you call same function create_bucket_params thrice . All params are local variable . In create_bucket you are overwriting some values. So once will work.

Line:85, pytests/buckettests.py -> You already has created Three base_param configuration in basetest, can we reuse it here ?

Line:600, pytests/security/rbacclitests.py -> Here you have same code for if / else . Only difference is one parameter. Can you do like  if from_bucket:
                       tmp_server = self.master
                   else:
                       tmp_server = self.xdc

then call function once .

Line:102, pytests/backup/opsbeforebackup.py -> both of these functions has this common part , can we call it once ?  Using a small function .

Line:219, lib/tasks/task.py -> will it be is None ?

Line:221, lib/tasks/task.py -> bucket_params is local variable , do you need to set ? it will overwrite the variable you passed

-------------------------------------
author: Jakobe Johnson
date: 2016-12-13 23:34:22.105000000

Patch Set 10: Code-Review+1

(2 comments)

Added responses to sandip's comments

Line:219, lib/tasks/task.py -> If you trace bucket_priority when it is set to 'low' basetestcase will change it to None and pass it on, basically bucket_priority is either 3 or 8, if bucket_priority is none  then the threadsnumber gets set to 3 by default, otherwise it gets set to 8 here in task.

Edit: even if bucket_priority is set to low, if not using basetestcase it will recieve a high priority, will fix in the next patch set.

Line:221, lib/tasks/task.py -> you are right it is no longer needed, I did this in case we were going to change the rest api create call, but we decided against it. Will remove

-------------------------------------
