Exemple #1
0
 def test_only_service_in_zomsrc_ns(self):
     '''
     Description: Test to validate only userC can create and delete service in zomsrc namespace
      Test steps:
             1. Create stackrc_dict for userC
             2. Create the resource expectation list
             3. Perform create and delete operations in default namespace and zomsrc namespace
      Pass criteria: userC must only be able to create and delete service in zomsrc namespace and nothing else
      Maintainer : [email protected]
     '''
     stackrc_dict = {
         'user_name': 'userC',
         'password': '******',
         'project_name': 'userC_project',
         'domain_name': 'userC_domain',
         'auth_url': self.__class__.admin.auth_url
     }
     resource_expectation = {'service': True}
     ResourceUtil.perform_operations(
         stackrc_dict=stackrc_dict,
         resource_expectation=resource_expectation,
         inputs=self.inputs)
     ResourceUtil.perform_operations(
         stackrc_dict=stackrc_dict,
         resource_expectation=resource_expectation,
         namespace='zomsrc',
         inputs=self.inputs)
Exemple #2
0
 def test_only_pods_deployments_services_in_easy_ns(self):
     '''
     For userD user, any operation on pods, deployments and services but only in easy namespace
     Description: Test to validate only userD can perform any operation on pods, deployments and services but only in easy namespace
      Test steps:
             1. Create stackrc_dict for userD
             2. Create the resource expectation list
             3. Perform create and delete operations in default namespace and easy_ns namespace
      Pass criteria: userD must only be able to perform any operation on pods, deployments and services in easy namespace and nothing else
      Maintainer : [email protected]
     '''
     stackrc_dict = {
         'user_name': 'userD',
         'password': '******',
         'project_name': 'userD_project',
         'domain_name': 'userD_domain',
         'auth_url': self.__class__.admin.auth_url
     }
     resource_expectation = {
         'pod': True,
         'deployment': True,
         'service': True,
         'namespace': True
     }
     ResourceUtil.perform_operations(
         resource_expectation=resource_expectation,
         stackrc_dict=stackrc_dict,
         inputs=self.inputs)
     ResourceUtil.perform_operations(
         stackrc_dict=stackrc_dict,
         resource_expectation=resource_expectation,
         namespace='easy',
         inputs=self.inputs)
Exemple #3
0
 def test_pod_with_agent_restart(self):
     '''
     Description: Test to validate only pod operations after vrouter agent restart for custom user
      Test steps:
             1. Create stackrc_dict for custom user
             2. Set the resource expectation list to only pods
             3. Perform create and delete operations on all resources
             4. Restart vrouter agent
             5. Perform create and delete operations on all resources again
      Pass criteria: Even after vrouter agent restart, custom user must be able to perform all operations only on pod resource successfully
      Maintainer : [email protected]
     '''
     ResourceUtil.create_policy_and_perform_operations(
         resource=TestRestartWithPodResource.resource,
         match=self.match,
         stackrc_dict=self.stackrc_dict,
         resource_expectation=TestRestartWithPodResource.
         resource_expectation,
         inputs=self.inputs)
     self.restart_vrouter_agent()
     ResourceUtil.create_policy_and_perform_operations(
         resource=TestRestartWithPodResource.resource,
         match=self.match,
         stackrc_dict=self.stackrc_dict,
         resource_expectation=TestRestartWithPodResource.
         resource_expectation,
         inputs=self.inputs)
Exemple #4
0
 def parallel_cleanup(self):
     cmds = ['kubectl config use-context juju-context']
     for resource in TestK8sResource.resource_expectation:
         template_file = ResourceUtil.templates[resource]
         cmd = 'kubectl delete -f %s -n default' % template_file
         cmds.append(cmd)
     ResourceUtil.execute_cmds_on_remote(ip=self.inputs.juju_server,
                                         cmd_list=cmds)
Exemple #5
0
 def test_all_in_admin_project(self):
     '''
     Description: Test to validate admin user can perform all operations
      Test steps:
             1. Create stackrc_dict for admin user
             2. Set the resource expectation list to all k8s resources
             3. Perform create and delete operations
      Pass criteria: admin user must be able to perform all operations successfully
      Maintainer : [email protected]
     '''
     self.stackrc_dict = ResourceUtil.admin_stackrc()
     ResourceUtil.create_policy_and_perform_operations(
         resource_expectation=TestK8sResource.resource_expectation,
         stackrc_dict=self.stackrc_dict,
         inputs=self.inputs)
Exemple #6
0
 def test_all_in_custom_project(self):
     '''
     Description: Test to validate custom user can perform all operations
      Test steps:
             1. Create stackrc_dict and get Openstack match object for custom user
             2. Set the resource expectation list to all k8s resources
             3. Perform create and delete operations
      Pass criteria: custom user must be able to perform all operations successfully
      Maintainer : [email protected]
     '''
     match, self.stackrc_dict = ResourceUtil.get_custom_match_stackrc()
     ResourceUtil.create_policy_and_perform_operations(
         match=match,
         resource_expectation=TestK8sResource.resource_expectation,
         stackrc_dict=self.stackrc_dict,
         inputs=self.inputs)
Exemple #7
0
    def test_pod_in_custom_project(self):
        '''
        Description: Test to validate custom user can perform all operations only on pod resource
         Test steps:
                1. Set resource to only pods
                2. Set the resource expectation list to only pod
                3. Perform create and delete operations on all resources
         Pass criteria: custom user must be able to perform all operations only on pod resource successfully
         Maintainer : [email protected]
        '''
        resource = {'resources': ['pods']}
        resource_expectation = {'pod': True}

        ResourceUtil.create_policy_and_perform_operations(
            resource=resource,
            match=self.match,
            stackrc_dict=self.stackrc_dict,
            resource_expectation=resource_expectation,
            inputs=self.inputs)
Exemple #8
0
 def test_only_pods_and_deployments_create(self):
     '''
     Description: Test to validate only userA can create pods and deployments
      Test steps:
             1. Create stackrc_dict for userA
             2. Create the resource expectation list
             3. Perform create and delete operations
      Pass criteria: userA must only be able to create pods and deployments and nothing else
      Maintainer : [email protected]
     '''
     stackrc_dict = {
         'user_name': 'userA',
         'password': '******',
         'project_name': 'userA_project',
         'domain_name': 'userA_domain',
         'auth_url': self.__class__.admin.auth_url
     }
     resource_expectation = {'pod': True, 'deployment': True}
     ResourceUtil.perform_operations(
         stackrc_dict=stackrc_dict,
         resource_expectation=resource_expectation,
         inputs=self.inputs)
Exemple #9
0
 def test_admin_project_with_agent_restart(self):
     '''
     Description: Test to validate normal operations after vrouter agent restart
      Test steps:
             1. Create stackrc_dict for admin user
             2. Set the resource expectation list to all k8s resources
             3. Perform create and delete operations
             4. Restart vrouter agent
             5. Perform create and delete operations again
      Pass criteria: Even after vrouter agent restart, admin user must be able to perform all operations successfully
      Maintainer : [email protected]
     '''
     stackrc_dict = ResourceUtil.admin_stackrc()
     ResourceUtil.create_policy_and_perform_operations(
         resource_expectation=TestRestart.resource_expectation,
         stackrc_dict=stackrc_dict,
         inputs=self.inputs)
     self.restart_vrouter_agent()
     ResourceUtil.create_policy_and_perform_operations(
         resource_expectation=TestRestart.resource_expectation,
         stackrc_dict=stackrc_dict,
         inputs=self.inputs)
Exemple #10
0
 def test_custom_project_with_kube_manager_restart(self):
     '''
     Description: Test to validate normal operations after kube manager restart for custom user
      Test steps:
             1. Create stackrc_dict for custom user
             2. Set the resource expectation list to all k8s resources
             3. Perform create and delete operations
             4. Restart kube manager
             5. Perform create and delete operations again
      Pass criteria: Even after kube manager restart, custom user must be able to perform all operations successfully
      Maintainer : [email protected]
     '''
     match, stackrc_dict = ResourceUtil.get_custom_match_stackrc()
     ResourceUtil.create_policy_and_perform_operations(
         match=match,
         resource_expectation=TestRestart.resource_expectation,
         stackrc_dict=stackrc_dict,
         inputs=self.inputs)
     self.restart_kube_manager()
     ResourceUtil.create_policy_and_perform_operations(
         match=match,
         resource_expectation=TestRestart.resource_expectation,
         stackrc_dict=stackrc_dict,
         inputs=self.inputs)
Exemple #11
0
 def setUp(self):
     super(TestRestartWithPodResource, self).setUp()
     self.match, self.stackrc_dict = ResourceUtil.get_custom_match_stackrc(
         rand=True)
Exemple #12
0
 def setUp(self):
     super(TestK8sResourceCustom, self).setUp()
     self.match, self.stackrc_dict = ResourceUtil.get_custom_match_stackrc(
         rand=True)