Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 1 | # 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. |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 14 | |
| 15 | import pytest |
| 16 | |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 17 | from tcp_tests import logger |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame^] | 18 | from tcp_tests.helpers import netchecker |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 19 | |
| 20 | LOG = logger.logger |
| 21 | |
| 22 | |
| 23 | @pytest.mark.deploy |
| 24 | class Testk8sInstall(object): |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 25 | """Test class for testing Kubernetes deploy""" |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 26 | |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 27 | @pytest.mark.fail_snapshot |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame^] | 28 | def test_k8s_install(self, config, show_step, |
| 29 | k8s_deployed, k8s_actions, sl_deployed): |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 30 | """Test for deploying MCP environment with k8s+stacklight and check it |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 31 | |
| 32 | Scenario: |
| 33 | 1. Prepare salt on hosts |
| 34 | 2. Setup controller nodes |
| 35 | 3. Setup compute nodes |
Tatyana Leontovich | 5acc82a | 2017-05-23 15:41:35 +0300 | [diff] [blame] | 36 | 4. Setup stack light nodes |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame^] | 37 | 5. Setup Kubernetes cluster and check it nodes |
| 38 | 6. Check netchecker server is running |
| 39 | 7. Check netchecker agent is running |
| 40 | 8. Check connectivity |
| 41 | 9. Get metrics from netchecker |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 42 | |
| 43 | """ |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame^] | 44 | # STEP #5 |
| 45 | show_step(5) |
| 46 | k8sclient = k8s_deployed.api |
| 47 | assert k8sclient.nodes.list() is not None, "Can not get nodes list" |
| 48 | |
| 49 | show_step(6) |
| 50 | netchecker.get_netchecker_pod_status(k8s=k8s_deployed, |
| 51 | namespace='netchecker') |
| 52 | |
| 53 | show_step(7) |
| 54 | netchecker.get_netchecker_pod_status(k8s=k8s_deployed, |
| 55 | pod_name='netchecker-agent', |
| 56 | namespace='netchecker') |
| 57 | |
| 58 | # show_step(8) |
| 59 | netchecker.wait_check_network(k8sclient, namespace='netchecker', |
| 60 | netchecker_pod_port=30811) |
| 61 | show_step(9) |
| 62 | res = netchecker.get_metric(k8sclient, netchecker_pod_port=30811, |
| 63 | namespace='netchecker') |
| 64 | |
| 65 | assert res.status_code == 200, 'Unexpected response code {}'.format(res) |
| 66 | metrics = ['ncagent_error_count_total', 'ncagent_http_probe_code', |
| 67 | 'ncagent_http_probe_connect_time_ms', |
| 68 | 'ncagent_http_probe_connection_result', |
| 69 | 'ncagent_http_probe_content_transfer_time_ms', |
| 70 | 'ncagent_http_probe_dns_lookup_time_ms', |
| 71 | 'ncagent_http_probe_server_processing_time_ms', |
| 72 | 'ncagent_http_probe_tcp_connection_time_ms', |
| 73 | 'ncagent_http_probe_total_time_ms', |
| 74 | 'ncagent_report_count_tota'] |
| 75 | for metric in metrics: |
| 76 | assert metric in res.text.strip(), \ |
| 77 | 'Mandotory metric {0} is missing in {1}'.format( |
| 78 | metric, res.text) |
| 79 | |
Tatyana Leontovich | 1c568f9 | 2017-07-03 15:16:27 +0300 | [diff] [blame] | 80 | if config.k8s.k8s_conformance_run: |
vrovachev | a9d0833 | 2017-06-22 20:01:59 +0400 | [diff] [blame] | 81 | k8s_actions.run_conformance() |
Tatyana Leontovich | b740459 | 2017-04-07 11:52:28 +0300 | [diff] [blame] | 82 | LOG.info("*************** DONE **************") |
vrovachev | 0a2f635 | 2017-06-09 12:48:59 +0400 | [diff] [blame] | 83 | |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 84 | @pytest.mark.fail_snapshot |
vrovachev | a9d0833 | 2017-06-22 20:01:59 +0400 | [diff] [blame] | 85 | def test_only_k8s_install(self, config, k8s_deployed, k8s_actions): |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 86 | """Test for deploying MCP environment with k8s and check it |
vrovachev | 0a2f635 | 2017-06-09 12:48:59 +0400 | [diff] [blame] | 87 | |
| 88 | Scenario: |
| 89 | 1. Prepare salt on hosts |
| 90 | 2. Setup controller nodes |
| 91 | 3. Setup compute nodes |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 92 | 4. Setup Kubernetes cluster |
vrovachev | a9d0833 | 2017-06-22 20:01:59 +0400 | [diff] [blame] | 93 | 5. Run conformance if need |
vrovachev | 0a2f635 | 2017-06-09 12:48:59 +0400 | [diff] [blame] | 94 | |
| 95 | """ |
Tatyana Leontovich | 1c568f9 | 2017-07-03 15:16:27 +0300 | [diff] [blame] | 96 | if config.k8s.k8s_conformance_run: |
vrovachev | a9d0833 | 2017-06-22 20:01:59 +0400 | [diff] [blame] | 97 | k8s_actions.run_conformance() |
vrovachev | 0a2f635 | 2017-06-09 12:48:59 +0400 | [diff] [blame] | 98 | LOG.info("*************** DONE **************") |