def test_base_resources_integration(self): """Define test for base resources interation from core porjects The alternative scenario is the following: 1. Create a stack with basic resources from core projects. 2. Check that all stack resources are created successfully. 3. Wait for deployment. 4. Check that stack was created. 5. Check stack outputs. """ self.private_net_name = test.rand_name('heat-net') parameters = { 'key_name': test.rand_name('heat-key'), 'flavor': self.conf.instance_type, 'image': self.conf.image_ref, 'vol_size': self.conf.volume_size, 'private_net_name': self.private_net_name } env_files, env = template_utils.process_environment_and_files( self.conf.boot_config_env) # Launch stack self.stack_identifier = self.launch_stack( template_name='test_base_resources.yaml', parameters=parameters, expected_status=None, environment=env) # Check stack self.check_stack()
def setUp(self): super(AwsStackTest, self).setUp() if not self.is_service_available('object-store'): self.skipTest('object-store service not available, skipping') self.object_container_name = test.rand_name() self.project_id = self.identity_client.project_id self.swift_key = hashlib.sha224( str(random.getrandbits(256)).encode('ascii')).hexdigest()[:32] key_header = 'x-container-meta-temp-url-key' self.object_client.put_container(self.object_container_name, {key_header: self.swift_key}) self.addCleanup(self.object_client.delete_container, self.object_container_name)
def test_update_on_failed_create(self): # create a stack with "server" dependent on "keypair", but # keypair fails, so "server" is not created properly. # We then fix the template and it should succeed. broken_templ = self.main_template.replace('replace-this', self.keypair_name) stack_identifier = self.stack_create( template=broken_templ, files={'server_fail.yaml': self.nested_templ}, expected_status='CREATE_FAILED') fixed_templ = self.main_template.replace('replace-this', test.rand_name()) self.update_stack(stack_identifier, fixed_templ, files={'server_fail.yaml': self.nested_templ})
def load_tests(loader, tests, pattern): """Provide a TestSuite to the discovery process.""" test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR) conf = config.CONF.heat_plugin if conf.auth_url is None: # It's not configured, let's not load tests return manager = clients.ClientManager(conf) endpoint = manager.identity_client.get_endpoint_url( 'orchestration', region=conf.region, endpoint_type=conf.endpoint_type) host = urlparse.urlparse(endpoint).hostname os.environ['OS_TOKEN'] = manager.identity_client.auth_token os.environ['PREFIX'] = test.rand_name('api') return driver.build_tests(test_dir, loader, host=host, url=endpoint, test_loader_name=__name__)
def load_tests(loader, tests, pattern): """Provide a TestSuite to the discovery process.""" test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR) endpoint = None conf = config.CONF.heat_plugin if conf.auth_url: try: manager = clients.ClientManager(conf) endpoint = manager.identity_client.get_endpoint_url( 'orchestration', region=conf.region, endpoint_type=conf.endpoint_type) os.environ['PREFIX'] = test.rand_name('api') # Catch the authentication exceptions that can happen if one of the # following conditions occur: # 1. conf.auth_url IP/port is incorrect or keystone not available # (ConnectFailure) # 2. conf.auth_url is malformed (BadRequest, UnknownConnectionError, # EndpointNotFound, NotFound, or DiscoveryFailure) # 3. conf.username/password is incorrect (Unauthorized) # 4. conf.project_name is missing/incorrect (EmptyCatalog) # These exceptions should not prevent a test list from being returned, # so just issue a warning log and move forward with test listing. except (keystoneauth1.exceptions.http.BadRequest, keystoneauth1.exceptions.http.Unauthorized, keystoneauth1.exceptions.http.NotFound, keystoneauth1.exceptions.catalog.EmptyCatalog, keystoneauth1.exceptions.catalog.EndpointNotFound, keystoneauth1.exceptions.discovery.DiscoveryFailure, keystoneauth1.exceptions.connection.UnknownConnectionError, keystoneauth1.exceptions.connection.ConnectFailure): LOG.warn("Keystone auth exception: %s: %s" % (sys.exc_info()[0], sys.exc_info()[1])) # Clear the auth_url, as there is no point in tempest trying # to authenticate later with mis-configured or unreachable endpoint conf.auth_url = None except Exception: LOG.error("Fatal exception: %s: %s" % (sys.exc_info()[0], sys.exc_info()[1])) raise def register_test_case_id(test_case): tempest_id = test_case.test_data.get('desc') test_name = test_case.id() if not tempest_id: raise AssertionError("No Tempest ID registered for API test %s" % test_name) def test_id(): return test_name + '[id-%s]' % tempest_id test_case.id = test_id def register_test_suite_ids(test_suite): for test_case in test_suite: if isinstance(test_case, unittest.TestSuite): register_test_suite_ids(test_case) else: register_test_case_id(test_case) api_tests = driver.build_tests(test_dir, loader, url=endpoint, host="", fixture_module=fixtures, test_loader_name=__name__) register_test_suite_ids(api_tests) return api_tests