Add installation steps for Ceph one-node cluster
Add steps to install Ceph one-node cluster over virtlet
installation to be able to test Ceph related virtlet features.
Change-Id: Ic9e531a69fcb52d7360fcf089312fa1913350e0b
Reviewed-on: https://review.gerrithub.io/362388
Reviewed-by: Tatyanka Leontovich <tleontovich@mirantis.com>
Tested-by: Tatyanka Leontovich <tleontovich@mirantis.com>
diff --git a/tcp_tests/fixtures/virtlet_ceph_fixtures.py b/tcp_tests/fixtures/virtlet_ceph_fixtures.py
new file mode 100644
index 0000000..9a13cb4
--- /dev/null
+++ b/tcp_tests/fixtures/virtlet_ceph_fixtures.py
@@ -0,0 +1,85 @@
+# 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.
+
+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 virtlet_ceph_manager
+
+LOG = logger.logger
+
+
+@pytest.fixture(scope='function')
+def virtlet_ceph_actions(config, underlay, salt_actions):
+ """Fixture that provides various actions for Virtlet project
+
+ :param config: fixture provides oslo.config
+ :param underlay: fixture provides underlay manager
+ :rtype: VirtletCephManager
+ """
+ return virtlet_ceph_manager.VirtletCephManager(config, underlay, salt_actions)
+
+
+@pytest.mark.revert_snapshot(ext.SNAPSHOT.virtlet_ceph_deployed)
+@pytest.fixture(scope='function')
+def virtlet_ceph_deployed(revert_snapshot, request, config,
+ hardware, underlay, common_services_deployed,
+ virtlet_deployed, virtlet_ceph_actions):
+ """Fixture to get or install Virtlet project 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 virtlet_deployed: fixture provides VirtletManager instance
+ :param virtlet_ceph_actions: fixture provides VirtletCephManager
+ :rtype: VirtletCephManager
+
+ If config.virtlet.ceph_installed is not set, this
+ fixture assumes that the One-node Ceph for Virtlet was not installed,
+ and do the following:
+ - install One-node Ceph cluster to the desired node
+ - make snapshot with name 'virtlet_ceph_deployed'
+ - return VirtletCephManager
+
+ If config.virtlet.ceph_installed was set, this fixture assumes that
+ the One-node Ceph cluster was already installed, and do the following:
+ - return VirtletCephManager instance
+
+ If you want to revert 'virtlet_ceph_deployed' snapshot, please use mark:
+ @pytest.mark.revert_snapshot("virtlet_ceph_deployed")
+ """
+ # Create Salt cluster
+ if not config.virtlet.ceph_installed:
+ steps_path = config.virtlet_deploy.virtlet_ceph_steps_path
+ commands = underlay.read_template(steps_path)
+ virtlet_ceph_actions.install(commands)
+ hardware.create_snapshot(ext.SNAPSHOT.virtlet_ceph_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 virtlet_ceph_actions
diff --git a/tcp_tests/helpers/ext.py b/tcp_tests/helpers/ext.py
index 748efee..470206b 100644
--- a/tcp_tests/helpers/ext.py
+++ b/tcp_tests/helpers/ext.py
@@ -41,6 +41,7 @@
'openstack_deployed',
'sl_deployed',
'virtlet_deployed',
+ 'virtlet_ceph_deployed',
)
LOG_LEVELS = enum(
diff --git a/tcp_tests/managers/virtlet_ceph_manager.py b/tcp_tests/managers/virtlet_ceph_manager.py
new file mode 100644
index 0000000..49c4c64
--- /dev/null
+++ b/tcp_tests/managers/virtlet_ceph_manager.py
@@ -0,0 +1,35 @@
+# 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 VirtletCephManager(ExecuteCommandsMixin):
+ """docstring for VirtletCephManager"""
+
+ __config = None
+ __underlay = None
+
+ def __init__(self, config, underlay, salt):
+ self.__config = config
+ self.__underlay = underlay
+ self._salt = salt
+ super(VirtletCephManager, self).__init__(
+ config=config, underlay=underlay)
+
+ def install(self, commands):
+ self.execute_commands(
+ commands,
+ label='Install One-node Ceph cluster in docker container')
+ self.__config.virtlet.ceph_installed = True
\ No newline at end of file
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index c6b5b74..52e3fd9 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -46,6 +46,9 @@
_default_virtlet_prepare_tests_steps_path = pkg_resources.resource_filename(
__name__, 'templates/{0}/virtlet.yaml'.format(
settings.LAB_CONFIG_NAME))
+_default_virtlet_ceph_prepare_tests_steps_path = pkg_resources.resource_filename(
+ __name__, 'templates/{0}/virtlet_ceph.yaml'.format(
+ settings.LAB_CONFIG_NAME))
hardware_opts = [
ct.Cfg('manager', ct.String(),
@@ -152,12 +155,19 @@
virtlet_deploy_opts = [
ct.Cfg('virtlet_steps_path', ct.String(),
help="Path to YAML with steps to deploy virtlet",
- default=_default_virtlet_prepare_tests_steps_path)
+ default=_default_virtlet_prepare_tests_steps_path),
+ ct.Cfg('virtlet_ceph_steps_path', ct.String(),
+ help="Path to YAML with steps to deploy one-node ceph cluster for "
+ "Virtlet Flexvolumes testing",
+ default=_default_virtlet_ceph_prepare_tests_steps_path)
]
virtlet_opts = [
ct.Cfg('virtlet_installed', ct.Boolean(),
help="", default=False),
+ ct.Cfg('ceph_installed', ct.Boolean(),
+ help="Determine, installed one-node ceph cluster or not",
+ default=False)
]
_group_opts = [
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet_ceph.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet_ceph.yaml
new file mode 100644
index 0000000..3f2468e
--- /dev/null
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/virtlet_ceph.yaml
@@ -0,0 +1,31 @@
+{% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CTL02 with context %}
+
+# Clone virtlet project from git to the ctl02 node to get ceph scripts
+- description: Cloning virtlet project on ctl02
+ cmd: |
+ if [[ ! -d virtlet ]]; then
+ git clone -b master https://github.com/Mirantis/virtlet.git;
+ else
+ echo "Virtlet project already present on node";
+ fi
+ node_name: {{ HOSTNAME_CTL02 }}
+ retry: {count: 1, delay: 1}
+ skip_fail: false
+
+# Make run_ceph.sh runnable
+- description: Set monitor ip for ceph
+ cmd: |
+ NODE_IP=$(ifconfig | grep -A 1 ens3 | tail -n +2 | awk '{print $2}' | sed 's/addr://g')
+ sed -i "0,/MON_IP=.*/s//MON_IP=${NODE_IP}/" virtlet/tests/e2e/run_ceph.sh
+ node_name: {{ HOSTNAME_CTL02 }}
+ retry: {count: 1, delay: 1}
+ skip_fail: false
+
+# Run Ceph in docker
+- description: Start Ceph container
+ cmd: |
+ SCR_DIR=$(realpath virtlet/tests/e2e)
+ virtlet/tests/e2e/run_ceph.sh ${SCR_DIR}
+ node_name: {{ HOSTNAME_CTL02 }}
+ retry: {count: 1, delay: 1}
+ skip_fail: false
\ No newline at end of file
diff --git a/tcp_tests/tests/system/conftest.py b/tcp_tests/tests/system/conftest.py
index e8ffb8d..89dfc3d 100644
--- a/tcp_tests/tests/system/conftest.py
+++ b/tcp_tests/tests/system/conftest.py
@@ -23,6 +23,8 @@
from tcp_tests.fixtures.opencontrail_fixtures import *
from tcp_tests.fixtures.stacklight_fixtures import *
from tcp_tests.fixtures.virtlet_fixtures import *
+from tcp_tests.fixtures.virtlet_ceph_fixtures import *
+
__all__ = sorted([ # sort for documentation
# common_fixtures
@@ -52,4 +54,6 @@
'sl_deployed',
'virtlet_actions',
'virtlet_deployed',
+ 'virtlet_ceph_actions',
+ 'virtlet_ceph_deployed'
])
diff --git a/tcp_tests/tests/system/test_install_virtlet.py b/tcp_tests/tests/system/test_install_virtlet.py
index 7976761..f49319d 100644
--- a/tcp_tests/tests/system/test_install_virtlet.py
+++ b/tcp_tests/tests/system/test_install_virtlet.py
@@ -48,3 +48,18 @@
"""
LOG.info("*************** DONE **************")
+
+ def test_virtlet_install_with_ceph(self, underlay, virtlet_ceph_deployed,
+ show_step):
+ """Test for deploying an mcp environment with virtlet and one-node
+ Ceph cluster.
+
+ Scenario:
+ 1. Prepare salt on hosts
+ 2. Setup controller nodes
+ 3. Setup compute nodes
+ 4. Setup virtlet
+ 5. Launch Ceph one-node cluster in docker
+
+ """
+ LOG.info("*************** DONE **************")
\ No newline at end of file