Browse Source

Add Upgrade test

Check that after Maintenance Update from 9.0 to 9.1 murano plugin
work correctly

Change-Id: I62d8769db0dc04aa5e6efe84b962047c3604a97c
MStolyarenko 2 years ago
parent
commit
b39062c406

+ 101
- 1
murano_plugin_tests/helpers/helpers.py View File

@@ -19,13 +19,15 @@ import urllib2
19 19
 
20 20
 from devops.helpers import helpers
21 21
 from fuelweb_test.helpers import os_actions
22
+from fuelweb_test.helpers.ssh_manager import SSHManager
22 23
 from fuelweb_test import logger
23 24
 from proboscis import asserts
24 25
 
26
+from devops.helpers.helpers import wait
27
+
25 28
 from murano_plugin_tests.helpers import remote_ops
26 29
 from murano_plugin_tests import settings
27 30
 
28
-
29 31
 PLUGIN_PACKAGE_RE = re.compile(r'([^/]+)-(\d+\.\d+)-(\d+\.\d+\.\d+)')
30 32
 
31 33
 
@@ -84,6 +86,7 @@ class PluginHelper(object):
84 86
         self._cluster_id = None
85 87
         self.nailgun_client = self.fuel_web.client
86 88
         self._os_conn = None
89
+        self.ssh_manager = SSHManager()
87 90
 
88 91
     @property
89 92
     def cluster_id(self):
@@ -608,3 +611,100 @@ class PluginHelper(object):
608 611
                         resource_name, pcm_nodes), config), None,
609 612
                 'Resource [{0}] is not properly configured'.format(
610 613
                     resource_name))
614
+
615
+    def add_centos_test_proposed_repo(self, repo_url, timestamp):
616
+        cmds = ["yum-config-manager --add-repo {0}{1}/x86_64/".format(
617
+                repo_url, timestamp),
618
+
619
+                "rpm --import {0}{1}/RPM-GPG-KEY-mos9.0".format(
620
+                repo_url, timestamp)]
621
+        for cmd in cmds:
622
+
623
+            self.ssh_manager.check_call(
624
+                ip=self.ssh_manager.admin_ip,
625
+                command=cmd)
626
+
627
+    def add_cluster_repo(self, repo):
628
+        attributes = self.fuel_web.client.get_cluster_attributes(
629
+            self.cluster_id)
630
+        repos_attr = attributes['editable']['repo_setup']['repos']
631
+        repos_attr['value'].append(repo)
632
+        self.fuel_web.client.update_cluster_attributes(
633
+            self.cluster_id, attributes)
634
+
635
+    def install_python_cudet(self):
636
+        cmd = "yum install -y python-cudet"
637
+        self.ssh_manager.check_call(
638
+            ip=self.ssh_manager.admin_ip,
639
+            command=cmd)
640
+
641
+    def prepare_update_master_node(self):
642
+        cmds = ['update-prepare prepare master',
643
+                'update-prepare update master']
644
+        for cmd in cmds:
645
+            self.ssh_manager.check_call(
646
+                ip=self.ssh_manager.admin_ip,
647
+                command=cmd)
648
+
649
+    def prepare_for_update(self):
650
+        cmd = "update-prepare prepare env {}".format(self.cluster_id)
651
+
652
+        self.ssh_manager.check_call(
653
+            ip=self.ssh_manager.admin_ip,
654
+            command=cmd)
655
+
656
+    def install_mu(self, repos='proposed'):
657
+        if repos:
658
+            cmd = "fuel2 update install --env {} --repos {} " \
659
+                  "--restart-rabbit --restart-mysql".format(self.cluster_id,
660
+                                                            repos)
661
+        else:
662
+            cmd = "fuel2 update install --env {}" \
663
+                  "--restart-rabbit --restart-mysql ".format(self.cluster_id)
664
+
665
+        std_out = self.ssh_manager.check_call(
666
+            ip=self.ssh_manager.admin_ip,
667
+            command=cmd).stderr_str
668
+
669
+        # "fuel2 update" command don't have json output
670
+        asserts.assert_true(
671
+            "fuel2 task show" in std_out,
672
+            "fuel2 update command don't return task id: \n {}".format(std_out))
673
+
674
+        task_id = int(std_out.split("fuel2 task show")[1].split("`")[0])
675
+        task = self.fuel_web.client.get_task(task_id)
676
+
677
+        self.assert_cli_task_success(task, timeout=120 * 60)
678
+
679
+    def assert_cli_task_success(self, task, timeout=70 * 60, interval=20):
680
+        logger.info('Wait {timeout} seconds for task: {task}'
681
+                    .format(timeout=timeout, task=task))
682
+        start = time.time()
683
+        wait(
684
+            lambda: (self.fuel_web.client.get_task(task['id'])['status'] not in
685
+                     ('pending', 'running')),
686
+            interval=interval,
687
+            timeout=timeout,
688
+            timeout_msg='Waiting timeout {timeout} sec was reached '
689
+                        'for task: {task}'.format(task=task["name"],
690
+                                                  timeout=timeout)
691
+        )
692
+        took = time.time() - start
693
+        task = self.fuel_web.client.get_task(task['id'])
694
+        logger.info('Task finished in {took} seconds with the result: {task}'
695
+                    .format(took=took, task=task))
696
+        asserts.assert_equal(
697
+            task['status'], 'ready',
698
+            "Task '{name}' has incorrect status. {status} != {exp}".format(
699
+                status=task['status'], exp='ready', name=task["name"]
700
+            )
701
+        )
702
+
703
+    def check_update(self):
704
+        cmd = "cudet -e {}".format(self.cluster_id)
705
+
706
+        std_out = self.ssh_manager.execute_on_remote(
707
+            ip=self.ssh_manager.admin_ip,
708
+            cmd=cmd)['stdout']
709
+        asserts.assert_true("ALL NODES UP-TO-DATE" in std_out[-1],
710
+                            "Cluster wasn't updated")

+ 58
- 0
murano_plugin_tests/murano_plugin/api.py View File

@@ -18,6 +18,8 @@ from devops.helpers import helpers as devops_helpers
18 18
 from fuelweb_test import logger
19 19
 from fuelweb_test.tests import base_test_case
20 20
 
21
+from murano_plugin_tests import settings
22
+
21 23
 from murano_plugin_tests.helpers import checkers
22 24
 from murano_plugin_tests.helpers import helpers
23 25
 from murano_plugin_tests.helpers import remote_ops
@@ -152,3 +154,59 @@ class MuranoPluginApi(object):
152 154
             nailgun_nodes[:1])
153 155
         operations[operation](target_node)
154 156
         self.wait_plugin_online()
157
+
158
+    def apply_maintenance_update_90_to_91(self):
159
+        """Method applies maintenance updates on whole cluster
160
+        from MOS9.0 to MOS9.1
161
+
162
+        1) Add latest proposed repository
163
+        2) Import PGP key for installed repository
164
+        3) Install `python-cudet`
165
+        4) Add repository and deploy changes
166
+        5) Update with keys all nodes
167
+        6) Update-prepare prepare master
168
+        7) Update-prepare update master
169
+        8) Update-prepare prepare env
170
+        9) Update
171
+        10) Verify that you have the latest packages included in
172
+        Mirantis OpenStack 9.1 -  Potential updates: ALL NODES UP-TO-DATE
173
+
174
+        """
175
+        logger.info("Add latest proposed repository")
176
+
177
+        timestamp = settings.MOS_CENTOS_PROPOSED_MIRROR_ID
178
+        self.helpers.add_centos_test_proposed_repo(
179
+            settings.CENTOS_REPO_URL, timestamp)
180
+
181
+        logger.info("Add extra Ubuntu repo to deployed cluster")
182
+
183
+        timestamp_ubuntu = settings.MOS_UBUNTU_MIRROR_ID
184
+
185
+        proposed = {
186
+            'name': 'proposed',
187
+            'section': 'main restricted',
188
+            'uri': settings.UBUNTU_REPO_URL + timestamp_ubuntu + '/',
189
+            'priority': 1200,
190
+            'suite': 'mos9.0-proposed',
191
+            'type': 'deb'}
192
+
193
+        self.helpers.add_cluster_repo(proposed)
194
+
195
+        logger.info("Install python-cudet library")
196
+
197
+        self.helpers.install_python_cudet()
198
+
199
+        logger.info("Update-prepare prepare master and "
200
+                    "Update-prepare update master")
201
+
202
+        self.helpers.prepare_update_master_node()
203
+
204
+        logger.info("Update-prepare prepare env")
205
+
206
+        self.helpers.prepare_for_update()
207
+
208
+        logger.info("Install MU")
209
+
210
+        self.helpers.install_mu()
211
+
212
+        self.helpers.check_update()

+ 73
- 0
murano_plugin_tests/murano_plugin/test_murano_maintenance_update.py View File

@@ -0,0 +1,73 @@
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
+from fuelweb_test.helpers.decorators import log_snapshot_after_test
16
+from proboscis import test
17
+
18
+from murano_plugin_tests.murano_plugin import api
19
+
20
+
21
+@test(groups=["plugins"])
22
+class TestMuranoPluginMU(api.MuranoPluginApi):
23
+    """Class for Maintenance Update testing the Murano plugin."""
24
+
25
+    @test(depends_on_groups=["deploy_murano_plugin"],
26
+          groups=["test_mu_upgrade_murano_node", "murano",
27
+                  "test_mu_upgrade", "murano_plugin_upgrade"])
28
+    @log_snapshot_after_test
29
+    def test_mu_upgrade_murano_node(self):
30
+        """Apply MU over cluster with plugin and Murano node
31
+
32
+        Scenario:
33
+
34
+        1. Deploy MOS 9.0 with Murano plugin and murano-node in non-ha
35
+        2. Run OSTF
36
+        3. Apply MU for 9.1
37
+        4. Run OSTF
38
+
39
+        Duration 70m
40
+        Snapshot test_mu_upgrade_murano_node
41
+
42
+        """
43
+
44
+        self.env.revert_snapshot("deploy_murano_plugin")
45
+        self.wait_plugin_online()
46
+        self.apply_maintenance_update_90_to_91()
47
+        self.run_ostf(['sanity', 'smoke'])
48
+        self.check_plugin_online()
49
+
50
+    @test(depends_on_groups=["deploy_murano_plugin_on_controller"],
51
+          groups=["test_mu_upgrade_murano_plugin", "murano",
52
+                  "test_mu_upgrade", "murano_plugin_upgrade"])
53
+    @log_snapshot_after_test
54
+    def test_mu_upgrade_without_murano_node(self):
55
+        """Apply MU over cluster with plugin without Murano node
56
+
57
+        Scenario:
58
+
59
+        1. Deploy MOS 9.0 with Murano plugin in non-ha
60
+        2. Run OSTF
61
+        3. Apply MU for 9.1
62
+        4. Run OSTF
63
+
64
+        Duration 100m
65
+        Snapshot test_mu_upgrade_without_murano_node
66
+
67
+        """
68
+
69
+        self.env.revert_snapshot("deploy_murano_plugin_on_controller")
70
+        self.wait_plugin_online()
71
+        self.apply_maintenance_update_90_to_91()
72
+        self.run_ostf(['sanity', 'smoke'])
73
+        self.check_plugin_online()

+ 1
- 0
murano_plugin_tests/run_system_test.py View File

@@ -40,6 +40,7 @@ class CloseSSHConnectionsPlugin(plugins.Plugin):
40 40
 
41 41
 def import_tests():
42 42
     from murano_plugin import test_failover  # noqa
43
+    from murano_plugin import test_murano_maintenance_update  # noqa
43 44
     from murano_plugin import test_murano_plugin_bvt  # noqa
44 45
     from murano_plugin import test_murano_plugin_update  # noqa
45 46
     from murano_plugin import test_post_install  # noqa

+ 13
- 0
murano_plugin_tests/settings.py View File

@@ -19,3 +19,16 @@ from fuelweb_test.settings import *  # noqa
19 19
 # Murano plugins
20 20
 
21 21
 MURANO_PLUGIN_PATH = os.environ.get('MURANO_PLUGIN_PATH')
22
+
23
+# Centos Repo for upgrade
24
+
25
+CENTOS_REPO_URL = 'http://mirror.fuel-infra.org/mos-repos/centos/' \
26
+                  'mos9.0-centos7/snapshots/'
27
+
28
+UBUNTU_REPO_URL = 'http://mirror.fuel-infra.org/mos-repos/ubuntu/snapshots/'
29
+
30
+# Timestamps for upgrade
31
+
32
+MOS_CENTOS_PROPOSED_MIRROR_ID = os.environ.get('MOS_CENTOS_PROPOSED_MIRROR_ID')
33
+
34
+MOS_UBUNTU_MIRROR_ID = os.environ.get('MOS_UBUNTU_MIRROR_ID')

Loading…
Cancel
Save