Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
e33cdc35
Commit
e33cdc35
authored
Apr 16, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test to validate all tosca examples
parent
f2de48e1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
232 additions
and
9 deletions
+232
-9
application_example_2_topologies.yaml
TOSCA/application_example_2_topologies.yaml
+3
-0
application_example_outputs.yaml
TOSCA/application_example_outputs.yaml
+172
-0
Dockerfile
bin/CI-docker/java/Dockerfile
+1
-1
send_to_sonarqube.sh
bin/CI-docker/java/send_to_sonarqube.sh
+6
-3
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+1
-1
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+20
-4
test_tosca_template_service.py
...ask-server/sure_tosca/test/test_tosca_template_service.py
+29
-0
No files found.
TOSCA/application_example_2_topologies.yaml
View file @
e33cdc35
tosca_definitions_version
:
"
tosca_simple_yaml_1_0"
topology_template
:
node_templates
:
compute
:
properties
:
...
...
@@ -154,6 +155,8 @@ topology_template:
playbooks
:
-
get_info_service.yml
description
:
"
TOSCA
example"
imports
:
-
nodes
:
"
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml"
...
...
TOSCA/application_example_outputs.yaml
0 → 100644
View file @
e33cdc35
tosca_definitions_version
:
"
tosca_simple_yaml_1_0"
topology_template
:
node_templates
:
compute
:
properties
:
disk_size
:
"
10000
MB"
mem_size
:
"
1000
MB"
num_cores
:
1
os
:
"
Ubuntu
18.04"
user_name
:
"
vm_user"
interfaces
:
Standard
:
create
:
"
dumy.yaml"
type
:
"
tosca.nodes.ARTICONF.VM.Compute"
compute_1
:
properties
:
disk_size
:
"
10000
MB"
mem_size
:
"
1000
MB"
num_cores
:
1
os
:
"
Ubuntu
18.04"
user_name
:
"
vm_user"
interfaces
:
Standard
:
create
:
"
dumy.yaml"
type
:
"
tosca.nodes.ARTICONF.VM.Compute"
kubernetes
:
requirements
:
-
host
:
capability
:
"
tosca.capabilities.ARTICONF.VM.topology"
node
:
"
topology"
relationship
:
"
tosca.relationships.HostedOn"
interfaces
:
Standard
:
configure
:
inputs
:
playbook
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/k8s_dashboard.yaml"
create
:
inputs
:
playbook
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yaml"
delete
:
inputs
:
playbook
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/k8s_delete.yaml"
type
:
"
tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes"
topology
:
properties
:
domain
:
"
Frankfurt"
provider
:
"
EC2"
requirements
:
-
vm
:
capability
:
"
tosca.capabilities.ARTICONF.VM"
node
:
"
compute_1"
relationship
:
"
tosca.relationships.DependsOn"
interfaces
:
CloudsStorm
:
delete
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
hscale
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
provision
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
start
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
stop
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
type
:
"
tosca.nodes.ARTICONF.VM.topology"
topology_1
:
properties
:
domain
:
"
Frankfurt"
provider
:
"
EC2"
requirements
:
-
vm
:
capability
:
"
tosca.capabilities.ARTICONF.VM"
node
:
"
compute_1"
relationship
:
"
tosca.relationships.DependsOn"
interfaces
:
CloudsStorm
:
delete
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
hscale
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
provision
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
start
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
stop
:
inputs
:
code_type
:
"
SEQ"
object_type
:
"
SubTopology"
type
:
"
tosca.nodes.ARTICONF.VM.topology"
artifacts
:
provisioned_files
:
required
:
false
type
:
"
string"
ws-pema
:
properties
:
ports
:
-
"
30001:8080"
requirements
:
-
host
:
capability
:
"
tosca.capabilities.ARTICONF.docker.Orchestrator"
node
:
"
kubernetes"
relationship
:
"
tosca.relationships.HostedOn"
type
:
"
tosca.nodes.ARTICONF.Container.Application.Docker"
artifacts
:
image
:
file
:
"
alogo53/ws-pema-lifewatch"
repository
:
"
docker_hub"
type
:
"
tosca.artifacts.Deployment.Image.Container.Docker"
interfaces
:
Kubernetes
:
delete
:
inputs
:
repository
:
https://github.com/skoulouzis/playbooks.git
playbooks
:
-
delete_service.yml
create
:
inputs
:
repository
:
https://github.com/skoulouzis/playbooks.git
playbooks
:
-
create_service.yml
scale
:
inputs
:
repository
:
https://github.com/skoulouzis/playbooks.git
playbooks
:
-
scale_service.yml
replicas
:
1
autoscale
:
inputs
:
repository
:
https://github.com/skoulouzis/playbooks.git
playbooks
:
-
autoscale_service.yml
horizontal_pod_autoscaler
:
horizontal_pod_autoscaler.yml
info
:
inputs
:
repository
:
https://github.com/skoulouzis/playbooks.git
playbooks
:
-
get_info_service.yml
outputs
:
private_ip_compute
:
description
:
The private IP address of the application’s first tier.
value
:
{
get_attribute
:
[
compute
,
private_ip
]
}
private_ip_compute_1
:
description
:
The private IP address of the application’s second tier.
value
:
{
get_attribute
:
[
compute_1
,
private_ip
]
}
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"
bin/CI-docker/java/Dockerfile
View file @
e33cdc35
...
...
@@ -8,7 +8,7 @@ COPY send_to_sonarqube.sh send_to_sonarqube.sh
CMD
./clone_git.sh $BRANCH $GIT_URL $FOLDER_NAME && \
./build.sh $FOLDER_NAME && \
./send_to_sonarqube.sh $SONAR_HOST $SONAR_LOGIN
./send_to_sonarqube.sh $
FOLDER_NAME $
SONAR_HOST $SONAR_LOGIN
...
...
bin/CI-docker/java/send_to_sonarqube.sh
View file @
e33cdc35
#!/bin/bash
SONAR_HOST
=
$1
SONAR_LOGIN
=
$2
SRC
=
$1
SONAR_HOST
=
$2
SONAR_LOGIN
=
$3
for
i
in
$(
find
-name
target
)
;
do
# Not recommended, will break on whitespace
cd
$SRC
for
i
in
$(
find
.
-name
target
)
;
do
# Not recommended, will break on whitespace
echo
"Sending
$i
"
done
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
e33cdc35
...
...
@@ -106,7 +106,7 @@ def save(file: FileStorage):
# try:
# tosca_template_file_path = os.path.join(db_dir_path, file.filename)
start
=
time
.
time
()
logger
.
info
(
"Got request for tosca template
"
)
logger
.
info
(
"Got request for tosca template
. File name: "
+
str
(
file
.
filename
)
)
purge_all_tables
()
dictionary
=
yaml
.
safe_load
(
file
.
stream
)
# dictionary = yaml.load(file.stream)
...
...
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
View file @
e33cdc35
...
...
@@ -21,7 +21,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties'
.
format
(
id
=
id_example
,
node_name
=
'compute'
),
...
...
@@ -36,6 +36,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types'
.
format
(
id
=
id_example
,
node_name
=
'compute'
),
...
...
@@ -50,7 +51,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements'
.
format
(
id
=
id_example
,
node_name
=
'kubernetes'
),
...
...
@@ -66,6 +67,7 @@ class TestDefaultController(BaseTestCase):
"""
# query_string = [('anchors', 'anchors_example'), ('derived_from', 'derived_from_example')]
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/dsl_definitions'
.
format
(
id
=
id_example
),
method
=
'GET'
)
...
...
@@ -77,6 +79,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/imports'
.
format
(
id
=
id_example
),
method
=
'GET'
)
...
...
@@ -87,7 +90,8 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
id_example
=
self
.
upload_file
(
'application_example_outputs.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs'
.
format
(
id
=
id_example
,
node_name
=
'compute'
),
...
...
@@ -102,6 +106,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'
.
format
(
id
=
id_example
,
node_name
=
'compute'
),
...
...
@@ -116,6 +121,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements'
.
format
(
id
=
id_example
,
node_name
=
'kubernetes'
),
...
...
@@ -130,6 +136,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
query_string
=
[(
'type_name'
,
None
),
(
'node_name'
,
'compute'
),
(
'has_interfaces'
,
True
),
...
...
@@ -200,6 +207,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name'
.
format
(
id
=
id_example
,
node_name
=
'compute'
),
...
...
@@ -214,6 +222,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from'
.
format
(
id
=
id_example
,
node_name
=
'kubernetes'
),
...
...
@@ -228,6 +237,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/related'
.
format
(
id
=
id_example
,
node_name
=
'mysql'
),
...
...
@@ -242,6 +252,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
query_string
=
[(
'type_name'
,
None
),
(
'derived_from'
,
None
)]
response
=
self
.
client
.
open
(
...
...
@@ -256,6 +267,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template'
.
format
(
id
=
id_example
),
method
=
'GET'
)
...
...
@@ -269,6 +281,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}'
.
format
(
id
=
id_example
),
method
=
'GET'
)
...
...
@@ -282,6 +295,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
query_string
=
[(
'kind_of_type'
,
'interface_types'
),
(
'has_interfaces'
,
None
),
(
'type_name'
,
'tosca.interfaces.ARTICONF.CloudsStorm'
),
...
...
@@ -321,6 +335,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
properties
=
{
'properties'
:
{
'cpu_frequency'
:
'2 GHz'
}}
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'
.
format
(
...
...
@@ -340,7 +355,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'
.
format
(
id
=
id_example
),
method
=
'GET'
,
...
...
@@ -356,6 +371,7 @@ class TestDefaultController(BaseTestCase):
"""
id_example
=
self
.
upload_file
(
'application_example_2_topologies.yaml'
)
self
.
assertTrue
(
id_example
>=
0
)
query_string
=
[(
'instance_name'
,
'instance_name_example'
),
(
'operation_name'
,
'provision'
)]
response
=
self
.
client
.
open
(
...
...
sure_tosca-flask-server/sure_tosca/test/test_tosca_template_service.py
View file @
e33cdc35
...
...
@@ -2,12 +2,41 @@ import os
from
unittest
import
TestCase
from
six
import
BytesIO
from
werkzeug.datastructures
import
FileStorage
import
logging
from
sure_tosca.models
import
ToscaTemplateModel
from
sure_tosca.service
import
tosca_template_service
logger
=
logging
.
getLogger
(
__name__
)
if
not
getattr
(
logger
,
'handler_set'
,
None
):
logger
.
setLevel
(
logging
.
INFO
)
h
=
logging
.
StreamHandler
()
formatter
=
logging
.
Formatter
(
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s'
)
h
.
setFormatter
(
formatter
)
logger
.
addHandler
(
h
)
logger
.
handler_set
=
True
class
Test
(
TestCase
):
def
test_upload
(
self
):
file_names
=
[
'application_example_outputs.yaml'
,
'application_example_2_topologies.yaml'
,
'lifeWatch_vre1.yaml'
,
'application_example_updated.yaml'
,
'compute.yaml'
,
'application_example_provisioned.yaml'
,
'topology.yaml'
,
'kubernetes.yaml'
,
'application_example_planed.yaml'
]
for
file_name
in
file_names
:
logger
.
info
(
"Testing : "
+
str
(
file_name
))
doc_id
=
tosca_template_service
.
save
(
self
.
upload_file
(
file_name
))
logger
.
info
(
"doc_id : "
+
str
(
doc_id
))
self
.
assertTrue
(
doc_id
>=
0
)
def
test_get_tosca_template_model_by_id
(
self
):
doc_id
=
tosca_template_service
.
save
(
self
.
upload_file
(
'application_example_updated.yaml'
))
tosca_template_dict
=
tosca_template_service
.
get_tosca_template_dict_by_id
(
doc_id
)
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
self
.
assertIsNotNone
(
tosca_template_model
)
self
.
assertIsNotNone
(
tosca_template_model
.
topology_template
)
self
.
assertIsNotNone
(
tosca_template_model
.
topology_template
.
node_templates
)
def
test_get_tosca_template_model_by_id
(
self
):
doc_id
=
tosca_template_service
.
save
(
self
.
upload_file
(
'application_example_updated.yaml'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment