From 47ad5c7df335a8273dd74b731b0f2c635b2ec26f Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 28 Jun 2016 14:56:54 +0200 Subject: [PATCH] Add test using container node types. Add a simple TOSCA example to test Container node types. Change-Id: I7db0b83ea2fd2a3344736dfbdad8f46abdd1a3d6 Partially-Implements: blueprint tosca-container-suppot --- toscaparser/tests/data/test_containers.yaml | 44 +++++++++++++++++++++ toscaparser/tests/test_toscatpl.py | 6 +++ 2 files changed, 50 insertions(+) create mode 100644 toscaparser/tests/data/test_containers.yaml diff --git a/toscaparser/tests/data/test_containers.yaml b/toscaparser/tests/data/test_containers.yaml new file mode 100644 index 00000000..ba1cc161 --- /dev/null +++ b/toscaparser/tests/data/test_containers.yaml @@ -0,0 +1,44 @@ +tosca_definitions_version: tosca_simple_yaml_1_0 + +description: > + TOSCA simple profile with mysql docker container. + +# Repositories to retrieve code artifacts from +repositories: + docker_hub: https://registry.hub.docker.com/ + +topology_template: + + inputs: + mysql_root_pwd: + type: string + description: Root password for MySQL. + + node_templates: + # The MYSQL container based on official MySQL image in Docker hub + mysql_container: + type: tosca.nodes.Container.Application + requirements: + - host: mysql_runtime + artifacts: + my_image: + file: mysql + type: tosca.artifacts.Deployment.Image.Container.Docker + repository: docker_hub + interfaces: + Standard: + create: + implementation: my_image + inputs: + MYSQL_ROOT_PASSWORD: { get_input: mysql_root_pwd } + + # The properties of the runtime to host the container + mysql_runtime: + type: tosca.nodes.Container.Runtime + capabilities: + host: + properties: + num_cpus: 1 + disk_size: 10 GB + mem_size: 2 MB + diff --git a/toscaparser/tests/test_toscatpl.py b/toscaparser/tests/test_toscatpl.py index 953d4f6f..bdfd982a 100644 --- a/toscaparser/tests/test_toscatpl.py +++ b/toscaparser/tests/test_toscatpl.py @@ -791,3 +791,9 @@ class ToscaTemplateTest(TestCase): vmax='65534')) exception.ExceptionCollector.assertExceptionMessage( exception.RangeValueError, msg) + + def test_containers(self): + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/test_containers.yaml") + ToscaTemplate(tosca_tpl)