diff --git a/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/Classes/HelloReporter.yaml b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/Classes/HelloReporter.yaml new file mode 100644 index 00000000..2eca9d0d --- /dev/null +++ b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/Classes/HelloReporter.yaml @@ -0,0 +1,25 @@ +Namespaces: + =: io.murano.apps + std: io.murano + sys: io.murano.system + + +Name: HelloReporter + +Extends: std:Application + +Properties: + name: + Contract: $.string().notNull() + +Workflow: + initialize: + Body: + - $.environment: $.find(std:Environment).require() + + deploy: + Body: + - If: not $.getAttr(deployed, false) + Then: + - $.environment.reporter.report($this, 'Starting deployment! Hello!') + - $.setAttr(deployed, True) diff --git a/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/UI/ui.yaml b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/UI/ui.yaml new file mode 100644 index 00000000..2d572f5f --- /dev/null +++ b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/UI/ui.yaml @@ -0,0 +1,23 @@ +Version: 2 + +Application: + ?: + type: io.murano.apps.HelloReporter + name: $.appConfiguration.name + +Forms: + - appConfiguration: + fields: + - name: name + type: string + label: Application Name + description: >- + Enter a desired name for the application. Just A-Z, a-z, 0-9, dash and + underline are allowed + - name: unitNamingPattern + type: string + required: false + hidden: true + widgetMedia: + js: ['muranodashboard/js/support_placeholder.js'] + css: {all: ['muranodashboard/css/support_placeholder.css']} diff --git a/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/manifest.yaml b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/manifest.yaml new file mode 100644 index 00000000..47e4d510 --- /dev/null +++ b/rally-jobs/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/manifest.yaml @@ -0,0 +1,10 @@ +Format: 1.0 +Type: Application +FullName: io.murano.apps.HelloReporter +Name: HelloReporter +Description: | + HelloReporter test app. +Author: 'Mirantis, Inc' +Tags: [App, Test, HelloWorld] +Classes: + io.murano.apps.HelloReporter: HelloReporter.yaml diff --git a/rally-jobs/rally-murano.yaml b/rally-jobs/rally-murano.yaml index 866c8285..b69431fe 100644 --- a/rally-jobs/rally-murano.yaml +++ b/rally-jobs/rally-murano.yaml @@ -46,3 +46,21 @@ sla: failure_rate: max: 0 + - + args: + packages_per_env: 2 + runner: + type: "constant" + times: 8 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + murano_packages: + app_package: "/home/jenkins/.rally/extra/murano/applications/HelloReporter/io.murano.apps.HelloReporter/" + roles: + - "admin" + sla: + failure_rate: + max: 0 diff --git a/rally/plugins/openstack/context/murano/murano_packages.py b/rally/plugins/openstack/context/murano/murano_packages.py index 018dcef1..f197b048 100644 --- a/rally/plugins/openstack/context/murano/murano_packages.py +++ b/rally/plugins/openstack/context/murano/murano_packages.py @@ -13,13 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. +import os import zipfile +from rally.common import fileutils from rally.common.i18n import _ from rally.common.i18n import _LE from rally.common import log as logging from rally.common import utils from rally import consts +from rally import exceptions from rally import osclients from rally.plugins.openstack.context.cleanup import manager as resource_manager from rally.task import context @@ -46,18 +49,27 @@ class PackageGenerator(context.Context): @utils.log_task_wrapper(LOG.info, _("Enter context: `Murano packages`")) def setup(self): - if not zipfile.is_zipfile(self.config["app_package"]): - msg = (_LE("There is no zip archive by this path: %s") - % self.config["app_package"]) - raise OSError(msg) + is_config_app_dir = False + if zipfile.is_zipfile(self.config["app_package"]): + zip_name = self.config["app_package"] + elif os.path.isdir(self.config["app_package"]): + is_config_app_dir = True + zip_name = fileutils.pack_dir(self.config["app_package"]) + else: + msg = (_LE("There is no zip archive or directory by this path:" + " %s") % self.config["app_package"]) + raise exceptions.ContextSetupFailure(msg=msg, + ctx="murano_packages") for user, tenant_id in utils.iterate_per_tenants( self.context["users"]): clients = osclients.Clients(user["endpoint"]) self.context["tenants"][tenant_id]["packages"] = [] + if is_config_app_dir: + self.context["tenants"][tenant_id]["murano_ctx"] = zip_name package = clients.murano().packages.create( {"categories": ["Web"], "tags": ["tag"]}, - {"file": open(self.config["app_package"])}) + {"file": open(zip_name)}) self.context["tenants"][tenant_id]["packages"].append(package) diff --git a/rally/plugins/openstack/scenarios/murano/environments.py b/rally/plugins/openstack/scenarios/murano/environments.py index 11cb13b7..2385492a 100644 --- a/rally/plugins/openstack/scenarios/murano/environments.py +++ b/rally/plugins/openstack/scenarios/murano/environments.py @@ -16,14 +16,13 @@ from rally.common import log as logging from rally import consts from rally.plugins.openstack.scenarios.murano import utils -from rally.plugins.openstack.scenarios.vm import utils as vm_utils from rally.task.scenarios import base from rally.task import validation LOG = logging.getLogger(__name__) -class MuranoEnvironments(utils.MuranoScenario, vm_utils.VMScenario): +class MuranoEnvironments(utils.MuranoScenario): """Benchmark scenarios for Murano environments.""" @validation.required_clients("murano") @validation.required_services(consts.Service.MURANO) diff --git a/tests/unit/plugins/openstack/context/murano/test_murano_packages.py b/tests/unit/plugins/openstack/context/murano/test_murano_packages.py index f3a38dbc..3685119b 100644 --- a/tests/unit/plugins/openstack/context/murano/test_murano_packages.py +++ b/tests/unit/plugins/openstack/context/murano/test_murano_packages.py @@ -80,14 +80,32 @@ class MuranoGeneratorTestCase(test.TestCase): @mock.patch("%s.osclients" % CTX) @mock.patch("%s.resource_manager.cleanup" % CTX) - def test_cleanup(self, mock_cleanup, mock_osclients): + def test_cleanup_with_zip(self, mock_cleanup, mock_osclients): mock_app = mock.Mock(id="fake_app_id") (mock_osclients.Clients().murano(). packages.create.return_value) = mock_app murano_ctx = murano_packages.PackageGenerator(self._get_context()) murano_ctx.setup() - murano_ctx.cleanup() + + mock_cleanup.assert_called_once_with(names=["murano.packages"], + users=murano_ctx.context["users"]) + + @mock.patch("%s.osclients" % CTX) + @mock.patch("%s.resource_manager.cleanup" % CTX) + def test_cleanup_with_dir(self, mock_cleanup, mock_osclients): + mock_app = mock.Mock(id="fake_app_id") + (mock_osclients.Clients().murano(). + packages.create.return_value) = mock_app + ctx_dict = self._get_context() + app_dir = ("rally-jobs/extra/murano/applications/" + "HelloReporter/io.murano.apps.HelloReporter/") + ctx_dict["config"]["murano_packages"]["app_package"] = app_dir + + murano_ctx = murano_packages.PackageGenerator(ctx_dict) + murano_ctx.setup() + murano_ctx.cleanup() + mock_cleanup.assert_called_once_with(names=["murano.packages"], users=murano_ctx.context["users"])