From d824939403a28ea2b41a8ed2aff9e41348f36440 Mon Sep 17 00:00:00 2001 From: Tatyana Leontovich Date: Wed, 14 Sep 2016 20:13:56 +0300 Subject: [PATCH] Add pre_commit tests for neutron Test coevrs: * deploy k8s * install ccp * update neutron service * build images * deploy openstack * install rally * run tempest.api.network tests * assert that there is no failures in tempest result * store test result into logs directory Change-Id: Ie26c1c39f04714bdf339e6f36cc906af68dd3413 --- .../helpers/post_os_deploy_checks.py | 4 +- fuel_ccp_tests/settings.py | 32 ++++---- .../tests/system/pre_commit/test_neutron.py | 82 +++++++++++++++++++ .../system/pre_commit/test_stacklight.py | 3 +- 4 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 fuel_ccp_tests/tests/system/pre_commit/test_neutron.py diff --git a/fuel_ccp_tests/helpers/post_os_deploy_checks.py b/fuel_ccp_tests/helpers/post_os_deploy_checks.py index 357e391..c6d44cb 100644 --- a/fuel_ccp_tests/helpers/post_os_deploy_checks.py +++ b/fuel_ccp_tests/helpers/post_os_deploy_checks.py @@ -63,7 +63,9 @@ def check_pod_status_by_name(name, k8sclient, namespace='ccp', count=None): pod_names = [pod.name for pod in k8sclient.pods.list(namespace=namespace) if name in pod.name] if count: - assert len(pod_names), count + fail_msg = 'Unexpected count of pods {0}. Current {1}'.format( + pod_names, len(pod_names)) + assert len(pod_names) == count, fail_msg for pod in pod_names: assert k8sclient.pods.get( diff --git a/fuel_ccp_tests/settings.py b/fuel_ccp_tests/settings.py index 761cd81..63fc7bb 100644 --- a/fuel_ccp_tests/settings.py +++ b/fuel_ccp_tests/settings.py @@ -61,10 +61,6 @@ KUBE_PROXY_MODE = os.environ.get("KUBE_PROXY_MODE", "iptables") IPIP_USAGE = get_var_as_bool('IPIP_USAGE', True) DOCKER_VERSION = float(os.environ.get("DOCKER_VERSION", "1.12")) -KARGO_REPO = os.environ.get('KARGO_REPO', - "https://github.com/kubespray/kargo.git") -KARGO_COMMIT = os.environ.get('KARGO_COMMIT', 'master') - HYPERKUBE_IMAGE_REPO = os.environ.get('HYPERKUBE_IMAGE_REPO', "quay.io/coreos/hyperkube") HYPERKUBE_IMAGE_TAG = os.environ.get('HYPERKUBE_IMAGE_TAG', "{}_coreos.0" @@ -72,6 +68,20 @@ HYPERKUBE_IMAGE_TAG = os.environ.get('HYPERKUBE_IMAGE_TAG', "{}_coreos.0" ETCD_IMAGE_REPO = os.environ.get('ETCD_IMAGE_REPO', "quay.io/coreos/etcd") ETCD_IMAGE_TAG = os.environ.get("ETCD_IMAGE_TAG", 'v3.0.1') ETCD_DEPLOYMENT_TYPE = os.environ.get('ETCD_DEPLOYMENT_TYPE', "docker") +# For dnsmasq purposes +UPSTREAM_DNS = os.environ.get('UPSTREAM_DNS', '8.8.8.8').split(',') +# For resolv.conf entries + +SERVICE_PATH = os.environ.get('SERVICE_PATH') +TEMPEST_SCRIPT_PATH = os.environ.get('TEMPEST_SCRIPT_PATH') +SEARCH_DOMAINS = os.environ.get('SEARCH_DOMAINS', + 'ccp.svc.cluster.local').split(',') +BUILDER_WORKERS = os.environ.get('BUILDER_WORKERS', 1) +BUILD_IMAGES = get_var_as_bool('BUILD_IMAGES', True) +REGISTRY = os.environ.get('REGISTRY', "127.0.0.1:31500") +IMAGES_NAMESPACE = os.environ.get('IMAGES_NAMESPACE', 'mcp') +IMAGES_TAG = os.environ.get('IMAGES_TAG', 'latest') + DEFAULT_CUSTOM_YAML = { "kube_network_plugin": KUBE_NETWORK_PLUGIN, @@ -86,6 +96,9 @@ DEFAULT_CUSTOM_YAML = { "hyperkube_image_repo": HYPERKUBE_IMAGE_REPO, "ipip": IPIP_USAGE, "kube_version": KUBE_VERSION, + "use_hyperkube_cni": str("true"), + "upstream_dns_servers": UPSTREAM_DNS, + "searchdomains": SEARCH_DOMAINS, } CALICO = { @@ -103,17 +116,6 @@ for key, val in CALICO.items(): if val: DEFAULT_CUSTOM_YAML[key] = val -BUILD_IMAGES = get_var_as_bool('BUILD_IMAGES', True) -REGISTRY = os.environ.get('REGISTRY', "127.0.0.1:31500") -IMAGES_NAMESPACE = os.environ.get('IMAGES_NAMESPACE', 'mcp') -IMAGES_TAG = os.environ.get('IMAGES_TAG', 'latest') -# For dnsmasq purposes -UPSTREAM_DNS = os.environ.get('UPSTREAM_DNS', '8.8.8.8').split(',') -SERVICE_PATH = os.environ.get('SERVICE_PATH') -TEMPEST_SCRIPT_PATH = os.environ.get('TEMPEST_SCRIPT_PATH') -SEARCH_DOMAINS = os.environ.get('SEARCH_DOMAINS', - 'ccp.svc.cluster.local').split(',') -BUILDER_WORKERS = os.environ.get('BUILDER_WORKERS', 1) DEPLOY_CONFIG = '/tmp/ccp-globals.yaml' FUEL_CCP_KEYSTONE_LOCAL_REPO = os.environ.get('FUEL_CCP_KEYSTONE_LOCAL_REPO', diff --git a/fuel_ccp_tests/tests/system/pre_commit/test_neutron.py b/fuel_ccp_tests/tests/system/pre_commit/test_neutron.py new file mode 100644 index 0000000..66d8307 --- /dev/null +++ b/fuel_ccp_tests/tests/system/pre_commit/test_neutron.py @@ -0,0 +1,82 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +import datetime +import json +import pytest + +from fuel_ccp_tests.helpers import post_os_deploy_checks +from fuel_ccp_tests.helpers import ext +from fuel_ccp_tests import logger +from fuel_ccp_tests import settings + +LOG = logger.logger +LOG.addHandler(logger.console) + + +class TestPreCommitNeutron(object): + """docstring for TestPreCommitNeutron + + Scenario: + 1. Install k8s + 2. Install fuel-ccp + 3. Fetch all repositories + 4. Fetch neutron from review + 5. Fetch containers from external registry + 6. Build neutron container + 7. Deploy Openstack + 8. Run tempest + """ + + @pytest.mark.test_neutron_on_commit + @pytest.mark.revert_snapshot(ext.SNAPSHOT.ccp_deployed) + def test_deploy_os_with_custom_neutron( + self, ccpcluster, k8s_actions, rally, underlay, config): + """ + Scenario: + 1. Install k8s + 2. Install fuel-ccp + 3. Fetch repos + 4. Upload repo with changes + 5. Build components + 6. Deploy components + 7. Run tempest suite + + """ + remote = underlay.remote(host=config.k8s.kube_host) + k8s_actions.create_registry() + ccpcluster.fetch() + ccpcluster.update_service('neutron') + ccpcluster.build(suppress_output=False) + ccpcluster.deploy() + rally.prepare() + rally.pull_image() + rally.run() + + post_os_deploy_checks.check_jobs_status(k8s_actions.api) + post_os_deploy_checks.check_pods_status(k8s_actions.api) + rally.run_tempest('--regex tempest.api.network') + LOG.info('Storing tests results...') + res_file_name = 'result.html' + file_prefix = 'results_' + datetime.datetime.now().strftime( + '%Y%m%d_%H%M%S') + '_' + file_dst = '{0}/logs/{1}{2}'.format( + settings.LOGS_DIR, file_prefix, res_file_name) + remote.download( + '/home/{0}/rally/{1}'.format(settings.SSH_LOGIN, res_file_name), + file_dst) + res = json.load(remote.open('/home/{}/rally/result.json'.format( + settings.SSH_LOGIN))) + + fail_msg = 'Tempest verification fails {}'.format(res) + assert res['failures'] == 0, fail_msg diff --git a/fuel_ccp_tests/tests/system/pre_commit/test_stacklight.py b/fuel_ccp_tests/tests/system/pre_commit/test_stacklight.py index 1709ea0..055cea4 100644 --- a/fuel_ccp_tests/tests/system/pre_commit/test_stacklight.py +++ b/fuel_ccp_tests/tests/system/pre_commit/test_stacklight.py @@ -94,4 +94,5 @@ class TestPreStackLight(object): res = requests.get(url, auth=('admin', 'admin')) - assert res.status_code, 200 + msg = 'Fail to auth in Grafana with {}'.format(res.status_code) + assert res.status_code == 200, msg