blob: df0d51617814f3369d826029e3482cb9b803ec96 [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
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030038@pytest.mark.revert_snapshot(ext.SNAPSHOT.stacklight_deployed)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030039@pytest.fixture(scope='function')
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030040def stacklight_deployed(revert_snapshot, request, config,
41 hardware, underlay, core_deployed,
42 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
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030055 if not config.stack_light.stacklight_installed:
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030056 steps_path = config.sl_deploy.sl_steps_path
57 commands = underlay.read_template(steps_path)
58 sl_actions.install(commands)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030059 hardware.create_snapshot(ext.SNAPSHOT.stacklight_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
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030073@pytest.mark.revert_snapshot(ext.SNAPSHOT.stacklight_deployed)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030074@pytest.fixture(scope='function')
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020075def sl_os_deployed(revert_snapshot,
76 openstack_deployed,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030077 stacklight_deployed):
Dennis Dmitriev17b9a9e2017-11-29 15:04:28 +020078 """Fixture to get or install SL and OpenStack services on environment
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030079
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030080 Uses fixtures openstack_deployed and stacklight_deployed,
81 with 'stacklight_deployed' 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 Dmitrievea48cf52018-07-18 18:04:39 +030085 return stacklight_deployed