Skip to content
Snippets Groups Projects
Commit a33659ee authored by Michele Chiari's avatar Michele Chiari
Browse files

Add one test for each requirement.

parent 92fd1bb3
No related branches found
No related tags found
No related merge requests found
Showing
with 962 additions and 19 deletions
......@@ -5,6 +5,8 @@ The DOML Model Checker verifies DOML models against a collection of requirements
devised to highlight the most common mistakes made by users when specifying cloud deployments.
Here we list and describe such requirements.
You may find examples of violations for each one of these requirements under the ``tests/doml`` directory.
VM Network Interfaces
---------------------
......
%% Cell type:code id: tags:
``` python
import mc_openapi.doml_mc as mc
doml_document_path = "../../tests/doml/nginx-openstack_v2.domlx"
# doml_document_path = "../../tests/doml/nginx-openstack_v2_wrong.domlx"
doml_document_path = "../../tests/doml/nginx-openstack_v2.0.domlx"
# doml_document_path = "../../tests/doml/nginx-openstack_v2.0_wrong_vm_iface.domlx"
# doml_document_path = "../../tests/doml/faas.domlx"
with open(doml_document_path, "rb") as xmif:
doc = xmif.read()
dmc = mc.ModelChecker(doc)
```
%% Cell type:code id: tags:
``` python
r = dmc.check_common_requirements(2, False, 50)
r.summarize()
```
......
doml nginx_openstack
application app {
software_component nginx {
properties {
source_code="/usr/share/nginx/html/index.html";
}
}
}
infrastructure infra {
vm_image v_img {
generates vm1
}
net net1 {
address "16.0.0.0/24"
protocol "tcp/ip"
}
security_group sg {
egress icmp {
from_port -1
to_port -1
protocol "icmp"
cidr ["0.0.0.0/0"]
}
ingress http {
from_port 80
to_port 80
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress https {
from_port 443
to_port 443
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress ssh {
from_port 22
to_port 22
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ifaces i1
}
key_pair ssh_key {
user "ubuntu"
keyfile "/home/user1/.ssh/openstack.key"
algorithm "RSA"
bits 4096
}
autoscale_group ag {
vm vm1 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
network net1
}
}
deployment config {
}
active deployment config
concretizations {
concrete_infrastructure con_infra {
provider openstack {
vm concrete_vm {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm1
}
vm_image concrete_vm_image {
properties {
name = "ubuntu-20.04.3";
}
maps v_img
}
net concrete_net {
properties {
name = "ostack2";
}
maps net1
}
}
}
active con_infra
}
optimization opt {
objectives {
"cost" => min
}
nonfunctional_requirements {
req1 "Cost <= 200" max 200.0 => "cost";
req2 "Provider" values "AMAZ" => "provider";
}
}
<?xml version="1.0" encoding="ASCII"?>
<commons:DOMLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:app="http://www.piacere-project.eu/doml/application" xmlns:commons="http://www.piacere-project.eu/doml/commons" xmlns:infra="http://www.piacere-project.eu/doml/infrastructure" xmlns:optimization="http://www.piacere-project.eu/doml/optimization" name="nginx_openstack" activeConfiguration="//@configurations.0" activeInfrastructure="//@concretizations.0">
<application name="app">
<components xsi:type="app:SoftwareComponent" name="nginx">
<annotations xsi:type="commons:SProperty" key="source_code" value="/usr/share/nginx/html/index.html"/>
</components>
</application>
<infrastructure name="infra">
<generators xsi:type="infra:VMImage" name="v_img" generatedVMs="//@infrastructure/@groups.0/@machineDefinition"/>
<credentials xsi:type="infra:KeyPair" name="ssh_key" user="ubuntu" keyfile="/home/user1/.ssh/openstack.key" algorithm="RSA" bits="4096"/>
<groups xsi:type="infra:AutoScalingGroup" name="ag" deploymentNetwork="//@infrastructure/@networks.0">
<machineDefinition name="vm1" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0" generatedFrom="//@infrastructure/@generators.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</machineDefinition>
</groups>
<securityGroups name="sg" ifaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0">
<rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="http" kind="INGRESS" protocol="tcp" fromPort="80" toPort="80">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="https" kind="INGRESS" protocol="tcp" fromPort="443" toPort="443">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="ssh" kind="INGRESS" protocol="tcp" fromPort="22" toPort="22">
<cidr>0.0.0.0/0</cidr>
</rules>
</securityGroups>
<networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0"/>
</infrastructure>
<concretizations name="con_infra">
<providers name="openstack">
<vms name="concrete_vm" maps="//@infrastructure/@groups.0/@machineDefinition">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vmImages name="concrete_vm_image" maps="//@infrastructure/@generators.0">
<annotations xsi:type="commons:SProperty" key="name" value="ubuntu-20.04.3"/>
</vmImages>
<networks name="concrete_net" maps="//@infrastructure/@networks.0">
<annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
</networks>
</providers>
</concretizations>
<optimization name="opt">
<objectives xsi:type="optimization:MeasurableObjective" kind="min" property="cost"/>
<nonfunctionalRequirements xsi:type="commons:RangedRequirement" name="req1" description="Cost &lt;= 200" property="cost" max="200.0"/>
<nonfunctionalRequirements xsi:type="commons:EnumeratedRequirement" name="req2" description="Provider" property="provider">
<values>AMAZ</values>
</nonfunctionalRequirements>
</optimization>
<configurations name="config"/>
</commons:DOMLModel>
doml nginx_openstack
application app {
software_component nginx {
properties {
source_code="/usr/share/nginx/html/index.html";
}
}
}
infrastructure infra {
vm_image v_img {
generates vm1
}
net net1 {
address "16.0.0.0/24"
protocol "tcp/ip"
}
security_group sg {
egress icmp {
from_port -1
to_port -1
protocol "icmp"
cidr ["0.0.0.0/0"]
}
ingress http {
from_port 80
to_port 80
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress https {
from_port 443
to_port 443
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress ssh {
from_port 22
to_port 22
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ifaces i1
}
key_pair ssh_key {
user "ubuntu"
keyfile "/home/user1/.ssh/openstack.key"
algorithm "RSA"
bits 4096
}
autoscale_group ag {
vm vm1 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
network net1
}
}
deployment config {
nginx -> vm1
}
active deployment config
concretizations {
concrete_infrastructure con_infra {
provider openstack {
vm concrete_vm {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm1
}
vm_image concrete_vm_image {
properties {
name = "ubuntu-20.04.3";
}
// maps v_img
}
net concrete_net {
properties {
name = "ostack2";
}
maps net1
}
}
}
active con_infra
}
optimization opt {
objectives {
"cost" => min
}
nonfunctional_requirements {
req1 "Cost <= 200" max 200.0 => "cost";
req2 "Provider" values "AMAZ" => "provider";
}
}
<?xml version="1.0" encoding="ASCII"?>
<commons:DOMLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:app="http://www.piacere-project.eu/doml/application" xmlns:commons="http://www.piacere-project.eu/doml/commons" xmlns:infra="http://www.piacere-project.eu/doml/infrastructure" xmlns:optimization="http://www.piacere-project.eu/doml/optimization" name="nginx_openstack" activeConfiguration="//@configurations.0" activeInfrastructure="//@concretizations.0">
<application name="app">
<components xsi:type="app:SoftwareComponent" name="nginx">
<annotations xsi:type="commons:SProperty" key="source_code" value="/usr/share/nginx/html/index.html"/>
</components>
</application>
<infrastructure name="infra">
<generators xsi:type="infra:VMImage" name="v_img" generatedVMs="//@infrastructure/@groups.0/@machineDefinition"/>
<credentials xsi:type="infra:KeyPair" name="ssh_key" user="ubuntu" keyfile="/home/user1/.ssh/openstack.key" algorithm="RSA" bits="4096"/>
<groups xsi:type="infra:AutoScalingGroup" name="ag" deploymentNetwork="//@infrastructure/@networks.0">
<machineDefinition name="vm1" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0" generatedFrom="//@infrastructure/@generators.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</machineDefinition>
</groups>
<securityGroups name="sg" ifaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0">
<rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="http" kind="INGRESS" protocol="tcp" fromPort="80" toPort="80">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="https" kind="INGRESS" protocol="tcp" fromPort="443" toPort="443">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="ssh" kind="INGRESS" protocol="tcp" fromPort="22" toPort="22">
<cidr>0.0.0.0/0</cidr>
</rules>
</securityGroups>
<networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0"/>
</infrastructure>
<concretizations name="con_infra">
<providers name="openstack">
<vms name="concrete_vm" maps="//@infrastructure/@groups.0/@machineDefinition">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vmImages name="concrete_vm_image">
<annotations xsi:type="commons:SProperty" key="name" value="ubuntu-20.04.3"/>
</vmImages>
<networks name="concrete_net" maps="//@infrastructure/@networks.0">
<annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
</networks>
</providers>
</concretizations>
<optimization name="opt">
<objectives xsi:type="optimization:MeasurableObjective" kind="min" property="cost"/>
<nonfunctionalRequirements xsi:type="commons:RangedRequirement" name="req1" description="Cost &lt;= 200" property="cost" max="200.0"/>
<nonfunctionalRequirements xsi:type="commons:EnumeratedRequirement" name="req2" description="Provider" property="provider">
<values>AMAZ</values>
</nonfunctionalRequirements>
</optimization>
<configurations name="config">
<deployments component="//@application/@components.0" node="//@infrastructure/@groups.0/@machineDefinition"/>
</configurations>
</commons:DOMLModel>
doml nginx_openstack
application app {
software_component nginx {
properties {
source_code="/usr/share/nginx/html/index.html";
}
}
}
infrastructure infra {
vm_image v_img {
generates vm1
}
net net1 {
address "16.0.0.0/24"
protocol "tcp/ip"
}
security_group sg {
egress icmp {
from_port -1
to_port -1
protocol "icmp"
cidr ["0.0.0.0/0"]
}
ingress http {
from_port 80
to_port 80
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress https {
from_port 443
to_port 443
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress ssh {
from_port 22
to_port 22
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ifaces i1
}
key_pair ssh_key {
user "ubuntu"
keyfile "/home/user1/.ssh/openstack.key"
algorithm "RSA"
bits 4096
}
autoscale_group ag {
vm vm1 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
network net1
}
}
deployment config {
nginx -> vm1
}
active deployment config
concretizations {
concrete_infrastructure con_infra {
provider openstack {
vm concrete_vm {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm1
}
vm_image concrete_vm_image {
properties {
name = "ubuntu-20.04.3";
}
maps v_img
}
}
}
active con_infra
}
optimization opt {
objectives {
"cost" => min
}
nonfunctional_requirements {
req1 "Cost <= 200" max 200.0 => "cost";
req2 "Provider" values "AMAZ" => "provider";
}
}
<?xml version="1.0" encoding="ASCII"?>
<commons:DOMLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:app="http://www.piacere-project.eu/doml/application" xmlns:commons="http://www.piacere-project.eu/doml/commons" xmlns:infra="http://www.piacere-project.eu/doml/infrastructure" xmlns:optimization="http://www.piacere-project.eu/doml/optimization" name="nginx_openstack" activeConfiguration="//@configurations.0" activeInfrastructure="//@concretizations.0">
<application name="app">
<components xsi:type="app:SoftwareComponent" name="nginx">
<annotations xsi:type="commons:SProperty" key="source_code" value="/usr/share/nginx/html/index.html"/>
</components>
</application>
<infrastructure name="infra">
<generators xsi:type="infra:VMImage" name="v_img" generatedVMs="//@infrastructure/@groups.0/@machineDefinition"/>
<credentials xsi:type="infra:KeyPair" name="ssh_key" user="ubuntu" keyfile="/home/user1/.ssh/openstack.key" algorithm="RSA" bits="4096"/>
<groups xsi:type="infra:AutoScalingGroup" name="ag" deploymentNetwork="//@infrastructure/@networks.0">
<machineDefinition name="vm1" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0" generatedFrom="//@infrastructure/@generators.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</machineDefinition>
</groups>
<securityGroups name="sg" ifaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0">
<rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="http" kind="INGRESS" protocol="tcp" fromPort="80" toPort="80">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="https" kind="INGRESS" protocol="tcp" fromPort="443" toPort="443">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="ssh" kind="INGRESS" protocol="tcp" fromPort="22" toPort="22">
<cidr>0.0.0.0/0</cidr>
</rules>
</securityGroups>
<networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0"/>
</infrastructure>
<concretizations name="con_infra">
<providers name="openstack">
<vms name="concrete_vm" maps="//@infrastructure/@groups.0/@machineDefinition">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vmImages name="concrete_vm_image" maps="//@infrastructure/@generators.0">
<annotations xsi:type="commons:SProperty" key="name" value="ubuntu-20.04.3"/>
</vmImages>
</providers>
</concretizations>
<optimization name="opt">
<objectives xsi:type="optimization:MeasurableObjective" kind="min" property="cost"/>
<nonfunctionalRequirements xsi:type="commons:RangedRequirement" name="req1" description="Cost &lt;= 200" property="cost" max="200.0"/>
<nonfunctionalRequirements xsi:type="commons:EnumeratedRequirement" name="req2" description="Provider" property="provider">
<values>AMAZ</values>
</nonfunctionalRequirements>
</optimization>
<configurations name="config">
<deployments component="//@application/@components.0" node="//@infrastructure/@groups.0/@machineDefinition"/>
</configurations>
</commons:DOMLModel>
doml nginx_openstack
application app {
software_component nginx {
properties {
source_code="/usr/share/nginx/html/index.html";
}
}
}
infrastructure infra {
vm_image v_img {
generates vm1
}
net net1 {
address "16.0.0.0/24"
protocol "tcp/ip"
}
security_group sg {
egress icmp {
from_port -1
to_port -1
protocol "icmp"
cidr ["0.0.0.0/0"]
}
ingress http {
from_port 80
to_port 80
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress https {
from_port 443
to_port 443
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress ssh {
from_port 22
to_port 22
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ifaces i1
}
key_pair ssh_key {
user "ubuntu"
keyfile "/home/user1/.ssh/openstack.key"
algorithm "RSA"
bits 4096
}
autoscale_group ag {
vm vm1 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
network net1
}
vm vm2 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
}
deployment config {
nginx -> vm1
}
active deployment config
concretizations {
concrete_infrastructure con_infra {
provider openstack {
vm concrete_vm {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm1
}
vm concrete_vm2 {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm2
}
vm_image concrete_vm_image {
properties {
name = "ubuntu-20.04.3";
}
maps v_img
}
net concrete_net {
properties {
name = "ostack2";
}
maps net1
}
}
}
active con_infra
}
optimization opt {
objectives {
"cost" => min
}
nonfunctional_requirements {
req1 "Cost <= 200" max 200.0 => "cost";
req2 "Provider" values "AMAZ" => "provider";
}
}
<?xml version="1.0" encoding="ASCII"?>
<commons:DOMLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:app="http://www.piacere-project.eu/doml/application" xmlns:commons="http://www.piacere-project.eu/doml/commons" xmlns:infra="http://www.piacere-project.eu/doml/infrastructure" xmlns:optimization="http://www.piacere-project.eu/doml/optimization" name="nginx_openstack" activeConfiguration="//@configurations.0" activeInfrastructure="//@concretizations.0">
<application name="app">
<components xsi:type="app:SoftwareComponent" name="nginx">
<annotations xsi:type="commons:SProperty" key="source_code" value="/usr/share/nginx/html/index.html"/>
</components>
</application>
<infrastructure name="infra">
<nodes xsi:type="infra:VirtualMachine" name="vm2" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</nodes>
<generators xsi:type="infra:VMImage" name="v_img" generatedVMs="//@infrastructure/@groups.0/@machineDefinition"/>
<credentials xsi:type="infra:KeyPair" name="ssh_key" user="ubuntu" keyfile="/home/user1/.ssh/openstack.key" algorithm="RSA" bits="4096"/>
<groups xsi:type="infra:AutoScalingGroup" name="ag" deploymentNetwork="//@infrastructure/@networks.0">
<machineDefinition name="vm1" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0" generatedFrom="//@infrastructure/@generators.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</machineDefinition>
</groups>
<securityGroups name="sg" ifaces="//@infrastructure/@nodes.0/@ifaces.0 //@infrastructure/@groups.0/@machineDefinition/@ifaces.0">
<rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="http" kind="INGRESS" protocol="tcp" fromPort="80" toPort="80">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="https" kind="INGRESS" protocol="tcp" fromPort="443" toPort="443">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="ssh" kind="INGRESS" protocol="tcp" fromPort="22" toPort="22">
<cidr>0.0.0.0/0</cidr>
</rules>
</securityGroups>
<networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@nodes.0/@ifaces.0 //@infrastructure/@groups.0/@machineDefinition/@ifaces.0"/>
</infrastructure>
<concretizations name="con_infra">
<providers name="openstack">
<vms name="concrete_vm" maps="//@infrastructure/@groups.0/@machineDefinition">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vms name="concrete_vm2" maps="//@infrastructure/@nodes.0">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vmImages name="concrete_vm_image" maps="//@infrastructure/@generators.0">
<annotations xsi:type="commons:SProperty" key="name" value="ubuntu-20.04.3"/>
</vmImages>
<networks name="concrete_net" maps="//@infrastructure/@networks.0">
<annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
</networks>
</providers>
</concretizations>
<optimization name="opt">
<objectives xsi:type="optimization:MeasurableObjective" kind="min" property="cost"/>
<nonfunctionalRequirements xsi:type="commons:RangedRequirement" name="req1" description="Cost &lt;= 200" property="cost" max="200.0"/>
<nonfunctionalRequirements xsi:type="commons:EnumeratedRequirement" name="req2" description="Provider" property="provider">
<values>AMAZ</values>
</nonfunctionalRequirements>
</optimization>
<configurations name="config">
<deployments component="//@application/@components.0" node="//@infrastructure/@groups.0/@machineDefinition"/>
</configurations>
</commons:DOMLModel>
doml nginx_openstack
application app {
software_component nginx {
properties {
source_code="/usr/share/nginx/html/index.html";
}
consumes {
database
}
}
software_component db {
provides {
database
}
}
}
infrastructure infra {
vm_image v_img {
generates vm1
}
net net1 {
address "16.0.0.0/24"
protocol "tcp/ip"
}
net net2 {
address "17.0.0.0/24"
protocol "tcp/ip"
}
security_group sg {
egress icmp {
from_port -1
to_port -1
protocol "icmp"
cidr ["0.0.0.0/0"]
}
ingress http {
from_port 80
to_port 80
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress https {
from_port 443
to_port 443
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ingress ssh {
from_port 22
to_port 22
protocol "tcp"
cidr ["0.0.0.0/0"]
}
ifaces i1
}
key_pair ssh_key {
user "ubuntu"
keyfile "/home/user1/.ssh/openstack.key"
algorithm "RSA"
bits 4096
}
autoscale_group ag {
vm vm1 {
os "ubuntu-20.04.3"
iface i1 {
address "16.0.0.1"
belongs_to net1
security sg
}
credentials ssh_key
}
network net1
}
vm vm2 {
os "ubuntu-20.04.3"
iface i2 {
address "17.0.0.1"
belongs_to net2
security sg
}
credentials ssh_key
}
}
deployment config {
nginx -> vm1,
db -> vm2
}
active deployment config
concretizations {
concrete_infrastructure con_infra {
provider openstack {
vm concrete_vm {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm1
}
vm concrete_vm2 {
properties {
vm_name = "nginx-host";
vm_flavor = "small";
vm_key_name = "user1";
}
maps vm2
}
vm_image concrete_vm_image {
properties {
name = "ubuntu-20.04.3";
}
maps v_img
}
net concrete_net {
properties {
name = "ostack2";
}
maps net1
}
net concrete_net2 {
properties {
name = "ostack2";
}
maps net2
}
}
}
active con_infra
}
optimization opt {
objectives {
"cost" => min
}
nonfunctional_requirements {
req1 "Cost <= 200" max 200.0 => "cost";
req2 "Provider" values "AMAZ" => "provider";
}
}
<?xml version="1.0" encoding="ASCII"?>
<commons:DOMLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:app="http://www.piacere-project.eu/doml/application" xmlns:commons="http://www.piacere-project.eu/doml/commons" xmlns:infra="http://www.piacere-project.eu/doml/infrastructure" xmlns:optimization="http://www.piacere-project.eu/doml/optimization" name="nginx_openstack" activeConfiguration="//@configurations.0" activeInfrastructure="//@concretizations.0">
<application name="app">
<components xsi:type="app:SoftwareComponent" name="nginx" consumedInterfaces="//@application/@components.1/@exposedInterfaces.0">
<annotations xsi:type="commons:SProperty" key="source_code" value="/usr/share/nginx/html/index.html"/>
</components>
<components xsi:type="app:SoftwareComponent" name="db">
<exposedInterfaces name="database"/>
</components>
</application>
<infrastructure name="infra">
<nodes xsi:type="infra:VirtualMachine" name="vm2" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0">
<ifaces name="i2" endPoint="17.0.0.1" belongsTo="//@infrastructure/@networks.1" associated="//@infrastructure/@securityGroups.0"/>
</nodes>
<generators xsi:type="infra:VMImage" name="v_img" generatedVMs="//@infrastructure/@groups.0/@machineDefinition"/>
<credentials xsi:type="infra:KeyPair" name="ssh_key" user="ubuntu" keyfile="/home/user1/.ssh/openstack.key" algorithm="RSA" bits="4096"/>
<groups xsi:type="infra:AutoScalingGroup" name="ag" deploymentNetwork="//@infrastructure/@networks.0">
<machineDefinition name="vm1" os="ubuntu-20.04.3" credentials="//@infrastructure/@credentials.0" generatedFrom="//@infrastructure/@generators.0">
<ifaces name="i1" endPoint="16.0.0.1" belongsTo="//@infrastructure/@networks.0" associated="//@infrastructure/@securityGroups.0"/>
</machineDefinition>
</groups>
<securityGroups name="sg" ifaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0 //@infrastructure/@nodes.0/@ifaces.0">
<rules name="icmp" protocol="icmp" fromPort="-1" toPort="-1">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="http" kind="INGRESS" protocol="tcp" fromPort="80" toPort="80">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="https" kind="INGRESS" protocol="tcp" fromPort="443" toPort="443">
<cidr>0.0.0.0/0</cidr>
</rules>
<rules name="ssh" kind="INGRESS" protocol="tcp" fromPort="22" toPort="22">
<cidr>0.0.0.0/0</cidr>
</rules>
</securityGroups>
<networks name="net1" protocol="tcp/ip" addressRange="16.0.0.0/24" connectedIfaces="//@infrastructure/@groups.0/@machineDefinition/@ifaces.0"/>
<networks name="net2" protocol="tcp/ip" addressRange="17.0.0.0/24" connectedIfaces="//@infrastructure/@nodes.0/@ifaces.0"/>
</infrastructure>
<concretizations name="con_infra">
<providers name="openstack">
<vms name="concrete_vm" maps="//@infrastructure/@groups.0/@machineDefinition">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vms name="concrete_vm2" maps="//@infrastructure/@nodes.0">
<annotations xsi:type="commons:SProperty" key="vm_name" value="nginx-host"/>
<annotations xsi:type="commons:SProperty" key="vm_flavor" value="small"/>
<annotations xsi:type="commons:SProperty" key="vm_key_name" value="user1"/>
</vms>
<vmImages name="concrete_vm_image" maps="//@infrastructure/@generators.0">
<annotations xsi:type="commons:SProperty" key="name" value="ubuntu-20.04.3"/>
</vmImages>
<networks name="concrete_net" maps="//@infrastructure/@networks.0">
<annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
</networks>
<networks name="concrete_net2" maps="//@infrastructure/@networks.1">
<annotations xsi:type="commons:SProperty" key="name" value="ostack2"/>
</networks>
</providers>
</concretizations>
<optimization name="opt">
<objectives xsi:type="optimization:MeasurableObjective" kind="min" property="cost"/>
<nonfunctionalRequirements xsi:type="commons:RangedRequirement" name="req1" description="Cost &lt;= 200" property="cost" max="200.0"/>
<nonfunctionalRequirements xsi:type="commons:EnumeratedRequirement" name="req2" description="Provider" property="provider">
<values>AMAZ</values>
</nonfunctionalRequirements>
</optimization>
<configurations name="config">
<deployments component="//@application/@components.0" node="//@infrastructure/@groups.0/@machineDefinition"/>
<deployments component="//@application/@components.1" node="//@infrastructure/@nodes.0"/>
</configurations>
</commons:DOMLModel>
from mc_openapi import __version__
from mc_openapi.doml_mc.common_reqs import CommonRequirements
import requests
......@@ -7,7 +8,7 @@ def test_version():
def test_post_nginx_sat():
with open("tests/doml/nginx-openstack_v2.domlx", "r") as f:
with open("tests/doml/nginx-openstack_v2.0.domlx", "r") as f:
doml = f.read()
r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
......@@ -17,8 +18,8 @@ def test_post_nginx_sat():
assert payload["result"] == "sat"
def test_post_nginx_unsat():
with open("tests/doml/nginx-openstack_v2_wrong.domlx", "r") as f:
def test_post_faas_sat():
with open("tests/doml/faas.domlx", "r") as f:
doml = f.read()
r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
......@@ -28,8 +29,9 @@ def test_post_nginx_unsat():
assert payload["result"] == "unsat"
def test_post_faas_sat():
with open("tests/doml/faas.domlx", "r") as f:
def test_post_common_reqs():
for req in CommonRequirements.get_all_requirements():
with open(f"tests/doml/nginx-openstack_v2.0_wrong_{req.assert_name}.domlx", "r") as f:
doml = f.read()
r = requests.post("http://0.0.0.0:8080/modelcheck", data=doml)
......@@ -37,3 +39,4 @@ def test_post_faas_sat():
assert r.status_code == requests.codes.ok
assert payload["result"] is not None
assert payload["result"] == "unsat"
assert req.error_description in payload["description"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment