f1b5aad38a
In this commit, a new subcloud_status called software was created, it's used when the usm switch is enabled to audit patches and loads using the usm API. When the usm switch is disabled, the subcloud_status patch and load are audited instead, using patch/sysinv API. The validations to create an upgrade orchestration strategy were changed when the usm switch is enabled, the subcloud_status software is checked instead of the load status. Test Plan: PASS: Turn the usm switch on and add a subcloud and verify that the subcloud has the subcloud_status software. PASS: Turn the usm switch off and verify that the patch/load status are audited. PASS: Turn the usm switch on and verify that the software status is audited. PASS: Turn the usm switch on, upload a patch to the subcloud and verify that the software status goes to out-of-sync. PASS: Turn the usm switch on, apply a patch to the system controller and verify that the software status goes to out-of-sync. PASS: Turn the usm switch on, with the software status out-of-sync, create an upgrade-strategy and verify that is created successfully. PASS: Turn the usm switch on, restart audit and verify that the usm endpoint was added to a existing subcloud. Story: 2010676 Task: 48784 Signed-off-by: Christopher Souza <Christopher.DeOliveiraSouza@windriver.com> Change-Id: If2d14c15a6ff4e38b004b24700d3443a2e86d2c2
82 lines
3.1 KiB
Python
82 lines
3.1 KiB
Python
# Copyright (c) 2023 Wind River Systems, Inc.
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
|
|
import mock
|
|
|
|
import oslo_messaging
|
|
|
|
from dcmanager.audit import rpcapi as rpc_client
|
|
from dcmanager.common import config
|
|
from dcmanager.common import consts
|
|
from dcmanager.common import messaging
|
|
from dcmanager.tests import base
|
|
from dcmanager.tests import utils
|
|
|
|
config.register_options()
|
|
|
|
|
|
class ManagerRpcAuditAPITestCase(base.DCManagerTestCase):
|
|
|
|
def setUp(self):
|
|
messaging.setup("fake://", optional=True)
|
|
self.addCleanup(messaging.cleanup)
|
|
self.context = utils.dummy_context()
|
|
super(ManagerRpcAuditAPITestCase, self).setUp()
|
|
|
|
def test_cast(self):
|
|
rpcapi = rpc_client.ManagerAuditWorkerClient()
|
|
transport = messaging.get_transport()
|
|
transport._send = mock.Mock()
|
|
|
|
fake_endpoints = {'service': 'fake_ip', 'service2': 'other_fake_ip'}
|
|
|
|
rpcapi.update_subcloud_endpoints(
|
|
self.context, 'subcloud', fake_endpoints)
|
|
|
|
exp_msg = {'method': 'update_subcloud_endpoints',
|
|
'args': {'subcloud_name': 'subcloud',
|
|
'endpoints': fake_endpoints},
|
|
'version': '1.0'}
|
|
|
|
# With fanout a new target is created
|
|
new_target = oslo_messaging.Target(
|
|
fanout=True, version=rpcapi.BASE_RPC_API_VERSION,
|
|
topic=consts.TOPIC_DC_MANAGER_AUDIT_WORKER)
|
|
transport._send.assert_called_with(new_target,
|
|
mock.ANY,
|
|
exp_msg,
|
|
retry=None,
|
|
transport_options=None)
|
|
|
|
# Without fanout the target is the same
|
|
rpcapi.audit_subclouds(
|
|
self.context, ['subcloud1', 'subcloud2'],
|
|
True, False, True, True, False, False)
|
|
|
|
exp_msg2 = {'method': 'audit_subclouds',
|
|
'args': {'subcloud_ids': ['subcloud1', 'subcloud2'],
|
|
'patch_audit_data': True,
|
|
'firmware_audit_data': False,
|
|
'kubernetes_audit_data': True,
|
|
'do_openstack_audit': True,
|
|
'kube_rootca_update_audit_data': False,
|
|
'software_audit_data': False},
|
|
'version': '1.0'}
|
|
|
|
transport._send.assert_called_with(rpcapi._client.target,
|
|
mock.ANY,
|
|
exp_msg2,
|
|
retry=None,
|
|
transport_options=None)
|