summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-28 16:18:28 +0000
committerGerrit Code Review <review@openstack.org>2016-12-28 16:18:28 +0000
commit7469806e699414e597b4471b787ca9cd7a31160b (patch)
treeca5f1f2196cf7b128dc763ccebb897b806a19105
parenta102043b11d012b4906b41e0536b108b007092dd (diff)
parente1c94fbe0e15593c4ae933ed202da31c6d574bd2 (diff)
Merge "Add conformance test"
-rw-r--r--fuel_ccp_tests/fixtures/k8s_fixtures.py20
-rw-r--r--fuel_ccp_tests/managers/k8smanager.py4
-rw-r--r--fuel_ccp_tests/settings_oslo.py4
-rw-r--r--fuel_ccp_tests/tests/component/k8s/test_conformance.py71
4 files changed, 90 insertions, 9 deletions
diff --git a/fuel_ccp_tests/fixtures/k8s_fixtures.py b/fuel_ccp_tests/fixtures/k8s_fixtures.py
index 3bcf0b0..0cb57a1 100644
--- a/fuel_ccp_tests/fixtures/k8s_fixtures.py
+++ b/fuel_ccp_tests/fixtures/k8s_fixtures.py
@@ -12,13 +12,14 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15from operator import attrgetter
15import os 16import os
16import pytest 17import pytest
17 18
18from fuel_ccp_tests import logger
19from fuel_ccp_tests.helpers import ext 19from fuel_ccp_tests.helpers import ext
20from fuel_ccp_tests import settings 20from fuel_ccp_tests import logger
21from fuel_ccp_tests.managers import k8smanager 21from fuel_ccp_tests.managers import k8smanager
22from fuel_ccp_tests import settings
22 23
23LOG = logger.logger 24LOG = logger.logger
24 25
@@ -94,12 +95,17 @@ def check_files_missing(request):
94 95
95 96
96@pytest.fixture(scope='class') 97@pytest.fixture(scope='class')
97def check_settings_missing(request): 98def check_settings_missing(request, config):
99 def get_attr(attr, obj):
100 try:
101 return attrgetter(attr)(obj)
102 except Exception:
103 return None
98 LOG.info("Required settings: {}".format(request.cls.required_settings)) 104 LOG.info("Required settings: {}".format(request.cls.required_settings))
99 settings_missing = [s for s in request.cls.required_settings 105 missing = [s for s in request.cls.required_settings
100 if not getattr(settings, s, None)] 106 if not (getattr(settings, s, None) or get_attr(s, config))]
101 assert len(settings_missing) == 0, \ 107 assert len(missing) == 0, \
102 "Following env variables are not set {}". format(settings_missing) 108 "Following env variables are not set {}". format(missing)
103 109
104 110
105@pytest.fixture(scope='class') 111@pytest.fixture(scope='class')
diff --git a/fuel_ccp_tests/managers/k8smanager.py b/fuel_ccp_tests/managers/k8smanager.py
index 0cb3e1f..b46985f 100644
--- a/fuel_ccp_tests/managers/k8smanager.py
+++ b/fuel_ccp_tests/managers/k8smanager.py
@@ -18,12 +18,12 @@ import yaml
18 18
19from devops.helpers import helpers 19from devops.helpers import helpers
20 20
21from fuel_ccp_tests.helpers import exceptions
22from fuel_ccp_tests.helpers import _subprocess_runner 21from fuel_ccp_tests.helpers import _subprocess_runner
22from fuel_ccp_tests.helpers import exceptions
23from fuel_ccp_tests.helpers import post_install_k8s_checks 23from fuel_ccp_tests.helpers import post_install_k8s_checks
24from fuel_ccp_tests import logger 24from fuel_ccp_tests import logger
25from fuel_ccp_tests import settings
26from fuel_ccp_tests.managers.k8s import cluster 25from fuel_ccp_tests.managers.k8s import cluster
26from fuel_ccp_tests import settings
27 27
28LOG = logger.logger 28LOG = logger.logger
29 29
diff --git a/fuel_ccp_tests/settings_oslo.py b/fuel_ccp_tests/settings_oslo.py
index 276499d..eb88c7d 100644
--- a/fuel_ccp_tests/settings_oslo.py
+++ b/fuel_ccp_tests/settings_oslo.py
@@ -84,6 +84,10 @@ k8s_deploy_opts = [
84 help="", default=None), 84 help="", default=None),
85 ct.Cfg('kube_settings', ct.JSONDict(), 85 ct.Cfg('kube_settings', ct.JSONDict(),
86 help="", default={}), 86 help="", default={}),
87 ct.Cfg('e2e_conformance_image', ct.String(),
88 help="", default=''),
89 ct.Cfg('e2e_conformance_timeout', ct.Integer(),
90 help="", default=3600),
87] 91]
88 92
89# Access credentials to a ready K8S cluster 93# Access credentials to a ready K8S cluster
diff --git a/fuel_ccp_tests/tests/component/k8s/test_conformance.py b/fuel_ccp_tests/tests/component/k8s/test_conformance.py
new file mode 100644
index 0000000..10ea0a6
--- /dev/null
+++ b/fuel_ccp_tests/tests/component/k8s/test_conformance.py
@@ -0,0 +1,71 @@
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.
14import pytest
15
16from fuel_ccp_tests.helpers import _subprocess_runner
17from fuel_ccp_tests.helpers import exceptions
18from fuel_ccp_tests import logger
19
20LOG = logger.logger
21
22
23@pytest.mark.k8s_conformance
24@pytest.mark.component_k8s
25class TestK8sConformance(object):
26
27 required_settings = [
28 'k8s_deploy.e2e_conformance_image',
29 ]
30
31 @pytest.mark.fail_snapshot
32 @pytest.mark.dashboard_exists
33 @pytest.mark.usefixtures("check_settings_missing", "k8scluster")
34 def test_k8s_conformance(self, underlay, config):
35 """Run k8s conformance tests.
36
37 Requires path to the image to be set via environment variable
38 E2E_CONFORMANCE_IMAGE
39
40 Scenario:
41 1. Get or deploy k8s environment.
42 2. Run conformance tests
43 """
44 LOG.info("Running e2e conformance tests")
45 remote = underlay.remote(host=config.k8s.kube_host)
46 cmd = 'docker run --rm --net=host ' \
47 '-e API_SERVER="http://127.0.0.1:8080" ' \
48 '{image} >> e2e-conformance.log'.format(
49 image=config.k8s_deploy.e2e_conformance_image
50 )
51 result = remote.execute(
52 cmd,
53 timeout=config.k8s_deploy.e2e_conformance_timeout,
54 verbose=True)
55
56 cmd = "mkdir -p logs"
57
58 # FIXME Use Subprocess.execute instead of Subprocess.check_call until
59 # check_call is not fixed (fuel-devops3.0.2)
60 _subprocess_runner.Subprocess.execute(cmd, verbose=True)
61
62 remote.download('/home/vagrant/e2e-conformance.log', 'logs/')
63
64 expected_ec = [0]
65 if result.exit_code not in expected_ec:
66 raise exceptions.UnexpectedExitCode(
67 cmd,
68 result.exit_code,
69 expected_ec,
70 stdout=result.stdout_brief,
71 stderr=result.stdout_brief)