def test_scalelist(self): blueprint_id = 'scalelist-{0}'.format(self.application_prefix) utils.execute_command( 'cfy blueprints upload cloudify_scalelist/' 'examples/blueprint.yaml -b {0}'.format(blueprint_id)) utils.create_deployment(blueprint_id) utils.execute_install(blueprint_id) node_one_instances = utils.get_node_instances('one', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_one_instances)), 1) node_two_instances = utils.get_node_instances('two', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_two_instances)), 1) node_three_instances = utils.get_node_instances('three', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_three_instances)), 1) node_four_instances = utils.get_node_instances('four', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_four_instances)), 1) # Scale Up 1:no change 2:2 3:3 if utils.execute_command( 'cfy executions start scaleuplist -d {0} ' '-p cloudify_scalelist/examples/scaleup_params.yaml'.format( blueprint_id)): raise Exception('{0} scaleup failed.'.format(blueprint_id)) sleep(5) node_one_instances = utils.get_node_instances('one', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_one_instances)), 1) node_two_instances = utils.get_node_instances('two', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_two_instances)), 3) node_three_instances = utils.get_node_instances('three', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_three_instances)), 4) node_four_instances = utils.get_node_instances('four', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_four_instances)), 4) # Undo Scaleup operations if utils.execute_command( 'cfy executions start scaledownlist -d {0} ' '-p cloudify_scalelist/examples/scaledown_params.yaml'.format( blueprint_id)): raise Exception('{0} scaleup failed.'.format(blueprint_id)) sleep(5) node_one_instances = utils.get_node_instances('one', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_one_instances)), 1) node_two_instances = utils.get_node_instances('two', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_two_instances)), 1) node_three_instances = utils.get_node_instances('three', blueprint_id) self.assertEqual( len(self._only_init_nodeinstances(node_three_instances)), 1) self.assertEqual( len(self._only_init_nodeinstances(node_four_instances)), 4)
def install_network(self): resource_group_name = \ 'cfyresource_group{0}'.format( os.environ['CIRCLE_BUILD_NUM']) self.addCleanup(self.teardown_failed_resource_group, resource_group_name) network_inputs = {'resource_suffix': os.environ['CIRCLE_BUILD_NUM']} utils.create_deployment('azure-example-network', inputs=network_inputs) utils.execute_install('azure-example-network') self.check_resources_in_deployment('azure-example-network')
def install_ssh_key(self, blueprint_id): utils.upload_blueprint(SSH_KEY_BP_ZIP, blueprint_id, 'keys.yaml') utils.create_deployment(blueprint_id) utils.execute_install(blueprint_id) delete_dep_command = \ 'cfy deployments delete -f {0}'.format(blueprint_id) utils.execute_command(delete_dep_command) if not utils.get_secrets('agent_key_private') or not \ utils.get_secrets('agent_key_public'): raise Exception( 'agent_key_private or agent_key_public not in secrets')
def install_deployment_proxy_external(self, blueprint_id): parent_id = '{0}-existing'.format(blueprint_id) utils.execute_command( 'cfy blueprints upload cloudify_deployment_proxy/' 'examples/test-blueprint-existing.yaml -b {0}'.format(parent_id)) utils.create_deployment(parent_id, inputs={'test_id': blueprint_id}) utils.execute_install(parent_id) rs = utils.get_deployment_resources_by_node_type_substring( parent_id, 'cloudify.nodes.DeploymentProxy') deployment_outputs = \ rs[0]['instances'][0]['runtime_properties']['deployment'] if 'output1' not in deployment_outputs['outputs']: raise Exception('output1 not in {0}'.format(deployment_outputs))
def install_file(self, blueprint_id): file_path = '/tmp/{0}'.format(blueprint_id) utils.execute_command( 'cfy blueprints upload cloudify_files/' 'examples/simple.yaml -b {0}'.format(blueprint_id)) utils.create_deployment(blueprint_id, inputs={'file_path': file_path}) utils.execute_install(blueprint_id) if utils.execute_command( 'docker exec cfy_manager stat {0}'.format(file_path)): raise Exception('{0} not written.'.format(file_path)) utils.execute_uninstall(blueprint_id) if not utils.execute_command( 'docker exec cfy_manager stat {0}'.format(file_path)): raise Exception('{0} not deleted.'.format(file_path))
def install_cloud_init(self, blueprint_id): utils.execute_command( 'cfy blueprints upload cloudify_cloudinit/' 'examples/simple.yaml -b {0}'.format(blueprint_id)) utils.create_deployment(blueprint_id) utils.execute_install(blueprint_id) rs = utils.get_deployment_resources_by_node_type_substring( blueprint_id, 'cloudify.nodes.CloudInit.CloudConfig') cloud_config = \ rs[0]['instances'][0]['runtime_properties']['cloud_config'] if '#cloud-config' not in cloud_config: raise Exception('{0} not in {1}'.format('#cloud-config', cloud_config)) utils.execute_uninstall(blueprint_id)
def install_rest(self, blueprint_id): utils.execute_command( 'cfy blueprints upload cloudify_rest/' 'examples/example-4-blueprint.yaml -b {0}'.format(blueprint_id)) utils.create_deployment(blueprint_id, inputs={'commit': os.environ['CIRCLE_SHA1']}) utils.execute_install(blueprint_id) rs = utils.get_deployment_resources_by_node_type_substring( blueprint_id, 'cloudify.rest.Requests') rest_instance = rs[0]['instances'][0]['runtime_properties'] if 'commit' not in rest_instance['result_propeties']: raise Exception('{0} not in {1}'.format( 'commit', rest_instance['result_propeties'])) utils.execute_uninstall(blueprint_id)
def test_network_deployment(self): # Create a list of node templates to verify. aws_nodes = [ 'nat_gateway', 'nat_gateway_ip', 'private_subnet_routetable', 'public_subnet_routetable', 'private_subnet', 'public_subnet', 'internet_gateway', 'vpc' ] # Prepare to call clean up method whenever test pass/fail self.addCleanup(self.remove_deployment, 'aws-example-network', aws_nodes) # Create Deployment (Blueprint already uploaded.) if utils.create_deployment('aws-example-network'): raise Exception('Deployment aws-example-network failed.') # Install Deployment. if utils.execute_install('aws-example-network'): raise Exception('Install aws-example-network failed.') # Get list of nodes in the deployment. deployment_nodes = \ utils.get_deployment_resources_by_node_type_substring( 'aws', self.node_type_prefix) # Check that the nodes really exist. self.check_resources_in_deployment_created(deployment_nodes, aws_nodes) self.check_nodecellar() self.check_external_nodecellar()
def test_install_network(self): network_inputs = { 'resource_suffix': os.environ['CIRCLE_BUILD_NUM'] } # Add Cleanup method to clean "gcp-example-network" whenever tests # fail or pass self.addCleanup(self.cleanup_deployment, 'gcp-example-network') # Check if creating deployment passed or not if utils.create_deployment('gcp-example-network', inputs=network_inputs): raise Exception( 'Deployment gcp-example-network failed.') # Check if executing install workflow passed or not if utils.execute_install('gcp-example-network'): raise Exception( 'Install aws-example-network failed.') gcp_network_resources =\ self.get_resources_from_deployment('gcp-example-network', self.node_type_prefix) self.check_resource_method(gcp_network_resources) self.check_nodecellar()
def install_network(self): resource_group_name = \ 'cfyresource_group{0}'.format( os.environ['CIRCLE_BUILD_NUM']) self.addCleanup( self.teardown_failed_resource_group, resource_group_name) network_inputs = { 'resource_suffix': os.environ['CIRCLE_BUILD_NUM'] } utils.create_deployment( 'azure-example-network', inputs=network_inputs) sleep(30) utils.execute_command('cfy executions list --include-system-workflows') utils.execute_install('azure-example-network') self.check_resources_in_deployment('azure-example-network')
def test_kubernetes_blueprint(self): blueprint_path = 'tests/blueprint.yaml' blueprint_id = 'infra-{0}'.format(self.application_prefix) self.addCleanup(self.cleanup_deployment, blueprint_id) failed = eco_utils.execute_command('cfy install {0} -b {1}'.format( blueprint_path, blueprint_id)) if failed: raise NonRecoverableError( 'Failed to install the infrastructure blueprint.') load_host = eco_utils.get_node_instances('k8s_load_host', blueprint_id)[0] node_host = eco_utils.get_node_instances('k8s_node_host', blueprint_id)[0] master_host = eco_utils.get_node_instances('k8s_master_host', blueprint_id)[0] compute_blueprint_path = 'baremetal.yaml' compute_blueprint_id = 'kube-{0}'.format(self.application_prefix) self.addCleanup(self.cleanup_deployment, compute_blueprint_id) eco_utils.execute_command('cfy blueprints upload {0} -b {1}'.format( compute_blueprint_path, compute_blueprint_id)) eco_utils.create_deployment( compute_blueprint_id, { 'public_master_ip': master_host.get('runtime_properties', {}).get('ip'), 'k8s_node_host_ip': node_host.get('runtime_properties', {}).get('ip'), 'k8s_load_host_ip': load_host.get('runtime_properties', {}).get('ip'), 'agent_user': '******', 'dashboard_ip': master_host.get('runtime_properties', {}).get('public_ip_address') }) eco_utils.execute_install(compute_blueprint_id) check_blueprint = eco_utils.install_nodecellar failed = check_blueprint('examples/wordpress-blueprint.yaml', blueprint_archive=WORDPRESS, blueprint_id='wp') if failed: raise NonRecoverableError( 'Failed to install the Wordpress blueprint.')
def test_install_network(self): network_inputs = {'resource_suffix': os.environ['CIRCLE_BUILD_NUM']} # Add Cleanup method to clean "gcp-example-network" whenever tests # fail or pass self.addCleanup(self.cleanup_deployment, 'gcp-example-network') # Check if creating deployment passed or not if utils.create_deployment('gcp-example-network', inputs=network_inputs): raise Exception('Deployment gcp-example-network failed.') # Check if executing install workflow passed or not if utils.execute_install('gcp-example-network'): raise Exception('Install aws-example-network failed.') gcp_network_resources =\ self.get_resources_from_deployment('gcp-example-network', self.node_type_prefix) self.check_resource_method(gcp_network_resources) self.check_nodecellar()