Merge "Add ability to specify directory with murano package files"

This commit is contained in:
Jenkins 2015-08-04 11:16:56 +00:00 committed by Gerrit Code Review
commit 48fe0d75c1
7 changed files with 114 additions and 9 deletions

View File

@ -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)

View File

@ -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']}

View File

@ -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

View File

@ -46,3 +46,21 @@
sla: sla:
failure_rate: failure_rate:
max: 0 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

View File

@ -13,13 +13,16 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os
import zipfile import zipfile
from rally.common import fileutils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common.i18n import _LE from rally.common.i18n import _LE
from rally.common import log as logging from rally.common import log as logging
from rally.common import utils from rally.common import utils
from rally import consts from rally import consts
from rally import exceptions
from rally import osclients from rally import osclients
from rally.plugins.openstack.context.cleanup import manager as resource_manager from rally.plugins.openstack.context.cleanup import manager as resource_manager
from rally.task import context from rally.task import context
@ -46,18 +49,27 @@ class PackageGenerator(context.Context):
@utils.log_task_wrapper(LOG.info, _("Enter context: `Murano packages`")) @utils.log_task_wrapper(LOG.info, _("Enter context: `Murano packages`"))
def setup(self): def setup(self):
if not zipfile.is_zipfile(self.config["app_package"]): is_config_app_dir = False
msg = (_LE("There is no zip archive by this path: %s") if zipfile.is_zipfile(self.config["app_package"]):
% self.config["app_package"]) zip_name = self.config["app_package"]
raise OSError(msg) 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( for user, tenant_id in utils.iterate_per_tenants(
self.context["users"]): self.context["users"]):
clients = osclients.Clients(user["endpoint"]) clients = osclients.Clients(user["endpoint"])
self.context["tenants"][tenant_id]["packages"] = [] 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( package = clients.murano().packages.create(
{"categories": ["Web"], "tags": ["tag"]}, {"categories": ["Web"], "tags": ["tag"]},
{"file": open(self.config["app_package"])}) {"file": open(zip_name)})
self.context["tenants"][tenant_id]["packages"].append(package) self.context["tenants"][tenant_id]["packages"].append(package)

View File

@ -16,14 +16,13 @@
from rally.common import log as logging from rally.common import log as logging
from rally import consts from rally import consts
from rally.plugins.openstack.scenarios.murano import utils 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.scenarios import base
from rally.task import validation from rally.task import validation
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class MuranoEnvironments(utils.MuranoScenario, vm_utils.VMScenario): class MuranoEnvironments(utils.MuranoScenario):
"""Benchmark scenarios for Murano environments.""" """Benchmark scenarios for Murano environments."""
@validation.required_clients("murano") @validation.required_clients("murano")
@validation.required_services(consts.Service.MURANO) @validation.required_services(consts.Service.MURANO)

View File

@ -80,14 +80,32 @@ class MuranoGeneratorTestCase(test.TestCase):
@mock.patch("%s.osclients" % CTX) @mock.patch("%s.osclients" % CTX)
@mock.patch("%s.resource_manager.cleanup" % 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_app = mock.Mock(id="fake_app_id")
(mock_osclients.Clients().murano(). (mock_osclients.Clients().murano().
packages.create.return_value) = mock_app packages.create.return_value) = mock_app
murano_ctx = murano_packages.PackageGenerator(self._get_context()) murano_ctx = murano_packages.PackageGenerator(self._get_context())
murano_ctx.setup() murano_ctx.setup()
murano_ctx.cleanup() 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"], mock_cleanup.assert_called_once_with(names=["murano.packages"],
users=murano_ctx.context["users"]) users=murano_ctx.context["users"])