Commit 632a6a56 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added more tests

parent 6321c6f2
......@@ -17,7 +17,7 @@ topology_template:
protocol: "ssh"
keys:
public_key: "c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFBZ1FDV3l6VEoxS1pycDVvVHVBVm15dmxKL2prMnRNdktZSlAvSWtHZ1JKeTVFNUgrbjl0eU1QRXdyUDN4c0lUMVZzRjlVNVhLTkkvVDVpZDgxNko5RmxjbEhOSHVrbEFTMlhqV3QzNnlZekorMkhsa3JET0I4Q25DdmgvQlQ5K2liNkpjVFpUd21Xb1FQbjFuVXpSelRSVGU5NUlyOUl4djgrTnNLVWYxdVYzNDBRPT0gYXV0byBnZW5lcmF0ZWQgdXNlciBhY2NlZXMga2V5cwo="
private_key: "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlDV3dJQkFBS0JnUUNXeXpUSjFLWnJwNW9UdUFWbXl2bEovamsydE12S1lKUC9Ja0dnUkp5NUU1SCtuOXR5Ck1QRXdyUDN4c0lUMVZzRjlVNVhLTkkvVDVpZDgxNko5RmxjbEhOSHVrbEFTMlhqV3QzNnlZekorMkhsa3JET0IKOENuQ3ZoL0JUOStpYjZKY1RaVHdtV29RUG4xblV6UnpUUlRlOTVJcjlJeHY4K05zS1VmMXVWMzQwUUlEQVFBQgpBb0dBSUJDMStQVXZMbFZGZmt2eldoaHZTankxRGQwRU9OU3dvK0EwOUUraXcvaFZZeis2K2wxTjdIdmN4RGcxCkRiYVZEb0ZucU1ma2picXpTdWpQdEttN2ZlVThldjF3a21aOHNRdzhac1JNdXd3NUxDUzZpMENnem5RMlJ3WmIKU2dqSlVrLy81VVF2Z2x2YkFEMXJpUlJ1TzR5N0cwTFZpa2Y4b3UvM0pBM21iQUVDUVFESm1VY2dBQjJONmpSYQpydWxhNklnYzFYYjdTUGl0TEpFQjFNZytyUW5EZDZWWXZqcVVGaW9zWVdhYlJSdGtPQ1VPdWt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1TzR5N0cwTFZpa2Y4b3UvM0pBM21iQUVDUVFESm1VY2dBQjJONmpSYQpydWxhNklnYzFYYjdTUGl0TEpFQjFNZytyUW5EZDZWWXZqcVVGaW9zWVdhYlJSdGtPQ1VPdWt5cklLY1puZ3Q4CjdrdHN6T1c1QWtFQXYzeEFHYUdyWkk1KzdjSTF4Si9NaWVRa1pkaFFWTEpEUnpwT3FJVjVKaFIzbCt2R3N2R2MKWWhwUG9IL1VoN3hsV3NLUVF2Q3Y2azhyaVh1dmZ6aTMyUUpBQTJDb0NtYzJGNHlXOS9YNlB1V3FjaUU1YnhoWAo0ajdlNXhMemorbENRcDRjalJJUzFTeFI1SkIxTWFERXhyY1NGOThUTGNMTVNlZVY5YS9nWDZCSE1RSkFadHNVCkIzQ2JBdW16N255cXF4SjNLUDUrT3FLbUM4aXhjTm8yRkRtVjZNbUhyL2c3QkRYYUhhd3FaM2tpclVLYVl0VXQKN25jZzEwaHRoMjBEeU4rcmlRSkFRMHVvNWf9HaUxJSHNEQUR5Nkw1azdrNTZjVUlhZnhpeVRHdzlWQ2tUY3puVQpPS1liYXFVM3lyaDRqbzRYTHlGd3JYcHJOdkNsb29pY1JIMTdSUkMxUHc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
public_ip: "192.125.18.246"
role: "master"
node_type: "t2.medium"
......@@ -82,7 +82,7 @@ topology_template:
- "/var/run/docker.sock:/var/run/docker.sock"
requirements:
- host:
capability: "tosca.capabilities.ARTICONF.Orchestrator"
capability: "tosca.capabilities.ARTICONF.docker.Orchestrator"
node: "kubernetes"
relationship: "tosca.relationships.HostedOn"
type: "tosca.nodes.ARTICONF.Container.Application.Docker"
......@@ -104,7 +104,7 @@ topology_template:
- "db_data:/var/lib/mysql"
requirements:
- host:
capability: "tosca.capabilities.ARTICONF.Orchestrator"
capability: "tosca.capabilities.ARTICONF.docker.Orchestrator"
node: "kubernetes"
relationship: "tosca.relationships.HostedOn"
type: "tosca.nodes.ARTICONF.Container.Application.Docker"
......
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template:
node_templates:
compute:
interfaces:
Standard:
create: dumy.yaml
properties:
disk_size: 50000 MB
mem_size: 6000 MB
num_cores: 2
os: Ubuntu 18.04
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template:
node_templates:
kubernetes:
interfaces:
Kubernetes:
configure:
inputs:
playbook: https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/dashboard.yaml
create:
inputs:
playbook: https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml
install:
inputs:
playbook: https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml
properties:
min_masters_num: 1
min_workers_num: 1
type: tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes
tosca_definitions_version: tosca_simple_yaml_1_0
tosca_definitions_version: tosca_simple_yaml_1_0
tosca_definitions_version: "tosca_simple_yaml_1_0"
description: "TOSCA example"
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
description: >
TOSCA example
- nodes: "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml"
- data: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml"
- capabilities: "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml"
- policies: "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml"
- interfaces: "https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml"
topology_template:
node_templates:
mongo:
type: tosca.nodes.ARTICONF.Container.Application.Docker
properties:
ports:
- "30001:27017"
volumes:
- db-data:/data/db
environment:
ROOT_PASSWORD: root_passwd
DATABASE: db
USER: user
PASSWORD: passwd
artifacts:
image:
type: tosca.artifacts.Deployment.Image.Container.Docker
file: mongo:3
repository: docker_hub
node_templates:
kubernetes:
properties:
min_masters_num: 1
min_workers_num: 1
#requirements:
#- host:
#capability: "tosca.capabilities.ARTICONF.VM.topology"
#node: "topology"
#relationship: "tosca.relationships.HostedOn"
interfaces:
Kubernetes:
create:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml"
install:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml"
type: "tosca.nodes.ARTICONF.Orchestrator.Kubernetes"
#mysql:
#type: "tosca.nodes.ARTICONF.Container.Application.Docker"
#properties:
#environment:
#MYSQL_DATABASE: "wordpress"
#MYSQL_PASSWORD: "wordpress"
#MYSQL_ROOT_PASSWORD: "somewordpress"
#MYSQL_USER: "wordpress"
#ports:
#- "3306:3306"
#volumes:
#- "db_data:/var/lib/mysql"
#requirements:
#- host:
#capability: "tosca.capabilities.ARTICONF.docker.Orchestrator"
#node: "kubernetes"
#relationship: "tosca.relationships.HostedOn"
#artifacts:
#image:
#file: "mysql:5.7"
#repository: "docker_hub"
#type: "tosca.artifacts.Deployment.Image.Container.Docker"
#topology:
#properties:
#domain: "Frankfurt"
#provider: "EC2"
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: "SEQ"
#object_type: "SubTopology"
#type: "tosca.nodes.ARTICONF.VM.topology"
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template:
node_templates:
topology:
interfaces:
CloudsStorm:
provision:
inputs:
code_type: SEQ
object_type: SubTopology
properties:
domain: Frankfurt
provider: EC2
type: tosca.nodes.ARTICONF.VM.topology
tosca_definitions_version: tosca_simple_yaml_1_0
......@@ -104,7 +104,7 @@ def handle_delivery(message, sys=None):
spec_service = SpecService(conf)
test_planner = Planner(tosca_path=input_tosca_file_path, spec_service=spec_service)
tosca_template = test_planner.resolve_requirements()
tosca_template = test_planner.set_infrastructure_specifications()
tosca_template = test_planner.set_node_templates_properties()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(tosca_template)
Planner(yaml_dict_tpl=template_dict, spec_service=spec_service)
......@@ -135,7 +135,7 @@ if __name__ == "__main__":
spec_service = SpecService(conf)
test_planner = Planner(input_tosca_file_path, spec_service)
test_tosca_template = test_planner.resolve_requirements()
test_tosca_template = test_planner.set_infrastructure_specifications()
test_tosca_template = test_planner.set_node_templates_properties()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template_dict))
......
This diff is collapsed.
This diff is collapsed.
......@@ -15,20 +15,38 @@ from service.spec_service import SpecService
from util import tosca_helper
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class MyTestCase(unittest.TestCase):
# def test_only_docker_node(self):
# file_name = 'application_example_updated.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
def test_docker(self):
file_name = 'application_example_updated.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
def test_with_existing_nodes(self):
file_name = 'lifeWatch_vre1.yaml'
def test_kubernetes(self):
file_name = 'kubernetes.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
def test_topology(self):
file_name = 'topology.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
def test_compute(self):
file_name = 'compute.yaml'
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
self.run_test(input_tosca_file_path)
# def test_lifeWatch(self):
# file_name = 'lifeWatch_vre1.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
def get_input_tosca_file_path(self, file_name):
tosca_path = "../../TOSCA/"
input_tosca_file_path = tosca_path + file_name
......@@ -46,10 +64,11 @@ class MyTestCase(unittest.TestCase):
test_planner = Planner(input_tosca_file_path, spec_service)
test_tosca_template = test_planner.resolve_requirements()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
test_tosca_template = test_planner.set_infrastructure_specifications()
test_tosca_template = test_planner.set_node_templates_properties()
template_dict = tosca_helper.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template_dict))
print(yaml.dump(template_dict))
ToscaTemplate(yaml_dict_tpl=copy.deepcopy(template_dict))
test_response = {'toscaTemplate': template_dict}
......@@ -58,5 +77,5 @@ class MyTestCase(unittest.TestCase):
output_current_milli_time = int(round(time.time() * 1000))
response["creationDate"] = output_current_milli_time
response["parameters"] = []
print("Output message:" + json.dumps(response))
# print("Output message:" + json.dumps(response))
self.assertEqual(True, True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment