blob: 7fc02bf6c6d3a306d6b873c89b597b8273404450 [file] [log] [blame]
Dennis Dmitriev85559962018-01-30 15:35:51 +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
16import os
17
18from tcp_tests import logger
19from tcp_tests import settings
20from tcp_tests.helpers import ext
21
22LOG = logger.logger
23
24
25class TestGenerateModel(object):
26 """Test class that generates and checks a cluster model"""
27
28 @pytest.mark.fail_snapshot
29 def test_generate_model(self, config, underlay, salt_actions):
30 config.salt.salt_master_host = \
31 underlay.host_by_node_role(
32 node_role=ext.UNDERLAY_NODE_ROLES.salt_master)
33
34 commands = underlay.read_template(config.salt_deploy.salt_steps_path)
35 salt_actions.install(commands)
36
Dennis Dmitriev92295c02018-02-02 13:18:25 +020037 node_name = underlay.get_target_node_names('cfg01')[0]
Dennis Dmitriev85559962018-01-30 15:35:51 +020038 arch_model_name = 'model_{0}.tar.gz'.format(settings.ENV_NAME)
39 commands = [
40 {
41 'description': "Copy generated model to /root/reclass",
42 'node_name': node_name,
43 'cmd': ('cp -r /srv/salt/reclass/ /root/;'
44 'rm -rf /root/reclass/classes/service/;'
45 'rm -rf /root/reclass/classes/system/;')},
46 {
47 'description': ("Archive the model to the /root/{0}"
48 .format(arch_model_name)),
49 'node_name': node_name,
50 'cmd': ('cd /root/reclass/;'
51 'tar --warning=no-file-changed -czf /root/{0} ./'
52 .format(arch_model_name))},
53 {
54 'description': "Download the model to the host",
55 'node_name': node_name,
56 'download': {
57 'remote_path': '/root/',
58 'remote_filename': arch_model_name,
59 'local_path': os.getcwd()
60 }},
61 ]
62
63 salt_actions.execute_commands(commands=commands,
64 label="Get the model from the cfg01")
65
66
67# tar_cmd = (
68# 'cp -r /srv/salt/reclass/ /root/;'
69# 'rm -rf /root/reclass/classes/service/;'
70# 'rm -rf /root/reclass/classes/system/;'
71# 'cd /root/reclass/;'
72# 'tar --warning=no-file-changed -czf /root/model_{0}.tar.gz ./'
73# .format(settings.ENV_NAME))
74# with underlay.remote(host=config.salt.salt_master_host) as r:
75# r.check_call(tar_cmd, verbose=True)
76# r.download('model_{0}.tar.gz'.format(settings.ENV_NAME),
77# os.getcwd())
78
79 LOG.info("*************** DONE **************")