blob: c294542933c4d1635b493a5262a499d06da9b3e8 [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')
25def ceph_actions(config, hardware, underlay, salt_deployed):
26 """Fixture that provides various actions for OpenStack
27
28 :param config: fixture provides oslo.config
29 :param config: fixture provides oslo.config
30 :param underlay: fixture provides underlay manager
31 :param salt_deployed: fixture provides salt manager
32 :rtype: CephManager
33
34 For use in tests or fixtures to deploy a custom OpenStack
35 """
36 return ceph_manager.CephManager(config, underlay, hardware, salt_deployed)
37
38
39@pytest.mark.revert_snapshot(ext.SNAPSHOT.ceph_deployed)
40@pytest.fixture(scope='function')
41def ceph_deployed(revert_snapshot, request, config,
42 hardware, underlay, common_services_deployed,
43 ceph_actions):
44 """Fixture to get or install Ceph services on environment
45
46 :param revert_snapshot: fixture that reverts snapshot that is specified
47 in test with @pytest.mark.revert_snapshot(<name>)
48 :param request: fixture provides pytest data
49 :param config: fixture provides oslo.config
50 :param hardware: fixture provides enviromnet manager
51 :param underlay: fixture provides underlay manager
52 :param common_services_deployed: fixture provides CommonServicesManager
53 :param ceph_actions: fixture provides CephManager instance
54 :rtype: CephManager
55
56 If config.ceph.ceph_installed is not set, this fixture assumes
57 that the ceph services were not installed, and do the following:
58 - install ceph services
59 - make snapshot with name 'ceph_deployed'
60 - return CephManager instance
61
62 If config.ceph.ceph_installed was set, this fixture assumes that
63 the ceph services were already installed, and do the following:
64 - return CephManager instance
65
66 If you want to revert 'ceph_deployed' snapshot, please use mark:
67 @pytest.mark.revert_snapshot("ceph_deployed")
68 """
69 # Deploy Ceph cluster
70 if not config.ceph.ceph_installed:
71 steps_path = config.ceph_deploy.ceph_steps_path
72 commands = underlay.read_template(steps_path)
73 ceph_actions.install(commands)
74 hardware.create_snapshot(ext.SNAPSHOT.ceph_deployed)
75
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