diff --git a/common/connections.py b/common/connections.py index 24de7c588..4eb17172a 100755 --- a/common/connections.py +++ b/common/connections.py @@ -98,16 +98,12 @@ def get_auth_h(self, refresh=False, project_name=None, project_name, self.inputs) return env[attr] - def get_vnc_lib_h(self, refresh=False, project_name=None, - username=None, password=None): - project_name = project_name or self.project_name - username = username or self.username - password = password or self.password - attr = '_vnc_lib_'+project_name+'_'+username + def get_vnc_lib_h(self, refresh=False): + attr = '_vnc_lib_' + self.project_name + '_' + self.username if not getattr(env, attr, None) or refresh: self.vnc_lib_fixture = VncLibFixture( - username=username, password=password, - domain=self.domain_name, project_name=project_name, + username=self.username, password=self.password, + domain=self.domain_name, project_name=self.project_name, inputs = self.inputs, cfgm_ip=self.inputs.cfgm_ip, api_server_port=self.inputs.api_server_port, diff --git a/common/contrail_test_init.py b/common/contrail_test_init.py index a16b2e6a1..0ae2458ba 100755 --- a/common/contrail_test_init.py +++ b/common/contrail_test_init.py @@ -73,26 +73,47 @@ def __init__(self, ini_file=None): 'Basic', 'provFile', None) self.key = read_config_option(self.config, 'Basic', 'key', 'key1') + + self.tenant_isolation = read_config_option(self.config, + 'Basic', + 'tenant_isolation', + True) + # Read admin credentials if any + + self.admin_username = read_config_option(self.config, + 'Basic', + 'adminUser', + os.getenv('OS_USERNAME', None)) + self.admin_password = read_config_option(self.config, + 'Basic', + 'adminPassword', + os.getenv('OS_PASSWORD', None)) + self.admin_tenant = read_config_option(self.config, + 'Basic', + 'adminTenant', + os.getenv('OS_TENANT_NAME', None)) + self.stack_user = read_config_option( self.config, 'Basic', 'stackUser', - os.getenv('OS_USERNAME', 'admin')) + self.admin_username) self.stack_password = read_config_option( self.config, 'Basic', 'stackPassword', - os.getenv('OS_PASSWORD', 'contrail123')) + self.admin_password) self.stack_tenant = read_config_option( self.config, 'Basic', 'stackTenant', - os.getenv('OS_TENANT_NAME', 'admin')) + self.admin_tenant) self.stack_domain = read_config_option( self.config, 'Basic', 'stackDomain', os.getenv('OS_DOMAIN_NAME', 'default-domain')) + self.endpoint_type = read_config_option( self.config, 'Basic', diff --git a/common/create_public_vn.py b/common/create_public_vn.py index 2c938deef..3473928ef 100644 --- a/common/create_public_vn.py +++ b/common/create_public_vn.py @@ -15,16 +15,16 @@ class PublicVn(fixtures.Fixture): __metaclass__ = Singleton - def __init__(self, user, password, inputs, ini_file = None ,logger = None, mx_rt = None): + def __init__(self, isolated_creds_obj, inputs, ini_file = None ,logger = None, mx_rt = None): -# self.project_name = project_name - self.user_name = user - self.password = password + self.isolated_creds = isolated_creds_obj + self.username = self.isolated_creds.username + self.password = self.isolated_creds.password self.inputs = inputs self.ini_file = ini_file self.logger = logger self.public_vn = self.inputs.public_vn - self.public_tenant = self.inputs.public_tenant + self.public_tenant = self.inputs.admin_tenant self.setUp() self.create_public_vn(mx_rt) self.create_floatingip_pool() @@ -32,19 +32,20 @@ def __init__(self, user, password, inputs, ini_file = None ,logger = None, mx_rt def setUp(self): super(PublicVn, self).setUp() - self.isolated_creds = isolated_creds.IsolatedCreds(self.public_tenant, \ - self.inputs, ini_file = self.ini_file, \ - logger = self.logger, - username=self.user_name, - password=self.password) - self.isolated_creds.setUp() - self.project = self.isolated_creds.create_tenant() - self.isolated_creds.create_and_attach_user_to_tenant() - self.inputs = self.isolated_creds.get_inputs() - self.connections = self.isolated_creds.get_conections() - self.isolated_creds.create_and_attach_user_to_tenant(self.user_name,self.password) - self.project.set_sec_group_for_allow_all(\ - self.public_tenant, 'default') + self.project = self.isolated_creds.create_tenant(self.public_tenant) + self.inputs = self.isolated_creds.get_inputs(self.project) + self.connections = self.isolated_creds.get_connections(self.inputs) + if self.isolated_creds.__class__.__name__ == 'AdminIsolatedCreds': + # If AdminIsolatedCreds, one could add user to tenant + # Else, it is assumed that the administrator has taken + # care + self.isolated_creds.create_and_attach_user_to_tenant( + self.project, + self.username, + self.password) + self.project.set_sec_group_for_allow_all(\ + self.public_tenant, 'default') + # end setUp def create_public_vn(self,mx_rt = None): if (('MX_GW_TEST' in os.environ) and ( diff --git a/common/isolated_creds.py b/common/isolated_creds.py index 79e85513e..6df071f02 100644 --- a/common/isolated_creds.py +++ b/common/isolated_creds.py @@ -7,128 +7,173 @@ import time from tcutils.util import get_random_name -ADMIN_TENANT = 'admin' + + class IsolatedCreds(fixtures.Fixture): - def __init__(self,project_name, inputs, ini_file=None, logger=None, + def __init__(self, inputs, project_name=None, ini_file=None, logger=None, username=None, password=None): + self.username = None + self.password = None self.inputs = inputs - self.admin_tenant = self.inputs.stack_tenant - if (self.inputs.public_tenant == project_name): - self.project_name = project_name - else: - self.project_name = get_random_name(project_name) - if username: - self.user = username - else: - self.user = project_name - if password: - self.password = password - else: + + if inputs.tenant_isolation: + self.project_name = get_random_name(project_name) + self.username = project_name self.password = project_name + else : + self.project_name = project_name or inputs.stack_tenant + self.username = username or inputs.stack_user + self.password = password or inputs.stack_password + self.ini_file = ini_file self.logger = logger if self.inputs.orchestrator == 'vcenter': self.project_name = self.inputs.stack_tenant - self.user = self.inputs.stack_user + self.username = self.inputs.stack_user self.password = self.inputs.stack_password + # end __init__ def setUp(self): super(IsolatedCreds, self).setUp() - self.connections= ContrailConnections(self.inputs, self.logger) + self.connections= ContrailConnections(self.inputs, self.logger, + username=self.username, + password=self.password, + project_name=self.project_name) self.vnc_lib= self.connections.vnc_lib self.auth = self.connections.auth - def create_tenant(self): + def use_tenant(self, project_fixture): + self.project = project_fixture - self.project = None - time.sleep(4) + def create_tenant(self, project_name): + ''' Get a Project. Returns instance of ProjectFixture + Creates the project if not found + ''' + project = None try: - self.project = project_test.ProjectFixture(project_name = self.project_name, auth=self.auth, - vnc_lib_h= self.vnc_lib,username= self.user,password= self.password, - connections= self.connections) - self.project.setUp() + project = project_test.ProjectFixture( + project_name = project_name, + auth=self.auth, + vnc_lib_h= self.vnc_lib, + username= self.username, + password= self.password, + connections= self.connections) + project.setUp() except Exception as e: - self.logger.warn("got exception as %s"%(e)) + self.logger.exception("Exception while creating project") finally: - return self.project - - def delete_tenant(self): + return project + # end create_tenant - self.project.cleanUp() + def delete_tenant(self, project_fixture): + project_fixture.cleanUp() - def delete_user(self,user=None): - if self.inputs.orchestrator == 'vcenter': - return - if user: - user = user - else: - user = self.user - self.auth.delete_user(user) - - def create_and_attach_user_to_tenant(self,user = None , password=None): - if self.inputs.orchestrator == 'vcenter': - return - user = user if user else self.user - password = password if password else self.password - self.auth.create_user(user,password) - self.auth.add_user_to_project(user, self.project_name) - self.auth.add_user_to_project('admin', self.project_name) - time.sleep(4) - - def get_inputs(self): - - self.project_inputs= ContrailTestInit(self.ini_file, - stack_user=self.project.username, - stack_password=self.project.password, + def get_inputs(self, project_fixture): + project_inputs= ContrailTestInit(self.ini_file, + stack_user=project_fixture.username, + stack_password=project_fixture.password, project_fq_name=['default-domain',self.project_name],logger = self.logger) - return self.project_inputs - - def get_conections(self): - self.project_connections= ContrailConnections(self.project_inputs, - project_name= self.project_name, - username=self.project.username, - password= self.project.password, - logger = self.logger) + return project_inputs + + def get_connections(self, project_inputs): + self.project_connections= ContrailConnections(project_inputs, + project_name=self.project_name, + username=self.username, + password=self.password, + logger=self.logger) return self.project_connections - def get_admin_inputs(self): - - admin = AdminCreds(self.admin_tenant , self.inputs , self.ini_file , self.logger) - return admin.get_inputs() - - def get_admin_connections(self): - - admin = AdminCreds(self.admin_tenant , self.inputs , self.ini_file , self.logger) - return admin.get_conections() - def cleanUp(self): super(IsolatedCreds, self).cleanUp() -class AdminCreds(fixtures.Fixture): - - def __init__(self,project_name,inputs,ini_file = None ,logger = None): +# end IsolatedCreds - self.project_name = project_name - self.user = project_name - self.password = project_name +class AdminIsolatedCreds(fixtures.Fixture): + def __init__(self, inputs, admin_project_name=None, ini_file=None, logger=None, + username=None, password=None): + self.project_name = admin_project_name or inputs.admin_tenant + self.username = username or inputs.admin_username + self.password = password or inputs.admin_password self.inputs = inputs + self.ini_file = ini_file self.logger = logger + if self.inputs.orchestrator == 'vcenter': + self.project_name = self.inputs.stack_tenant + self.username = self.inputs.stack_user + self.password = self.inputs.stack_password - def get_inputs(self): - - return self.inputs - - def get_conections(self): - - connections= ContrailConnections(self.inputs,project_name= self.project_name, - username=self.inputs.stack_user - ,password= self.inputs.stack_password, - logger = self.logger) - return connections - - def cleanUp(self): - super(AdminCreds, self).cleanUp() + # end __init__ + + def setUp(self): + self.connections = ContrailConnections(self.inputs, self.logger, + project_name=self.project_name, + username=self.username, + password=self.password) + self.vnc_lib = self.connections.vnc_lib + self.auth = self.connections.auth + + def delete_user(self, user): + if self.inputs.orchestrator == 'vcenter': + return + self.auth.delete_user(user) + # end delete_user + + def create_and_attach_user_to_tenant(self, project_fixture, + username, password): + project_fixture.set_user_creds(username, password) + project_name = project_fixture.project_name + if self.inputs.orchestrator == 'vcenter': + return + if self.inputs.tenant_isolation: + self.auth.create_user(username, password) + self.auth.add_user_to_project(username, project_name) + if self.inputs.admin_username: + self.auth.add_user_to_project(self.inputs.admin_username, project_name) + # end create_and_attach_user_to_tenant + + def use_tenant(self, project_fixture): + self.project = project_fixture + + def create_tenant(self, project_name): + ''' Get a Project. Returns instance of ProjectFixture + Creates the project if not found + ''' + + project = None + try: + project = project_test.ProjectFixture( + project_name = project_name, + auth=self.auth, + vnc_lib_h= self.vnc_lib, + username= self.username, + password= self.password, + connections= self.connections) + project.setUp() + except Exception as e: + self.logger.exception("Exception while creating project") + finally: + return project + # end create_tenant + + def delete_tenant(self, project_fixture): + project_fixture.cleanUp() + + def get_inputs(self, project_fixture): + project_inputs= ContrailTestInit(self.ini_file, + stack_user=project_fixture.username, + stack_password=project_fixture.password, + project_fq_name=['default-domain',self.project_name],logger = self.logger) + return project_inputs + + def get_connections(self, project_inputs): + self.project_connections= ContrailConnections(project_inputs, + project_name=self.project_name, + username=self.username, + password=self.password, + logger=self.logger) + return self.project_connections +# end AdminIsolatedCreds diff --git a/common/neutron/base.py b/common/neutron/base.py index e9a321cbd..d5fbb3b66 100644 --- a/common/neutron/base.py +++ b/common/neutron/base.py @@ -1,5 +1,5 @@ import time -import test +import test_v1 from netaddr import * from common.connections import ContrailConnections @@ -22,24 +22,12 @@ contrail_api_conf = '/etc/contrail/contrail-api.conf' -class BaseNeutronTest(test.BaseTestCase): +class BaseNeutronTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): + cls.public_vn_obj = None super(BaseNeutronTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -47,9 +35,13 @@ def setUpClass(cls): cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj cls.api_s_inspect = cls.connections.api_server_inspect + + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.__name__, - cls.__name__, + public_creds, cls.inputs, ini_file=cls.ini_file, logger=cls.logger) @@ -57,7 +49,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(BaseNeutronTest, cls).tearDownClass() # end tearDownClass diff --git a/common/openstack_libs.py b/common/openstack_libs.py index fd233a2a3..fcc87fe4a 100644 --- a/common/openstack_libs.py +++ b/common/openstack_libs.py @@ -59,3 +59,8 @@ except: ceilo_client = None +try: + from glanceclient import Client as glance_client +except: + glance_client = None + diff --git a/fixtures/ipam_test.py b/fixtures/ipam_test.py index faabae132..d9e65c3fc 100644 --- a/fixtures/ipam_test.py +++ b/fixtures/ipam_test.py @@ -17,7 +17,7 @@ class IPAMFixture(fixtures.Fixture): def __init__(self, name=None, connections=None, project_obj=None, ipamtype=IpamType("dhcp"), vdns_obj=None, uuid=None): self.name = name - self.connections = connections or project_obj.connections + self.connections = connections or project_obj.get_project_connections() self.inputs = self.connections.inputs self.logger = self.connections.logger self.api_s_inspect = self.connections.api_server_inspect diff --git a/fixtures/nova_test.py b/fixtures/nova_test.py index ad937fd07..822d834c0 100644 --- a/fixtures/nova_test.py +++ b/fixtures/nova_test.py @@ -75,6 +75,7 @@ def _connect_to_openstack(self): self.zones = self._list_zones() self.hosts_list = [] self.hosts_dict = self._list_hosts() + # end setUp def get_hosts(self, zone=None): @@ -691,6 +692,8 @@ def get_vm_console_output(self, vm_obj): def get_vm_in_nova_db(self, vm_obj, node_ip): + if not self.inputs.get_mysql_token(): + return None issue_cmd = 'mysql -u root --password=%s -e \'use nova; select vm_state, uuid, task_state from instances where uuid=\"%s\" ; \' ' % ( self.inputs.get_mysql_token(), vm_obj.id) username = self.inputs.host_data[node_ip]['username'] @@ -702,6 +705,8 @@ def get_vm_in_nova_db(self, vm_obj, node_ip): @retry(tries=10, delay=5) def is_vm_deleted_in_nova_db(self, vm_obj, node_ip): + if not self.inputs.get_mysql_token(): + return True output = self.get_vm_in_nova_db(vm_obj, node_ip) if 'deleted' in output and 'NULL' in output: self.logger.info('VM %s is removed in Nova DB' % (vm_obj.name)) diff --git a/fixtures/project_test.py b/fixtures/project_test.py index 66886dd65..0733b7607 100644 --- a/fixtures/project_test.py +++ b/fixtures/project_test.py @@ -47,6 +47,8 @@ def __init__(self, vnc_lib_h, connections, auth=None, project_name=None, self.auth = VcenterAuth(self.inputs.stack_user, self.inputs.stack_password, self.inputs.project_name, self.inputs) + self.project_username = None + self.project_user_password = None # end __init__ def read(self): @@ -149,8 +151,9 @@ def check_no_project_references(self): # end check_no_project_references def get_project_connections(self, username=None, password=None): - username = username or self.username or self.inputs.stack_user - password = password or self.password or self.inputs.stack_password + username = username or self.project_username or self.inputs.stack_user + password = password or self.project_user_password or \ + self.inputs.stack_password if not self.project_connections: self.project_connections = ContrailConnections( inputs=self.inputs, @@ -282,4 +285,11 @@ def verify_on_cleanup(self): self.project_name)) return result # end verify_on_cleanup + + def set_user_creds(self, username, password): + '''Set a user,password who is allowed to login to this project + ''' + self.project_username = username + self.project_user_password = password + # end set_user_creds # end ProjectFixture diff --git a/fixtures/vm_test.py b/fixtures/vm_test.py index 3d684007c..4a189edc6 100644 --- a/fixtures/vm_test.py +++ b/fixtures/vm_test.py @@ -1725,6 +1725,8 @@ def verify_vm_not_in_nova(self): self.verify_vm_not_in_nova_flag = True # In environments which does not have mysql token file, skip the check if not self.inputs.get_mysql_token(): + self.logger.debug('Skipping check for VM %s deletion in nova db' + 'since mysql_token is not available' % (self.vm_name)) return result for vm_obj in self.vm_objs: result = result and self.orch.is_vm_deleted(vm_obj) diff --git a/sanity_params.ini.sample b/sanity_params.ini.sample index 13f9b8f96..8d9cda5ca 100755 --- a/sanity_params.ini.sample +++ b/sanity_params.ini.sample @@ -10,12 +10,22 @@ provFile=$__testbed_json_file__ # Nova Keypair key=$__nova_keypair_name__ -# Admin tenant credentials +# Tenant credentials when tests are to be run in a +# specific tenant only stackUser=$__stack_user__ stackPassword=$__stack_password__ stackTenant=$__stack_tenant__ stackDomain=$__stack_domain__ +# Set tenant_isolation to true to Let the tests +# create and destroy projects/tenants +# Setting this to true requires that admin credentials below are populated +tenant_isolation=$__tenant_isolation__ +adminUser=$__admin_user__ +adminPassword=$__admin_password__ +adminTenant=$__admin_tenant__ + + # Keystone IP can be VIP ip if HA setup auth_ip=$__auth_ip__ auth_port=$__auth_port__ diff --git a/scripts/analytics/base.py b/scripts/analytics/base.py index d4a2e7a46..65daaa07b 100644 --- a/scripts/analytics/base.py +++ b/scripts/analytics/base.py @@ -1,20 +1,14 @@ -import test +import test_v1 from common import isolated_creds from vn_test import * from vm_test import * import fixtures -class AnalyticsBaseTest(test.BaseTestCase): +class AnalyticsBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(AnalyticsBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, cls.inputs, ini_file = cls.ini_file, logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.orch = cls.connections.orch cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h @@ -29,7 +23,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.res.cleanUp() - cls.isolated_creds.delete_tenant() super(AnalyticsBaseTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/ceilometer_tests/base.py b/scripts/ceilometer_tests/base.py index 185eb6f65..c80e61751 100644 --- a/scripts/ceilometer_tests/base.py +++ b/scripts/ceilometer_tests/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common import isolated_creds from vn_test import * from vm_test import * @@ -7,7 +7,7 @@ from common import create_public_vn from openstack import OpenstackAuth -class CeilometerBaseTest(test.BaseTestCase): +class CeilometerBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): @@ -19,24 +19,21 @@ def setUpClass(cls): inst = cls() raise inst.skipTest( "Skipping Test.Ceilometer not enabled in the setup") - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, cls.inputs, ini_file = cls.ini_file, logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.__name__, - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) + public_creds, + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) cls.public_vn_obj.configure_control_nodes() resource_class = cls.__name__ + 'Resource' @@ -46,7 +43,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.res.cleanUp() - cls.isolated_creds.delete_tenant() super(CeilometerBaseTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/discovery_regression/base.py b/scripts/discovery_regression/base.py index 826b0ec0b..a13cfd0c8 100644 --- a/scripts/discovery_regression/base.py +++ b/scripts/discovery_regression/base.py @@ -1,20 +1,12 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds -class BaseDiscoveryTest(test.BaseTestCase): +class BaseDiscoveryTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseDiscoveryTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -26,7 +18,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(BaseDiscoveryTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/ecmp/base.py b/scripts/ecmp/base.py index 27a62d8da..5d26bdb2c 100644 --- a/scripts/ecmp/base.py +++ b/scripts/ecmp/base.py @@ -1,25 +1,15 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds -class BaseECMPTest(test.BaseTestCase): +class BaseECMPTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseECMPTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj @@ -27,8 +17,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseECMPTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/encap/base.py b/scripts/encap/base.py index d97501487..618cd5323 100644 --- a/scripts/encap/base.py +++ b/scripts/encap/base.py @@ -1,28 +1,16 @@ -import test +import test_v1 import fixtures from common import isolated_creds -class BaseEncapTest(test.BaseTestCase): +class BaseEncapTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseEncapTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj @@ -30,7 +18,5 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseEncapTest, cls).tearDownClass() # end tearDownClass diff --git a/scripts/floatingip/base.py b/scripts/floatingip/base.py index f5fdb4c45..695d9ac03 100644 --- a/scripts/floatingip/base.py +++ b/scripts/floatingip/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common import isolated_creds from common import create_public_vn from vn_test import * @@ -6,23 +6,11 @@ import fixtures -class FloatingIpBaseTest(test.BaseTestCase): +class FloatingIpBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(FloatingIpBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -30,18 +18,20 @@ def setUpClass(cls): cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj cls.orch = cls.connections.orch + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.__name__, - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) + public_creds, + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) cls.public_vn_obj.configure_control_nodes() # end setUpClass @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(FloatingIpBaseTest, cls).tearDownClass() # end tearDownClass diff --git a/scripts/heat/base.py b/scripts/heat/base.py index c8ce7217f..90632da99 100644 --- a/scripts/heat/base.py +++ b/scripts/heat/base.py @@ -1,4 +1,4 @@ -import time +import time_v1 import test from common.connections import ContrailConnections from common import isolated_creds @@ -22,24 +22,11 @@ contrail_api_conf = '/etc/contrail/contrail-api.conf' -class BaseHeatTest(test.BaseTestCase): +class BaseHeatTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseHeatTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.admin_connections = cls.isolated_creds.get_admin_connections() - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -51,7 +38,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(BaseHeatTest, cls).tearDownClass() # end tearDownClass diff --git a/scripts/multi_tenancy/base.py b/scripts/multi_tenancy/base.py index 839e4a4d3..79f91ab86 100644 --- a/scripts/multi_tenancy/base.py +++ b/scripts/multi_tenancy/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 import os from common.connections import ContrailConnections from vm_test import VMFixture @@ -7,15 +7,11 @@ from vnc_api.vnc_api import * from keystone_tests import KeystoneCommands -class BaseMultitenancyTest(test.BaseTestCase): +class BaseMultitenancyTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseMultitenancyTest, cls).setUpClass() - cls.connections = ContrailConnections(cls.inputs, project_name = cls.inputs.project_name, - username = cls.inputs.stack_user, - password = cls.inputs.stack_password, - logger = cls.logger) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -25,7 +21,10 @@ def setUpClass(cls): 'http://' + cls.inputs.openstack_ip + ':5000/v2.0' insecure = bool(os.getenv('OS_INSECURE',True)) cls.key_stone_clients = KeystoneCommands( - username=cls.inputs.stack_user, password = cls.inputs.stack_password, tenant = cls.inputs.project_name, auth_url=auth_url, + username=cls.inputs.admin_user, + password = cls.inputs.admin_password, + tenant = cls.inputs.admin_tenant, + auth_url=auth_url, insecure=insecure) #end setUpClass diff --git a/scripts/policy/base.py b/scripts/policy/base.py index 06eff9d66..7b50b6af6 100644 --- a/scripts/policy/base.py +++ b/scripts/policy/base.py @@ -1,22 +1,12 @@ -import test +import test_v1 from common import isolated_creds -class BasePolicyTest(test.BaseTestCase): +class BasePolicyTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BasePolicyTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.orch = cls.connections.orch cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h @@ -29,8 +19,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BasePolicyTest, cls).tearDownClass() # end tearDownClass #end BasePolicyTest class diff --git a/scripts/project/base.py b/scripts/project/base.py index af9140ca1..df3bd0409 100644 --- a/scripts/project/base.py +++ b/scripts/project/base.py @@ -7,25 +7,49 @@ class BaseProjectTest(test.BaseTestCase): @classmethod def setUpClass(cls): super(BaseProjectTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.quantum_h= cls.connections.quantum_h - cls.nova_h = cls.connections.nova_h - cls.vnc_lib= cls.connections.vnc_lib - cls.agent_inspect= cls.connections.agent_inspect - cls.cn_inspect= cls.connections.cn_inspect - cls.analytics_obj=cls.connections.analytics_obj + + cls.project = None + cls.admin_inputs = None + cls.admin_connections = None + if not cls.inputs.admin_username: + # It is expected that is_test_applicable will not + # let the testcase run if admin_username is not set + return + cls.admin_isolated_creds = isolated_creds.AdminIsolatedCreds( + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) + cls.admin_isolated_creds.setUp() + cls.admin_connections = cls.admin_isolated_creds.get_connections( + cls.admin_inputs) + cls.admin_project = cls.admin_isolated_creds.create_tenant( + cls.admin_isolated_creds.project_name) + cls.admin_inputs = cls.admin_isolated_creds.get_inputs( + cls.admin_project) + cls.admin_connections = cls.admin_isolated_creds.get_connections( + cls.admin_inputs) + + cls.quantum_h = cls.admin_connections.quantum_h + cls.nova_h = cls.admin_connections.nova_h + cls.vnc_lib = cls.admin_connections.vnc_lib + cls.agent_inspect = cls.admin_connections.agent_inspect + cls.cn_inspect = cls.admin_connections.cn_inspect + cls.analytics_obj = cls.admin_connections.analytics_obj + cls.connections = cls.admin_connections #end setUpClass @classmethod def tearDownClass(cls): -# cls.isolated_creds.delete_tenant() super(BaseProjectTest, cls).tearDownClass() #end tearDownClass + def is_test_applicable(self): + if not (self.inputs.admin_username or \ + self.inputs.admin_password or \ + self.inputs.admin_tenant or \ + self.inputs.tenant_isolation) : + return (False, 'Need admin credentials and access to ' + 'create projects') + return (True, None) + # end is_test_applicable + diff --git a/scripts/project/test_projects.py b/scripts/project/test_projects.py index e6fe1f268..fbef866ae 100644 --- a/scripts/project/test_projects.py +++ b/scripts/project/test_projects.py @@ -35,15 +35,18 @@ def test_project_add_delete(self): result = True project_name = get_random_name('project128') user_fixture= self.useFixture(UserFixture( - connections=self.connections, username=self.inputs.stack_user, - password=self.inputs.stack_password)) + connections=self.admin_connections, + username=self.inputs.admin_username, + password=self.inputs.admin_password)) project_fixture_obj = self.useFixture(ProjectFixture( - username=self.inputs.stack_user, - password=self.inputs.stack_password, + username=self.inputs.admin_username, + password=self.inputs.admin_password, project_name=project_name, vnc_lib_h=self.vnc_lib, - connections=self.connections)) - user_fixture.add_user_to_tenant(project_name, self.inputs.stack_user, 'admin') + connections=self.admin_connections)) + user_fixture.add_user_to_tenant(project_name, + self.inputs.admin_username, + 'admin') assert project_fixture_obj.verify_on_setup() # Check if the default SG is present in it diff --git a/scripts/rt_filter/base.py b/scripts/rt_filter/base.py index 141db57fc..595aee5db 100644 --- a/scripts/rt_filter/base.py +++ b/scripts/rt_filter/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds from vm_test import VMFixture @@ -6,24 +6,14 @@ from tcutils.util import retry -class BaseRtFilterTest(test.BaseTestCase): +class BaseRtFilterTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseRtFilterTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, - cls.inputs, ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj @@ -32,8 +22,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseRtFilterTest, cls).tearDownClass() # end tearDownClass diff --git a/scripts/securitygroup/base.py b/scripts/securitygroup/base.py index e931f2757..63e63d9a5 100644 --- a/scripts/securitygroup/base.py +++ b/scripts/securitygroup/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from vn_test import MultipleVNFixture from vm_test import MultipleVMFixture from fabric.api import run, hide, settings @@ -12,19 +12,11 @@ import os from tcutils.topo.sdn_topo_setup import * -class BaseSGTest(test.BaseTestCase): +class BaseSGTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseSGTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.orch = cls.connections.orch cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h @@ -38,8 +30,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseSGTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/serial_scripts/__init__.py b/scripts/serial_scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/scripts/smgr/base.py b/scripts/smgr/base.py index daeb83ec3..03e9d0701 100644 --- a/scripts/smgr/base.py +++ b/scripts/smgr/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 import fixtures import sys import os @@ -6,7 +6,7 @@ from smgr_common import SmgrFixture -class ServerManagerTest(test.BaseTestCase): +class ServerManagerTest(test_v1.BaseTestCase_v1): @classmethod diff --git a/scripts/svc_firewall/base.py b/scripts/svc_firewall/base.py index 10f28c17a..d069cc59a 100644 --- a/scripts/svc_firewall/base.py +++ b/scripts/svc_firewall/base.py @@ -1,32 +1,25 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds from common import create_public_vn -class BaseSvc_FwTest(test.BaseTestCase): +class BaseSvc_FwTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseSvc_FwTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.__name__, - cls.__name__, + public_creds, cls.inputs, ini_file=cls.ini_file, logger=cls.logger) @@ -35,8 +28,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseSvc_FwTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/svc_mirror/base.py b/scripts/svc_mirror/base.py index 343136fdf..6c0c68ec3 100644 --- a/scripts/svc_mirror/base.py +++ b/scripts/svc_mirror/base.py @@ -1,20 +1,12 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds -class BaseMirrorTest(test.BaseTestCase): +class BaseMirrorTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseMirrorTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -25,8 +17,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseMirrorTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/vdns/base.py b/scripts/vdns/base.py index 064d03f4d..461b4cbd4 100644 --- a/scripts/vdns/base.py +++ b/scripts/vdns/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds from random import randint @@ -27,19 +27,11 @@ from vnc_api.gen.resource_test import * from tcutils.wrappers import preposttest_wrapper -class BasevDNSTest(test.BaseTestCase): +class BasevDNSTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BasevDNSTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -53,8 +45,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BasevDNSTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/vm_regression/base.py b/scripts/vm_regression/base.py index b588de8aa..db3ec01be 100644 --- a/scripts/vm_regression/base.py +++ b/scripts/vm_regression/base.py @@ -1,24 +1,16 @@ -import test +import test_v1 import re from common.connections import ContrailConnections from common import isolated_creds from vm_test import VMFixture from vn_test import VNFixture -class BaseVnVmTest(test.BaseTestCase): +class BaseVnVmTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseVnVmTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() cls.inputs.set_af('v4') - cls.connections = cls.isolated_creds.get_conections() cls.orch = cls.connections.orch cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h @@ -31,8 +23,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseVnVmTest, cls).tearDownClass() #end tearDownClass diff --git a/scripts/vpc/base.py b/scripts/vpc/base.py index e8d00b955..fc13549b2 100644 --- a/scripts/vpc/base.py +++ b/scripts/vpc/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common import isolated_creds from common import create_public_vn from vn_test import * @@ -9,40 +9,30 @@ from vpc_vm_fixture import VPCVMFixture -class VpcBaseTest(test.BaseTestCase): +class VpcBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(VpcBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.admin_connections.username, - cls.admin_connections.password, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) + public_creds, + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) # end setUpClass @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(VpcBaseTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/analytics/base.py b/serial_scripts/analytics/base.py index 4ec8f9883..22e823e56 100644 --- a/serial_scripts/analytics/base.py +++ b/serial_scripts/analytics/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common import isolated_creds from vn_test import * from vm_test import * @@ -10,17 +10,11 @@ from traffic.core.helpers import Sender, Receiver from tcutils.util import Singleton -class AnalyticsBaseTest(test.BaseTestCase): +class AnalyticsBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(AnalyticsBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, cls.inputs, ini_file = cls.ini_file, logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -35,7 +29,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.res.cleanUp() - cls.isolated_creds.delete_tenant() super(AnalyticsBaseTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/control_node_scaling/base.py b/serial_scripts/control_node_scaling/base.py index 2e3b0c960..8bd439ecb 100644 --- a/serial_scripts/control_node_scaling/base.py +++ b/serial_scripts/control_node_scaling/base.py @@ -1,26 +1,16 @@ -import test +import test_v1 from common import isolated_creds -class BaseBGPScaleTest(test.BaseTestCase): +class BaseBGPScaleTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseBGPScaleTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.inputs.set_af('v4') #end setUpClass @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseBGPScaleTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/discovery_regression/base.py b/serial_scripts/discovery_regression/base.py index 77a5d3378..6c587ce88 100644 --- a/serial_scripts/discovery_regression/base.py +++ b/serial_scripts/discovery_regression/base.py @@ -1,22 +1,14 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds import threading import time -class BaseDiscoveryTest(test.BaseTestCase): +class BaseDiscoveryTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseDiscoveryTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -28,7 +20,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(BaseDiscoveryTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/ecmp/base.py b/serial_scripts/ecmp/base.py index 7f58d8f50..5bef3b04b 100644 --- a/serial_scripts/ecmp/base.py +++ b/serial_scripts/ecmp/base.py @@ -1,25 +1,15 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds -class BaseECMPRestartTest(test.BaseTestCase): +class BaseECMPRestartTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseECMPRestartTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj @@ -27,8 +17,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseECMPRestartTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/encap/base.py b/serial_scripts/encap/base.py index d97501487..ae1ee1b0d 100644 --- a/serial_scripts/encap/base.py +++ b/serial_scripts/encap/base.py @@ -1,28 +1,16 @@ -import test +import test_v1 import fixtures from common import isolated_creds -class BaseEncapTest(test.BaseTestCase): +class BaseEncapTest(test_v1.BaseTestCase): @classmethod def setUpClass(cls): super(BaseEncapTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj @@ -30,7 +18,5 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseEncapTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/evpn/base.py b/serial_scripts/evpn/base.py index 93fc05ede..773a196e8 100644 --- a/serial_scripts/evpn/base.py +++ b/serial_scripts/evpn/base.py @@ -1,25 +1,15 @@ -import test +import test_v1 import fixtures from common import isolated_creds -class BaseEvpnTest(test.BaseTestCase): +class BaseEvpnTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseEvpnTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj @@ -27,8 +17,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseEvpnTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/floatingip/base.py b/serial_scripts/floatingip/base.py index 8c7cb04dd..c1c50ccb9 100644 --- a/serial_scripts/floatingip/base.py +++ b/serial_scripts/floatingip/base.py @@ -1,39 +1,30 @@ -import test +import test_v1 from common import isolated_creds, create_public_vn from vn_test import * from vm_test import * import fixtures -class FloatingIpBaseTest(test.BaseTestCase): +class FloatingIpBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(FloatingIpBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj + if cls.inputs.admin_username: + public_creds = cls.admin_isolated_creds + else: + public_creds = cls.isolated_creds cls.public_vn_obj = create_public_vn.PublicVn( - cls.__name__, - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) + public_creds, + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) cls.public_vn_obj.configure_control_nodes() # end setUpClass diff --git a/serial_scripts/ha/base.py b/serial_scripts/ha/base.py index 171302f97..d384358cb 100644 --- a/serial_scripts/ha/base.py +++ b/serial_scripts/ha/base.py @@ -5,7 +5,7 @@ import socket import random from fabric.state import connections as fab_connections -import test +import test_v1 import traffic_tests from common.contrail_test_init import * from common import isolated_creds @@ -19,29 +19,19 @@ from traffic.core.helpers import Host from traffic.core.helpers import Sender, Receiver -class HABaseTest(test.BaseTestCase): +class HABaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(HABaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.nova_h = cls.connections.nova_h cls.orch = cls.connections.orch cls.vnc_lib_fixture = cls.connections.vnc_lib_fixture -# cls.logger= cls.inputs.logger cls.ipmi_list = cls.inputs.hosts_ipmi[0] #end setUpClass @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_tenant() super(HABaseTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/headless_vrouter/base.py b/serial_scripts/headless_vrouter/base.py index 5143d71c9..52b03347a 100644 --- a/serial_scripts/headless_vrouter/base.py +++ b/serial_scripts/headless_vrouter/base.py @@ -1,22 +1,12 @@ -import test +import test_v1 from common import isolated_creds -class BaseHeadlessVrouterTest(test.BaseTestCase): +class BaseHeadlessVrouterTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseHeadlessVrouterTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -29,8 +19,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseHeadlessVrouterTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/md5/base.py b/serial_scripts/md5/base.py index b93e49b20..ba59af91d 100644 --- a/serial_scripts/md5/base.py +++ b/serial_scripts/md5/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from vn_test import MultipleVNFixture from vnc_api.vnc_api import * #from vnc_api.vnc_api import VncApi @@ -17,19 +17,11 @@ import re from physical_router_fixture import PhysicalRouterFixture -class Md5Base(test.BaseTestCase, VerifySecGroup, ConfigPolicy): +class Md5Base(test_v1.BaseTestCase_v1, VerifySecGroup, ConfigPolicy): @classmethod def setUpClass(cls): super(Md5Base, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, - cls.inputs, ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -41,8 +33,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(Md5Base, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/policy/base.py b/serial_scripts/policy/base.py index 8ea78cf26..99a05259a 100644 --- a/serial_scripts/policy/base.py +++ b/serial_scripts/policy/base.py @@ -1,22 +1,12 @@ -import test +import test_v1 from common import isolated_creds -class BaseSerialPolicyTest(test.BaseTestCase): +class BaseSerialPolicyTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseSerialPolicyTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -29,8 +19,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseSerialPolicyTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/rsyslog/base.py b/serial_scripts/rsyslog/base.py index 05d69c6a3..ef460f141 100644 --- a/serial_scripts/rsyslog/base.py +++ b/serial_scripts/rsyslog/base.py @@ -1,22 +1,12 @@ -import test +import test_v1 from common import isolated_creds -class BaseRsyslogTest(test.BaseTestCase): +class BaseRsyslogTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseRsyslogTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -29,8 +19,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseRsyslogTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/system_test/flow_tests/base.py b/serial_scripts/system_test/flow_tests/base.py index ca591c24f..082e9be6c 100644 --- a/serial_scripts/system_test/flow_tests/base.py +++ b/serial_scripts/system_test/flow_tests/base.py @@ -1,24 +1,12 @@ -import test +import test_v1 from common import isolated_creds -class BaseFlowTest(test.BaseTestCase): +class BaseFlowTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseFlowTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - cls.admin_inputs = cls.isolated_creds.get_admin_inputs() - cls.admin_connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -30,8 +18,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseFlowTest, cls).tearDownClass() # end tearDownClass diff --git a/serial_scripts/upgrade/base.py b/serial_scripts/upgrade/base.py index cc440b169..3e42e57cb 100644 --- a/serial_scripts/upgrade/base.py +++ b/serial_scripts/upgrade/base.py @@ -1,20 +1,14 @@ -import test +import test_v1 from common.connections import ContrailConnections from common.contrail_test_init import ContrailTestInit from common import isolated_creds from verify import BaseResource -class UpgradeBaseTest(test.BaseTestCase): +class UpgradeBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(UpgradeBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, cls.inputs, ini_file = cls.ini_file, logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib @@ -28,7 +22,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.res.cleanUp() - cls.isolated_creds.delete_tenant() super(UpgradeBaseTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/vgw/base.py b/serial_scripts/vgw/base.py index c2c6ca35a..fbb795a9a 100644 --- a/serial_scripts/vgw/base.py +++ b/serial_scripts/vgw/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds from project_test import * @@ -6,22 +6,14 @@ from vm_test import * -class BaseVgwTest(test.BaseTestCase): +class BaseVgwTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseVgwTest, cls).setUpClass() - cls.connections = ContrailConnections( - cls.inputs, - project_name=cls.inputs.project_name, - username=cls.inputs.stack_user, - password=cls.inputs.stack_password, - logger=cls.logger) - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib - #cls.logger= cls.inputs.logger cls.agent_inspect = cls.connections.agent_inspect cls.cn_inspect = cls.connections.cn_inspect cls.analytics_obj = cls.connections.analytics_obj @@ -30,8 +22,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - # cls.isolated_creds.delete_user() - # cls.isolated_creds.delete_tenant() for vn in cls.vn_fixture_dict: vn.verify_is_run = False vn.cleanUp() diff --git a/serial_scripts/vm_regression/base.py b/serial_scripts/vm_regression/base.py index 79cdd2ba1..9533ec13a 100644 --- a/serial_scripts/vm_regression/base.py +++ b/serial_scripts/vm_regression/base.py @@ -1,28 +1,18 @@ -import test +import test_v1 from common.connections import ContrailConnections from common import isolated_creds from vm_test import VMFixture from vn_test import VNFixture import os -class BaseVnVmTest(test.BaseTestCase): +class BaseVnVmTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(BaseVnVmTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__, \ - cls.inputs, ini_file = cls.ini_file, \ - logger = cls.logger) - cls.isolated_creds.setUp() - cls.project = cls.isolated_creds.create_tenant() - cls.isolated_creds.create_and_attach_user_to_tenant() - cls.inputs = cls.isolated_creds.get_inputs() - cls.connections = cls.isolated_creds.get_conections() - #cls.connections= ContrailConnections(cls.inputs) cls.quantum_h= cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib= cls.connections.vnc_lib -# cls.logger= cls.inputs.logger cls.agent_inspect= cls.connections.agent_inspect cls.cn_inspect= cls.connections.cn_inspect cls.analytics_obj=cls.connections.analytics_obj @@ -31,8 +21,6 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - #cls.isolated_creds.delete_user() - cls.isolated_creds.delete_tenant() super(BaseVnVmTest, cls).tearDownClass() #end tearDownClass diff --git a/serial_scripts/webui/base.py b/serial_scripts/webui/base.py index 3c4e310bd..a28c62221 100644 --- a/serial_scripts/webui/base.py +++ b/serial_scripts/webui/base.py @@ -1,4 +1,4 @@ -import test +import test_v1 from common import isolated_creds from vn_test import * from vm_test import * @@ -21,18 +21,11 @@ import random -class WebuiBaseTest(test.BaseTestCase): +class WebuiBaseTest(test_v1.BaseTestCase_v1): @classmethod def setUpClass(cls): super(WebuiBaseTest, cls).setUpClass() - cls.isolated_creds = isolated_creds.IsolatedCreds( - cls.__name__, - cls.inputs, - ini_file=cls.ini_file, - logger=cls.logger) - cls.inputs = cls.isolated_creds.get_admin_inputs() - cls.connections = cls.isolated_creds.get_admin_connections() cls.quantum_h = cls.connections.quantum_h cls.nova_h = cls.connections.nova_h cls.vnc_lib = cls.connections.vnc_lib @@ -54,7 +47,6 @@ def setUpClass(cls): def tearDownClass(cls): cls.UicleanUp() cls.res.cleanUp() - # cls.isolated_creds.delete_tenant() super(WebuiBaseTest, cls).tearDownClass() # end tearDownClass diff --git a/tcutils/util.py b/tcutils/util.py index 39abb686b..e74636dc5 100644 --- a/tcutils/util.py +++ b/tcutils/util.py @@ -662,10 +662,19 @@ def read_config_option(config, section, option, default_option): val = config.get(section, option) if val.lower() == 'true': val = True - elif val.lower() == 'false' or val.lower() == 'none': + #elif val.lower() == 'false' or val.lower() == 'none': + elif val.lower() == 'false': val = False elif not val: val = default_option + + if type(val) is not bool and val is not None and ( + '$__' in val or val.lower() == 'none'): + # ie. having a template value unpopulated(for $__xyz__) + # or None + val = '' + if val == '' : + val = default_option return val except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): return default_option diff --git a/test_v1.py b/test_v1.py new file mode 100644 index 000000000..3c8bc718f --- /dev/null +++ b/test_v1.py @@ -0,0 +1,57 @@ +from common.isolated_creds import * +from test import BaseTestCase + +class BaseTestCase_v1(BaseTestCase): + @classmethod + def setUpClass(cls): + cls.project = None + cls.admin_inputs = None + cls.admin_connections = None + super(BaseTestCase_v1, cls).setUpClass() + + if not cls.inputs.tenant_isolation: + project_name = cls.inputs.stack_tenant + else: + project_name = cls.__name__ + + cls.isolated_creds = IsolatedCreds( + cls.inputs, + project_name=project_name, + ini_file=cls.ini_file, + logger=cls.logger) + + if cls.inputs.tenant_isolation: + cls.admin_isolated_creds = AdminIsolatedCreds( + cls.inputs, + ini_file=cls.ini_file, + logger=cls.logger) + cls.admin_isolated_creds.setUp() + + cls.project = cls.admin_isolated_creds.create_tenant( + cls.isolated_creds.project_name) + cls.admin_inputs = cls.admin_isolated_creds.get_inputs(cls.project) + cls.admin_isolated_creds.create_and_attach_user_to_tenant( + cls.project, + cls.isolated_creds.username, + cls.isolated_creds.password) + cls.admin_connections = cls.admin_isolated_creds.get_connections( + cls.admin_inputs) + # endif + + cls.isolated_creds.setUp() + if not cls.project: + cls.project = cls.isolated_creds.create_tenant( + cls.isolated_creds.project_name) + cls.inputs = cls.isolated_creds.get_inputs(cls.project) + cls.connections = cls.isolated_creds.get_connections(cls.inputs) + # end setUpClass + + @classmethod + def tearDownClass(cls): + if cls.inputs.tenant_isolation: + cls.admin_isolated_creds.delete_tenant(cls.project) + cls.admin_isolated_creds.delete_user(cls.isolated_creds.username) + super(BaseTestCase_v1, cls).tearDownClass() + # end tearDownClass + +