Browse Source

Add test with ccp in container

- Add test where ccp is installed as container
and OS is deployed with containerized ccp

Change-Id: Ic6d1884b8330b3ef1e3a214391a5c442306b4fd6
asledzinskiy 2 years ago
parent
commit
a102043b11

+ 23
- 4
fuel_ccp_tests/managers/ccpmanager.py View File

@@ -34,17 +34,20 @@ class CCPManager(object):
34 34
         self.__underlay = underlay
35 35
         super(CCPManager, self).__init__()
36 36
 
37
-    def install_ccp(self, use_defaults=True):
38
-        """Base action to deploy k8s by external deployment script"""
39
-        LOG.info("Trying to install fuel-ccp on admin node")
37
+    def fetch_ccp(self):
40 38
         with self.__underlay.remote(
41 39
                 host=self.__config.k8s.kube_host) as remote:
42
-
43 40
             ccp_repo_url = settings.CCP_REPO
44 41
             LOG.info("Fetch ccp from github")
45 42
             cmd = 'git clone {}'.format(ccp_repo_url)
46 43
             remote.check_call(cmd, verbose=True)
47 44
 
45
+    def install_ccp(self, use_defaults=True):
46
+        """Base action to deploy k8s by external deployment script"""
47
+        LOG.info("Trying to install fuel-ccp on admin node")
48
+        self.fetch_ccp()
49
+        with self.__underlay.remote(
50
+                host=self.__config.k8s.kube_host) as remote:
48 51
             LOG.info('Install fuel-ccp from local path')
49 52
             cmd = 'pip install --upgrade fuel-ccp/'
50 53
             with remote.get_sudo(remote):
@@ -53,6 +56,22 @@ class CCPManager(object):
53 56
                 LOG.debug("*** Result STDOUT:\n{0}".format(result.stdout_str))
54 57
                 LOG.debug("*** Result STDERR:\n{0}".format(result.stderr_str))
55 58
 
59
+    def dockerize_ccp(self):
60
+        self.__underlay.sudo_check_call("cd fuel-ccp/docker/"
61
+                                        "ccp&&./dockerize.sh",
62
+                                        host=self.__config.k8s.kube_host)
63
+        ccp_script = '''
64
+        docker run --rm  -i --name=fuel-ccp --network=host \
65
+        -v ~/:/home/`whoami`/ -v /var/run/docker.sock:/var/run/docker.sock \
66
+        -e LOCAL_USER_ID=`id -u $USER` -e LOCAL_USER_NAME=`whoami` \
67
+        fuel-ccp:latest $@
68
+        '''
69
+        self.__underlay.sudo_check_call("echo -e '{}' > /usr/local/"
70
+                                        "bin/ccp".format(ccp_script),
71
+                                        host=self.__config.k8s.kube_host)
72
+        self.__underlay.sudo_check_call("chmod +x /usr/local/bin/ccp",
73
+                                        host=self.__config.k8s.kube_host)
74
+
56 75
     @property
57 76
     def default_params(self):
58 77
         if hasattr(self, '_default_params'):

+ 88
- 0
fuel_ccp_tests/tests/system/test_ccp_containerized.py View File

@@ -0,0 +1,88 @@
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
+
15
+import pytest
16
+
17
+import base_test
18
+from fuel_ccp_tests import logger
19
+from fuel_ccp_tests import settings
20
+from fuel_ccp_tests.helpers import post_os_deploy_checks
21
+
22
+LOG = logger.logger
23
+
24
+
25
+class TestCcpContainerized(base_test.SystemBaseTest):
26
+    """Deploy OpenStack with CCP in container
27
+
28
+       pytest.mark: ccp_containerized
29
+    """
30
+
31
+    @pytest.mark.ccp_containerized
32
+    @pytest.mark.fail_snapshot
33
+    def test_fuel_ccp_containerized(
34
+            self, underlay, config, k8scluster, ccp_actions, show_step):
35
+        """Deploy environment using ccp in container
36
+
37
+        Scenario:
38
+        1. Revert snapshot
39
+        2. Install ccp in container
40
+        3. Deploy environment
41
+        4. Check deployment
42
+
43
+        Duration 35 min
44
+        """
45
+
46
+        ccp_actions.default_params = settings.CCP_CLI_PARAMS
47
+        show_step(2)
48
+        ccp_actions.fetch_ccp()
49
+        ccp_actions.dockerize_ccp()
50
+
51
+        ccp_actions.put_yaml_config(
52
+            path=settings.CCP_DEPLOY_CONFIG,
53
+            config=settings.CCP_DEFAULT_GLOBALS)
54
+        ccp_actions.put_yaml_config(
55
+            path=settings.CCP_SOURCES_CONFIG,
56
+            config=settings.CCP_BUILD_SOURCES)
57
+        ccp_actions.put_yaml_config(
58
+            path=settings.CCP_FETCH_CONFIG,
59
+            config=settings.CCP_FETCH_PARAMS)
60
+
61
+        with open(config.ccp_deploy.topology_path, 'r') as f:
62
+            ccp_actions.put_raw_config(
63
+                path=settings.CCP_DEPLOY_TOPOLOGY,
64
+                content=f.read())
65
+
66
+        ccp_actions.init_default_config(include_files=[
67
+            settings.CCP_DEPLOY_CONFIG,
68
+            settings.CCP_SOURCES_CONFIG,
69
+            settings.CCP_DEPLOY_TOPOLOGY,
70
+            settings.CCP_FETCH_CONFIG])
71
+        config.ccp.os_host = config.k8s.kube_host
72
+
73
+        if settings.REGISTRY == "127.0.0.1:31500":
74
+            k8scluster.create_registry()
75
+            ccp_actions.build()
76
+        show_step(3)
77
+        ccp_actions.deploy()
78
+        post_os_deploy_checks.check_jobs_status(k8scluster.api)
79
+        post_os_deploy_checks.check_pods_status(k8scluster.api)
80
+        show_step(4)
81
+        remote = underlay.remote(host=config.k8s.kube_host)
82
+        underlay.sudo_check_call("pip install python-openstackclient",
83
+                                 host=config.k8s.kube_host)
84
+        remote.check_call(
85
+            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
86
+            " create".format(
87
+                settings.CCP_CONF["kubernetes"]["namespace"]),
88
+            timeout=600)

Loading…
Cancel
Save