blob: a06965b3b13cf663056b58922849bfbcdb37cb3d [file] [log] [blame]
Tatyana Leontovicha754ce52017-11-13 16:46:43 +02001# Copyright 2017 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import pytest
16
17from tcp_tests import logger
18from tcp_tests.helpers import ext
19from tcp_tests.managers import ceph_manager
20
21LOG = logger.logger
22
23
24@pytest.fixture(scope='function')
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030025def ceph_actions(config, underlay_actions, salt_actions):
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020026 """Fixture that provides various actions for OpenStack
27
28 :param config: fixture provides oslo.config
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020029 :param underlay: fixture provides underlay manager
30 :param salt_deployed: fixture provides salt manager
31 :rtype: CephManager
32
33 For use in tests or fixtures to deploy a custom OpenStack
34 """
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030035 return ceph_manager.CephManager(config, underlay_actions, salt_actions)
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020036
37
38@pytest.mark.revert_snapshot(ext.SNAPSHOT.ceph_deployed)
39@pytest.fixture(scope='function')
40def ceph_deployed(revert_snapshot, request, config,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030041 hardware, underlay, core_deployed,
Dennis Dmitrievb8115f52017-12-15 13:09:56 +020042 salt_deployed, ceph_actions):
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020043 """Fixture to get or install Ceph services on environment
44
45 :param revert_snapshot: fixture that reverts snapshot that is specified
46 in test with @pytest.mark.revert_snapshot(<name>)
47 :param request: fixture provides pytest data
48 :param config: fixture provides oslo.config
49 :param hardware: fixture provides enviromnet manager
50 :param underlay: fixture provides underlay manager
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030051 :param core_deployed: fixture provides CoreManager
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020052 :param ceph_actions: fixture provides CephManager instance
53 :rtype: CephManager
54
55 If config.ceph.ceph_installed is not set, this fixture assumes
56 that the ceph services were not installed, and do the following:
57 - install ceph services
58 - make snapshot with name 'ceph_deployed'
59 - return CephManager instance
60
61 If config.ceph.ceph_installed was set, this fixture assumes that
62 the ceph services were already installed, and do the following:
63 - return CephManager instance
64
65 If you want to revert 'ceph_deployed' snapshot, please use mark:
66 @pytest.mark.revert_snapshot("ceph_deployed")
67 """
68 # Deploy Ceph cluster
69 if not config.ceph.ceph_installed:
70 steps_path = config.ceph_deploy.ceph_steps_path
71 commands = underlay.read_template(steps_path)
72 ceph_actions.install(commands)
73 hardware.create_snapshot(ext.SNAPSHOT.ceph_deployed)
Dennis Dmitrievb8115f52017-12-15 13:09:56 +020074 salt_deployed.sync_time()
Tatyana Leontovicha754ce52017-11-13 16:46:43 +020075
76 else:
77 # 1. hardware environment created and powered on
78 # 2. config.underlay.ssh contains SSH access to provisioned nodes
79 # (can be passed from external config with TESTS_CONFIGS variable)
80 # 3. config.tcp.* options contain access credentials to the already
81 # installed TCP API endpoint
82 pass
83
84 return ceph_actions