ocs_ci.helpers package
Submodules
ocs_ci.helpers.bdi_helpers module
Helper functions specific for bdi
- ocs_ci.helpers.bdi_helpers.clean_temp_files(class_instance)
Deletes temporary files created during the execution
- ocs_ci.helpers.bdi_helpers.init_configure_workload_yaml(namespace=None, image=None, sf=1, pvc_name=None)
Loads the “configure-workload.yaml” and sets all the relevant parameters according to the type of execution
- Parameters:
namespace (str) – The name of the namespace
image (str) – The name of the image to pull
sf (int) – scale factor. Can be 1, 10, 100…
pvc_name (str) – The name of the pvc to be used
- Returns:
The dictionary representing the yaml with all the relevant changes
- Return type:
dict
- ocs_ci.helpers.bdi_helpers.init_data_load_yaml(namespace=None, image=None, pvc_name=None, secret_name=None)
Loads the “data-load-job” and sets all the relevant parameters according to the type of execution
- Parameters:
namespace (str) – The name of the namespace
image (str) – The name of the image to pull
pvc_name (str) – The name of the pvc to be used
secret_name (str) – The secret name to be used
- Returns:
The dictionary representing the yaml with all the relevant changes
- Return type:
dict
- ocs_ci.helpers.bdi_helpers.init_run_workload_yaml(namespace=None, image=None, pvc_name=None, secret_name=None)
Loads the “run-workload-job” and sets all the relevant parameters according to the type of execution
- Parameters:
namespace (str) – The name of the namespace
image (str) – The name of the image to pull
pvc_name (str) – The name of the pvc to be used
secret_name (str) – The secret name to be used
- Returns:
The dictionary representing the yaml with all the relevant changes
- Return type:
dict
- ocs_ci.helpers.bdi_helpers.install_db2u(class_instance)
Chart installation
ocs_ci.helpers.cluster_exp_helpers module
- class ocs_ci.helpers.cluster_exp_helpers.BackgroundOps
Bases:
object
- EXPANSION_COMPLETED = False
- wrap(func, *args, **kwargs)
Wraps the function to run specific iterations
- Returns:
True if function runs successfully
- Return type:
bool
- class ocs_ci.helpers.cluster_exp_helpers.ClusterFiller(pods_to_fill, percent_required_filled, namespace)
Bases:
object
Class for performing IOs on the pods
- cluster_filler()
- concurrent_copies = 5
- filler(fill_pod)
This function copies the file downloaded by ‘downloader’ function in a unique directory to increase the cluster space utilization. Currently it makes 30 copies of the downloaded file in a given directory which is equivalent to almost 4 GiB of storage.
- Parameters:
fill_pod – the pod on which the storage space need to be filled.
- ocs_ci.helpers.cluster_exp_helpers.check_nodes_status()
This function runs in a loop to check the status of nodes. If the node(s) are in NotReady state then an exception is raised. Note: this function needs to be run as a background thread during the execution of a test
- ocs_ci.helpers.cluster_exp_helpers.cluster_copy_ops(copy_pod)
Function to do copy operations in a given pod. Mainly used as a background IO during cluster expansion. It does of series of copy operations and verifies the data integrity of the files copied.
- Parameters:
copy_pod (pod) – on which copy operations need to be done
- Returns:
False, if there is data integrity check failure. Else, True
- Return type:
Boolean
- ocs_ci.helpers.cluster_exp_helpers.raw_block_io(raw_blk_pod, size='10G')
Runs the block ios on pod baased raw block pvc :param raw_blk_pod: pod on which block IOs should run :type raw_blk_pod: pod :param size: IO size :type size: str
ocs_ci.helpers.cnv_helpers module
Helper functions specific for CNV
- ocs_ci.helpers.cnv_helpers.cal_md5sum_vm(vm_obj, file_path, username=None)
Calculate the MD5 checksum of a file via SSH on a virtual machine.
- Parameters:
vm_obj (obj) – The virtual machine object.
file_path (str) – Full path to the file to calculate the MD5 checksum for.
username (str, optional) – The username to use for SSH authentication. Defaults to None.
- Returns:
The MD5 checksum of the specified file.
- Return type:
str
- ocs_ci.helpers.cnv_helpers.convert_ssh_key_to_base64(ssh_key)
Convert SSH key to base64 encoding
- Parameters:
ssh_key (str) – SSH key
- Returns:
Base64 encoded SSH key
- Return type:
str
- ocs_ci.helpers.cnv_helpers.create_pvc_using_data_source(source_name, pvc_size=None, sc_name=None, namespace='openshift-cnv')
Create a PVC using a specified data source
- Parameters:
source_name (str) – Name of the data source (VolumeImportSource) for the PVC
pvc_size (str) – Size of the PVC
sc_name (str) – StorageClass name for the PVC
namespace (str) – The namespace in which to create the PVC
- Returns:
PVC object
- Return type:
pvc_data_obj
- ocs_ci.helpers.cnv_helpers.create_vm_secret(path=None, secret_name=None, namespace='openshift-cnv')
Create an SSH secret for the VM
- Parameters:
path (str) – Path to the SSH public key file - optional
secret_name (str, optional) – Name of the secret. If not provided, a unique name will be generated.
namespace (str, optional) – Namespace in which the secret will be created. Defaults to constants.CNV_NAMESPACE.
- Returns:
An OCS instance
- Return type:
secret_obj
- ocs_ci.helpers.cnv_helpers.create_vm_using_standalone_pvc(namespace='openshift-cnv', vm_name=None, pvc_size=None, sc_name=None, ssh=True, running=True, wait_for_vm_boot=True, vm_dict_path=None)
Create a Virtual Machine (VM) in the specified namespace using a standalone Persistent Volume Claim (PVC)
- Parameters:
namespace (str) – The namespace in which to create the VM.
vm_name (str) – Name for the VM. If not provided, a unique name will be generated.
pvc_size (str) – The size of the PVC to create
sc_name (str) – Storageclass name to use
ssh (bool) – If set to True, it adds a statically manged public SSH key during the VM creation at the first boot
running (bool) – Set to True for the VM to start upon it’s creation, False otherwise
wait_for_vm_boot (bool) – If True and running is True, wait for the VM to finish booting and
connectivity (ensure SSH) –
vm_dict_path (str) – Path to the VM YAML file
- Returns:
The VirtualMachine object
- Return type:
vm_obj
- Raises:
CommandFailed – If an error occurs during the creation of the VM
- ocs_ci.helpers.cnv_helpers.create_volume_import_source(name=None, url=None)
Create a VolumeImportSource object
- Parameters:
name (str) – Name for the VolumeImportSource. If not provided, a unique name will be generated
url (str) – URL for the registry source
- Returns:
The created VolumeImportSource object
- Return type:
source_data_obj
- ocs_ci.helpers.cnv_helpers.get_pvc_from_vm(vm_obj)
Get the PVC name from VM obj
- Returns:
PVC in the form of ocs object
- Return type:
- ocs_ci.helpers.cnv_helpers.get_secret_from_vm(vm_obj)
Get the secret name from VM obj
- Returns:
Secret in the form of ocs object
- Return type:
- ocs_ci.helpers.cnv_helpers.get_ssh_private_key_path()
Get the full path of the derived private key file from the associated SSH public key file
- Returns:
The full path of the derived private key file
- Return type:
str
- ocs_ci.helpers.cnv_helpers.get_ssh_pub_key_with_filename(path=None)
Retrieve the content of the SSH public key and its file name
- Parameters:
path (str) – Path to the SSH public key file - Optional
- Returns:
A tuple containing the content of the SSH public key and the file name
- Return type:
tuple
Raises: FileNotFoundError: If the provided ssh pub key path does not exist
- ocs_ci.helpers.cnv_helpers.get_volumeimportsource(pvc_obj)
Get the volumeimportsource name from PVC obj
- Returns:
volumeimportsource in the form of ocs object
- Return type:
- ocs_ci.helpers.cnv_helpers.run_dd_io(vm_obj, file_path, size='10240', username=None, verify=False)
Perform input/output (I/O) operation using dd command via SSH on a virtual machine.
- Parameters:
vm_obj (obj) – The virtual machine object.
file_path (str) – The full path of the file to write on
size (str, optional) – Size in MB. Defaults to “102400” which is 10GB.
username (str, optional) – The username to use for SSH authentication. Defaults to None.
verify (bool, optional) – Whether to verify the I/O operation by calculating MD5 checksum. Defaults to False.
- Returns:
If verify is True, returns the MD5 checksum of the written file. Otherwise, None.
- Return type:
str or None
ocs_ci.helpers.disconnected module
- ocs_ci.helpers.disconnected.get_oc_mirror_tool()
Download and install oc mirror tool.
- ocs_ci.helpers.disconnected.get_opm_tool()
Download and install opm tool.
ocs_ci.helpers.disruption_helpers module
- class ocs_ci.helpers.disruption_helpers.Disruptions
Bases:
object
This class contains methods of disrupt operations
- check_new_pid(node_name=None)
Check if the pid of the daemon has changed from the initially selected pid(daemon_pid attribute)
- Parameters:
node_name (str) – Name of node in which the resource daemon is running
- cluster_kubeconfig = ''
- daemon_pid = None
- delete_resource(resource_id=0)
- kill_daemon(node_name=None, check_new_pid=True, kill_signal='9')
Kill self.resource daemon
- Parameters:
node_name (str) – Name of node in which the resource daemon has to be killed
check_new_pid (bool) – True to check for new pid after killing the daemon. False to skip the check.
kill_signal (str) – kill signal type
- kubeconfig_parameter()
Returns the ‘–kubeconfig <value>’ parameter for the oc command
- Returns:
- The ‘–kubeconfig <value>’ parameter for oc command if the attribute ‘cluster_kubeconfig’ is not empty.
Empty string if the the attribute ‘cluster_kubeconfig’ is empty.
- Return type:
str
- resource = None
- resource_count = 0
- resource_obj = None
- select_daemon(node_name=None)
Select pid of self.resource daemon
- Parameters:
node_name (str) – Name of node in which the resource daemon has to be selected.
- selector = None
- set_resource(resource, leader_type='provisioner', cluster_index=None)
ocs_ci.helpers.dr_helpers module
Helper functions specific for DR
- ocs_ci.helpers.dr_helpers.check_mirroring_status_ok(replaying_images=None)
Check if mirroring status has health OK and expected number of replaying images
- Parameters:
replaying_images (int) – Expected number of images in replaying state
- Returns:
True if status contains expected health and states values, False otherwise
- Return type:
bool
- ocs_ci.helpers.dr_helpers.check_vr_state(state, namespace)
Check if all VRs in the given namespace are in expected state
- Parameters:
state (str) – The VRs state to check for (e.g. ‘primary’, ‘secondary’)
namespace (str) – the namespace of the VR resources
- Returns:
True if all VRs are in expected state or were deleted, False otherwise
- Return type:
bool
- ocs_ci.helpers.dr_helpers.check_vrg_existence(namespace)
Check if VRG resource exists in the given namespace
- Parameters:
namespace (str) – the namespace of the VRG resource
- ocs_ci.helpers.dr_helpers.check_vrg_state(state, namespace)
Check if VRG in the given namespace is in expected state
- Parameters:
state (str) – The VRG state to check for (e.g. ‘primary’, ‘secondary’)
namespace (str) – the namespace of the VRG resources
- Returns:
True if VRG is in expected state or was deleted, False otherwise
- Return type:
bool
- ocs_ci.helpers.dr_helpers.configure_drcluster_for_fencing()
Configures DRClusters for enabling fencing
- ocs_ci.helpers.dr_helpers.create_backup_schedule()
Create backupschedule resource only on active hub
- ocs_ci.helpers.dr_helpers.enable_fence(drcluster_name, switch_ctx=None)
Once the managed cluster is fenced, all communication from applications to the ODF external storage cluster will fail
- Parameters:
drcluster_name (str) – Name of the DRcluster which needs to be fenced
switch_ctx (int) – The cluster index by the cluster name
- ocs_ci.helpers.dr_helpers.enable_unfence(drcluster_name, switch_ctx=None)
The OpenShift cluster to be Unfenced is the one where applications are not currently running and the cluster that was Fenced earlier.
- Parameters:
drcluster_name (str) – Name of the DRcluster which needs to be fenced
switch_ctx (int) – The cluster index by the cluster name
- ocs_ci.helpers.dr_helpers.failover(failover_cluster, namespace, workload_type='Subscription', workload_placement_name=None, switch_ctx=None)
Initiates Failover action to the specified cluster
- Parameters:
failover_cluster (str) – Cluster name to which the workload should be failed over
namespace (str) – Namespace where workload is running
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
workload_placement_name (str) – Placement name
switch_ctx (int) – The cluster index by the cluster name
- ocs_ci.helpers.dr_helpers.fence_state(drcluster_name, fence_state, switch_ctx=None)
Sets the specified clusterFence state
- Parameters:
drcluster_name (str) – Name of the DRcluster which needs to be fenced
fence_state (str) – Specify the clusterfence state either constants.ACTION_UNFENCE and ACTION_FENCE
switch_ctx (int) – The cluster index by the cluster name
- ocs_ci.helpers.dr_helpers.get_all_drpolicy()
Gets all DRPolicy from hub cluster
- Returns:
List of all DRPolicy
- Return type:
list
- ocs_ci.helpers.dr_helpers.get_current_primary_cluster_name(namespace, workload_type='Subscription')
Get current primary cluster name based on workload namespace
- Parameters:
namespace (str) – Name of the namespace
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
- Returns:
Current primary cluster name
- Return type:
str
- ocs_ci.helpers.dr_helpers.get_current_secondary_cluster_name(namespace, workload_type='Subscription')
Get current secondary cluster name based on workload namespace
- Parameters:
namespace (str) – Name of the namespace
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
- Returns:
Current secondary cluster name
- Return type:
str
- ocs_ci.helpers.dr_helpers.get_fence_state(drcluster_name, switch_ctx=None)
Returns the clusterfence state of given drcluster
- Parameters:
drcluster_name (str) – Name of the DRcluster
switch_ctx (int) – The cluster index by the cluster name
- Returns:
If drcluster are fenced: Fenced or Unfenced, else None if not defined
- Return type:
state (str)
- ocs_ci.helpers.dr_helpers.get_image_uuids(namespace)
Gets all image UUIDs associated with the PVCs in the given namespace
- Parameters:
namespace (str) – the namespace of the VR resources
- Returns:
List of all image UUIDs
- Return type:
list
- ocs_ci.helpers.dr_helpers.get_managed_cluster_node_ips()
Gets node ips of individual managed clusters for enabling fencing on MDR DRCluster configuration
- Returns:
Returns list of managed cluster, indexes and their node IPs
- Return type:
cluster (list)
- ocs_ci.helpers.dr_helpers.get_pv_count(namespace)
Gets PV resource count in the given namespace
- Parameters:
namespace (str) – the namespace of the workload
- Returns:
PV resource count
- Return type:
int
- ocs_ci.helpers.dr_helpers.get_replicationdestinations_count(namespace)
Gets ReplicationDestination resource count in given namespace
- Parameters:
namespace (str) – the namespace of the ReplicationDestination resources
- Returns:
ReplicationDestination resource count
- Return type:
int
- ocs_ci.helpers.dr_helpers.get_replicationsources_count(namespace)
Gets ReplicationSource resource count in given namespace
- Parameters:
namespace (str) – the namespace of the ReplicationSource resources
- Returns:
ReplicationSource resource count
- Return type:
int
- ocs_ci.helpers.dr_helpers.get_scheduling_interval(namespace, workload_type='Subscription')
Get scheduling interval for the workload in the given namespace
- Parameters:
namespace (str) – Name of the namespace
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
- Returns:
scheduling interval value from DRPolicy
- Return type:
int
- ocs_ci.helpers.dr_helpers.get_vr_count(namespace)
Gets VR resource count in given namespace
- Parameters:
namespace (str) – the namespace of the VR resources
- Returns:
VR resource count
- Return type:
int
- ocs_ci.helpers.dr_helpers.gracefully_reboot_ocp_nodes(drcluster_name, disable_eviction=False)
Gracefully reboot OpenShift Container Platform nodes which was fenced before
- Parameters:
drcluster_name (str) – Name of the drcluster which needs to be rebooted
disable_eviction (bool) – On True will delete pod that is protected by PDB, False by default
- ocs_ci.helpers.dr_helpers.relocate(preferred_cluster, namespace, workload_type='Subscription', workload_placement_name=None, switch_ctx=None)
Initiates Relocate action to the specified cluster
- Parameters:
preferred_cluster (str) – Cluster name to which the workload should be relocated
namespace (str) – Namespace where workload is running
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
workload_placement_name (str) – Placement name
switch_ctx (int) – The cluster index by the cluster name
- ocs_ci.helpers.dr_helpers.restore_backup()
Restores the backup in new hub and make it as active
- ocs_ci.helpers.dr_helpers.set_current_primary_cluster_context(namespace, workload_type='Subscription')
Set current primary cluster context based on workload namespace
- Parameters:
namespace (str) – Name of the namespace
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
- ocs_ci.helpers.dr_helpers.set_current_secondary_cluster_context(namespace, workload_type='Subscription')
Set secondary cluster context based on workload namespace
- Parameters:
namespace (str) – Name of the namespace
workload_type (str) – Type of workload, i.e., Subscription or ApplicationSet
- ocs_ci.helpers.dr_helpers.verify_drpolicy_cli(switch_ctx=None)
Function to verify DRPolicy status
- Returns:
True if the status is in succeed state, else raise exception switch_ctx (int): The cluster index by the cluster name
- Return type:
bool
- ocs_ci.helpers.dr_helpers.verify_fence_state(drcluster_name, state, switch_ctx=None)
Verify the specified drcluster is in expected state
- Parameters:
drcluster_name (str) – Name of the DRcluster
state (str) – The fence state it is either constants.ACTION_FENCE or constants.ACTION_UNFENCE
switch_ctx (int) – The cluster index by the cluster name
- Raises:
Raises exception Unexpected-behaviour if the specified drcluster is not in the given state condition –
- ocs_ci.helpers.dr_helpers.verify_restore_is_completed()
Function to verify restore is completed or finished
- ocs_ci.helpers.dr_helpers.wait_for_all_resources_creation(pvc_count, pod_count, namespace, timeout=900, skip_replication_resources=False)
Wait for workload and replication resources to be created
- Parameters:
pvc_count (int) – Expected number of PVCs
pod_count (int) – Expected number of Pods
namespace (str) – the namespace of the workload
timeout (int) – time in seconds to wait for resource creation
skip_replication_resources (bool) – if true vr status wont’t be check
- ocs_ci.helpers.dr_helpers.wait_for_all_resources_deletion(namespace, check_replication_resources_state=True, timeout=1000)
Wait for workload and replication resources to be deleted
- Parameters:
namespace (str) – the namespace of the workload
check_replication_resources_state (bool) – True for checking replication resources state, False otherwise
timeout (int) – time in seconds to wait for resource deletion
- ocs_ci.helpers.dr_helpers.wait_for_cnv_workload(vm_name, namespace, phase='Running', timeout=600)
Wait for VM to reach a phase
- Parameters:
vm_name (str) – Name of the VM
namespace (str) – Namespace of the vm workload
phase (str) – Phase of the vm resource to wait for. example: Running, Stopped
timeout (int) – time in seconds to wait for resource deletion
- ocs_ci.helpers.dr_helpers.wait_for_mirroring_status_ok(replaying_images=None, timeout=300)
Wait for mirroring status to reach health OK and expected number of replaying images for each of the ODF cluster
- Parameters:
replaying_images (int) – Expected number of images in replaying state
timeout (int) – time in seconds to wait for mirroring status reach OK
- Returns:
True if status contains expected health and states values
- Return type:
bool
- Raises:
TimeoutExpiredError – In case of unexpected mirroring status
- ocs_ci.helpers.dr_helpers.wait_for_replication_destinations_creation(rep_dest_count, namespace, timeout=900)
Wait for ReplicationDestination resources to be created
- Parameters:
rep_dest_count (int) – Expected number of ReplicationDestination resource
namespace (str) – The namespace of the ReplicationDestination resources
timeout (int) – Time in seconds to wait for ReplicationDestination resources to be created
- Raises:
TimeoutExpiredError – If expected number of ReplicationDestination resources not created
- ocs_ci.helpers.dr_helpers.wait_for_replication_destinations_deletion(namespace, timeout=900)
Wait for ReplicationDestination resources to be deleted
- Parameters:
namespace (str) – The namespace of the ReplicationDestination resources
timeout (int) – Time in seconds to wait for ReplicationDestination resources to be deleted
- Raises:
TimeoutExpiredError – If expected number of ReplicationDestination resources not deleted
- ocs_ci.helpers.dr_helpers.wait_for_replication_resources_creation(vr_count, namespace, timeout)
Wait for replication resources to be created
- Parameters:
vr_count (int) – Expected number of VR resources or ReplicationSource count
namespace (str) – the namespace of the VR or ReplicationSource resources
timeout (int) – time in seconds to wait for VR or ReplicationSource resources to be created or reach expected state
- Raises:
TimeoutExpiredError – In case replication resources not created
- ocs_ci.helpers.dr_helpers.wait_for_replication_resources_deletion(namespace, timeout, check_state=True)
Wait for replication resources to be deleted
- Parameters:
namespace (str) – the namespace of the resources’
timeout (int) – time in seconds to wait for resources to reach expected state or deleted
check_state (bool) – True for checking resources state before deletion, False otherwise
- Raises:
TimeoutExpiredError – In case replication resources not deleted
ocs_ci.helpers.dr_helpers_ui module
Helper functions specific to DR User Interface
- ocs_ci.helpers.dr_helpers_ui.check_cluster_status_on_acm_console(acm_obj, down_cluster_name=None, cluster_names=None, timeout=900, expected_text='Ready')
This function checks the current status of imported clusters on the ACM console. These clusters are the managed OCP clusters and the ACM Hub cluster.
- Parameters:
acm_obj (AcmAddClusters) – ACM Page Navigator Class
down_cluster_name (str) – If Failover is performed when a cluster goes down, it waits and checks the updated status of cluster unavailability on the ACM console. It takes the cluster name which is down.
cluster_names (list) – This is a list of cluster names involved in a DR setup. You can either pass the cluster names as args in the form of list, but if not passed, it fetches the primary & secondary cluster names passed at run time for context setting (max. 3 for now including ACM Hub cluster). ACM Hub cluster name is hard coded as “local-cluster” as the name is constant & isn’t expected to change.
timeout (int) – Timeout to wait for certain elements to be found on the ACM UI
expected_text (str) – Any particular string/status of the cluster to be checked on the ACM console. Default is set to ready
- ocs_ci.helpers.dr_helpers_ui.dr_submariner_validation_from_ui(acm_obj)
This function is only applicable for Regional DR.
This function calls other function and does pre-checks on ACM UI such as Submariner validation from ACM console for Regional DR.
- Parameters:
acm_obj (AcmAddClusters) – ACM Page Navigator Class
- ocs_ci.helpers.dr_helpers_ui.failover_relocate_ui(acm_obj, scheduling_interval=0, workload_to_move=None, policy_name=None, failover_or_preferred_cluster=None, action='Failover', timeout=120, move_workloads_to_same_cluster=False)
Function to perform Failover/Relocate operations via ACM UI
- Parameters:
acm_obj (AcmAddClusters) – ACM Page Navigator Class
scheduling_interval (int) – scheduling interval value from DRPolicy
workload_to_move (str) – Name of running workloads on which action to be taken
policy_name (str) – Name of the DR policy applied to the running workload
failover_or_preferred_cluster (str) – Name of the failover cluster or preferred cluster to which workloads will be moved
action (str) – action could be “Failover” or “Relocate”, “Failover” is set to default
timeout (int) – timeout to wait for certain elements to be found on the ACM UI
move_workloads_to_same_cluster (bool) – Bool condition to test negative failover/relocate scenarios to move running workloads to same cluster
- Returns:
True if the action is triggered, raises Exception if any of the mandatory argument is not provided
- Return type:
bool
- ocs_ci.helpers.dr_helpers_ui.verify_drpolicy_ui(acm_obj, scheduling_interval)
Function to verify DRPolicy status and replication policy on Data Policies page of ACM console
- Parameters:
acm_obj (AcmAddClusters) – ACM Page Navigator Class
scheduling_interval (int) – Scheduling interval in the DRPolicy to be verified on ACM UI
- ocs_ci.helpers.dr_helpers_ui.verify_failover_relocate_status_ui(acm_obj, action='Failover', timeout=120)
Function to verify current status of in progress Failover/Relocate operation on ACM UI
- Parameters:
acm_obj (AcmAddClusters) – ACM Page Navigator Class
action (str) – action “Failover” or “Relocate” which was taken on the workloads, “Failover” is set to default
timeout (int) – timeout to wait for certain elements to be found on the ACM UI
ocs_ci.helpers.e2e_helpers module
- ocs_ci.helpers.e2e_helpers.create_muliple_types_provider_obcs(num_of_buckets, bucket_types, cloud_providers, bucket_factory)
This function creates valid OBCs of different cloud providers and bucket types
- Parameters:
num_of_buckets (int) – Number of buckets
bucket_types (dict) – Dict representing mapping between bucket type and relevant configuration
cloud_providers (dict) – Dict representing mapping between cloud providers and relevant configuration
bucket_factory (fixture) – bucket_factory fixture method
- Returns:
list of created buckets
- Return type:
List
- ocs_ci.helpers.e2e_helpers.validate_mcg_bucket_replicaton(awscli_pod_session, mcg_obj_session, source_target_map, uploaded_objects_dir, downloaded_obejcts_dir, event, run_in_bg=False, object_amount=5)
Validate MCG bucket replication feature
- Parameters:
awscli_pod_session (Pod) – Pod object representing aws-cli pod
mcg_obj_session (MCG) – MCG object
source_target_map (Dict) – Dictionary consisting of source - target buckets
uploaded_objects_dir (str) – directory where uploaded objects are kept
downloaded_obejcts_dir (str) – directory where downloaded objects are kept
event (threading.Event()) – Event() object
run_in_bg (bool) – If True, validation is run in background
object_amount (int) – Amounts of objects
- ocs_ci.helpers.e2e_helpers.validate_mcg_caching(awscli_pod_session, mcg_obj_session, cld_mgr, cache_buckets, uploaded_objects_dir, downloaded_obejcts_dir, event, run_in_bg=False)
Validate noobaa caching feature against the cache buckets
- Parameters:
awscli_pod_session (Pod) – Pod object representing aws-cli pod
mcg_obj_session (MCG) – MCG object
cld_mgr (cld_mgr) – cld_mgr object
cache_buckets (List) – List consisting of cache buckets
uploaded_objects_dir (str) – directory where uploaded objects are kept
downloaded_obejcts_dir (str) – directory where downloaded objects are kept
event (threading.Event()) – Event() object
run_in_bg (bool) – If True, validation is run in background
- ocs_ci.helpers.e2e_helpers.validate_mcg_nsfs_feature()
- ocs_ci.helpers.e2e_helpers.validate_mcg_object_expiration(mcg_obj, buckets, event, run_in_bg=False, object_amount=5, prefix='')
Validates objects expiration for MCG buckets
- Parameters:
mcg_obj (MCG) – MCG object
buckets (List) – List of MCG buckets
event (threading.Event()) – Event() object
run_in_bg (Bool) – True if wants to run in background
object_amount (Int) – Amount of objects
prefix (str) – Any prefix used for objects
- ocs_ci.helpers.e2e_helpers.validate_rgw_kafka_notification(kafka_rgw_dict, event, run_in_bg=False)
Validate kafka notifications for RGW buckets
- Parameters:
kafka_rgw_dict (Dict) – Dict consisting of rgw bucket,
kafka_topic –
etc (kafkadrop_host) –
event (threading.Event()) – Event() object
run_in_bg (Bool) – True if you want to run in the background
ocs_ci.helpers.helpers module
Helper functions file for OCS QE
- ocs_ci.helpers.helpers.add_scc_policy(sa_name, namespace)
Adding ServiceAccount to scc anyuid and privileged
- Parameters:
sa_name (str) – ServiceAccount name
namespace (str) – The namespace for the scc_policy creation
- ocs_ci.helpers.helpers.calc_local_file_md5_sum(path)
Calculate and return the MD5 checksum of a local file
- Parameters:
path (str) – The path to the file
- Returns:
The MD5 checksum
- Return type:
str
- ocs_ci.helpers.helpers.change_default_storageclass(scname)
Change the default StorageClass to the given SC name
- Parameters:
scname (str) – StorageClass name
- Returns:
True on success
- Return type:
bool
- ocs_ci.helpers.helpers.change_vm_network_state(ip, label='Network adapter 1', network='VM Network', connect=False)
Changes the network state of a virtual machine.
- Parameters:
ip (str) – The IP address of the virtual machine.
label (str, optional) – The label of the network adapter to be changed. Defaults to constants.VM_DEFAULT_NETWORK_ADAPTER.
network (str, optional) – The name of the network to which the network adapter should be connected. Defaults to constants.VM_DEFAULT_NETWORK.
connect (bool, optional) – If True, the network adapter is connected. If False, the network adapter is disconnected. Defaults to False.
- Returns:
Returns True if the operation was successful, False otherwise.
- Return type:
bool
- ocs_ci.helpers.helpers.check_cluster_is_compact()
- ocs_ci.helpers.helpers.check_number_of_mon_pods(expected_mon_num=3)
Function to check the number of monitoring pods
- Returns:
True if number of mon pods is 3, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.check_osd_log_exist_on_rook_ceph_operator_pod(last_log_date_time_obj, expected_strings=(), unexpected_strings=())
- Verify logs contain the expected strings and the logs do not
contain the unexpected strings
- Parameters:
last_log_date_time_obj (datetime obj) – type of log
expected_strings (list) – verify the logs contain the expected strings
unexpected_strings (list) – verify the logs do not contain the strings
- Returns:
True if logs contain the expected strings and the logs do not contain the unexpected strings, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.check_rbd_image_used_size(pvc_objs, usage_to_compare, rbd_pool='ocs-storagecluster-cephblockpool', expect_match=True)
Check if RBD image used size of the PVCs are matching with the given value
- Parameters:
pvc_objs (list) – List of PVC objects
usage_to_compare (str) – Value of image used size to be compared with actual value. eg: “5GiB”
rbd_pool (str) – Name of the pool
expect_match (bool) – True to verify the used size is equal to ‘usage_to_compare’ value. False to verify the used size is not equal to ‘usage_to_compare’ value.
- Returns:
True if the verification is success for all the PVCs, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.check_rook_ceph_crashcollector_pods_where_rook_ceph_pods_are_running()
check rook-ceph-crashcollector pods running on worker nodes where rook-ceph pods are running.
- Returns:
- True if the rook-ceph-crashcollector pods running on worker nodes
where rook-ceph pods are running. False otherwise.
- Return type:
bool
- ocs_ci.helpers.helpers.check_selinux_relabeling(pod_obj)
Check SeLinux Relabeling is set to false.
- Parameters:
pod_obj (Pod object) – App pod
- ocs_ci.helpers.helpers.clean_all_test_projects(project_name='test')
Delete all namespaces with ‘test’ in its name ‘test’ can be replaced with another string
- Parameters:
project_name (str) – expression to be deleted. Defaults to “test”.
- ocs_ci.helpers.helpers.clear_crash_warning_and_osd_removal_leftovers()
Clear crash warnings and osd removal leftovers. This function can be used for example, after the device replacement test or the node replacement test.
- ocs_ci.helpers.helpers.collect_performance_stats(dir_name)
Collect performance stats and saves them in file in json format.
dir_name (str): directory name to store stats.
- Performance stats include:
IOPs and throughput percentage of cluster CPU, memory consumption of each nodes
- ocs_ci.helpers.helpers.converge_lists(list_to_converge)
Function to flatten and remove the sublist created during future obj
- Parameters:
list_to_converge (list) – arg list of lists, eg: [[1,2],[3,4]]
- Returns:
return converged list eg: [1,2,3,4]
- Return type:
list (list)
- ocs_ci.helpers.helpers.craft_s3_command(cmd, mcg_obj=None, api=False)
Crafts the AWS CLI S3 command including the login credentials and command to be ran
- Parameters:
mcg_obj – An MCG object containing the MCG S3 connection credentials
cmd – The AWSCLI command to run
api – True if the call is for s3api, false if s3
- Returns:
The crafted command, ready to be executed on the pod
- Return type:
str
- ocs_ci.helpers.helpers.create_build_from_docker_image(image_name, install_package, namespace, source_image='quay.io/ocsci/fedora', source_image_label='fio')
Allows to create a build config using a Dockerfile specified as an argument, eg.:
$ oc new-build -D $'FROM centos:7\nRUN yum install -y httpd'
creates a build with
httpd
installed.- Parameters:
image_name (str) – Name of the image to be created
source_image (str) – Source image to build docker image from, defaults to Centos as base image
namespace (str) – project where build config should be created
source_image_label (str) – Tag to use along with the image name, defaults to ‘latest’
install_package (str) – package to install over the base image
- Returns:
The OCP object for the image Fails on UnavailableBuildException exception if build creation fails
- Return type:
ocs_ci.ocs.ocp.OCP (obj)
- ocs_ci.helpers.helpers.create_ceph_block_pool(pool_name=None, replica=3, compression=None, failure_domain=None, verify=True)
Create a Ceph block pool ** This method should not be used anymore ** ** This method is for internal testing only **
- Parameters:
pool_name (str) – The pool name to create
failure_domain (str) – Failure domain name
verify (bool) – True to verify the pool exists after creation, False otherwise
replica (int) – The replica size for a pool
compression (str) – Compression type for a pool
- Returns:
An OCS instance for the Ceph block pool
- Return type:
- ocs_ci.helpers.helpers.create_ceph_file_system(pool_name=None)
Create a Ceph file system ** This method should not be used anymore ** ** This method is for internal testing only **
- Parameters:
pool_name (str) – The pool name to create
- Returns:
An OCS instance for the Ceph file system
- Return type:
- ocs_ci.helpers.helpers.create_multilpe_projects(number_of_project)
Create one or more projects
- Parameters:
number_of_project (int) – Number of projects to be created
- Returns:
List of project objects
- Return type:
list
- ocs_ci.helpers.helpers.create_multiple_pvc_parallel(sc_obj, namespace, number_of_pvc, size, access_modes)
Funtion to create multiple PVC in parallel using threads Function will create PVCs based on the available access modes
- Parameters:
sc_obj (str) – Storage Class object
namespace (str) – The namespace for creating pvc
number_of_pvc (int) – NUmber of pvc to be created
size (str) – size of the pvc eg: ‘10Gi’
access_modes (list) – List of access modes for PVC creation
- Returns:
List of pvc objs created in function
- Return type:
pvc_objs_list (list)
- ocs_ci.helpers.helpers.create_multiple_pvcs(sc_name, namespace, number_of_pvc=1, size=None, do_reload=False, access_mode='ReadWriteOnce', burst=False)
Create one or more PVC as a bulk or one by one
- Parameters:
sc_name (str) – The name of the storage class to provision the PVCs from
namespace (str) – The namespace for the PVCs creation
number_of_pvc (int) – Number of PVCs to be created
size (str) – The size of the PVCs to create
do_reload (bool) – True for wait for reloading PVC after its creation, False otherwise
access_mode (str) – The kind of access mode for PVC
burst (bool) – True for bulk creation, False ( default) for multiple creation
- Returns:
List of PVC objects tmpdir (str): The full path of the directory in which the yamls for pvc objects creation reside
- Return type:
ocs_objs (list)
- ocs_ci.helpers.helpers.create_ocs_object_from_kind_and_name(kind, resource_name, namespace=None)
Create OCS object from kind and name
- Parameters:
kind (str) – resource kind like CephBlockPool, pvc.
resource_name (str) – name of the resource.
namespace (str) – then value from config will be used.
- Returns:
returns OCS object from kind and name.
- Return type:
- ocs_ci.helpers.helpers.create_pod(interface_type=None, pvc_name=None, do_reload=True, namespace='openshift-storage', node_name=None, pod_dict_path=None, sa_name=None, security_context=None, dc_deployment=False, raw_block_pv=False, raw_block_device='/dev/rbdblock', replica_count=1, pod_name=None, node_selector=None, command=None, command_args=None, ports=None, deploy_pod_status='Completed', subpath=None, deployment=False, scc=None, volumemounts=None, pvc_read_only_mode=None, priorityClassName=None)
Create a pod
- Parameters:
interface_type (str) – The interface type (CephFS, RBD, etc.)
pvc_name (str) – The PVC that should be attached to the newly created pod
do_reload (bool) – True for reloading the object after creation, False otherwise
namespace (str) – The namespace for the new resource creation
node_name (str) – The name of specific node to schedule the pod
pod_dict_path (str) – YAML path for the pod
sa_name (str) – Serviceaccount name
security_context (dict) – Set security context on container in the form of dictionary
dc_deployment (bool) – True if creating pod as deploymentconfig
raw_block_pv (bool) – True for creating raw block pv based pod, False otherwise
raw_block_device (str) – raw block device for the pod
replica_count (int) – Replica count for deployment config
pod_name (str) – Name of the pod to create
node_selector (dict) – dict of key-value pair to be used for nodeSelector field eg: {‘nodetype’: ‘app-pod’}
command (list) – The command to be executed on the pod
command_args (list) – The arguments to be sent to the command running on the pod
ports (dict) – Service ports
deploy_pod_status (str) – Expected status of deploy pod. Applicable only if dc_deployment is True
subpath (str) – Value of subPath parameter in pod yaml
deployment (bool) – True for Deployment creation, False otherwise
scc (dict) – Set security context on pod like fsGroup, runAsUer, runAsGroup
volumemounts (list) – Value of mountPath parameter in pod yaml
- Returns:
A Pod instance
- Return type:
- Raises:
AssertionError – In case of any failure
- ocs_ci.helpers.helpers.create_pods(pvc_objs, pod_factory, interface, pods_for_rwx=1, status='', nodes=None)
Create pods
- Parameters:
pvc_objs (list) – List of ocs_ci.ocs.resources.pvc.PVC instances
pod_factory (function) – pod_factory function
interface (int) – Interface type
pods_for_rwx (int) – Number of pods to be created if access mode of PVC is RWX
status (str) – If provided, wait for desired state of each pod before creating next one
nodes (list) – Node name for each pod will be selected from this list.
- Returns:
list of Pod objects
- Return type:
list
- ocs_ci.helpers.helpers.create_pods_parallel(pvc_list, namespace, interface, pod_dict_path=None, sa_name=None, raw_block_pv=False, dc_deployment=False, node_selector=None)
Function to create pods in parallel
- Parameters:
pvc_list (list) – List of pvcs to be attached in pods
namespace (str) – The namespace for creating pod
interface (str) – The interface backed the PVC
pod_dict_path (str) – pod_dict_path for yaml
sa_name (str) – sa_name for providing permission
raw_block_pv (bool) – Either RAW block or not
dc_deployment (bool) – Either DC deployment or not
node_selector (dict) – dict of key-value pair to be used for nodeSelector field eg: {‘nodetype’: ‘app-pod’}
- Returns:
Returns list of pods created
- Return type:
pod_objs (list)
- ocs_ci.helpers.helpers.create_priority_class(priority, value)
Function to create priority class on the cluster :returns: Returns priority class obj :rtype: bool
- ocs_ci.helpers.helpers.create_project(project_name=None)
Create a project
- Parameters:
project_name (str) – The name for the new project
- Returns:
Project object
- Return type:
- ocs_ci.helpers.helpers.create_pvc(sc_name, pvc_name=None, namespace='openshift-storage', size=None, do_reload=True, access_mode='ReadWriteOnce', volume_mode=None)
Create a PVC
- Parameters:
sc_name (str) – The name of the storage class for the PVC to be associated with
pvc_name (str) – The name of the PVC to create
namespace (str) – The namespace for the PVC creation
size (str) – Size of pvc to create
do_reload (bool) – True for wait for reloading PVC after its creation, False otherwise
access_mode (str) – The access mode to be used for the PVC
volume_mode (str) – Volume mode for rbd RWX pvc i.e. ‘Block’
- Returns:
PVC instance
- Return type:
- ocs_ci.helpers.helpers.create_reclaim_space_cronjob(pvc_name, reclaim_space_job_name=None, backoff_limit=None, retry_deadline_seconds=None, schedule='weekly')
Create ReclaimSpaceCronJob to invoke reclaim space operation on RBD volume
- Parameters:
pvc_name (str) – Name of the PVC
reclaim_space_job_name (str) – The name of the ReclaimSpaceCRonJob to be created
backoff_limit (int) – The number of retries before marking reclaim space operation as failed
retry_deadline_seconds (int) – The duration in seconds relative to the start time that the operation may be retried
schedule (str) – Type of schedule
- Returns:
An OCS object representing ReclaimSpaceJob
- Return type:
- ocs_ci.helpers.helpers.create_reclaim_space_job(pvc_name, reclaim_space_job_name=None, backoff_limit=None, retry_deadline_seconds=None)
Create ReclaimSpaceJob to invoke reclaim space operation on RBD volume
- Parameters:
pvc_name (str) – Name of the PVC
reclaim_space_job_name (str) – The name of the ReclaimSpaceJob to be created
backoff_limit (int) – The number of retries before marking reclaim space operation as failed
retry_deadline_seconds (int) – The duration in seconds relative to the start time that the operation may be retried
- Returns:
An OCS object representing ReclaimSpaceJob
- Return type:
- ocs_ci.helpers.helpers.create_resource(do_reload=True, **kwargs)
Create a resource
- Parameters:
do_reload (bool) – True for reloading the resource following its creation, False otherwise
kwargs (dict) – Dictionary of the OCS resource
- Returns:
An OCS instance
- Return type:
- Raises:
AssertionError – In case of any failure
- ocs_ci.helpers.helpers.create_sa_token_secret(sa_name, namespace='openshift-storage')
Creates a serviceaccount token secret
- Parameters:
sa_name (str) – Name of the serviceaccount for which the secret has to be created
namespace (str) – Namespace in which the serviceaccount exists
- Returns:
Name of the serviceaccount token secret
- Return type:
str
- ocs_ci.helpers.helpers.create_scc(scc_name=None, scc_dict=None, scc_dict_path=None)
Create a SecurityContextConstraints
- Parameters:
scc_name (str) – Name of the SCC
scc_dict (dict) – Dictionary containing the details on provileges, capabilities etc
scc_dict_path (str) – Path to custom SCC yaml file
- Returns:
OCS object for scc created
- Return type:
scc_obj
- ocs_ci.helpers.helpers.create_secret(interface_type)
Create a secret ** This method should not be used anymore ** ** This method is for internal testing only **
- Parameters:
interface_type (str) – The type of the interface (e.g. CephBlockPool, CephFileSystem)
- Returns:
An OCS instance for the secret
- Return type:
- ocs_ci.helpers.helpers.create_serviceaccount(namespace)
Create a Serviceaccount
- Parameters:
namespace (str) – The namespace for the serviceaccount creation
- Returns:
An OCS instance for the service_account
- Return type:
- ocs_ci.helpers.helpers.create_storage_class(interface_type, interface_name, secret_name, reclaim_policy='Delete', sc_name=None, provisioner=None, rbd_thick_provision=False, encrypted=False, encryption_kms_id=None, fs_name=None, volume_binding_mode='Immediate', allow_volume_expansion=True, kernelMountOptions=None)
Create a storage class ** This method should not be used anymore ** ** This method is for internal testing only **
- Parameters:
interface_type (str) – The type of the interface (e.g. CephBlockPool, CephFileSystem)
interface_name (str) – The name of the interface
secret_name (str) – The name of the secret
sc_name (str) – The name of storage class to create
reclaim_policy (str) – Type of reclaim policy. Defaults to ‘Delete’ (eg., ‘Delete’, ‘Retain’)
rbd_thick_provision (bool) – True to enable RBD thick provisioning. Applicable if interface_type is CephBlockPool
encrypted (bool) – True to create encrypted SC else False
encryption_kms_id (str) – ID of the KMS entry from connection details
fs_name (str) – the name of the filesystem for CephFS StorageClass
volume_binding_mode (str) – Can be “Immediate” or “WaitForFirstConsumer” which the PVC will be in pending till pod attachment.
allow_volume_expansion (bool) – True to create sc with volume expansion
kernelMountOptions (str) – Mount option for security context
- Returns:
An OCS instance for the storage class
- Return type:
- ocs_ci.helpers.helpers.create_unique_resource_name(resource_description, resource_type)
Creates a unique object name by using the object_description, object_type and a random uuid(in hex) as suffix trimmed due to kubernetes limitation of 63 characters
- Parameters:
resource_description (str) – The user provided object description
resource_type (str) – The type of object for which the unique name will be created. For example: project, pvc, etc
- Returns:
A unique name
- Return type:
str
- ocs_ci.helpers.helpers.default_ceph_block_pool()
Returns default CephBlockPool
- Returns:
default CephBlockPool
- ocs_ci.helpers.helpers.default_storage_class(interface_type)
Return default storage class based on interface_type
- Parameters:
interface_type (str) – The type of the interface (e.g. CephBlockPool, CephFileSystem)
- Returns:
Existing StorageClass Instance
- Return type:
- ocs_ci.helpers.helpers.default_thick_storage_class()
Return default RBD thick storage class
- Returns:
Existing RBD thick StorageClass instance
- Return type:
- ocs_ci.helpers.helpers.default_volumesnapshotclass(interface_type)
Return default VolumeSnapshotClass based on interface_type
- Parameters:
interface_type (str) – The type of the interface (e.g. CephBlockPool, CephFileSystem)
- Returns:
VolumeSnapshotClass Instance
- Return type:
- ocs_ci.helpers.helpers.delete_bulk_pvcs(pvc_yaml_dir, pv_names_list, namespace)
Deletes all the pvcs created from yaml file in a provided dir :param pvc_yaml_dir: Directory in which yaml file resides :type pvc_yaml_dir: str :param pv_names_list: List of pv objects to be deleted :type pv_names_list: str
- ocs_ci.helpers.helpers.delete_cephblockpools(cbp_objs)
Function for deleting CephBlockPool
- Parameters:
cbp_objs (list) – List of CBP objects for deletion
- Returns:
True if deletion of CephBlockPool is successful
- Return type:
bool
- ocs_ci.helpers.helpers.delete_objs_parallel(obj_list)
Function to delete objs specified in list :param obj_list: List can be obj of pod, pvc, etc :type obj_list: list
- Returns:
True if obj deleted else False
- Return type:
bool
- ocs_ci.helpers.helpers.delete_storageclasses(sc_objs)
” Function for Deleting storageclasses
- Parameters:
sc_objs (list) – List of SC objects for deletion
- Returns:
True if deletion is successful
- Return type:
bool
- ocs_ci.helpers.helpers.delete_volume_in_backend(img_uuid, pool_name=None, disable_mirroring=False)
Delete an Image/Subvolume in the backend
- Parameters:
img_uuid (str) – Part of VolID which represents corresponding image/subvolume in backend, eg:
oc get pv/<volumeName> -o jsonpath='{.spec.csi.volumeHandle}'
Output is the CSI generated VolID and looks like:0001-000c-rook-cluster-0000000000000001-f301898c-a192-11e9-852a-1eeeb6975c91
where image_uuid isf301898c-a192-11e9-852a-1eeeb6975c91
pool_name (str) – The name of the pool
disable_mirroring (bool) – True to disable the mirroring for the image, False otherwise
- Returns:
- True if image deleted successfully
- False if:
Pool not found image not found image not deleted
- Return type:
bool
- ocs_ci.helpers.helpers.disable_vm_network_for_duration(ip, label='Network adapter 1', network='VM Network', duration=5)
Disable network connectivity for a virtual machine with a specified IP address for a given duration.
- Parameters:
ip (str) – The IP address of the virtual machine to disable network connectivity for.
label (str, optional) – The label of the network adapter to disable. (default: “Network adapter 1”)
network (str, optional) – The name of the network to connect to. (default: “VM Network”)
duration (int, optional) – The duration in seconds to disable network connectivity. (default: 5 seconds)
- Returns:
True if network connectivity was successfully disabled and re-enabled, False otherwise.
- Return type:
bool
- ocs_ci.helpers.helpers.fetch_used_size(cbp_name, exp_val=None)
Fetch used size in the pool :param exp_val: Expected size in GB :type exp_val: float
- Returns:
Used size in GB
- Return type:
float
- ocs_ci.helpers.helpers.flatten_multilevel_dict(d)
Recursively extracts the leaves of a multi-level dictionary and returns them as a list.
- Parameters:
d (dict) – The multi-level dictionary.
- Returns:
A list containing the leaves of the dictionary.
- Return type:
list
- ocs_ci.helpers.helpers.get_admin_key()
Fetches admin key secret from Ceph
- Returns:
The admin key
- Return type:
str
- ocs_ci.helpers.helpers.get_all_pvs()
Gets all pvs in cluster namespace (openshift-storage or fusion-storage)
- Returns:
Dict of all pv in the cluster namespace
- Return type:
dict
- ocs_ci.helpers.helpers.get_all_storageclass_names()
Function for getting all storageclass
- Returns:
list of storageclass name
- Return type:
list
- ocs_ci.helpers.helpers.get_architecture_path(cli_type)
Get Architcture path
- Parameters:
cli_type (str) – choose which bin file you want to download [“odf” -> odf-cli , “mcg” -> mcg-cli]
- Returns:
path of MCG/ODF CLI Binary in the image.
- Return type:
(str)
- ocs_ci.helpers.helpers.get_ceph_log_level(service, subsystem)
Return CEPH log level value.
- Parameters:
service (_type_) – _description_
subsystem (_type_) – _description_
- ocs_ci.helpers.helpers.get_cephblockpool_names()
Function for getting all CephBlockPool
- Returns:
list of cephblockpool name
- Return type:
list
- ocs_ci.helpers.helpers.get_cephfs_data_pool_name()
Fetches ceph fs datapool name from Ceph
- Returns:
fs datapool name
- Return type:
str
- ocs_ci.helpers.helpers.get_cephfs_name()
Function to retrive CephFS name :returns: Name of CFS :rtype: str
- ocs_ci.helpers.helpers.get_cephfs_subvolumegroup()
Get the name of cephfilesystemsubvolumegroup. The name should be fetched if the platform is not MS.
- Returns:
The name of cephfilesystemsubvolumegroup
- Return type:
str
- ocs_ci.helpers.helpers.get_current_test_name()
A function to return the current test name in a parsed manner :returns: The test name. :rtype: str
- ocs_ci.helpers.helpers.get_default_storage_class()
Get the default StorageClass(es)
- Returns:
default StorageClass(es) list
- Return type:
list
- ocs_ci.helpers.helpers.get_end_creation_time(interface, pvc_name)
Get the ending creation time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pvc_name (str) – Name of the PVC for creation time measurement
- Returns:
End time of PVC creation
- Return type:
datetime object
- ocs_ci.helpers.helpers.get_end_deletion_time(interface, pv_name)
Get the ending deletion time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pv_name (str) – Name of the PVC for deletion time measurement
- Returns:
End time of PVC deletion
- Return type:
datetime object
- ocs_ci.helpers.helpers.get_event_line_datetime(event_line)
Get the event line datetime
- Parameters:
event_line (str) – The event line to get it’s datetime
- Returns:
The event line datetime
- Return type:
datetime object
- ocs_ci.helpers.helpers.get_failure_domain()
Get Failure Domain
- Returns:
type of failure domain
- Return type:
string
- ocs_ci.helpers.helpers.get_failure_domin()
Function is used to getting failure domain of pool
- Returns:
Failure domain from cephblockpool
- Return type:
str
- ocs_ci.helpers.helpers.get_full_test_logs_path(cname, fname=None)
Getting the full path of the logs file for particular test
this function use the inspect module to find the name of the caller function, so it need to be call once from the main test function. the output is in the form of ocsci_log_path/<full test file path>/<test filename>/<test class name>/<test function name>
- Parameters:
cname (obj) – the Class object which was run and called this function
fname (str) – the function name for different tests log path
- Returns:
full path of the test logs relative to the ocs-ci base logs path
- Return type:
str
- ocs_ci.helpers.helpers.get_last_log_time_date()
Get last log time
- Returns:
type of log
- Return type:
last_log_date_time_obj (datetime obj)
- ocs_ci.helpers.helpers.get_logs_rook_ceph_operator()
Get logs from a rook_ceph_operator pod
- Returns:
Output from ‘oc get logs rook-ceph-operator command
- Return type:
str
- ocs_ci.helpers.helpers.get_logs_with_errors(errors=None)
From logs of all pods and nodes, get only logs containing any of specified errors
- Parameters:
errors (list) – List of errors to look for
- Returns:
node/pod name as key, logs content as value; may be empty
- Return type:
dict
- ocs_ci.helpers.helpers.get_memory_leak_median_value()
Function to calculate memory leak Median value by collecting the data for 180 sec and find the median value which will be considered as starting point to evaluate memory leak using “RES” value of ceph-osd daemon i.e. list[7] in code
- Returns:
dict of worker nodes and respective median value
- Return type:
median_dict (dict)
- ocs_ci.helpers.helpers.get_mon_db_size_in_kb(mon_pod_obj)
Get mon db size and returns the size in KB The output of ‘du -sh’ command contains the size of the directory and its path as string e.g. “67M /var/lib/ceph/mon/ceph-c/store.db” The size is extracted by splitting the string with ‘ ‘. The size format for example: 1K, 234M, 2G For uniformity, this test uses KB
- Parameters:
mon_pod_obj (obj) – Mon pod resource object
- Returns:
Converted Mon db size in KB
- Return type:
convert_device_size (int)
- ocs_ci.helpers.helpers.get_mon_pdb()
Check for Mon PDB
- Returns:
Count of mon allowed disruption min_available_mon (int): Count of minimum mon available max_unavailable_mon (int): Count of maximun mon unavailable
- Return type:
disruptions_allowed (int)
- ocs_ci.helpers.helpers.get_noobaa_db_used_space()
Get noobaa db size
- Returns:
noobaa_db used space
- Return type:
df_out (str)
- ocs_ci.helpers.helpers.get_noobaa_url()
Get the URL of noobaa console
- Returns:
url of noobaa console
- Return type:
str
- ocs_ci.helpers.helpers.get_pods_nodes_logs()
Get logs from all pods and nodes
- Returns:
node/pod name as key, logs content as value (string)
- Return type:
dict
- ocs_ci.helpers.helpers.get_pool_cr(pool_name)
Get the pool CR even if the kind is unknown.
- Parameters:
pool_name (str) – The name of the pool to get the CR for.
- Returns:
If the resource is found, None otherwise.
- Return type:
dict
- ocs_ci.helpers.helpers.get_provision_time(interface, pvc_name, status='start')
Get the starting/ending creation time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pvc_name (str / list) – Name of the PVC(s) for creation time the list will be list of pvc objects
status (str) – the status that we want to get - Start / End
- Returns:
Time of PVC(s) creation
- Return type:
datetime object
- ocs_ci.helpers.helpers.get_pv_names()
Get Pv names
- Returns:
list of pv names
- Return type:
list
- ocs_ci.helpers.helpers.get_pv_size(storageclass=None)
Get Pv size from requested storageclass
- Parameters:
storageclass (str) – Name of storageclass
- Returns:
list of pv’s size
- Return type:
list
- ocs_ci.helpers.helpers.get_rook_ceph_pod_events(pod_name)
Get the rook ceph pod events from the rook ceph pod operator logs
- Parameters:
pod_name (str) – The rook ceph pod name to get the events
- Returns:
List of all the event lines with the specific pod
- Return type:
list
- ocs_ci.helpers.helpers.get_rook_ceph_pod_events_by_keyword(pod_name, keyword)
Get the rook ceph pod events with the keyword ‘keyword’ from the rook ceph pod operator logs
- Parameters:
pod_name (str) – The rook ceph pod name to get the events
keyword (str) – The keyword to search in the events
- Returns:
List of all the event lines with the specific pod that has the keyword ‘keyword’
- Return type:
list
- ocs_ci.helpers.helpers.get_s3_credentials_from_secret(secret_name)
- ocs_ci.helpers.helpers.get_secret_names(namespace='openshift-storage', resource_name='')
Get secrets names
- Parameters:
namespace (str) – The name of the project.
resource_name (str) – The resource name to fetch.
- Returns:
secret names
- Return type:
dict
- ocs_ci.helpers.helpers.get_serviceaccount_obj(sa_name, namespace)
Get serviceaccount obj
- Parameters:
sa_name (str) – Service Account name
namespace (str) – The namespace for the serviceaccount creation
- Returns:
An OCS instance for the service_account
- Return type:
- ocs_ci.helpers.helpers.get_snapshot_content_obj(snap_obj)
Get volume snapshot content of a volume snapshot
- ocs_ci.helpers.helpers.get_start_creation_time(interface, pvc_name)
Get the starting creation time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pvc_name (str) – Name of the PVC for creation time measurement
- Returns:
Start time of PVC creation
- Return type:
datetime object
- ocs_ci.helpers.helpers.get_start_deletion_time(interface, pv_name)
Get the starting deletion time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pvc_name (str) – Name of the PVC for deletion time measurement
- Returns:
Start time of PVC deletion
- Return type:
datetime object
- ocs_ci.helpers.helpers.induce_mon_quorum_loss()
Take mon quorum out by deleting /var/lib/ceph/mon directory so that it will start crashing and the quorum is lost
- Returns:
List of mon objects mon_pod_running[0] (obj): A mon object which is running ceph_mon_daemon_id (list): List of crashed ceph mon id
- Return type:
mon_pod_obj_list (list)
- ocs_ci.helpers.helpers.is_volume_present_in_backend(interface, image_uuid, pool_name=None)
Check whether Image/Subvolume is present in the backend.
- Parameters:
interface (str) – The interface backed the PVC
image_uuid (str) – Part of VolID which represents corresponding image/subvolume in backend, eg:
oc get pv/<volumeName> -o jsonpath='{.spec.csi.volumeHandle}'
Output is the CSI generated VolID and looks like:0001-000c-rook-cluster-0000000000000001-f301898c-a192-11e9-852a-1eeeb6975c91
where image_uuid isf301898c-a192-11e9-852a-1eeeb6975c91
pool_name (str) – Name of the rbd-pool if interface is CephBlockPool
- Returns:
True if volume is present and False if volume is not present
- Return type:
bool
- ocs_ci.helpers.helpers.label_worker_node(node_list, label_key, label_value)
Function to label worker node for running app pods on specific worker nodes.
- Parameters:
node_list (list) – List of node name
label_key (str) – Label_key to be added in worker
label_value (str) – Label_value
- ocs_ci.helpers.helpers.measure_pv_deletion_time_bulk(interface, pv_name_list, wait_time=60, return_log_times=False)
Measure PV deletion time of bulk PV, based on logs.
- Parameters:
interface (str) – The interface backed the PV
pv_name_list (list) – List of PV Names for measuring deletion time
wait_time (int) – Seconds to wait before collecting CSI log
return_log_times (bool) – Determines the return value – if False, dictionary of pv_names with the deletion time is returned; if True – the dictionary of pv_names with the tuple of (srart_deletion_time, end_deletion_time) is returned
- Returns:
- Dictionary where the pv_names are the keys. The value of the dictionary depend on the
return_log_times argument value and are either the corresponding deletion times (when return_log_times is False) or a tuple of (start_deletion_time, end_deletion_time) as they appear in the logs
- Return type:
pv_dict (dict)
- ocs_ci.helpers.helpers.measure_pvc_creation_time(interface, pvc_name)
Measure PVC creation time based on logs
- Parameters:
interface (str) – The interface backed the PVC pvc_name (str): Name of the PVC for creation time measurement
- Returns:
Creation time for the PVC
- Return type:
float
- ocs_ci.helpers.helpers.measure_pvc_creation_time_bulk(interface, pvc_name_list, wait_time=60)
Measure PVC creation time of bulk PVC based on logs.
- Parameters:
interface (str) – The interface backed the PVC
pvc_name_list (list) – List of PVC Names for measuring creation time
wait_time (int) – Seconds to wait before collecting CSI log
- Returns:
Dictionary of pvc_name with creation time.
- Return type:
pvc_dict (dict)
- ocs_ci.helpers.helpers.measure_pvc_deletion_time(interface, pv_name)
Measure PVC deletion time based on logs
- Parameters:
interface (str) – The interface backed the PVC
pv_name (str) – Name of the PV for creation time measurement
- Returns:
Deletion time for the PVC
- Return type:
float
- ocs_ci.helpers.helpers.memory_leak_analysis(median_dict)
Function to analyse Memory leak after execution of test case Memory leak is analyzed based on top output “RES” value of ceph-osd daemon, i.e.
list[7]
in code.More Detail on Median value: For calculating memory leak require a constant value, which should not be start or end of test, so calculating it by getting memory for 180 sec before TC execution and take a median out of it. Memory value could be different for each nodes, so identify constant value for each node and update in median_dict
- Parameters:
median_dict (dict) – dict of worker nodes and respective median value
eg – median_dict = {‘worker_node_1’:102400, ‘worker_node_2’:204800, …}
Usage:
test_case(.., memory_leak_function): ..... median_dict = helpers.get_memory_leak_median_value() ..... TC execution part, memory_leak_fun will capture data .... helpers.memory_leak_analysis(median_dict) ....
- ocs_ci.helpers.helpers.modify_deployment_replica_count(deployment_name, replica_count, namespace='openshift-storage')
Function to modify deployment replica count, i.e to scale up or down deployment
- Parameters:
deployment_name (str) – Name of deployment
replica_count (int) – replica count to be changed to
namespace (str) – namespace where the deployment exists
- Returns:
True in case if changes are applied. False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.modify_job_parallelism_count(job_name, count, namespace='openshift-storage')
Function to modify Job instances count,
- Parameters:
job_name (str) – Name of job
count (int) – instances count to be changed to
namespace (str) – namespace where the job is running
- Returns:
True in case if changes are applied. False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.modify_osd_replica_count(resource_name, replica_count)
Function to modify osd replica count to 0 or 1
- Parameters:
resource_name (str) – Name of osd i.e, ‘rook-ceph-osd-0-c9c4bc7c-bkf4b’
replica_count (int) – osd replica count to be changed to
- Returns:
True in case if changes are applied. False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.modify_statefulset_replica_count(statefulset_name, replica_count, namespace='openshift-storage')
Function to modify statefulset replica count, i.e to scale up or down statefulset
- Parameters:
statefulset_namee (str) – Name of statefulset
replica_count (int) – replica count to be changed to
- Returns:
True in case if changes are applied. False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.mon_pods_running_on_same_node()
Verifies two mons are running on same node
- ocs_ci.helpers.helpers.odf_cli_set_log_level(service, log_level, subsystem)
Set the log level for a Ceph service. :param service: The Ceph service name. :type service: str :param log_level: The log level to set. :type log_level: str :param subsystem: The subsystem for which to set the log level. :type subsystem: str
- Returns:
The output of the command execution.
- Return type:
str
- ocs_ci.helpers.helpers.pod_start_time(pod_obj)
Function to measure time taken for container(s) to get into running state by measuring the difference between container’s start time (when container went into running state) and started time (when container was actually started)
- Parameters:
pod_obj (obj) – pod object to measure start time
- Returns:
Returns the name and start time of container(s) in a pod
- Return type:
containers_start_time(dict)
- ocs_ci.helpers.helpers.pull_images(image_name)
Function to pull images on all nodes
- Parameters:
image_name (str) – Name of the container image to be pulled
Returns: None
- ocs_ci.helpers.helpers.recover_mon_quorum(mon_pod_obj_list, mon_pod_running, ceph_mon_daemon_id)
Recover mon quorum back by following procedure mentioned in https://access.redhat.com/solutions/5898541
- Parameters:
mon_pod_obj_list (list) – List of mon objects
mon_pod_running (obj) – A mon object which is running
ceph_mon_daemon_id (list) – List of crashed ceph mon id
- ocs_ci.helpers.helpers.refresh_oc_login_connection(user=None, password=None)
Function to refresh oc user login Default login using kubeadmin user and password
- Parameters:
user (str) – Username to login
password (str) – Password to login
- ocs_ci.helpers.helpers.remove_label_from_worker_node(node_list, label_key)
Function to remove label from worker node.
- Parameters:
node_list (list) – List of node name
label_key (str) – Label_key to be remove from worker node
- ocs_ci.helpers.helpers.remove_ocs_object_from_list(kind, resource_name, object_list)
Given a list of OCS objects, the function removes the object with kind and resource from the list
- Parameters:
kind (str) – resource kind like CephBlockPool, pvc.
resource_name (str) – name of the resource.
object_list (array) – Array of OCS objects.
- Returns:
Array of OCS objects without removed object.
- Return type:
(array)
- ocs_ci.helpers.helpers.remove_scc_policy(sa_name, namespace)
Removing ServiceAccount from scc anyuid and privileged
- Parameters:
sa_name (str) – ServiceAccount name
namespace (str) – The namespace for the scc_policy deletion
- ocs_ci.helpers.helpers.retrieve_cli_binary(cli_type='mcg')
Download the MCG-CLI/ODF-CLI binary and store it locally.
- Parameters:
cli_type (str) – choose which bin file you want to download [“odf” -> odf-cli , “mcg” -> mcg-cli]
- Raises:
AssertionError – In the case the CLI binary is not executable.
- ocs_ci.helpers.helpers.retrieve_default_ingress_crt()
Copy the default ingress certificate from the router-ca secret to the local code runner for usage with boto3.
- ocs_ci.helpers.helpers.rsync_kubeconf_to_node(node)
Function to copy kubeconfig to OCP node
- Parameters:
node (str) – OCP node to copy kubeconfig if not present
- ocs_ci.helpers.helpers.run_cmd_verify_cli_output(cmd=None, expected_output_lst=(), cephtool_cmd=False, ocs_operator_cmd=False, debug_node=None)
Run command and verify its output
- Parameters:
cmd (str) – cli command
expected_output_lst (set) – A set of strings that need to be included in the command output.
cephtool_cmd (bool) – command on ceph-tool pod
ocs_operator_cmd (bool) – command on ocs-operator pod
debug_node (str) – name of node
- Returns:
True of all strings are included in the command output, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.run_io_with_rados_bench(**kw)
A task for radosbench. Runs radosbench command on specified pod . If parameters are not provided task assumes few default parameters.This task runs command in synchronous fashion.
- Parameters:
kw (dict) –
a dictionary of various radosbench parameters. ex:
pool_name:pool pg_num:number of pgs for pool op: type of operation {read, write} cleanup: True OR False
- Returns:
return value of radosbench command
- Return type:
ret
- ocs_ci.helpers.helpers.scale_nb_resources(replica=1)
Function scales noobaa resources
- Parameters:
replica (int) – Replica count
- ocs_ci.helpers.helpers.select_unique_pvcs(pvcs)
Get the PVCs with unique access mode and volume mode combination.
- Parameters:
pvcs (list) – List of PVC objects
- Returns:
List of selected PVC objects
- Return type:
list
- ocs_ci.helpers.helpers.set_configmap_log_level_rook_ceph_operator(value)
Set ROOK_LOG_LEVEL on configmap of rook-ceph-operator
- Parameters:
value (str) – type of log
- ocs_ci.helpers.helpers.set_image_lookup(image_name)
Function to enable lookup, which allows reference to the image stream tag in the image field of the object. Example:
$ oc set image-lookup mysql $ oc run mysql --image=mysql
- Parameters:
image_name (str) – Name of the image stream to pull the image locally
- Returns:
output of set image-lookup command
- Return type:
str
- ocs_ci.helpers.helpers.setup_pod_directories(pod_obj, dir_names)
Creates directories on the specified pod. Directories created under the respective test name directory.
- Parameters:
pod_obj – A pod object on which to create directories
dir_names – A list of directories names to create.
- Returns:
A list of all the full paths of the created directories
- Return type:
list
- ocs_ci.helpers.helpers.storagecluster_independent_check()
Check whether the storagecluster is running in independent mode by checking the value of spec.externalStorage.enable
- Returns:
True if storagecluster is running on external mode False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.validate_cephfilesystem(fs_name)
Verify CephFileSystem exists at Ceph and OCP
- Parameters:
fs_name (str) – The name of the Ceph FileSystem
- Returns:
- True if CephFileSystem is created at Ceph and OCP side else
will return False with valid msg i.e Failure cause
- Return type:
bool
- ocs_ci.helpers.helpers.validate_pod_oomkilled(pod_name, namespace='openshift-storage', container=None)
Validate pod oomkilled message are found on log
- Parameters:
pod_name (str) – Name of the pod
namespace (str) – Namespace of the pod
container (str) – Name of the container
- Returns:
- True if oomkill messages are not found on log.
False Otherwise.
- Return type:
bool
- Raises:
Assertion if failed to fetch logs –
- ocs_ci.helpers.helpers.validate_pods_are_running_and_not_restarted(pod_name, pod_restart_count, namespace)
Validate given pod is in running state and not restarted or re-spinned
- Parameters:
pod_name (str) – Name of the pod
pod_restart_count (int) – Restart count of pod
namespace (str) – Namespace of the pod
- Returns:
- True if pod is in running state and restart
count matches the previous one
- Return type:
bool
- ocs_ci.helpers.helpers.validate_pv_delete(pv_name)
validates if pv is deleted after pvc deletion
- Parameters:
pv_name (str) – pv from pvc to validates
- Returns:
True if deletion is successful
- Return type:
bool
- Raises:
AssertionError – If pv is not deleted
- ocs_ci.helpers.helpers.validate_scc_policy(sa_name, namespace, scc_name='privileged')
Validate serviceaccount is added to scc of privileged
- Parameters:
sa_name (str) – Service Account name
namespace (str) – The namespace for the serviceaccount creation
scc_name (str) – SCC name
- Returns:
True if sc_name is present in scc of privileged else False
- Return type:
bool
- ocs_ci.helpers.helpers.verify_block_pool_exists(pool_name)
Verify if a Ceph block pool exist
- Parameters:
pool_name (str) – The name of the Ceph block pool
- Returns:
True if the Ceph block pool exists, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.verify_log_exist_in_pods_logs(pod_names, expected_log, container=None, namespace='openshift-storage', all_containers_flag=True, since=None)
Verify log exist in pods logs.
- Parameters:
pod_names (list) – Name of the pod
expected_log (str) – the expected logs in “oc logs” command
container (str) – Name of the container
namespace (str) – Namespace of the pod
all_containers_flag (bool) – fetch logs from all containers of the resource
since (str) – only return logs newer than a relative duration like 5s, 2m, or 3h.
- Returns:
return True if log exist otherwise False
- Return type:
bool
- ocs_ci.helpers.helpers.verify_pdb_mon(disruptions_allowed, max_unavailable_mon)
Compare between the PDB status and the expected PDB status
- Parameters:
disruptions_allowed (int) – the expected number of disruptions_allowed
max_unavailable_mon (int) – the expected number of max_unavailable_mon
- Returns:
True if the expected pdb state equal to actual pdb state, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.verify_pv_mounted_on_node(node_pv_dict)
Check if mount point of a PV exists on a node
- Parameters:
node_pv_dict (dict) – Node to PV list mapping eg: {‘node1’: [‘pv1’, ‘pv2’, ‘pv3’], ‘node2’: [‘pv4’, ‘pv5’]}
- Returns:
- Node to existing PV list mapping
eg: {‘node1’: [‘pv1’, ‘pv3’], ‘node2’: [‘pv5’]}
- Return type:
dict
- ocs_ci.helpers.helpers.verify_pvc_size(pod_obj, expected_size)
Verify PVC size is as expected or not.
- Parameters:
pod_obj – Pod Object
expected_size – Expected size of PVC
- Returns:
True if expected size is matched with the PVC attached to pod. else False
- Return type:
bool
- ocs_ci.helpers.helpers.verify_quota_resource_exist(quota_name)
Verify quota resource exist
- Parameters:
quota_name (str) – The name of quota
- Returns:
return True if quota_name exist in list, otherwise False
- Return type:
bool
- ocs_ci.helpers.helpers.verify_rook_ceph_crashcollector_pods_where_rook_ceph_pods_are_running(timeout=90)
Verify rook-ceph-crashcollector pods running on worker nodes where rook-ceph pods are running.
- Parameters:
timeout (int) – time to wait for verifying
- Returns:
- True if rook-ceph-crashcollector pods running on worker nodes
where rook-ceph pods are running in the given timeout. False otherwise.
- Return type:
bool
- ocs_ci.helpers.helpers.verify_storagecluster_nodetopology()
Verify only nodes with OCS label in storagecluster under nodeTopologies block
- Returns:
return True if storagecluster contain only nodes with OCS label
- Return type:
bool
- ocs_ci.helpers.helpers.verify_volume_deleted_in_backend(interface, image_uuid, pool_name=None, timeout=180)
Ensure that Image/Subvolume is deleted in the backend.
- Parameters:
interface (str) – The interface backed the PVC
image_uuid (str) – Part of VolID which represents corresponding image/subvolume in backend, eg:
oc get pv/<volumeName> -o jsonpath='{.spec.csi.volumeHandle}'
Output is the CSI generated VolID and looks like:0001-000c-rook-cluster-0000000000000001-f301898c-a192-11e9-852a-1eeeb6975c91
where image_uuid isf301898c-a192-11e9-852a-1eeeb6975c91
pool_name (str) – Name of the rbd-pool if interface is CephBlockPool
timeout (int) – Wait time for the volume to be deleted.
- Returns:
- True if volume is deleted before timeout.
False if volume is not deleted.
- Return type:
bool
- ocs_ci.helpers.helpers.wait_for_ct_pod_recovery()
In case the of node failures scenarios, in which the selected node is running the ceph tools pod, we’ll want to wait for the pod recovery
- Returns:
True in case the ceph tools pod was recovered, False otherwise
- Return type:
bool
- ocs_ci.helpers.helpers.wait_for_pv_delete(pv_objs, timeout=180)
Wait for PVs to delete. Delete PVs having ReclaimPolicy ‘Retain’
- Parameters:
pv_objs (list) – OCS instances of kind PersistentVolume
- ocs_ci.helpers.helpers.wait_for_resource_count_change(func_to_use, previous_num, namespace, change_type='increase', min_difference=1, timeout=20, interval=2, **func_kwargs)
Wait for a change in total count of PVC or pod
- Parameters:
func_to_use (function) – Function to be used to fetch resource info Supported functions: pod.get_all_pvcs(), pod.get_all_pods()
previous_num (int) – Previous number of pods/PVCs for comparison
namespace (str) – Name of the namespace
change_type (str) – Type of change to check. Accepted values are ‘increase’ and ‘decrease’. Default is ‘increase’.
min_difference (int) – Minimum required difference in PVC/pod count
timeout (int) – Maximum wait time in seconds
interval (int) – Time in seconds to wait between consecutive checks
- Returns:
- True if difference in count is greater than or equal to
’min_difference’. False in case of timeout.
- ocs_ci.helpers.helpers.wait_for_resource_state(resource, state, timeout=60)
Wait for a resource to get to a given status
- Parameters:
resource (OCS obj) – The resource object
state (str) – The status to wait for
timeout (int) – Time in seconds to wait
- Raises:
ResourceWrongStatusException – In case the resource hasn’t reached the desired state
- ocs_ci.helpers.helpers.wait_for_rook_ceph_pod_status(pod_obj, desired_status, timeout=420)
Wait for the rook ceph pod to reach the desired status. If the pod didn’t reach the desired status, check if the reason is that the pod is not found. If this is the case, check in the rook ceph pod operator logs to see if the pod reached the desired status.
- Parameters:
pod_obj (ocs_ci.ocs.resources.pod.Pod) – The rook ceph pod object
desired_status (str) – The desired status of the pod to wait for
timeout (int) – time to wait for the pod to reach the desired status
- Returns:
True if the rook ceph pod to reach the desired status. False, otherwise
- Return type:
bool
ocs_ci.helpers.longevity_helpers module
- ocs_ci.helpers.longevity_helpers.create_restore_verify_snapshots(multi_snapshot_factory, snapshot_restore_factory, pod_factory, pvc_objs, namespace, file_name)
Creates snapshots from each PVC in the provided list of PVCs, Restores new PVCs out of the created snapshots and Verifies data integrity by checking the existence and md5sum of file in the restored PVC.
- Parameters:
multi_snapshot_factory – Fixture to create a VolumeSnapshot of each PVC in the provided list of PVCs.
snapshot_restore_factory – Fixture to create a new PVCs out of the VolumeSnapshot provided.
pod_factory – Fixture to create new PODs.
pvc_objs (list) – List of PVC objects for which snapshots are to be created.
namespace (str) – Namespace in which the PVCs are created.
file_name (str) – Name of the file on which FIO is performed.
- Returns:
- A tuple of size 2 containing a list of restored PVC objects and a list of the pods attached to the
restored PVCs, respectively.
- Return type:
tuple
- ocs_ci.helpers.longevity_helpers.expand_verify_pvcs(pvc_objs, pod_objs, pvc_size_new, file_name, fio_size)
Expands size of each PVC in the provided list of PVCs, Verifies data integrity by checking the existence and md5sum of file in the expanded PVC and Runs FIO on expanded PVCs and verifies results.
- Parameters:
pvc_objs (list) – List of PVC objects which are to be expanded.
pod_objs (list) – List of POD objects attached to the PVCs.
pvc_size_new (int) – Size of the expanded PVC in GB.
file_name (str) – Name of the file on which FIO is performed.
fio_size (int) – Size in MB of FIO.
- ocs_ci.helpers.longevity_helpers.measure_pod_creation_time(namespace, num_of_pods)
Measures and Logs the POD Creation Time of all the PODs.
- Parameters:
namespace (str) – Namespace in which the PODs are created.
num_of_pods (int) – Number of PODs created.
- Logs:
POD Creation Time of all the PODs.
- ocs_ci.helpers.longevity_helpers.measure_pod_to_pvc_attach_time(pod_objs)
Measures and Logs Attach Time of all PODs.
- Parameters:
pod_objs (list) – List of POD objects for which we have to measure the time.
- Logs:
Attach time of all PODs, as well as the average time.
- ocs_ci.helpers.longevity_helpers.measure_pvc_creation_time(interface, pvc_objs, start_time)
Measures and Logs PVC Creation Time of all PVCs.
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on.
pvc_objs (list) – List of PVC objects for which we have to measure the time.
start_time (str) – Formatted time from which and on to search the relevant logs.
- Logs:
PVC Creation Time of all the PVCs.
- ocs_ci.helpers.longevity_helpers.measure_pvc_deletion_time(interface, pvc_objs)
Measures and Logs PVC Deletion Time of all PVCs.
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on.
pvc_objs (list) – List of PVC objects for which we have to measure the time.
- Logs:
PVC Deletion Time of all the PVCs.
- ocs_ci.helpers.longevity_helpers.write_empty_files_to_bucket(mcg_obj, awscli_pod_session, bucket_name, test_directory_setup)
Write empty files to bucket and verify if they are created.
- Parameters:
mcg_obj (MCG) – An MCG object containing the MCG S3 connection credentials
awscli_pod_session – Fixture to create a new AWSCLI pod for relaying commands.
bucket_name (str) – Name of the bucket on which files are to be written.
test_directory_setup – Fixture to setup test DIRs.
- Raises:
UnexpectedBehaviour – Raises an exception if files are not created.
- Returns:
A set of names of all bucket objects.
- Return type:
Set
ocs_ci.helpers.managed_services module
Managed Services related functionalities
- ocs_ci.helpers.managed_services.get_all_storageclassclaims()
Get all storageclassclaims
- Returns:
OCS objects of kind Storageclassclaim
- Return type:
List
- ocs_ci.helpers.managed_services.get_ocs_osd_deployer_version()
Get OCS OSD deployer version from CSV
- Returns:
OCS OSD deployer version
- Return type:
Version
- ocs_ci.helpers.managed_services.get_storageclassclaims_of_storageclient(storageclient_name)
Get all storageclassclaims associated with a storageclient
- Parameters:
storageclient_name (str) – Name of the storageclient
- Returns:
OCS objects of kind Storageclassclaim
- Return type:
List
- ocs_ci.helpers.managed_services.get_used_capacity(msg)
Verify OSD percent used capacity greate than ceph_full_ratio
- Parameters:
msg (str) – message to be logged
- Returns:
The percentage of the used capacity in the cluster
- Return type:
float
- ocs_ci.helpers.managed_services.verify_client_operator_security()
Check ocs-client-operator-controller-manager permissions
Verify runAsUser is not 0
Verify SecurityContext.allowPrivilegeEscalation is set to false
Verify SecurityContext.capabilities.drop contains ALL
- ocs_ci.helpers.managed_services.verify_faas_cluster_secrets()
Verify the secrets present in FaaS cluster
- ocs_ci.helpers.managed_services.verify_faas_consumer_resources()
Verify resources specific to FaaS consumer
Verify CSV phase
Verify client endpoint
Check that there’s no storagecluster
- ocs_ci.helpers.managed_services.verify_faas_provider_resources()
Verify resources specific to FaaS provider cluster
Verify CSV phase
Verify ocs-provider-server pod is Running
Verify ocs-metrics-exporter pod is Running
Verify that Cephcluster is Ready and hostNetworking is True
Verify that the security groups are set up correctly
Check the presence of catalogsource and its state
Check the presence of subscription and its health
Check that mon PVCs have gp3-csi storageclass
Check managedFusionOffering release, usableCapacityInTiB and onboardingValidationKey
Verify the version of Prometheus
Verify aws volumes
Verify configmaps
- ocs_ci.helpers.managed_services.verify_faas_provider_storagecluster(sc_data)
Verify provider storagecluster
allowRemoteStorageConsumers: true
hostNetwork: true
- matchExpressions:
key: node-role.kubernetes.io/worker operator: Exists key: node-role.kubernetes.io/infra operator: DoesNotExist
storageProviderEndpoint
- annotations:
uninstall.ocs.openshift.io/cleanup-policy: delete uninstall.ocs.openshift.io/mode: graceful
Check the storagecluster resources limits and requests are valid
Verify the Faas provider storagecluster storages
- Parameters:
sc_data (dict) – storagecluster data dictionary
- ocs_ci.helpers.managed_services.verify_faas_provider_storagecluster_storages(sc_data)
Verify the Faas provider storagecluster storages
Check the storagecluster backingStorageClasses.
Check that the default ocs storage class is exist in the backingStorageClasses.
Check that the type of the default ocs storage class is “gp3”.
Check the defaultStorageProfile value
Check that the default storage profile is found in the StorageProfiles.
Check that the values in the storage profile are correct
- Parameters:
sc_data (dict) – The storagecluster data
- ocs_ci.helpers.managed_services.verify_faas_resources()
Verify the presence and status of resources in FaaS clusters
- ocs_ci.helpers.managed_services.verify_osd_distribution_on_provider()
Verify the OSD distribution on the provider cluster
- ocs_ci.helpers.managed_services.verify_osd_used_capacity_greater_than_expected(expected_used_capacity)
Verify OSD percent used capacity greater than ceph_full_ratio
- Parameters:
expected_used_capacity (float) – expected used capacity
- Returns:
True if used_capacity greater than expected_used_capacity, False otherwise
- Return type:
bool
- ocs_ci.helpers.managed_services.verify_pods_in_managed_fusion_namespace()
Verify the status of pods in the namespace managed-fusion
- ocs_ci.helpers.managed_services.verify_provider_aws_volumes()
Verify provider AWS volumes: 1. Volumes for OSD have size 4096 2. Volumes for OSD have IOPS 12000 3. Namespace should be fusion-storage
- ocs_ci.helpers.managed_services.verify_provider_topology()
Verify topology in a Managed Services provider cluster
Verify replica count
Verify total size
Verify OSD size
Verify worker node instance type
Verify worker node instance count
Verify OSD count
Verify OSD CPU and memory
- ocs_ci.helpers.managed_services.verify_storageclient(storageclient_name=None, namespace=None, provider_name=None, verify_sc=True)
Verify status, values and resources related to a storageclient
- Parameters:
storageclient_name (str) – Name of the storageclient to be verified. If the name is not given, it will be assumed that only one storageclient is present in the cluster.
namespace (str) – Namespace where the storageclient is present. Default value will be taken from ENV_DATA[“cluster_namespace”]
provider_name (str) – Name of the provider cluster to which the storageclient is connected.
verify_sc (bool) – True to verify the storageclassclaims and storageclasses associated with the storageclient.
- ocs_ci.helpers.managed_services.verify_storageclient_storageclass_claims(storageclient)
Verify the status of storageclassclaims and the presence of the storageclass associated with the storageclient
- Parameters:
storageclient_name (str) – Name of the storageclient
ocs_ci.helpers.performance_lib module
- ocs_ci.helpers.performance_lib.calculate_operation_time(name, times)
Calculation the total time in seconds.
- Parameters:
name (str) – The name of object to calculate the time - for logging only
times (dict) – Dictioanry of {‘start’: datetime, ‘end’: datetime, ‘total’: int}
- Returns:
the number of seconds between start time to end time.
- Return type:
float
- ocs_ci.helpers.performance_lib.csi_bulk_pvc_time_measure(interface, pvc_objs, operation, start_time)
Measure PVC time (create / delete) in the CSI driver
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on
pvc_objs (list) – list of the PVC objects which we want to mesure
operation (str) – which operation to mesure - ‘create’ / ‘delete’
start_time (str) – Formatted time from which and on to search the relevant logs
- Returns:
time in seconds which took the CSI to hendale the PVC
- Return type:
(float)
- ocs_ci.helpers.performance_lib.csi_pvc_time_measure(interface, pvc_obj, operation, start_time)
Measure PVC time (create / delete) in the CSI driver
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on
pvc_obj (PVC) – the PVC object which we want to mesure
operation (str) – which operation to mesure - ‘create’ / ‘delete’
start_time (str) – Formatted time from which and on to search the relevant logs
- Returns:
time in seconds which took the CSI to hendale the PVC
- Return type:
(float)
- ocs_ci.helpers.performance_lib.extruct_timestamp_from_log(line)
Excructing from the log line the timestamp of a message. adidng the current year since it is not exists in the log line.
- Parameters:
line (str) – a log line.
- Returns:
string of the timestamp from the log line.
- Return type:
str
- ocs_ci.helpers.performance_lib.get_logfile_names(interface, provisioning=True)
Finds names for log files pods in which logs for pvc creation are located
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on
provisioning (bool) – if True, look for the provisioner log pods
- Returns:
names of the log files relevant for searching in
- Return type:
log names (list)
- ocs_ci.helpers.performance_lib.get_pvc_provision_times(interface, pvc_name, start_time, time_type='all', op='all')
Get the starting/ending creation time of a PVC based on provisioner logs
- Parameters:
interface (str) – The interface backed the PVC
pvc_name (str / list) – Name of the PVC(s) for creation time the list will be list of pvc objects
start_time (time) – the starttime of the test to reduce log size reading
time_type (str) – the type of time to mesure : csi / total / all (csi & total)
op (str) – the operation to mesure : create / delete / all (create & delete)
- Returns:
all creation and deletion times for each pvc.
- Return type:
dictioanry
- ocs_ci.helpers.performance_lib.get_snapshot_time(snap_name, status, start_time)
Get the starting/ending creation time of a snapshot based on logs
The time and date extraction code below has been modified to read the month and day data in the logs. This fixes an error where negative time values are calculated when test runs cross midnight. Also, previous calculations would not set the year, and so the calculations were done as if the year were 1900. This is not a problem except that 1900 was not a leap year and so the next February 29th would throw ValueErrors for the whole day. To avoid this problem, changes were made to also include the current year.
Incorrect times will still be given for tests that cross over from December 31 to January 1.
- Parameters:
pvc_name (str / list) – Name of the PVC(s) for creation time the list will be list of pvc objects
status (str) – the status that we want to get - Start / End
start_time (str) – start time, starting from which the logs are searched
- Returns:
Time of searched snapshot operation
- Return type:
datetime object
- ocs_ci.helpers.performance_lib.measure_csi_snapshot_creation_time(interface, snapshot_id, start_time)
Measure PVC creation time, provided pvc name and time after which the PVC was created
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on
snapshot_id (str) – Id of the snapshot which creation time is measured
start_time (str) – Formatted time from which and on to search the relevant logs
- Returns:
(float) snapshot creation time in seconds
- ocs_ci.helpers.performance_lib.measure_pvc_creation_time(interface, pvc_name, start_time)
Measure PVC creation time, provided pvc name and time after which the PVC was created
- Parameters:
interface (str) – an interface (RBD or CephFS) to run on
pvc_name (str) – Name of the pvc for which we measure the time
start_time (str) – Formatted time from which and on to search the relevant logs
- Returns:
(float) creation time for PVC in seconds
- ocs_ci.helpers.performance_lib.measure_total_snapshot_creation_time(snap_name, start_time)
Measure Snapshot creation time based on logs
- Parameters:
snap_name (str) – Name of the snapshot for creation time measurement
start_time (str) – start time, starting from which the logs are searched
- Returns:
Creation time for the snapshot
- Return type:
float
- ocs_ci.helpers.performance_lib.pod_attach_csi_time(interface, pv_name, start_time, namespace='openshift-storage')
Get the pod start/attach csi time of a pod based on csi-rbdplugin container in csi-rbdplugin pods
- Parameters:
interface (str) – The interface backed the PVC
pv_name (str) – Name of the PV
start_time (time) – the start time of the test to reduce log size reading
namespace (str) – the tests namespace
- Returns:
Pod attachment csi time in seconds (time. time): Start time of node stage, End time of node publish
- Return type:
float
- Raises:
Exception – in case that the expected time logs are not found
- ocs_ci.helpers.performance_lib.pod_bulk_attach_csi_time(interface, pvc_objs, csi_start_time, namespace)
- Parameters:
interface (str) – The interface backed the PVC
pvc_objs (list) – List of PVC objects to which pods were attached
csi_start_time (time) – the start time of the test to reduce log size reading
namespace (str) – the tests namespace
Returns:
- ocs_ci.helpers.performance_lib.read_csi_logs(log_names, container_name, start_time)
Reading specific CSI logs starting on a specific time
- Parameters:
log_names (list) – list of pods to read log from them
container_name (str) – the name of the specific container in the pod
start_time (time) – the time stamp which will use as starting point in the log
- Returns:
list of lines from all logs
- Return type:
list
- ocs_ci.helpers.performance_lib.run_command(cmd, timeout=600, out_format='string', **kwargs)
Running command on the OS and return the STDOUT & STDERR outputs in case of argument is not string or list, return error message
- Parameters:
cmd (str/list) – the command to execute
timeout (int) – the command timeout in seconds, default is 10 Min.
out_format (str) – in which format to return the output: string / list
kwargs (dict) – dictionary of argument as subprocess get
- Returns:
all STDOUT and STDERR output as list of lines, or one string separated by NewLine
- Return type:
list or str
- ocs_ci.helpers.performance_lib.run_oc_command(cmd, namespace=None)
Running an ‘oc’ command This function is needed in Performance tests in order to be able to run a separate command within the test without creating additional objects which increases memory consumed by the test.
- Parameters:
cmd (str) – the command to run
namespace (str) – the namespace where to run the command. If None is provided then value from config will be used.
- Returns:
the results of the command as list of lines
- Return type:
list
- ocs_ci.helpers.performance_lib.string_to_time(time_string)
Converting string which present a time stamp to a time object
- Parameters:
time_string (str) – the string to convert
- Returns:
a time object
- Return type:
datetime
- ocs_ci.helpers.performance_lib.wait_for_cronjobs(namespace, cronjobs_num, msg, timeout=60)
Runs ‘oc get reclaimspacecronjob’ with the TimeoutSampler
- Parameters:
namespace (str) – namespace in which cronjobs will be looked for
cronjobs_num (int) – the exact number of cronjobs that should exist
msg (str) – Error message to be printed if the desired condition is not reached
timeout (int) – Timeout
- Returns:
Result of ‘oc get reclaimspacecronjob’ command
- Return type:
list
- ocs_ci.helpers.performance_lib.wait_for_resource_bulk_status(resource, resource_count, namespace, status, timeout=60, sleep_time=3)
Waiting for bulk of resources (from the same type) to reach the desire status
- Parameters:
resource (str) – the resoure type to wait for
resource_count (int) – the number of rusource to wait for - to wait for deleteion of resources, this should be ‘0’
namespace (str) – the namespace where the resources should be
status (str) – the status of the resources to be in.
timeout (int) – how much time to wait for the resources (in sec.)- default is 1 Minute
sleep_time (int) – how much time to wait between each iteration check - default is 3 sec.
- Returns:
‘True’ if all resources reach the desire state
- Return type:
bool
- Raises:
Exception – in case of not all resources reach the desire state.
- ocs_ci.helpers.performance_lib.write_fio_on_pod(pod_obj, file_size)
Writes IO of file_size size to a pod
- Parameters:
pod_obj – pod object to write IO
file_size – the size of the IO to be written opn pod
ocs_ci.helpers.proxy module
- ocs_ci.helpers.proxy.get_cluster_proxies()
Get http and https proxy configuration:
If both
DEPLOYMENT["proxy"]
andDEPLOYMENT["disconnected"]
are not set or set tofalse
, return empty strings for allhttp_proxy
,https_proxy
andno_proxy
.Next statements apply, if one of
DEPLOYMENT["proxy"]
orDEPLOYMENT["disconnected"]
is set to true.If configuration
ENV_DATA["http_proxy"]
andENV_DATA["no_proxy"]
(and prospectivelyENV_DATA["https_proxy"]
) exists, return the respective values. (If https_proxy not defined, use value from http_proxy.)If configuration
ENV_DATA["http_proxy"]
orENV_DATA["no_proxy"]
doesn’t exist, try to gather cluster wide proxy configuration. (If just one of those parameters exists, the configuration value have higher priority and the other value is gathered from cluster wide proxy configuration object.)Additionally if
http_proxy
is gathered from cluster wide proxy configuration andDEPLOYMENT["disconnected"]
is not defined or set tofalse
, mark the cluster as cluster behind proxy by settingDEPLOYMENT["proxy"]
totrue
.
- Returns:
(http_proxy, https_proxy, no_proxy)
- Return type:
tuple
- ocs_ci.helpers.proxy.update_container_with_proxy_env(job_pod_dict)
If applicable, update Job or Pod configuration dict with http_proxy, https_proxy and no_proxy env variables (required for disconnected clusters and clusters behind proxy).
- Parameters:
job_pod_dict (dict) – dictionary with Job or Pod configuration (updated in-place)
ocs_ci.helpers.pvc_ops module
- ocs_ci.helpers.pvc_ops.create_pvcs(multi_pvc_factory, interface, project=None, status='', storageclass=None)
- ocs_ci.helpers.pvc_ops.delete_pods(pod_objs)
Delete pods
- ocs_ci.helpers.pvc_ops.test_create_delete_pvcs(multi_pvc_factory, pod_factory, project=None)
ocs_ci.helpers.sanity_helpers module
- class ocs_ci.helpers.sanity_helpers.Sanity
Bases:
object
Class for cluster health and functional validations
- create_pvc_delete(multi_pvc_factory, project=None)
Creates and deletes all types of PVCs
- create_resources(pvc_factory, pod_factory, bucket_factory, rgw_bucket_factory, run_io=True)
Sanity validation: Create resources - pods, OBCs (RGW and MCG), PVCs (FS and RBD) and run IO
- Parameters:
pvc_factory (function) – A call to pvc_factory function
pod_factory (function) – A call to pod_factory function
bucket_factory (function) – A call to bucket_factory function
rgw_bucket_factory (function) – A call to rgw_bucket_factory function
run_io (bool) – True for run IO, False otherwise
- delete_resources()
Sanity validation - Delete resources (pods, PVCs and OBCs)
- health_check(cluster_check=True, tries=20)
Perform Ceph and cluster health checks
- obc_put_obj_create_delete(mcg_obj, bucket_factory, timeout=300)
Creates bucket then writes, reads and deletes objects
- class ocs_ci.helpers.sanity_helpers.SanityExternalCluster
Bases:
Sanity
Helpers for health check and functional validation in External mode
- class ocs_ci.helpers.sanity_helpers.SanityManagedService(create_scale_pods_and_pvcs_using_kube_job_on_ms_consumers, scale_count=None, pvc_per_pod_count=5, start_io=True, io_runtime=None, pvc_size=None, max_pvc_size=30, consumer_indexes=None)
Bases:
Sanity
Class for cluster health and functional validations for the Managed Service
- base_create_resources_on_ms_consumers()
Create resources on MS consumers. This function uses the factory “create_scale_pods_and_pvcs_using_kube_job_on_ms_consumers” for creating the resources - Create scale pods, PVCs, and run IO using a Kube job on MS consumers. If it fails to create the resources, it cleans up the current resources.
- Raises:
ocs_ci.ocs.exceptions.CommandFailed – In case of a command failed
- create_resources_on_ms_consumers(tries=1, delay=30)
Try creates resources for MS consumers ‘tries’ times with delay ‘delay’ between the iterations using the method ‘base_create_resources_on_ms_consumers’. If not specified, the default value of ‘tries’ is 1 - which means that by default, it only tries to create the resources once. In every iteration, if it fails to generate the resources, it cleans up the current resources before continuing to the next iteration.
- Parameters:
tries (int) – The number of tries to create the resources on MS consumers
delay (int) – The delay in seconds between retries
- Raises:
ocs_ci.ocs.exceptions.CommandFailed – In case of a command failed
- delete_resources_on_ms_consumers()
Delete the resources from the MS consumers
- health_check_ms(cluster_check=True, tries=20, consumers_ceph_health_check=True, consumers_tries=10)
Perform Ceph and cluster health checks on Managed Service cluster
- Parameters:
cluster_check (bool) – If true, perform the cluster check. False, otherwise.
tries (int) – The number of tries to perform ceph health check
consumers_ceph_health_check (bool) – If true and the cluster is an MS provider cluster, perform ceph health check on the ms consumer clusters.
consumers_tries – The number of tries to perform ceph health check on the MS consumer clusters
- class ocs_ci.helpers.sanity_helpers.SanityProviderMode(create_scale_pods_and_pvcs_using_kube_job_on_hci_clients, scale_count=None, pvc_per_pod_count=5, start_io=True, io_runtime=None, pvc_size=None, max_pvc_size=30, client_indices=None)
Bases:
Sanity
Class for cluster health and functional validations for the Provider mode platform
- base_create_resources_on_clients()
Create resources on clients. This function uses the factory “create_scale_pods_and_pvcs_using_kube_job_on_hci_clients” for creating the resources - Create scale pods, PVCs, and run IO using a Kube job on HCI clients. If it fails to create the resources, it cleans up the current resources.
- Raises:
ocs_ci.ocs.exceptions.CommandFailed – In case of a command failed
- create_resources_on_clients(tries=1, delay=30)
Try creates resources for client ‘tries’ times with delay ‘delay’ between the iterations using the method ‘base_create_resources_on_hci_clients’. If not specified, the default value of ‘tries’ is 1 - which means that by default, it only tries to create the resources once. In every iteration, if it fails to generate the resources, it cleans up the current resources before continuing to the next iteration.
- Parameters:
tries (int) – The number of tries to create the resources on the clients
delay (int) – The delay in seconds between retries
- Raises:
ocs_ci.ocs.exceptions.CommandFailed – In case of a command failed
- delete_resources_on_clients(**kwargs)
- health_check_provider_mode(cluster_check=True, tries=20, run_client_clusters_health_check=True)
Perform Ceph and cluster health checks on the cluster
- Parameters:
cluster_check (bool) – If true, perform the cluster check. False, otherwise.
tries (int) – The number of tries to perform ceph health check
run_client_clusters_health_check (bool) – If true and the cluster is a provider cluster, run the cluster health check on the client clusters.
ocs_ci.helpers.stretchcluster_helper module
- ocs_ci.helpers.stretchcluster_helper.recover_from_ceph_stuck(sc_obj)
To recover from the ceph stuck issue, we need to reset the connection score for each mon
- Parameters:
sc_obj (StretchCluster Object) – A StretchCluster Object
- ocs_ci.helpers.stretchcluster_helper.recover_workload_pods_post_recovery(sc_obj, pods_not_running)
There seems to be a known issue https://bugzilla.redhat.com/show_bug.cgi?id=2244353 and this will apply the workaround to resolve that issue
- Parameters:
sc_obj (StretchCluster Object) – A stretch cluster object created for the test calling this function
pods_not_running (List) – A list of Pod objects that are not in Running state