blob: 0e122058fb34f9c045ef0190e7ff5dbb923e877f [file] [log] [blame]
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +02001# 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.
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020014
15import pytest
16
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020017from tcp_tests import logger
sgudzcced67d2017-10-11 15:56:09 +030018from tcp_tests import settings
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020019
20LOG = logger.logger
21
22
23@pytest.mark.deploy
24class TestOpenContrail(object):
25 """Test class for testing OpenContrail on a TCP lab"""
26
Dennis Dmitriev99b26fe2017-04-26 12:34:44 +030027 @pytest.mark.fail_snapshot
sgudz868f0862018-03-16 21:47:18 +020028 @pytest.mark.with_rally(rally_node="ctl01.")
sgudz850e6072018-06-05 14:46:53 +030029 def test_opencontrail_simple(self, config, underlay, salt_deployed,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030030 openstack_deployed, stacklight_deployed,
31 show_step):
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020032 """Runner for Juniper contrail-tests
33
34 Scenario:
35 1. Prepare salt on hosts
36 2. Setup controller nodes
37 3. Setup compute nodes
sgudz850e6072018-06-05 14:46:53 +030038 4. Run tempest
39 5. Run SL test
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020040 """
sgudzcced67d2017-10-11 15:56:09 +030041 openstack_deployed._salt.local(
42 tgt='*', fun='cmd.run',
43 args='service ntp stop; ntpd -gq; service ntp start')
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020044
sgudzcced67d2017-10-11 15:56:09 +030045 if settings.RUN_TEMPEST:
sgudz850e6072018-06-05 14:46:53 +030046 tempest_conf_name = '/var/lib/contrail_fixed_mcp.conf'
sgudzcaa14a62018-02-07 12:25:07 +020047 openstack_deployed.run_tempest(target='ctl01',
sgudz850e6072018-06-05 14:46:53 +030048 pattern=settings.PATTERN,
49 conf_name=tempest_conf_name)
sgudzcaa14a62018-02-07 12:25:07 +020050 openstack_deployed.download_tempest_report(stored_node='ctl01')
sgudz850e6072018-06-05 14:46:53 +030051 # Run SL component tetsts
52 if settings.RUN_SL_TESTS:
53 show_step(5)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030054 stacklight_deployed.run_sl_functional_tests(
sgudzfc5b22f2018-08-23 17:45:04 +030055 'cfg01',
sgudz850e6072018-06-05 14:46:53 +030056 '/root/stacklight-pytest/stacklight_tests/',
vitalygusev0e57ef62018-11-30 12:13:56 +040057 'tests',
sgudz850e6072018-06-05 14:46:53 +030058 'test_alerts.py')
59 show_step(8)
60 # Download report
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030061 stacklight_deployed.download_sl_test_report(
sgudzfc5b22f2018-08-23 17:45:04 +030062 'cfg01',
sgudz850e6072018-06-05 14:46:53 +030063 '/root/stacklight-pytest/stacklight_tests/report.xml')
sgudzcced67d2017-10-11 15:56:09 +030064 LOG.info("*************** DONE **************")
65
sgudzf5a51222018-05-11 14:20:50 +030066 @pytest.mark.fail_snapshot
67 @pytest.mark.with_rally(rally_node="ctl01.")
sgudz850e6072018-06-05 14:46:53 +030068 def test_opencontrail3_maas(self, config, underlay, salt_actions,
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030069 openstack_deployed, show_step,
70 stacklight_deployed):
sgudzf5a51222018-05-11 14:20:50 +030071 """Runner for Juniper contrail-tests
sgudzcced67d2017-10-11 15:56:09 +030072
sgudzf5a51222018-05-11 14:20:50 +030073 Scenario:
74 1. Prepare salt on hosts
75 2. Setup controller nodes
76 3. Setup compute nodes
77 4. Run tempest
78 5. Exporting results
79 6. Check docker services
80 7. Run SL tests
81 8. Download sl tests report
82 """
83 openstack_deployed._salt.local(
84 tgt='*', fun='cmd.run',
85 args='service ntp stop; ntpd -gq; service ntp start')
86
87 if settings.RUN_TEMPEST:
88 show_step(4)
89 openstack_deployed.run_tempest(target='ctl01',
90 pattern=settings.PATTERN)
91 openstack_deployed.download_tempest_report(stored_node='ctl01')
92
93 expected_service_list = ['monitoring_server',
94 'monitoring_remote_agent',
95 'dashboard_grafana',
96 'monitoring_alertmanager',
97 'monitoring_remote_collector',
98 'monitoring_pushgateway']
Dennis Dmitrievea48cf52018-07-18 18:04:39 +030099 mon_nodes = stacklight_deployed.get_monitoring_nodes()
sgudzf5a51222018-05-11 14:20:50 +0300100 LOG.debug('Mon nodes list {0}'.format(mon_nodes))
101
102 prometheus_relay_enabled = salt_actions.get_pillar(
103 tgt=mon_nodes[0],
104 pillar="prometheus:relay:enabled")[0]
105 if not prometheus_relay_enabled:
106 # InfluxDB is used if prometheus relay service is not installed
107 expected_service_list.append('monitoring_remote_storage_adapter')
108 show_step(6)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +0300109 stacklight_deployed.check_docker_services(mon_nodes,
110 expected_service_list)
sgudzf5a51222018-05-11 14:20:50 +0300111 # Run SL component tetsts
112 if settings.RUN_SL_TESTS:
113 show_step(7)
Dennis Dmitrievea48cf52018-07-18 18:04:39 +0300114 stacklight_deployed.run_sl_functional_tests(
sgudz850e6072018-06-05 14:46:53 +0300115 'ctl01',
sgudzf5a51222018-05-11 14:20:50 +0300116 '/root/stacklight-pytest/stacklight_tests/',
vitalygusev0e57ef62018-11-30 12:13:56 +0400117 'tests',
sgudzf5a51222018-05-11 14:20:50 +0300118 'test_alerts.py')
119 show_step(8)
120 # Download report
Dennis Dmitrievea48cf52018-07-18 18:04:39 +0300121 stacklight_deployed.download_sl_test_report(
sgudz850e6072018-06-05 14:46:53 +0300122 'ctl01',
sgudzf5a51222018-05-11 14:20:50 +0300123 '/root/stacklight-pytest/stacklight_tests/report.xml')
sgudzfc5b22f2018-08-23 17:45:04 +0300124 LOG.info("*************** DONE **************")
sgudzf5a51222018-05-11 14:20:50 +0300125
sgudz8b01cf42018-10-08 18:59:11 +0300126 @pytest.mark.extract(container_system='docker', extract_from='conformance',
sgudzfc5b22f2018-08-23 17:45:04 +0300127 files_to_extract=['report'])
128 @pytest.mark.merge_xunit(path='/root/report',
129 output='/root/conformance_result.xml')
130 @pytest.mark.grab_k8s_results(name=['k8s_conformance.log',
131 'conformance_result.xml'])
132 @pytest.mark.grab_versions
133 @pytest.mark.fail_snapshot
134 def test_install_opencontrail4_k8s(self, config, show_step,
135 k8s_deployed, k8s_logs):
136 """Test for deploying MCP environment with k8s and check it
137
138 Scenario:
139 1. Prepare salt on hosts
140 2. Setup controller nodes
141 3. Setup compute nodes
142 4. Setup Kubernetes cluster
143 5. Run conformance if need
144
145 """
146
147 if config.k8s.k8s_conformance_run:
148 show_step(5)
149 k8s_deployed.run_conformance(raise_on_err=False)
150 LOG.info("*************** DONE **************")
151
sgudz8b01cf42018-10-08 18:59:11 +0300152 @pytest.mark.extract(container_system='docker', extract_from='conformance',
sgudzfc5b22f2018-08-23 17:45:04 +0300153 files_to_extract=['report'])
154 @pytest.mark.merge_xunit(path='/root/report',
155 output='/root/conformance_result.xml')
156 @pytest.mark.grab_k8s_results(name=['k8s_conformance.log',
157 'conformance_result.xml'])
158 @pytest.mark.grab_versions
159 @pytest.mark.fail_snapshot
160 def test_install_opencontrail4_k8s_lma(self, config, show_step,
161 k8s_deployed,
162 stacklight_deployed,
163 k8s_logs):
164 """Test for deploying MCP environment with k8s and check it
165
166 Scenario:
167 1. Prepare salt on hosts
168 2. Setup controller nodes
169 3. Setup compute nodes
170 4. Setup Kubernetes cluster
171 5. Check targets
172 6. Check docker services
173 7. Run SL tests
174 8. Download SL report
175 9. Run conformance if need
176 """
177 # Run SL component tetsts
178 if settings.RUN_SL_TESTS:
179 show_step(7)
180 stacklight_deployed.run_sl_functional_tests(
181 'cfg01',
182 '/root/stacklight-pytest/stacklight_tests/',
vitalygusev0e57ef62018-11-30 12:13:56 +0400183 'tests',
sgudzfc5b22f2018-08-23 17:45:04 +0300184 'test_alerts.py')
185 show_step(8)
186 # Download report
187 stacklight_deployed.download_sl_test_report(
188 'cfg01',
189 '/root/stacklight-pytest/stacklight_tests/report.xml')
190
191 if config.k8s.k8s_conformance_run:
192 show_step(9)
193 k8s_deployed.run_conformance(raise_on_err=False)
sgudzf5a51222018-05-11 14:20:50 +0300194 LOG.info("*************** DONE **************")