Add MuranoPackage context
- Add murano context that can upload package to Murano from specific path. - Add to rally-jobs/extra/ base structure and first Murano package, that is used in gates for testing purpose. Co-Authored-By: Roman Vasilets <rvasilets@mirantis.com> Co-Authored-By: Sergey Murashov <smurashov@mirantis.com> Change-Id: I4767be09aec54a441cf31eb924f89444482b66d3
This commit is contained in:

committed by
Roman Vasilets

parent
cadc3d0d3d
commit
0f67c3f6e7
1
.gitignore
vendored
1
.gitignore
vendored
@@ -39,5 +39,6 @@ doc/source/_build/
|
|||||||
# Mr Developer
|
# Mr Developer
|
||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
.project
|
.project
|
||||||
|
.idea
|
||||||
.pydevproject
|
.pydevproject
|
||||||
*.swp
|
*.swp
|
||||||
|
@@ -4,3 +4,8 @@ Extra files
|
|||||||
All files from this directory will be copy pasted to gates, so you are able to
|
All files from this directory will be copy pasted to gates, so you are able to
|
||||||
use absolute path in rally tasks. Files will be in ~/.rally/extra/*
|
use absolute path in rally tasks. Files will be in ~/.rally/extra/*
|
||||||
|
|
||||||
|
murano/ directory
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Here we have Murano applications that is used to prepare Murano context and
|
||||||
|
to deploy environment.
|
Binary file not shown.
17
rally-jobs/extra/murano/applications/README.rst
Normal file
17
rally-jobs/extra/murano/applications/README.rst
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
Murano applications
|
||||||
|
===================
|
||||||
|
|
||||||
|
Files for Murano benchmarking
|
||||||
|
|
||||||
|
Structure
|
||||||
|
---------
|
||||||
|
|
||||||
|
* <application_name>/ directories. Each directory store a simple Murano package
|
||||||
|
for environment deployment in Murano context. Also there can be other files
|
||||||
|
needs for application.
|
||||||
|
|
||||||
|
|
||||||
|
Useful links
|
||||||
|
------------
|
||||||
|
|
||||||
|
* `More about Murano package <https://wiki.openstack.org/wiki/Murano/Documentation/How_to_create_application_package>`_
|
@@ -423,6 +423,14 @@ class MuranoEnvironments(base.ResourceManager):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@base.resource("murano", "packages", tenant_resource=True,
|
||||||
|
order=next(_murano_order))
|
||||||
|
class MuranoPackages(base.ResourceManager):
|
||||||
|
def list(self):
|
||||||
|
return filter(lambda x: x.name != "Core library",
|
||||||
|
super(MuranoPackages, self).list())
|
||||||
|
|
||||||
|
|
||||||
# KEYSTONE
|
# KEYSTONE
|
||||||
|
|
||||||
_keystone_order = get_order(9000)
|
_keystone_order = get_order(9000)
|
||||||
|
66
rally/benchmark/context/murano_packages.py
Normal file
66
rally/benchmark/context/murano_packages.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
# Copyright 2015: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
from rally.benchmark.context import base
|
||||||
|
from rally.benchmark.context.cleanup import manager as resource_manager
|
||||||
|
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 osclients
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@base.context(name="murano_packages", order=401)
|
||||||
|
class PackageGenerator(base.Context):
|
||||||
|
"""Context class for uploading applications for murano."""
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = {
|
||||||
|
"type": "object",
|
||||||
|
"$schema": consts.JSON_SCHEMA,
|
||||||
|
"properties": {
|
||||||
|
"app_package": {
|
||||||
|
"type": "string",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["app_package"],
|
||||||
|
"additionalProperties": False
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
|
||||||
|
for user, tenant_id in utils.iterate_per_tenants(
|
||||||
|
self.context["users"]):
|
||||||
|
clients = osclients.Clients(user["endpoint"])
|
||||||
|
self.context["tenants"][tenant_id]["packages"] = []
|
||||||
|
package = clients.murano().packages.create(
|
||||||
|
{"categories": ["Web"], "tags": ["tag"]},
|
||||||
|
{"file": open(self.config["app_package"])})
|
||||||
|
|
||||||
|
self.context["tenants"][tenant_id]["packages"].append(package)
|
||||||
|
|
||||||
|
@utils.log_task_wrapper(LOG.info, _("Exit context: `Murano packages`"))
|
||||||
|
def cleanup(self):
|
||||||
|
resource_manager.cleanup(names=["murano.packages"],
|
||||||
|
users=self.context.get("users", []))
|
93
tests/unit/benchmark/context/test_murano_packages.py
Normal file
93
tests/unit/benchmark/context/test_murano_packages.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Copyright 2015: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from rally.benchmark.context import murano_packages
|
||||||
|
from tests.unit import test
|
||||||
|
|
||||||
|
CTX = "rally.benchmark.context"
|
||||||
|
|
||||||
|
|
||||||
|
class MuranoGeneratorTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(MuranoGeneratorTestCase, self).setUp()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_context():
|
||||||
|
return {
|
||||||
|
"config": {
|
||||||
|
"users": {
|
||||||
|
"tenants": 2,
|
||||||
|
"users_per_tenant": 1,
|
||||||
|
"concurrent": 1,
|
||||||
|
},
|
||||||
|
"murano_packages": {
|
||||||
|
"app_package": (
|
||||||
|
"rally-jobs/extra/murano/"
|
||||||
|
"applications/HelloReporter/"
|
||||||
|
"io.murano.apps.HelloReporter.zip")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"admin": {
|
||||||
|
"endpoint": mock.MagicMock()
|
||||||
|
},
|
||||||
|
"task": mock.MagicMock(),
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"id": "user_0",
|
||||||
|
"tenant_id": "tenant_0",
|
||||||
|
"endpoint": "endpoint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "user_1",
|
||||||
|
"tenant_id": "tenant_1",
|
||||||
|
"endpoint": "endpoint"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tenants": {
|
||||||
|
"tenant_0": {"name": "tenant_0_name"},
|
||||||
|
"tenant_1": {"name": "tenant_1_name"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@mock.patch("rally.benchmark.context.murano_packages.osclients")
|
||||||
|
def test_setup(self, mock_clients):
|
||||||
|
mock_app = mock.MagicMock(id="fake_app_id")
|
||||||
|
(mock_clients.Clients().murano().
|
||||||
|
packages.create.return_value) = mock_app
|
||||||
|
|
||||||
|
murano_ctx = murano_packages.PackageGenerator(self._get_context())
|
||||||
|
murano_ctx.setup()
|
||||||
|
|
||||||
|
self.assertEqual(2, len(murano_ctx.context["tenants"]))
|
||||||
|
tenant_id = murano_ctx.context["users"][0]["tenant_id"]
|
||||||
|
self.assertEqual([mock_app],
|
||||||
|
murano_ctx.context["tenants"][tenant_id]["packages"])
|
||||||
|
|
||||||
|
@mock.patch("rally.benchmark.context.murano_packages.osclients")
|
||||||
|
@mock.patch("%s.images.resource_manager.cleanup" % CTX)
|
||||||
|
def test_cleanup(self, mock_cleanup, mock_clients):
|
||||||
|
mock_app = mock.Mock(id="fake_app_id")
|
||||||
|
(mock_clients.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"])
|
Reference in New Issue
Block a user