Add a fixture for Decapod
Change-Id: I4cf305d6a844462024d77bc279133e730b6d5c38
Reviewed-on: https://review.gerrithub.io/373733
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/fixtures/decapod_fixtures.py b/tcp_tests/fixtures/decapod_fixtures.py
new file mode 100644
index 0000000..ddbb8c9
--- /dev/null
+++ b/tcp_tests/fixtures/decapod_fixtures.py
@@ -0,0 +1,84 @@
+# Copyright 2016 Mirantis, Inc.
+#
+# 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 os
+
+import pytest
+import yaml
+
+from tcp_tests import logger
+from tcp_tests.helpers import ext
+from tcp_tests import settings
+from tcp_tests.managers import decapod_manager
+
+LOG = logger.logger
+
+
+@pytest.fixture(scope='function')
+def decapod_actions(config, underlay, salt_actions):
+ """Fixture that provides various actions for Decapod
+
+ :param config: fixture provides oslo.config
+ :param underlay: fixture provides underlay manager
+ :rtype: DecapodManager
+ """
+ return decapod_manager.DecapodManager(config, underlay, salt_actions)
+
+
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.decapod_deployed)
+@pytest.fixture(scope='function')
+def decapod_deployed(revert_snapshot, request, config,
+ hardware, underlay, salt_deployed,
+ decapod_actions):
+ """Fixture to get or install Decapod on the environment
+
+ :param revert_snapshot: fixture that reverts snapshot that is specified
+ in test with @pytest.mark.revert_snapshot(<name>)
+ :param request: fixture provides pytest data
+ :param config: fixture provides oslo.config
+ :param hardware: fixture provides enviromnet manager
+ :param underlay: fixture provides underlay manager
+ :param decapod_actions: fixture provides DecapodManager instance
+ :rtype: DecapodManager
+
+ If config.decapod.decapod_installed is not set, this
+ fixture assumes that the Decapod were not installed
+ , and do the following:
+ - install Decapod
+ - make snapshot with name 'decapod_deployed'
+ - return DecapodManager
+
+ If config.decapod.decapod_installed was set, this fixture
+ assumes that the Decapod were already installed, and do
+ the following:
+ - return DecapodManager instance
+
+ If you want to revert 'decapod_deployed' snapshot, please use mark:
+ @pytest.mark.revert_snapshot("decapod_deployed")
+ """
+ if not config.decapod.decapod_installed:
+ steps_path = config.decapod_deploy.decapod_steps_path
+ commands = underlay.read_template(steps_path)
+ decapod_actions.install(commands)
+ hardware.create_snapshot(ext.SNAPSHOT.decapod_deployed)
+
+ else:
+ # 1. hardware environment created and powered on
+ # 2. config.underlay.ssh contains SSH access to provisioned nodes
+ # (can be passed from external config with TESTS_CONFIGS variable)
+ # 3. config.tcp.* options contain access credentials to the already
+ # installed TCP API endpoint
+ pass
+
+ return decapod_actions
diff --git a/tcp_tests/helpers/ext.py b/tcp_tests/helpers/ext.py
index 17bcee5..98853f5 100644
--- a/tcp_tests/helpers/ext.py
+++ b/tcp_tests/helpers/ext.py
@@ -27,6 +27,9 @@
'salt_master',
'salt_minion',
'k8s_virtlet',
+ 'decapod_mon',
+ 'decapod_osd',
+ 'decapod_all',
)
NETWORK_TYPE = enum(
@@ -44,7 +47,8 @@
'sl_deployed',
'virtlet_deployed',
'virtlet_ceph_deployed',
- 'k8s_deployed'
+ 'k8s_deployed',
+ 'decapod_deployed',
)
LOG_LEVELS = enum(
diff --git a/tcp_tests/managers/decapod_manager.py b/tcp_tests/managers/decapod_manager.py
new file mode 100644
index 0000000..0206bea
--- /dev/null
+++ b/tcp_tests/managers/decapod_manager.py
@@ -0,0 +1,39 @@
+# Copyright 2017 Mirantis, Inc.
+#
+# 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.
+
+from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
+
+
+class DecapodManager(ExecuteCommandsMixin):
+ """docstring for DecapodManager"""
+
+ __config = None
+ __underlay = None
+
+ def __init__(self, config, underlay, salt=None):
+ self.__config = config
+ self.__underlay = underlay
+ self._salt = salt
+ self.decapod_nodes = [
+ i for i in self.__config.underlay.ssh
+ if any([ext.UNDERLAY_NODE_ROLES.decapod_mon in i['roles'],
+ ext.UNDERLAY_NODE_ROLES.decapod_osd in i['roles'],
+ ext.UNDERLAY_NODE_ROLES.decapod_all in i['roles']])]
+ super(DecapodManager, self).__init__(
+ config=config, underlay=underlay)
+
+ def install(self, commands):
+ self.execute_commands(commands,
+ label='Deploy Ceph cluster with Decapod')
+ self.__config.decapod.decapod_installed = True
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index e0dd605..7913340 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -38,6 +38,10 @@
__name__,
'templates/{0}/oss.yaml'.format(
settings.LAB_CONFIG_NAME))
+_default_decapod_steps = pkg_resources.resource_filename(
+ __name__,
+ 'templates/{0}/decapod.yaml'.format(
+ settings.LAB_CONFIG_NAME))
_default_openstack_steps = pkg_resources.resource_filename(
__name__, 'templates/{0}/openstack.yaml'.format(
settings.LAB_CONFIG_NAME))
@@ -144,6 +148,17 @@
help="", default=False),
]
+decapod_deploy_opts = [
+ ct.Cfg('decapod_steps_path', ct.String(),
+ help="Path to YAML with steps to deploy Ceph with Decapod",
+ default=_default_decapod_steps),
+]
+
+decapod_opts = [
+ ct.Cfg('decapod_installed', ct.Boolean(),
+ help="", default=False),
+]
+
openstack_deploy_opts = [
ct.Cfg('openstack_steps_path', ct.String(),
help="Path to YAML with steps to deploy openstack",
@@ -277,6 +292,8 @@
('common_services', common_services_opts),
('oss_deploy', oss_deploy_opts),
('oss', oss_opts),
+ ('decapod_deploy', decapod_deploy_opts),
+ ('decapod', decapod_opts),
('openstack_deploy', openstack_deploy_opts),
('openstack', openstack_opts),
('opencontrail', opencontrail_opts),
@@ -326,6 +343,15 @@
config.register_opts(group='oss_deploy',
opts=oss_deploy_opts)
+ config.register_group(cfg.OptGroup(name='decapod',
+ title="Decapod options for Ceph", help=""))
+ config.register_opts(group='decapod', opts=decapod_opts)
+
+ config.register_group(cfg.OptGroup(name='decapod_deploy',
+ title="Decapod deploy config", help=""))
+ config.register_opts(group='decapod_deploy',
+ opts=decapod_deploy_opts)
+
config.register_group(cfg.OptGroup(name='openstack',
title="Openstack config and credentials", help=""))
config.register_opts(group='openstack', opts=openstack_opts)
@@ -344,8 +370,8 @@
config.register_opts(group='stack_light', opts=sl_opts)
config.register_group(
cfg.OptGroup(name='sl_deploy',
- title="SL deploy config and credentials",
- help=""))
+ title="SL deploy config and credentials",
+ help=""))
config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
config.register_group(cfg.OptGroup(name='virtlet_deploy',
title='Virtlet deploy config', help=""))
diff --git a/tcp_tests/tests/system/conftest.py b/tcp_tests/tests/system/conftest.py
index 2fc3f23..4f904ed 100644
--- a/tcp_tests/tests/system/conftest.py
+++ b/tcp_tests/tests/system/conftest.py
@@ -22,6 +22,7 @@
from tcp_tests.fixtures.openstack_fixtures import *
from tcp_tests.fixtures.opencontrail_fixtures import *
from tcp_tests.fixtures.oss_fixtures import *
+from tcp_tests.fixtures.decapod_fixtures import *
from tcp_tests.fixtures.stacklight_fixtures import *
from tcp_tests.fixtures.virtlet_fixtures import *
from tcp_tests.fixtures.virtlet_ceph_fixtures import *
@@ -52,6 +53,9 @@
# oss_fixtures
'oss_actions',
'oss_deployed',
+ # decapod_fixtures
+ 'decapod_actions',
+ 'decapod_deployed',
# component fixtures
'opencontrail',
# stacklight_fixtures
diff --git a/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py b/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
index f029744..b11d78a 100644
--- a/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
+++ b/tcp_tests/tests/system/test_install_mcp11_ovs_ocata.py
@@ -57,3 +57,17 @@
3. Setup compute nodes
"""
LOG.info("*************** DONE **************")
+
+ @pytest.mark.fail_snapshot
+ def test_mcp11_ocata_dvr_decapod_install(self, underlay, decapod_deployed,
+ openstack_deployed, show_step):
+ """Test for deploying an mcp dpdk environment and check it
+
+ :type list: decapod_deployed.decapod_nodes , list of
+ config.underlay.ssh objects filtered for decapod roles.
+ Scenario:
+ 1. Prepare salt on hosts
+ 2. Setup controller nodes
+ 3. Setup compute nodes
+ """
+ LOG.info("*************** DONE **************")