add tempest test to activate library policies
Test activating library policies in dsvm job. Helpful for testing contributions to policy library. Ideally the test would be done in local unit tests, but with the way policy creation works right now, a functioning datasource (eg. nova) is required. It may be helpful in the future to add a new way of validating library policies without the running datasource. Change-Id: I36d78a7f2764386a1fc251dedd4ecfa696000ec1
This commit is contained in:
parent
1335688b5f
commit
136315c7ed
|
@ -45,15 +45,23 @@ class PolicyClient(rest_client.RestClient):
|
|||
driver = '/v1/system/drivers'
|
||||
driver_path = '/v1/system/drivers/%s'
|
||||
|
||||
def _add_params_to_url(self, url, params):
|
||||
for key in params:
|
||||
url = url + '?{param_name}={param_value}'.format(
|
||||
param_name=key, param_value=params[key])
|
||||
return url
|
||||
|
||||
def _resp_helper(self, resp, body=None):
|
||||
if body:
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_policy(self, body):
|
||||
def create_policy(self, body, params=None):
|
||||
if params is None:
|
||||
params = {}
|
||||
body = json.dumps(body)
|
||||
resp, body = self.post(
|
||||
self.policy, body=body)
|
||||
self._add_params_to_url(self.policy, params), body=body)
|
||||
return self._resp_helper(resp, body)
|
||||
|
||||
def delete_policy(self, policy):
|
||||
|
|
|
@ -241,6 +241,26 @@ class TestPolicyLibraryBasicOps(manager_congress.ScenarioPolicyBase):
|
|||
self.assertNotIn(test_policy, new_state,
|
||||
'library policy delete not reflected in list results')
|
||||
|
||||
@decorators.attr(type='smoke')
|
||||
def test_create_library_policies(self):
|
||||
'''test the library policies by loading into policy engine'''
|
||||
|
||||
# list library policies (by name) to skip in this test, perhaps
|
||||
# because it depends on datasources not available in gate
|
||||
skip_names_list = []
|
||||
|
||||
response = self.admin_manager.congress_client.list_library_policy()
|
||||
library_policies = response['results']
|
||||
|
||||
for library_policy in library_policies:
|
||||
if library_policy['name'] not in skip_names_list:
|
||||
resp = self.admin_manager.congress_client.create_policy(
|
||||
body=None, params={'library_policy': library_policy['id']})
|
||||
self.assertEqual(resp.response['status'], '201',
|
||||
'Policy activation failed')
|
||||
self.addCleanup(self.os_admin.congress_client.delete_policy,
|
||||
resp['id'])
|
||||
|
||||
|
||||
class TestCongressDataSources(manager_congress.ScenarioPolicyBase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue