Browse Source

Merge "Add conformance test"

Jenkins 2 years ago
parent
commit
7469806e69

+ 13
- 7
fuel_ccp_tests/fixtures/k8s_fixtures.py View File

@@ -12,13 +12,14 @@
12 12
 #    License for the specific language governing permissions and limitations
13 13
 #    under the License.
14 14
 
15
+from operator import attrgetter
15 16
 import os
16 17
 import pytest
17 18
 
18
-from fuel_ccp_tests import logger
19 19
 from fuel_ccp_tests.helpers import ext
20
-from fuel_ccp_tests import settings
20
+from fuel_ccp_tests import logger
21 21
 from fuel_ccp_tests.managers import k8smanager
22
+from fuel_ccp_tests import settings
22 23
 
23 24
 LOG = logger.logger
24 25
 
@@ -94,12 +95,17 @@ def check_files_missing(request):
94 95
 
95 96
 
96 97
 @pytest.fixture(scope='class')
97
-def check_settings_missing(request):
98
+def 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 104
     LOG.info("Required settings: {}".format(request.cls.required_settings))
99
-    settings_missing = [s for s in request.cls.required_settings
100
-                        if not getattr(settings, s, None)]
101
-    assert len(settings_missing) == 0, \
102
-        "Following env variables are not set {}". format(settings_missing)
105
+    missing = [s for s in request.cls.required_settings
106
+               if not (getattr(settings, s, None) or get_attr(s, config))]
107
+    assert len(missing) == 0, \
108
+        "Following env variables are not set {}". format(missing)
103 109
 
104 110
 
105 111
 @pytest.fixture(scope='class')

+ 2
- 2
fuel_ccp_tests/managers/k8smanager.py View File

@@ -18,12 +18,12 @@ import yaml
18 18
 
19 19
 from devops.helpers import helpers
20 20
 
21
-from fuel_ccp_tests.helpers import exceptions
22 21
 from fuel_ccp_tests.helpers import _subprocess_runner
22
+from fuel_ccp_tests.helpers import exceptions
23 23
 from fuel_ccp_tests.helpers import post_install_k8s_checks
24 24
 from fuel_ccp_tests import logger
25
-from fuel_ccp_tests import settings
26 25
 from fuel_ccp_tests.managers.k8s import cluster
26
+from fuel_ccp_tests import settings
27 27
 
28 28
 LOG = logger.logger
29 29
 

+ 4
- 0
fuel_ccp_tests/settings_oslo.py View File

@@ -84,6 +84,10 @@ k8s_deploy_opts = [
84 84
            help="", default=None),
85 85
     ct.Cfg('kube_settings', ct.JSONDict(),
86 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 93
 # Access credentials to a ready K8S cluster

+ 71
- 0
fuel_ccp_tests/tests/component/k8s/test_conformance.py View File

@@ -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.
14
+import pytest
15
+
16
+from fuel_ccp_tests.helpers import _subprocess_runner
17
+from fuel_ccp_tests.helpers import exceptions
18
+from fuel_ccp_tests import logger
19
+
20
+LOG = logger.logger
21
+
22
+
23
+@pytest.mark.k8s_conformance
24
+@pytest.mark.component_k8s
25
+class 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)

Loading…
Cancel
Save