diff --git a/.gitignore b/.gitignore index 7dfa8ae8..91ec4367 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ pip-log.txt .tox nosetests.xml .testrepository +.stestr # Translations *.mo @@ -50,4 +51,5 @@ ChangeLog *~ .*.swp .idea -*.iml \ No newline at end of file +*.iml + diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 00000000..17ed5ad8 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./translator/tests/ +top_dir=./ diff --git a/doc/requirements.txt b/doc/requirements.txt index ec949998..d0c715ec 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,2 +1,2 @@ -openstackdocstheme>=2.2.1 # Apache-2.0 -sphinx>=2.0.0,!=2.1.0 # BSD +openstackdocstheme>=3.4.1 # Apache-2.0 +sphinx>=8.1.3 # BSD diff --git a/requirements.txt b/requirements.txt index 63633d99..9b98ae81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,15 +2,15 @@ # date but we do not test them so no guarantee of having them all correct. If # you find any incorrect lower bounds, let us know or propose a fix. -pbr!=2.1.0,>=2.0.0 # Apache-2.0 -cliff!=2.9.0,>=2.8.0 # Apache-2.0 +pbr>=6.0.0 # Apache-2.0 +cliff>=4.9.1 # Apache-2.0 PyYAML>=3.13 # MIT -python-dateutil>=2.5.3 # BSD -tosca-parser>=1.6.1 # Apache-2.0 -keystoneauth1>=3.4.0 # Apache-2.0 -python-novaclient>=9.1.0 # Apache-2.0 -python-heatclient>=1.10.0 # Apache-2.0 -python-glanceclient>=2.8.0 # Apache-2.0 -requests>=2.18.0 # Apache-2.0 +python-dateutil>=2.9.0 # BSD +tosca-parser>=2.12.0 # Apache-2.0 +keystoneauth1>=5.11.0 # Apache-2.0 +python-novaclient>=18.9.0 # Apache-2.0 +python-heatclient>=4.2.0 # Apache-2.0 +python-glanceclient>=4.8.0 # Apache-2.0 +requests>=2.32.2 # Apache-2.0 -oslo.log>=3.36.0 # Apache-2.0 +oslo.log>=7.1.0 # Apache-2.0 diff --git a/samples/tests/data/etsi_nfv/etsi_nfv_sol001_vnfd_types.yaml b/samples/tests/data/etsi_nfv/etsi_nfv_sol001_vnfd_types.yaml index 01cbc5ed..f3b7cece 100644 --- a/samples/tests/data/etsi_nfv/etsi_nfv_sol001_vnfd_types.yaml +++ b/samples/tests/data/etsi_nfv/etsi_nfv_sol001_vnfd_types.yaml @@ -1210,18 +1210,20 @@ node_types: - virtual_link: capability: tosca.capabilities.nfv.VirtualLinkable relationship: tosca.relationships.nfv.VirtualLinksTo + occurrences: [0, 1] - virtual_binding: capability: tosca.capabilities.nfv.VirtualBindable relationship: tosca.relationships.nfv.VirtualBindsTo node: tosca.nodes.nfv.Vdu.Compute + occurrences: [0, 1] tosca.nodes.nfv.VnfVirtualLink: derived_from: tosca.nodes.Root - description: Describes the information about an internal VNF VL + description: Describes the information about an internal VNF VL properties: connectivity_type: type: tosca.datatypes.nfv.ConnectivityType - description: Specifies the protocol exposed by the VL and the flow pattern supported by the VL + description: Specifies the protocol exposed by the VL and the flow pattern supported by the VL required: true description: type: string diff --git a/samples/tests/data/hot_output/hot_host_assignment.yaml b/samples/tests/data/hot_output/hot_host_assignment.yaml index 33f30592..4a27cd39 100644 --- a/samples/tests/data/hot_output/hot_host_assignment.yaml +++ b/samples/tests/data/hot_output/hot_host_assignment.yaml @@ -25,6 +25,13 @@ resources: image: ubuntu-software-config-os-init user_data_format: SOFTWARE_CONFIG + elasticsearch_server: + type: OS::Nova::Server + properties: + flavor: m1.medium + image: ubuntu-software-config-os-init + user_data_format: SOFTWARE_CONFIG + app_collectd_create_config: type: OS::Heat::SoftwareConfig properties: @@ -91,12 +98,17 @@ resources: group: script logstash_create_deploy: - type: OS::Heat::SoftwareDeployment + type: OS::Heat::SoftwareDeploymentGroup properties: config: get_resource: logstash_create_config - server: - get_resource: logstash_server + servers: + logstash_server: + get_resource: logstash_server + elasticsearch_server: + get_resource: elasticsearch_server + depends_on: + - elasticsearch_server logstash_start_config: type: OS::Heat::SoftwareConfig @@ -106,12 +118,15 @@ resources: group: script logstash_start_deploy: - type: OS::Heat::SoftwareDeployment + type: OS::Heat::SoftwareDeploymentGroup properties: config: get_resource: logstash_start_config - server: - get_resource: logstash_server + servers: + logstash_server: + get_resource: logstash_server + elasticsearch_server: + get_resource: elasticsearch_server depends_on: - logstash_create_deploy @@ -123,12 +138,15 @@ resources: group: script app_collectd_logstash_connect_deploy: - type: OS::Heat::SoftwareDeployment + type: OS::Heat::SoftwareDeploymentGroup properties: config: get_resource: app_collectd_logstash_connect_config - server: - get_resource: logstash_server + servers: + logstash_server: + get_resource: logstash_server + elasticsearch_server: + get_resource: elasticsearch_server depends_on: - logstash_create_deploy diff --git a/samples/tests/data/network/test_tosca_custom_network_nodes_imports.yaml b/samples/tests/data/network/test_tosca_custom_network_nodes_imports.yaml index ea473b11..ed1fb3f1 100644 --- a/samples/tests/data/network/test_tosca_custom_network_nodes_imports.yaml +++ b/samples/tests/data/network/test_tosca_custom_network_nodes_imports.yaml @@ -29,8 +29,12 @@ topology_template: requirements: - virtualLink: node: VL1 + - link: + node: VL1 - virtualBinding: node: VDU1 + - binding: + node: VDU1 VL1: type: tosca.nodes.vendor.VL diff --git a/samples/tests/data/network/test_tosca_custom_network_nodes_inline.yaml b/samples/tests/data/network/test_tosca_custom_network_nodes_inline.yaml index 509aab4b..05741e91 100644 --- a/samples/tests/data/network/test_tosca_custom_network_nodes_inline.yaml +++ b/samples/tests/data/network/test_tosca_custom_network_nodes_inline.yaml @@ -7,17 +7,18 @@ node_types: tosca.nodes.vendor.VDU: derived_from: tosca.nodes.Compute capabilities: - virtualbinding: + binding: type: tosca.capabilities.vendor.VendorBindable tosca.nodes.vendor.CP: derived_from: tosca.nodes.network.Port requirements: - - virtualLink: + - link: capability: tosca.capabilities.VendorLinkable relationship: tosca.relationships.vendor.VendorLinksTo node: tosca.nodes.vendor.VL - - virtualBinding: + occurrences: [0, 1] + - binding: capability: tosca.capabilities.vendor.VendorBindable node: tosca.nodes.vendor.VDU relationship: tosca.relationships.vendor.VendorBindsTo @@ -25,7 +26,7 @@ node_types: tosca.nodes.vendor.VL: derived_from: tosca.nodes.network.Network capabilities: - virtual_linkable: + link: type: tosca.capabilities.vendor.VendorLinkable relationship_types: @@ -66,10 +67,11 @@ topology_template: CP1: type: tosca.nodes.vendor.CP requirements: - - virtualLink: + - link: node: VL1 relationship: tosca.relationships.vendor.VendorLinksTo - - virtualBinding: + occurrences: [0, 1] + - binding: node: VDU1 relationship: tosca.relationships.vendor.VendorBindsTo diff --git a/samples/tests/data/nfv/test_tosca_nfv_autoscaling.yaml b/samples/tests/data/nfv/test_tosca_nfv_autoscaling.yaml index 14978222..6c1b2156 100644 --- a/samples/tests/data/nfv/test_tosca_nfv_autoscaling.yaml +++ b/samples/tests/data/nfv/test_tosca_nfv_autoscaling.yaml @@ -26,8 +26,12 @@ topology_template: requirements: - virtualLink: node: VL1 + - link: + node: VL1 - virtualBinding: node: VDU1 + - binding: + node: VDU1 VDU2: type: tosca.nodes.nfv.VDU.Tacker @@ -46,8 +50,12 @@ topology_template: requirements: - virtualLink: node: VL1 + - link: + node: VL1 - virtualBinding: node: VDU2 + - binding: + node: VDU2 VL1: type: tosca.nodes.nfv.VL diff --git a/samples/tests/data/nfv/test_tosca_nfv_autoscaling_with_params.yaml b/samples/tests/data/nfv/test_tosca_nfv_autoscaling_with_params.yaml index 6774932a..4cd5eb11 100644 --- a/samples/tests/data/nfv/test_tosca_nfv_autoscaling_with_params.yaml +++ b/samples/tests/data/nfv/test_tosca_nfv_autoscaling_with_params.yaml @@ -37,8 +37,12 @@ topology_template: requirements: - virtualLink: node: VL1 + - link: + node: VL1 - virtualBinding: node: VDU1 + - binding: + node: VDU1 VL1: type: tosca.nodes.nfv.VL diff --git a/samples/tests/data/nfv/test_tosca_nfv_sample.yaml b/samples/tests/data/nfv/test_tosca_nfv_sample.yaml index 5e938dab..a9afa0e8 100644 --- a/samples/tests/data/nfv/test_tosca_nfv_sample.yaml +++ b/samples/tests/data/nfv/test_tosca_nfv_sample.yaml @@ -61,9 +61,14 @@ topology_template: - virtualLink: node: VL1 # relationship: tosca.relationships.nfv.VirtualLinksTo + - link: + node: VL1 - virtualBinding: node: VDU1 relationship: tosca.relationships.nfv.VirtualBindsTo + - binding: + node: VDU1 + relationship: tosca.relationships.nfv.VirtualBindsTo CP2: type: tosca.nodes.nfv.CP @@ -73,9 +78,14 @@ topology_template: - virtualLink: node: VL1 # relationship: tosca.relationships.nfv.VirtualLinksTo + - link: + node: VL1 - virtualBinding: node: VDU2 relationship: tosca.relationships.nfv.VirtualBindsTo + - binding: + node: VDU2 + relationship: tosca.relationships.nfv.VirtualBindsTo VL1: type: tosca.nodes.nfv.VL diff --git a/samples/tests/data/reservation/tosca-vnfd-reservation-id.yaml b/samples/tests/data/reservation/tosca-vnfd-reservation-id.yaml index 9d1a30cd..3e1671c5 100644 --- a/samples/tests/data/reservation/tosca-vnfd-reservation-id.yaml +++ b/samples/tests/data/reservation/tosca-vnfd-reservation-id.yaml @@ -32,8 +32,12 @@ topology_template: requirements: - virtualLink: node: VL1 + - link: + node: VL1 - virtualBinding: node: VDU1 + - binding: + node: VDU1 VL1: type: tosca.nodes.nfv.VL properties: diff --git a/samples/tests/data/test_host_assignment.yaml b/samples/tests/data/test_host_assignment.yaml index acffd24b..da603ece 100644 --- a/samples/tests/data/test_host_assignment.yaml +++ b/samples/tests/data/test_host_assignment.yaml @@ -57,6 +57,8 @@ topology_template: requirements: - host: node: logstash_server + - search_endpoint: + node: elasticsearch_server interfaces: Standard: create: logstash/create.sh @@ -70,6 +72,14 @@ topology_template: host: properties: *host_capabilities + elasticsearch_server: + type: tosca.nodes.Compute + capabilities: + host: + properties: *host_capabilities + os: + properties: *os_capabilities + logstash_server: type: tosca.nodes.Compute capabilities: diff --git a/test-requirements.txt b/test-requirements.txt index 89f32abd..0ac7ff9e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,9 @@ -hacking>=7.0.0,<7.1.0 # Apache-2.0 -coverage!=4.4,>=4.0 # Apache-2.0 -fixtures>=3.0.0 # Apache-2.0/BSD -oslotest>=3.2.0 # Apache-2.0 -python-subunit>=1.0.0 # Apache-2.0/BSD -testrepository>=0.0.18 # Apache-2.0/BSD -testscenarios>=0.4 # Apache-2.0/BSD -testtools>=2.2.0 # MIT +hacking>=7.0.0 # Apache-2.0 +coverage>=7.8.1 # Apache-2.0 +fixtures>=4.2.5 # Apache-2.0/BSD +oslotest>=5.0.1 # Apache-2.0 +python-subunit>=1.4.4 # Apache-2.0/BSD +stestr>=2.0.0 # Apache-2.0 +testrepository>=0.0.21 # Apache-2.0/BSD +testscenarios>=0.5.0 # Apache-2.0/BSD +testtools>=2.7.2 # MIT diff --git a/tox.ini b/tox.ini index 2de0a8c8..318f6cd8 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = python setup.py test --slowest --testr-args='{posargs}' +commands = stestr run --slowest '{posargs}' [testenv:pep8] commands = flake8 @@ -28,7 +28,12 @@ commands = flake8 commands = {posargs} [testenv:cover] -commands = python setup.py test --coverage --coverage-package-name=translator --testr-args='{posargs}' +setenv = + PYTHON=coverage run --source translator --parallel-mode +commands = stestr run '{posargs}' + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml [testenv:docs] deps = diff --git a/translator/tests/test_shell.py b/translator/tests/test_shell.py index fb0739db..45c04aff 100644 --- a/translator/tests/test_shell.py +++ b/translator/tests/test_shell.py @@ -11,9 +11,11 @@ # under the License. +import importlib import json import os import shutil +import sys import tempfile from unittest import mock @@ -31,6 +33,24 @@ class ShellTest(TestCase): template_validation = "--validate-only" failure_msg = _('The program raised an exception unexpectedly.') + def tearDown(self): + """Ensure all mocks are properly cleaned up after each test""" + super().tearDown() + mock.patch.stopall() + modules_to_clear = [ + 'translator.common.flavors', + 'translator.common.images', + 'novaclient.client', + 'keystoneauth1.adapter', + 'novaclient.v2.flavors' + ] + for module in modules_to_clear: + if module in sys.modules: + try: + importlib.reload(sys.modules[module]) + except (ImportError, AttributeError): + sys.modules.pop(module, None) + def test_invalid_file_value(self): error = self.assertRaises(ValueError, shell.main, ('--template-file=template.txt',