blob: a91129485bb0fd03bead2b8791d75d9aa2e318ce [file] [log] [blame]
Tatyana Leontovichb7404592017-04-07 11:52:28 +03001# 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 Leontovichb7404592017-04-07 11:52:28 +030014
15import pytest
16
Tatyana Leontovichb7404592017-04-07 11:52:28 +030017from tcp_tests import logger
Tatyana Leontovichf00b2342017-07-04 18:26:25 +030018from tcp_tests.helpers import netchecker
Tatyana Leontovichb7404592017-04-07 11:52:28 +030019
20LOG = logger.logger
21
22
23@pytest.mark.deploy
24class Testk8sInstall(object):
Artem Panchenko0594cd72017-06-12 13:25:26 +030025 """Test class for testing Kubernetes deploy"""
Tatyana Leontovichb7404592017-04-07 11:52:28 +030026
Artem Panchenko0594cd72017-06-12 13:25:26 +030027 @pytest.mark.fail_snapshot
Tatyana Leontovichf00b2342017-07-04 18:26:25 +030028 def test_k8s_install(self, config, show_step,
29 k8s_deployed, k8s_actions, sl_deployed):
Artem Panchenko0594cd72017-06-12 13:25:26 +030030 """Test for deploying MCP environment with k8s+stacklight and check it
Tatyana Leontovichb7404592017-04-07 11:52:28 +030031
32 Scenario:
33 1. Prepare salt on hosts
34 2. Setup controller nodes
35 3. Setup compute nodes
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +030036 4. Setup stack light nodes
Tatyana Leontovichf00b2342017-07-04 18:26:25 +030037 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 Leontovichb7404592017-04-07 11:52:28 +030042
43 """
Tatyana Leontovichf00b2342017-07-04 18:26:25 +030044 # 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 Leontovich1c568f92017-07-03 15:16:27 +030080 if config.k8s.k8s_conformance_run:
vrovacheva9d08332017-06-22 20:01:59 +040081 k8s_actions.run_conformance()
Tatyana Leontovichb7404592017-04-07 11:52:28 +030082 LOG.info("*************** DONE **************")
vrovachev0a2f6352017-06-09 12:48:59 +040083
Artem Panchenko0594cd72017-06-12 13:25:26 +030084 @pytest.mark.fail_snapshot
vrovacheva9d08332017-06-22 20:01:59 +040085 def test_only_k8s_install(self, config, k8s_deployed, k8s_actions):
Artem Panchenko0594cd72017-06-12 13:25:26 +030086 """Test for deploying MCP environment with k8s and check it
vrovachev0a2f6352017-06-09 12:48:59 +040087
88 Scenario:
89 1. Prepare salt on hosts
90 2. Setup controller nodes
91 3. Setup compute nodes
Artem Panchenko0594cd72017-06-12 13:25:26 +030092 4. Setup Kubernetes cluster
vrovacheva9d08332017-06-22 20:01:59 +040093 5. Run conformance if need
vrovachev0a2f6352017-06-09 12:48:59 +040094
95 """
Tatyana Leontovich1c568f92017-07-03 15:16:27 +030096 if config.k8s.k8s_conformance_run:
vrovacheva9d08332017-06-22 20:01:59 +040097 k8s_actions.run_conformance()
vrovachev0a2f6352017-06-09 12:48:59 +040098 LOG.info("*************** DONE **************")