
This commit changes the playbook execution function from run_playbook to AnsiblePlaybook, introduced in the 'dcmanager subcloud deploy abort' commit [1]. To avoid the unwanted abort and resume execution, the flag 'initial_deployment' is set in the subcloud inventory, and these operations are only allowed to run if the flag is set to True. This commit also fixes the following bugs: - During a deploy resume that included bootstrap phase, the subcloud inventory creation would fail if the user submited a new bootstrap_values file without providing the bootstrap_address. The bootstrap_address is now loaded into the payload from overrides file if not provided in the request. - During deploy bootstrap, if the user provided a new bootstrap_values file without keys that were present in stored overrides file (E.g. docker_registries), the old keys would still persist. Now, only software_version and bootstrap-address (if not provided in request) are loaded into the payload in this case. Aditionally, this commit also better integrates the deploy complete phase in the current subcloud add/redeploy/resume flows. If deploy config is not going to be executed, deploy complete is executed in its place, instead of separately updating the db like before. Test plan: Success cases: - PASS: Run all deploy phases (create, install, bootstrap and config) and verify that they completed successfully. - PASS: Run 'dcmanager subcloud add' and verify that it was completed successfully. - PASS: Run 'dcmanager subcloud add' with the migrate option and verify that it was completed successfully. - PASS: Prestage a subcloud and verify that it was completed successfully. - PASS: Upgrade a subcloud from 21.12 to 22.12 and verify that it was completed successfully. - PASS: Backup, restore and delete a subcloud backup file and verify all three operations were completed successfully. - PASS: Run 'dcmanager subcloud update' with network reconfiguration and verify that the playbook was executed correctly. - PASS: Run 'dcmanager subcloud deploy bootstrap' passing a bootstrap_values.yml with less keys than the one provided in deploy create and verify that only values from the new file are present on the overrides file. - PASS: Resume the deployment from bootstrap providing a new bootstrap_values.yml without passing the bootstrap_address on the CLI and verify the deployment could be resumed correctly. Failure cases: - PASS: Verify it's only possible to abort or resume the subcloud installation during initial deployment, meaning installation from restore --with-install or upgrade are not abortable and not resumable. [1] https://review.opendev.org/c/starlingx/distcloud/+/884710 Story: 2010756 Task: 48608 Change-Id: I549b8391f4f7eb08150fdce45b524790c1e8a0e0 Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
#
|
|
# Copyright (c) 2022-2023 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from dccommon.exceptions import PlaybookExecutionTimeout
|
|
from dccommon.tests import base
|
|
from dccommon import utils
|
|
|
|
FAKE_SUBCLOUD_NAME = 'subcloud1'
|
|
FAKE_LOG_FILE = '/dev/null'
|
|
|
|
|
|
class TestUtils(base.DCCommonTestCase):
|
|
|
|
def setUp(self):
|
|
super(TestUtils, self).setUp()
|
|
|
|
def tearDown(self):
|
|
super(TestUtils, self).tearDown()
|
|
|
|
def test_exec_playbook(self):
|
|
# no timeout:
|
|
testscript = ['dccommon/tests/unit/test_utils_script.sh', '1']
|
|
ansible = utils.AnsiblePlaybook(FAKE_SUBCLOUD_NAME)
|
|
ansible.run_playbook(FAKE_LOG_FILE, testscript)
|
|
|
|
def test_exec_playbook_timeout(self):
|
|
testscript = ['dccommon/tests/unit/test_utils_script.sh', '30']
|
|
ansible = utils.AnsiblePlaybook(FAKE_SUBCLOUD_NAME)
|
|
self.assertRaises(PlaybookExecutionTimeout,
|
|
ansible.run_playbook,
|
|
FAKE_LOG_FILE,
|
|
testscript,
|
|
timeout=2)
|
|
|
|
def test_exec_playbook_timeout_requires_kill(self):
|
|
# This option ignores a regular TERM signal, and requires a
|
|
# kill -9 (KILL signal) to terminate. We're using this to simulate
|
|
# a hung process
|
|
script = ['dccommon/tests/unit/test_utils_script.sh', '30', 'TERM']
|
|
ansible = utils.AnsiblePlaybook(FAKE_SUBCLOUD_NAME)
|
|
self.assertRaises(PlaybookExecutionTimeout,
|
|
ansible.run_playbook,
|
|
FAKE_LOG_FILE,
|
|
script,
|
|
timeout=2)
|