def test_many_deployments_are_updated(self): self.setup_deployment_ids = ['d{0}'.format(uuid.uuid4()) for _ in range(5)] self.setup_node_id = 'node' self.plugin_name = 'version_aware' self.client.blueprints.upload( path=self._get_dsl_blueprint_path(''), entity_id=self.base_blueprint_id) wait_for_blueprint_upload(self.base_blueprint_id, self.client) blueprint = self.client.blueprints.get(self.base_blueprint_id) for dep_id in self.setup_deployment_ids: self.client.deployments.create(blueprint.id, dep_id) wait_for_deployment_creation_to_complete( self.env.container_id, dep_id, self.client ) self.execute_workflow('install', dep_id) self._upload_v_2_plugin() # Execute base (V 1.0) workflows for dep_id in self.setup_deployment_ids: self.setup_deployment_id = dep_id self._execute_workflows() self._assert_host_values(self.versions[0]) plugins_update = self._perform_plugins_update() self.assertEqual(plugins_update.state, STATES.SUCCESSFUL) # Execute mod (V 2.0) workflows for dep_id in self.setup_deployment_ids: self.setup_deployment_id = dep_id self._execute_workflows() self._assert_host_values(self.versions[1])
def test_many_deployments_are_updates(self): self.setup_deployment_ids = [ 'd{0}'.format(uuid.uuid4()) for _ in range(5) ] self.setup_node_id = 'node' self.plugin_name = 'version-aware-plugin' # Upload V1.0 and V2.0 plugins self.upload_mock_plugin(self.plugin_name) blueprint = self.client.blueprints.upload( path=self._get_dsl_blueprint_path(''), entity_id=self.base_blueprint_id) for dep_id in self.setup_deployment_ids: self.client.deployments.create(blueprint.id, dep_id) wait_for_deployment_creation_to_complete(dep_id) BaseTestCase.execute_workflow('install', dep_id) self._upload_v_2_plugin() # Execute base (V 1.0) host op for dep_id in self.setup_deployment_ids: self.setup_deployment_id = dep_id self._execute_workflows() self._assert_host_values(self.versions[0]) self._perform_plugins_update() # Execute mod (V 2.0) host op for dep_id in self.setup_deployment_ids: self.setup_deployment_id = dep_id self._execute_workflows() self._assert_host_values(self.versions[1])
def _start_a_workflow(self): # Start the create deployment workflow dsl_path = utils.get_resource('dsl/basic.yaml') blueprint_id = deployment_id = 'basic_{}'.format(uuid.uuid4()) self.client.blueprints.upload(dsl_path, blueprint_id) self.client.deployments.create(blueprint_id, deployment_id) utils.wait_for_deployment_creation_to_complete(deployment_id) return deployment_id
def _start_a_workflow(self): # Start the create deployment workflow dsl_path = utils.get_resource('dsl/basic.yaml') blueprint_id = deployment_id = 'basic_{}'.format(uuid.uuid4()) self.client.blueprints.upload(dsl_path, blueprint_id) self.client.deployments.create(blueprint_id, deployment_id) utils.wait_for_deployment_creation_to_complete(deployment_id) return deployment_id
def _create_basic_deployment(self, dsl_path=None, blueprint_id=None, deployment_id=None): dsl_path = dsl_path or self.dsl_path blueprint_id = blueprint_id or self.blueprint_id deployment_id = deployment_id or self.deployment_id self.client.blueprints.upload(dsl_path, blueprint_id) self.client.deployments.create(blueprint_id, deployment_id) wait_for_deployment_creation_to_complete(deployment_id=deployment_id)
def _create_deployment_from_blueprint_with_labels(self, new_labels=None): dsl_path = utils.get_resource('dsl/blueprint_with_labels.yaml') blueprint_id = deployment_id = 'd{0}'.format(uuid.uuid4()) self.client.blueprints.upload(dsl_path, blueprint_id) deployment = self.client.deployments.create(blueprint_id, deployment_id, labels=new_labels) utils.wait_for_deployment_creation_to_complete(self.env.container_id, deployment_id, self.client) return deployment
def _create_basic_deployment(self, dsl_path=None, blueprint_id=None, deployment_id=None): dsl_path = dsl_path or self.dsl_path blueprint_id = blueprint_id or self.blueprint_id deployment_id = deployment_id or self.deployment_id self.client.blueprints.upload(dsl_path, blueprint_id) self.client.deployments.create(blueprint_id, deployment_id, skip_plugins_validation=True) wait_for_deployment_creation_to_complete( deployment_id=deployment_id)
def deploy(dsl_path, blueprint_id=None, deployment_id=None, inputs=None): client = test_utils.create_rest_client() if not blueprint_id: blueprint_id = 'b{0}'.format(uuid.uuid4()) blueprint = client.blueprints.upload(dsl_path, blueprint_id) if deployment_id is None: deployment_id = 'd{0}'.format(uuid.uuid4()) deployment = client.deployments.create(blueprint.id, deployment_id, inputs=inputs, skip_plugins_validation=True) wait_for_deployment_creation_to_complete(deployment_id=deployment_id) return deployment
def deploy(dsl_path, blueprint_id=None, deployment_id=None, inputs=None): client = test_utils.create_rest_client() if not blueprint_id: blueprint_id = str(uuid.uuid4()) blueprint = client.blueprints.upload(dsl_path, blueprint_id) if deployment_id is None: deployment_id = str(uuid.uuid4()) deployment = client.deployments.create(blueprint.id, deployment_id, inputs=inputs) test_utils.wait_for_deployment_creation_to_complete( deployment_id=deployment_id) return deployment
def test_maintenance_mode(self): blueprint_id = 'b{0}'.format(uuid.uuid4()) deployment_id = blueprint_id blueprint_path = resource('dsl/agent_tests/maintenance_mode.yaml') self.client.blueprints.upload(blueprint_path, entity_id=blueprint_id) wait_for_blueprint_upload(blueprint_id, self.client) self.client.deployments.create(blueprint_id=blueprint_id, deployment_id=deployment_id) wait_for_deployment_creation_to_complete(self.env.container_id, deployment_id, self.client) # Running none blocking installation execution = self.client.executions.start(deployment_id=deployment_id, workflow_id='install') self.wait_for_execution_status(execution.id, status=Execution.STARTED) self.logger.info( "checking if maintenance status has status 'deactivated'") self._check_maintenance_status('deactivated') self.logger.info('activating maintenance mode') self.client.maintenance_mode.activate() self.addCleanup(self.cleanup) self.logger.info( "checking if maintenance status has changed to 'activating'") self.do_assertions(self._check_maintenance_status, timeout=60, status='activating') self.logger.info('cancelling installation') self.client.executions.cancel(execution['id']) self.logger.info( "checking if maintenance status has changed to 'activated'") self.do_assertions(self._check_maintenance_status, timeout=60, status='activated') self.logger.info('deactivating maintenance mode') self.client.maintenance_mode.deactivate() self.logger.info( "checking if maintenance status has changed to 'deactivated'") self.do_assertions(self._check_maintenance_status, timeout=60, status='deactivated')
def deploy(self, dsl_path=None, blueprint_id=None, deployment_id=None, inputs=None, wait=True, client=None, runtime_only_evaluation=False, blueprint_visibility=None, deployment_visibility=None): if not (dsl_path or blueprint_id): raise RuntimeWarning('Please supply blueprint path ' 'or blueprint id for deploying') client = client or self.client resource_id = uuid.uuid4() blueprint_id = blueprint_id or 'blueprint_{0}'.format(resource_id) if dsl_path: blueprint_upload_kw = { 'path': dsl_path, 'entity_id': blueprint_id } # If not provided, use the client's default if blueprint_visibility: blueprint_upload_kw['visibility'] = blueprint_visibility blueprint = client.blueprints.upload(**blueprint_upload_kw) else: blueprint = None deployment_id = deployment_id or 'deployment_{0}'.format(resource_id) deployment_create_kw = { 'blueprint_id': blueprint.id if blueprint else blueprint_id, 'deployment_id': deployment_id, 'inputs': inputs, 'skip_plugins_validation': True, 'runtime_only_evaluation': runtime_only_evaluation } # If not provided, use the client's default if deployment_visibility: deployment_create_kw['visibility'] = deployment_visibility deployment = client.deployments.create(**deployment_create_kw) if wait: wait_for_deployment_creation_to_complete( self.env.container_id, deployment_id, client=client) return deployment
def test_deployment_with_the_same_id(self): """Create multiple deployments with the same ID. The goal of this test is run multiple create/delete deployment cycles to find out if there's any race condition that prevents the creation of a deployment of the same ID just after it's been deleted. """ dsl_path = utils.get_resource('dsl/basic.yaml') blueprint_id = deployment_id = 'd{0}'.format(uuid.uuid4()) self.client.blueprints.upload(dsl_path, blueprint_id) for _ in range(self.DEPLOYMENTS_COUNT): self.client.deployments.create(blueprint_id, deployment_id, skip_plugins_validation=True) utils.wait_for_deployment_creation_to_complete(deployment_id) self.client.deployments.delete(deployment_id)
def deploy(dsl_path, blueprint_id=None, deployment_id=None, inputs=None, wait=True, client=None, runtime_only_evaluation=False): client = client or test_utils.create_rest_client() resource_id = uuid.uuid4() blueprint_id = blueprint_id or 'blueprint_{0}'.format(resource_id) blueprint = client.blueprints.upload(dsl_path, blueprint_id) deployment_id = deployment_id or 'deployment_{0}'.format(resource_id) deployment = client.deployments.create( blueprint.id, deployment_id, inputs=inputs, skip_plugins_validation=True, runtime_only_evaluation=runtime_only_evaluation) if wait: wait_for_deployment_creation_to_complete(deployment_id, client=client) return deployment
def test_deployment_with_the_same_id(self): """Create multiple deployments with the same ID. The goal of this test is run multiple create/delete deployment cycles to find out if there's any race condition that prevents the creation of a deployment of the same ID just after it's been deleted. """ dsl_path = utils.get_resource('dsl/basic.yaml') blueprint_id = deployment_id = 'd{0}'.format(uuid.uuid4()) self.client.blueprints.upload(dsl_path, blueprint_id) for _ in range(self.DEPLOYMENTS_COUNT): self.client.deployments.create( blueprint_id, deployment_id, skip_plugins_validation=True) utils.wait_for_deployment_creation_to_complete(deployment_id) self.client.deployments.delete(deployment_id) utils.wait_for_deployment_deletion_to_complete(deployment_id)
def test_maintenance_mode(self): blueprint_id = 'b{0}'.format(uuid.uuid4()) deployment_id = blueprint_id blueprint_path = resource('dsl/agent_tests/maintenance_mode.yaml') self.client.blueprints.upload(blueprint_path, entity_id=blueprint_id) self.client.deployments.create(blueprint_id=blueprint_id, deployment_id=deployment_id) wait_for_deployment_creation_to_complete(deployment_id=deployment_id) # Running none blocking installation execution = self.client.executions.start(deployment_id=deployment_id, workflow_id='install') self.logger.info( "checking if maintenance status has status 'deactivated'") self._check_maintenance_status('deactivated') self.logger.info('activating maintenance mode') self.client.maintenance_mode.activate() self.addCleanup(self.cleanup) self.logger.info( "checking if maintenance status has changed to 'activating'") self.do_assertions(self._check_maintenance_status, timeout=60, status='activating') self.logger.info('cancelling installation') self.cfy.executions.cancel(execution['id']) self.logger.info( "checking if maintenance status has changed to 'activated'") self.do_assertions(self._check_maintenance_status, timeout=60, status='activated') self.logger.info('deactivating maintenance mode') self.client.maintenance_mode.deactivate() self.logger.info( "checking if maintenance status has changed to 'deactivated'") self.do_assertions(self._check_maintenance_status, timeout=60, status='deactivated')