Commit 163e531e authored by Spiros Koulouzis's avatar Spiros Koulouzis

added tests

parent 8650a4b3
......@@ -10,12 +10,12 @@ topology_template:
Standard:
create: dumy.yaml
properties:
cpu_frequency: 0.5 GHz
disk_size: 15000 MB
disk_size: 50000 MB
host_name: vm
mem_size: 500 MB
num_cpus: 1
os: ubuntu 15
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
role: master
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
compute_1:
......@@ -23,15 +23,24 @@ topology_template:
Standard:
create: dumy.yaml
properties:
cpu_frequency: 0.5 GHz
disk_size: 15000 MB
disk_size: 50000 MB
host_name: vm
mem_size: 500 MB
num_cpus: 1
os: ubuntu 15
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
role: worker
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
kubernetes:
interfaces:
Standard:
create: interfaces/playbooks/kubernetes_install.yaml
requirements:
- host:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
mysql:
artifacts:
image:
......@@ -51,48 +60,24 @@ topology_template:
requirements:
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: swarm
relationship: tosca.relationships.HostedOn
- useless:
capability: tosca.capabilities.ARTICONF.Useless
node: swarm
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
swarm:
interfaces:
Standard:
create: interfaces/playbooks/docker_swarm_install.yaml
properties:
masters_num: 1
workers_num: 1
requirements:
- host:
capability: tosca.capabilities.Scalable
node: topology
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Swarm
topology:
interfaces:
Standard:
create: dumy.yaml
properties:
domain: {}
name: {}
provider: {}
domain: UvA (Amsterdam, The Netherlands) XO Rack
provider: ExoGeni
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute
occurrences:
- 1
- UNBOUNDED
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_1
occurrences:
- 1
- UNBOUNDED
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology
wordpress:
......@@ -116,11 +101,7 @@ topology_template:
type: tosca.relationships.DependsOn
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: swarm
relationship: tosca.relationships.HostedOn
- useless:
capability: tosca.capabilities.ARTICONF.Useless
node: swarm
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
policies:
......
......@@ -2,8 +2,13 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/planner/simple_spec_alayzer.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/rpc_server.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/rpc_server.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/test_planner.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/tests/test_planner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/tosca.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/tosca.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -39,6 +44,9 @@
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/tests" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/planner" />
</key>
......@@ -90,7 +98,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" />
<option name="PARAMETERS" value="test_local" />
<option name="PARAMETERS" value="localhost planner_queue" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
......@@ -110,7 +118,7 @@
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/test_planner.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/tests/test_planner.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
......@@ -119,9 +127,24 @@
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="Unittests in tests" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<module name="drip_planner2" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/src/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.rpc_server" />
<item itemvalue="Python tests.Unittests in tests" />
<item itemvalue="Python.test_planner" />
<item itemvalue="Python.basic_planner" />
</list>
......@@ -257,7 +280,14 @@
<option name="project" value="LOCAL" />
<updated>1571757387680</updated>
</task>
<option name="localTasksCounter" value="18" />
<task id="LOCAL-00018" summary="check if topology node has properties">
<created>1571760668434</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1571760668434</updated>
</task>
<option name="localTasksCounter" value="19" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
......@@ -290,7 +320,8 @@
<MESSAGE value="set min number of VMs based on the swarm default workers and masters" />
<MESSAGE value="fixed policies error" />
<MESSAGE value="added test" />
<option name="LAST_COMMIT_MESSAGE" value="added test" />
<MESSAGE value="check if topology node has properties" />
<option name="LAST_COMMIT_MESSAGE" value="check if topology node has properties" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
......@@ -305,11 +336,6 @@
<line>22</line>
<option name="timeStamp" value="128" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>136</line>
<option name="timeStamp" value="295" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>106</line>
......@@ -317,13 +343,8 @@
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>99</line>
<option name="timeStamp" value="303" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/planner/simple_spec_alayzer.py</url>
<line>24</line>
<option name="timeStamp" value="304" />
<line>138</line>
<option name="timeStamp" value="305" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
......
......@@ -5,11 +5,11 @@ from toscaparser.topology_template import TopologyTemplate
import operator
from planner.simple_spec_alayzer import SimpleAnalyzer
from planner.spec_service import *
from utils.tosca import *
from planner.specification_analyzer import *
from utils import tosca as tosca_util
from src.planner.simple_spec_alayzer import SimpleAnalyzer
from src.planner.spec_service import *
from src.utils.tosca import *
from src.planner.specification_analyzer import *
from src.utils import tosca as tosca_util
import matplotlib.pyplot as plt
......
......@@ -31,7 +31,6 @@ class SimpleAnalyzer(SpecificationAnalyzer):
masters_num = orchestrator_nodes[0].get_property_value('masters_num')
workers_num = orchestrator_nodes[0].get_property_value('workers_num')
topology_nodes = tosca_util.get_nodes_by_type('tosca.nodes.ARTICONF.VM.topology',
self.tosca_template.nodetemplates, self.all_node_types,
self.all_custom_def)
......
......@@ -98,7 +98,7 @@ def handle_delivery(message):
logger.info("template ----: \n" + yaml.dump(template_dict))
response = {'toscaTemplate': template_dict}
output_current_milli_time = lambda: int(round(time.time() * 1000))
output_current_milli_time = int(round(time.time() * 1000))
response["creationDate"] = output_current_milli_time
response["parameters"] = []
if queue_name == "planner_queue":
......@@ -118,7 +118,7 @@ if __name__ == "__main__":
test_planner = Planner(input_tosca_file_path, spec_service)
test_tosca_template = test_planner.resolve_requirements()
test_tosca_template = test_planner.set_infrastructure_specifications()
template = tosca_util.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
template_dict = tosca_util.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template))
try:
......@@ -132,9 +132,12 @@ if __name__ == "__main__":
input_tosca_file_path = tosca_path + '/application_example_output.yaml'
with open(input_tosca_file_path, 'w') as outfile:
outfile.write(yaml.dump(template))
outfile.write(yaml.dump(template_dict))
ToscaTemplate(input_tosca_file_path)
test_response = {'toscaTemplate': template_dict}
logger.info("Output message:" + json.dumps(test_response))
else:
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv)
......
import json
import logging
import os
import os.path
import tempfile
import time
import unittest
from planner.planner import *
from planner.spec_service import SpecService
from utils import tosca as tosca_util
from src.planner.planner import *
from src.planner.spec_service import SpecService
from src.utils import tosca as tosca_util
class MyTestCase(unittest.TestCase):
def test_something(self):
tosca_path = "../../TOSCA/"
tosca_file_path = tosca_path+'/application_example_updated.yaml'
logger = logging.getLogger(__name__)
tosca_path = "../../../TOSCA/"
input_tosca_file_path = tosca_path + '/application_example.yaml'
dir_path = os.path.dirname(os.path.realpath(__file__))
print(dir_path)
self.assertEqual(True, os.path.exists(input_tosca_file_path),
"Input TOSCA file: " + input_tosca_file_path + " not found")
conf = {'url': "http://host"}
spec_service = SpecService(conf)
test_planner = Planner(tosca_file_path, spec_service)
tosca_template = test_planner.resolve_requirements()
tosca_template = test_planner.set_infrastructure_specifications()
template = tosca_util.get_tosca_template_2_topology_template_dictionary(tosca_template)
# logger.info("template ----: \n" + yaml.dump(template))
test_planner = Planner(input_tosca_file_path, spec_service)
test_tosca_template = test_planner.resolve_requirements()
test_tosca_template = test_planner.set_infrastructure_specifications()
template_dict = tosca_util.get_tosca_template_2_topology_template_dictionary(test_tosca_template)
logger.info("template ----: \n" + yaml.dump(template_dict))
try:
tosca_folder_path = os.path.join(tempfile.gettempdir(), tosca_path)
......@@ -28,10 +39,18 @@ class MyTestCase(unittest.TestCase):
tosca_folder_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.path.join(tempfile.gettempdir(),
tosca_path)
tosca_file_name = 'tosca_template'
input_tosca_file_path = tosca_path+'/application_example_output.yaml'
input_tosca_file_path = tosca_path + '/application_example_output.yaml'
with open(input_tosca_file_path, 'w') as outfile:
outfile.write(yaml.dump(template))
outfile.write(yaml.dump(template_dict))
ToscaTemplate(input_tosca_file_path)
test_response = {'toscaTemplate': template_dict}
response = {'toscaTemplate': template_dict}
output_current_milli_time = int(round(time.time() * 1000))
response["creationDate"] = output_current_milli_time
response["parameters"] = []
print("Output message:" + json.dumps(response))
self.assertEqual(True, True)
......@@ -5,7 +5,7 @@ from toscaparser import tosca_template
from toscaparser.elements.nodetype import NodeType
from toscaparser.nodetemplate import NodeTemplate
from utils.TOSCA_parser import TOSCAParser
from src.utils.TOSCA_parser import TOSCAParser
import yaml
import logging
......
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