Files
distcloud/distributedcloud/dcmanager/tests/unit/orchestrator/states/fakes.py
albailey 462e3a90f0 DC kube upgrade robustness improvements
- Removed the patch steps from kube upgrade orchestration.
They were no longer needed, and would cause a failure if
there were no patches at all in the subcloud.

- The version selected for the subcloud is now the
available version in the kube version list.
This permits 'stepping' up a subcloud by one upgrade,
where it would have previously attempted to jump
multiple versions.

- Audit considers a subcloud out-of-sync if the
kube version is higher, so added a pre-check step
to determine if the upgrade should be skipped.

- Added support for to-version as an extra arg to
the strategy so that the subcloud can be upgraded
to a version greater or equal to the available version
in the subcloud.

- Added the ability for force to permit the kube
upgrade of a subcloud that is in-sync.

- Allow the --force to orchestrate all subclouds
if no explicit subcloud is indicated.

Test Plan:
=========
PASS:-System Controller and Subcloud same version.
     -Audit shows in-sync.
     -Subcloud not added to orchestration steps.

PASS:-System Controller lower version than Subcloud.
     -Audit shows out-of-sync.
     -Subcloud added to orchestration, but not upgraded.
     -Skipped during pre-check.

PASS:-System Controller lower version than Subcloud.
     -Audit shows out-of-sync.
     -Pass in 'to-version' lower than subcloud available
      version.
     -Subcloud added to orchestration, but not upgraded.
     -Skipped during pre-check.

PASS:-System Controller lower version than Subcloud.
     -Audit shows out-of-sync.
     -Pass in partial 'to-version' lower than subcloud
      available version.
     -Subcloud added to orchestration, but not upgraded.
     -Skipped during pre-check.

PASS:-System Controller lower version than Subcloud.
     -Audit shows out-of-sync.
     -Pass in 'to-version' higher than subcloud available
      version.
     -Subcloud added to orchestration, and upgraded to its
      'available' version.

PASS:-System Controller lower version than Subcloud.
     -Audit shows out-of-sync.
     -Pass in 'to-version' equal to subcloud available
      version.
     -Subcloud added to orchestration, and upgraded to its
      'available' version.

PASS:-System Controller lower version than Subcloud.
     -Subcloud at its highest version, no available version.
     -Audit shows out-of-sync.
     -Pass in 'to-version' higher that the version on subcloud
     -Subcloud added to orchestration, but not upgraded.
     -Skipped during pre-check.

PASS:-System Controller higher version than Subcloud.
     -Audit shows out-of-sync.
     -Subcloud added to orchestration, and upgraded to its
      'available' version.

PASS:-Subcloud already has a kube upgrade in progress and
     versions showing as partial. to-version is equal.
     -Audit shows out-of-sync.
     -Subcloud added to orchestration, and its upgrade is
      resumed.

PASS:-Subcloud already has a kube upgrade in progress but
     to-version passed to orchestration is lower version.
     -Audit shows out-of-sync.
     -Subcloud added to orchestration, and is skipped by
     the pre-check.

PASS:-Subcloud in sync with system controller.  Passing
     force and an explicit to-version allows the subcloud
     to be orchestrated beyond the version on the system
     controller.

Change-Id: Ia00a329349afe0c651d66ea04a6b1b388172a8eb
Story: 2008972
Task: 44133
Signed-off-by: albailey <Al.Bailey@windriver.com>
2021-12-22 11:40:38 -06:00

214 lines
5.6 KiB
Python

#
# Copyright (c) 2020-2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import uuid
from dcmanager.common import consts
PREVIOUS_PREVIOUS_VERSION = '01.23'
PREVIOUS_VERSION = '12.34'
UPGRADED_VERSION = '56.78'
PREVIOUS_KUBE_VERSION = 'v1.2.3'
UPGRADED_KUBE_VERSION = 'v1.2.4'
FAKE_VENDOR = '8086'
FAKE_DEVICE = '0b30'
class FakeController(object):
def __init__(self,
host_id=1,
hostname='controller-0',
administrative=consts.ADMIN_UNLOCKED,
operational=consts.OPERATIONAL_ENABLED,
availability=consts.AVAILABILITY_ONLINE,
ihost_action=None,
target_load=UPGRADED_VERSION,
software_load=PREVIOUS_VERSION,
task=None,
capabilities={"Personality": "Controller-Active"}):
self.uuid = str(uuid.uuid4())
self.id = host_id
self.hostname = hostname
self.administrative = administrative
self.operational = operational
self.availability = availability
self.ihost_action = ihost_action
self.target_load = target_load
self.software_load = software_load
self.task = task
self.capabilities = capabilities
class FakeDevice(object):
def __init__(self,
obj_id,
pvendor_id=FAKE_VENDOR,
pdevice_id=FAKE_DEVICE,
enabled=True):
self.uuid = obj_id
self.pvendor_id = pvendor_id
self.pdevice_id = pdevice_id
self.enabled = enabled
class FakeDeviceImage(object):
def __init__(self,
obj_id,
pci_vendor=FAKE_VENDOR,
pci_device=FAKE_DEVICE,
bitstream_type='functional',
applied=False,
applied_labels=None):
self.uuid = obj_id
self.pci_vendor = pci_vendor
self.pci_device = pci_device
self.bitstream_type = bitstream_type
self.applied = applied
self.applied_labels = applied_labels
class FakeDeviceLabel(object):
def __init__(self,
label_key=None,
label_value=None,
pcidevice_uuid=None):
self.uuid = str(uuid.uuid4())
self.label_key = label_key
self.label_value = label_value
self.pcidevice_uuid = pcidevice_uuid
class FakeHostFilesystem(object):
def __init__(self,
name='scratch',
logical_volume='scratch-lv',
size=16):
self.name = name
self.logical_volume = logical_volume
self.size = size
self.uuid = str(uuid.uuid4())
class FakeKeystoneClient(object):
def __init__(self):
self.session = mock.MagicMock()
class FakeKubeRootCaUpdate(object):
def __init__(self,
obj_id=1,
state='update-started'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.state = state
class FakeKubeUpgrade(object):
def __init__(self,
obj_id=1,
from_version=PREVIOUS_KUBE_VERSION,
to_version=UPGRADED_KUBE_VERSION,
state='upgrade-complete'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.from_version = state
self.to_version = to_version
self.state = state
class FakeKubeVersion(object):
def __init__(self,
obj_id=1,
version=UPGRADED_KUBE_VERSION,
target=True,
state='active'):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.version = version
self.target = target
self.state = state
self.upgrade_from = []
self.applied_patches = []
self.available_patches = []
def to_dict(self):
return dict(self.__dict__)
class FakeLoad(object):
def __init__(self,
obj_id,
compatible_version='N/A',
required_patches='N/A',
software_version=PREVIOUS_VERSION,
state='active',
created_at=None,
updated_at=None):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.compatible_version = compatible_version
self.required_patches = required_patches
self.software_version = software_version
self.state = state
self.created_at = created_at
self.updated_at = updated_at
@staticmethod
def from_dict(load_data):
return FakeLoad(**load_data)
def to_dict(self):
return dict(self.__dict__)
class FakeSysinvClient(object):
def __init__(self):
pass
class FakePatchingClient(object):
def __init__(self):
pass
class FakeFmClient(object):
def __init__(self):
pass
class FakeSystem(object):
def __init__(self,
obj_id=1,
software_version=UPGRADED_VERSION):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.software_version = software_version
class FakeUpgrade(object):
def __init__(self,
obj_id=1,
state='completed',
from_release=PREVIOUS_VERSION,
to_release=UPGRADED_VERSION):
self.id = obj_id
self.uuid = str(uuid.uuid4())
self.state = state
self.from_release = from_release
self.to_release = to_release
self.links = []
class FakeAlarm(object):
def __init__(self,
alarm_id='12.34',
mgmt_affecting='False'):
self.alarm_id = alarm_id
self.mgmt_affecting = mgmt_affecting