blob: c1747b8ca1c3aa6fc781be8d5bc20de557555a30 [file] [log] [blame]
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +03001# Copyright 2016 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
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030015
16import pytest
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030017
18from tcp_tests import logger
19from tcp_tests.helpers import ext
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030020from tcp_tests.managers import sl_manager
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030021
22LOG = logger.logger
23
24
25@pytest.fixture(scope='function')
26def sl_actions(config, underlay, salt_deployed):
27 """Fixture that provides various actions for K8S
28
29 :param config: fixture provides oslo.config
30 :param underlay: fixture provides underlay manager
31 :rtype: SLManager
32
33 For use in tests or fixtures to deploy a custom K8S
34 """
35 return sl_manager.SLManager(config, underlay, salt_deployed)
36
37
38@pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
39@pytest.fixture(scope='function')
40def sl_deployed(revert_snapshot, request, config,
Dina Belovae6fdffb2017-09-19 13:58:34 -070041 hardware, underlay, common_services_deployed,
Dennis Dmitrievb8115f52017-12-15 13:09:56 +020042 salt_deployed, sl_actions):
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030043 """Fixture to get or install SL 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
51 :param tcp_actions: fixture provides SLManager instance
52 :rtype: SLManager
53 """
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020054 # Deploy SL services
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030055 if not config.stack_light.sl_installed:
56 steps_path = config.sl_deploy.sl_steps_path
57 commands = underlay.read_template(steps_path)
58 sl_actions.install(commands)
59 hardware.create_snapshot(ext.SNAPSHOT.sl_deployed)
Dennis Dmitrievb8115f52017-12-15 13:09:56 +020060 salt_deployed.sync_time()
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030061
62 else:
63 # 1. hardware environment created and powered on
64 # 2. config.underlay.ssh contains SSH access to provisioned nodes
65 # (can be passed from external config with TESTS_CONFIGS variable)
66 # 3. config.tcp.* options contain access credentials to the already
67 # installed TCP API endpoint
68 pass
69
70 return sl_actions
71
72
73@pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed)
74@pytest.fixture(scope='function')
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020075def sl_os_deployed(revert_snapshot,
76 openstack_deployed,
77 sl_deployed):
78 """Fixture to get or install SL and OpenStack services on environment
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030079
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020080 Uses fixtures openstack_deployed and sl_deployed, with 'sl_deployed'
81 top-level snapshot.
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030082
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020083 Returns SLManager instance object
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030084 """
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020085 return sl_deployed