Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 1 | # 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 Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 14 | |
| 15 | import pytest |
| 16 | |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 17 | from tcp_tests import logger |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 18 | from tcp_tests import settings |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 19 | |
| 20 | LOG = logger.logger |
| 21 | |
| 22 | |
| 23 | @pytest.mark.deploy |
| 24 | class TestOpenContrail(object): |
| 25 | """Test class for testing OpenContrail on a TCP lab""" |
| 26 | |
Dennis Dmitriev | 99b26fe | 2017-04-26 12:34:44 +0300 | [diff] [blame] | 27 | @pytest.mark.fail_snapshot |
sgudz | 868f086 | 2018-03-16 21:47:18 +0200 | [diff] [blame] | 28 | @pytest.mark.with_rally(rally_node="ctl01.") |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 29 | def test_opencontrail_simple(self, config, underlay, salt_deployed, |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 30 | openstack_deployed, stacklight_deployed, |
| 31 | show_step): |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 32 | """Runner for Juniper contrail-tests |
| 33 | |
| 34 | Scenario: |
| 35 | 1. Prepare salt on hosts |
| 36 | 2. Setup controller nodes |
| 37 | 3. Setup compute nodes |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 38 | 4. Run tempest |
| 39 | 5. Run SL test |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 40 | """ |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 41 | openstack_deployed._salt.local( |
| 42 | tgt='*', fun='cmd.run', |
| 43 | args='service ntp stop; ntpd -gq; service ntp start') |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 44 | |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 45 | if settings.RUN_TEMPEST: |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 46 | tempest_conf_name = '/var/lib/contrail_fixed_mcp.conf' |
sgudz | caa14a6 | 2018-02-07 12:25:07 +0200 | [diff] [blame] | 47 | openstack_deployed.run_tempest(target='ctl01', |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 48 | pattern=settings.PATTERN, |
| 49 | conf_name=tempest_conf_name) |
sgudz | caa14a6 | 2018-02-07 12:25:07 +0200 | [diff] [blame] | 50 | openstack_deployed.download_tempest_report(stored_node='ctl01') |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 51 | # Run SL component tetsts |
| 52 | if settings.RUN_SL_TESTS: |
| 53 | show_step(5) |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 54 | stacklight_deployed.run_sl_functional_tests( |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 55 | 'ctl01', |
| 56 | '/root/stacklight-pytest/stacklight_tests/', |
| 57 | 'tests/prometheus', |
| 58 | 'test_alerts.py') |
| 59 | show_step(8) |
| 60 | # Download report |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 61 | stacklight_deployed.download_sl_test_report( |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 62 | 'ctl01', |
| 63 | '/root/stacklight-pytest/stacklight_tests/report.xml') |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 64 | LOG.info("*************** DONE **************") |
| 65 | |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 66 | @pytest.mark.fail_snapshot |
| 67 | @pytest.mark.with_rally(rally_node="ctl01.") |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 68 | def test_opencontrail3_maas(self, config, underlay, salt_actions, |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 69 | openstack_deployed, show_step, |
| 70 | stacklight_deployed): |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 71 | """Runner for Juniper contrail-tests |
sgudz | cced67d | 2017-10-11 15:56:09 +0300 | [diff] [blame] | 72 | |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 73 | 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 Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 99 | mon_nodes = stacklight_deployed.get_monitoring_nodes() |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 100 | 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 Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 109 | stacklight_deployed.check_docker_services(mon_nodes, |
| 110 | expected_service_list) |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 111 | # Run SL component tetsts |
| 112 | if settings.RUN_SL_TESTS: |
| 113 | show_step(7) |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 114 | stacklight_deployed.run_sl_functional_tests( |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 115 | 'ctl01', |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 116 | '/root/stacklight-pytest/stacklight_tests/', |
| 117 | 'tests/prometheus', |
| 118 | 'test_alerts.py') |
| 119 | show_step(8) |
| 120 | # Download report |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 121 | stacklight_deployed.download_sl_test_report( |
sgudz | 850e607 | 2018-06-05 14:46:53 +0300 | [diff] [blame] | 122 | 'ctl01', |
sgudz | f5a5122 | 2018-05-11 14:20:50 +0300 | [diff] [blame] | 123 | '/root/stacklight-pytest/stacklight_tests/report.xml') |
| 124 | |
| 125 | LOG.info("*************** DONE **************") |