blob: 9a13cb48a3730403553d0d91748ff8ddbf34e8b5 [file] [log] [blame]
Victor Ryzhenkin655587f2017-05-24 20:00:07 +04001# 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 os
16
17import pytest
18import yaml
19
20from tcp_tests import logger
21from tcp_tests.helpers import ext
22from tcp_tests import settings
23from tcp_tests.managers import virtlet_ceph_manager
24
25LOG = logger.logger
26
27
28@pytest.fixture(scope='function')
29def virtlet_ceph_actions(config, underlay, salt_actions):
30 """Fixture that provides various actions for Virtlet project
31
32 :param config: fixture provides oslo.config
33 :param underlay: fixture provides underlay manager
34 :rtype: VirtletCephManager
35 """
36 return virtlet_ceph_manager.VirtletCephManager(config, underlay, salt_actions)
37
38
39@pytest.mark.revert_snapshot(ext.SNAPSHOT.virtlet_ceph_deployed)
40@pytest.fixture(scope='function')
41def virtlet_ceph_deployed(revert_snapshot, request, config,
42 hardware, underlay, common_services_deployed,
43 virtlet_deployed, virtlet_ceph_actions):
44 """Fixture to get or install Virtlet project on the 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 virtlet_deployed: fixture provides VirtletManager instance
53 :param virtlet_ceph_actions: fixture provides VirtletCephManager
54 :rtype: VirtletCephManager
55
56 If config.virtlet.ceph_installed is not set, this
57 fixture assumes that the One-node Ceph for Virtlet was not installed,
58 and do the following:
59 - install One-node Ceph cluster to the desired node
60 - make snapshot with name 'virtlet_ceph_deployed'
61 - return VirtletCephManager
62
63 If config.virtlet.ceph_installed was set, this fixture assumes that
64 the One-node Ceph cluster was already installed, and do the following:
65 - return VirtletCephManager instance
66
67 If you want to revert 'virtlet_ceph_deployed' snapshot, please use mark:
68 @pytest.mark.revert_snapshot("virtlet_ceph_deployed")
69 """
70 # Create Salt cluster
71 if not config.virtlet.ceph_installed:
72 steps_path = config.virtlet_deploy.virtlet_ceph_steps_path
73 commands = underlay.read_template(steps_path)
74 virtlet_ceph_actions.install(commands)
75 hardware.create_snapshot(ext.SNAPSHOT.virtlet_ceph_deployed)
76
77 else:
78 # 1. hardware environment created and powered on
79 # 2. config.underlay.ssh contains SSH access to provisioned nodes
80 # (can be passed from external config with TESTS_CONFIGS variable)
81 # 3. config.tcp.* options contain access credentials to the already
82 # installed TCP API endpoint
83 pass
84
85 return virtlet_ceph_actions