ocs_ci.ocs package

Submodules

ocs_ci.ocs.amq module

AMQ Class to run amq specific tests

class ocs_ci.ocs.amq.AMQ(**kwargs)

Bases: object

Workload operation using AMQ

cleanup(kafka_namespace='myproject', tiller_namespace='tiller')

Clean up function, will start to delete from amq cluster operator then amq-connector, persistent, bridge, at the end it will delete the created namespace

Parameters
  • kafka_namespace (str) – Created namespace for amq

  • tiller_namespace (str) – Created namespace for benchmark

create_consumer_pod(num_of_pods=1, value='10000')

Creates producer pods

Parameters
  • num_of_pods (int) – Number of consumer pods to be created

  • value (str) – Number of messages to be received

Returns: consumer pod object

create_kafka_topic(name='my-topic', partitions=1, replicas=1)

Creates kafka topic

Parameters
  • name (str) – Name of the kafka topic

  • partitions (int) – Number of partitions

  • replicas (int) – Number of replicas

Return: kafka_topic object

create_kafka_user(name='my-user')

Creates kafka user

Parameters

name (str) – Name of the kafka user

Return: kafka_user object

create_messaging_on_amq(topic_name='my-topic', user_name='my-user', partitions=1, replicas=1, num_of_producer_pods=1, num_of_consumer_pods=1, value='10000')

Creates workload using Open Messaging tool on amq cluster

Parameters
  • topic_name (str) – Name of the topic to be created

  • user_name (str) – Name of the user to be created

  • partitions (int) – Number of partitions of topic

  • replicas (int) – Number of replicas of topic

  • num_of_producer_pods (int) – Number of producer pods to be created

  • num_of_consumer_pods (int) – Number of consumer pods to be created

  • value (str) – Number of messages to be sent and received

create_namespace(namespace)

create namespace for amq

Parameters

namespace (str) – Namespace for amq pods

create_producer_pod(num_of_pods=1, value='10000')

Creates producer pods

Parameters
  • num_of_pods (int) – Number of producer pods to be created

  • value (str) – Number of the messages to be sent

Returns: producer pod object

export_amq_output_to_gsheet(amq_output, sheet_name, sheet_index)

Collect amq data to google spreadsheet

Parameters
  • amq_output (dict) – amq output in dict

  • sheet_name (str) – Name of the sheet

  • sheet_index (int) – Index of sheet

is_amq_pod_running(pod_pattern, expected_pods, namespace='myproject')

The function checks if provided pod_pattern finds a pod and if the status is running or not

Parameters
  • pod_pattern (str) – the pattern for pod

  • expected_pods (int) – Number of pods

  • namespace (str) – Namespace for amq pods

Returns

status of pod: True if found pod is running

Return type

bool

run_amq_benchmark(benchmark_pod_name='benchmark', kafka_namespace='myproject', tiller_namespace='tiller', num_of_clients=8, worker=None, timeout=1800, amq_workload_yaml=None, run_in_bg=False)

Run benchmark pod and get the results

Parameters
  • benchmark_pod_name (str) – Name of the benchmark pod

  • kafka_namespace (str) – Namespace where kafka cluster created

  • tiller_namespace (str) – Namespace where tiller pod needs to be created

  • num_of_clients (int) – Number of clients to be created

  • worker (str) – Loads to create on workloads separated with commas e.g http://benchmark-worker-0.benchmark-worker:8080, http://benchmark-worker-1.benchmark-worker:8080

  • timeout (int) – Time to complete the run

  • amq_workload_yaml (dict) – Contains amq workloads information keys and values :name (str): Name of the workloads :topics (int): Number of topics created :partitions_per_topic (int): Number of partitions per topic :message_size (int): Message size :payload_file (str): Load to run on workload :subscriptions_per_topic (int): Number of subscriptions per topic :consumer_per_subscription (int): Number of consumers per subscription :producers_per_topic (int): Number of producers per topic :producer_rate (int): Producer rate :consumer_backlog_sizegb (int): Size of block in gb :test_duration_minutes (int): Time to run the workloads

  • run_in_bg (bool) – On true the workload will run in background

Returns

Returns benchmark run information if run_in_bg is False.

Otherwise a thread of the amq workload execution

Return type

result (str/Thread obj)

run_amq_workload(command, benchmark_pod_name, tiller_namespace, timeout)

Runs amq workload in bg

Parameters
  • command (str) – Command to run on pod

  • benchmark_pod_name (str) – Pod name

  • tiller_namespace (str) – Namespace of pod

  • timeout (int) – Time to complete the run

Returns

Returns benchmark run information

Return type

result (str)

run_in_bg(namespace='myproject', value='10000', since_time=1800)

Validate messages are produced and consumed in bg

Parameters
  • namespace (str) – Namespace of the pod

  • value (str) – Number of messages to be sent and received

  • since_time (int) – Number of seconds to required to sent and receive msg

setup_amq_cluster(sc_name, namespace='myproject', size=100, replicas=3)

Creates amq cluster with persistent storage.

Parameters
  • sc_name (str) – Name of sc

  • namespace (str) – Namespace for amq cluster

  • size (int) – Size of the storage

  • replicas (int) – Number of kafka and zookeeper pods to be created

setup_amq_cluster_operator(namespace='myproject')

Function to setup amq-cluster_operator, the file is pulling from github it will make sure cluster-operator pod is running

Parameters

namespace (str) – Namespace for AMQ pods

setup_amq_kafka_bridge()

Function to setup amq-kafka, the file file is pulling from github it will make kind: KafkaBridge and will make sure the pod status is running

Return: kafka_bridge object

setup_amq_kafka_connect()

The function is to setup amq-kafka-connect, the yaml file is pulling from github it will make kind: KafkaConnect and will make sure the status is running

Returns: kafka_connect object

setup_amq_kafka_persistent(sc_name, size=100, replicas=3)

Function to setup amq-kafka-persistent, the file is pulling from github it will make kind: Kafka and will make sure the status is running

Parameters
  • sc_name (str) – Name of sc

  • size (int) – Size of the storage in Gi

  • replicas (int) – Number of kafka and zookeeper pods to be created

return : kafka_persistent

validate_amq_benchmark(result, amq_workload_yaml, benchmark_pod_name='benchmark')

Validates amq benchmark run

Parameters
  • result (str) – Benchmark run information

  • amq_workload_yaml (dict) – AMQ workload information

  • benchmark_pod_name (str) – Name of the benchmark pod

Returns

Returns the dict output on success, Otherwise none

Return type

res_dict (dict)

validate_messages_are_consumed(namespace='myproject', value='10000', since_time=1800)

Validates if all messages are received in consumer pod

Parameters
  • namespace (str) – Namespace of the pod

  • value (str) – Number of messages are recieved

  • since_time (int) – Number of seconds to required to receive the msg

Raises exception on failures

validate_messages_are_produced(namespace='myproject', value='10000', since_time=1800)

Validates if all messages are sent in producer pod

Parameters
  • namespace (str) – Namespace of the pod

  • value (str) – Number of messages are sent

  • since_time (int) – Number of seconds to required to sent the msg

Raises exception on failures

validate_msg(pod, namespace='myproject', value='10000', since_time=1800)

Validate if messages are sent or received

Parameters
  • pod (str) – Name of the pod

  • namespace (str) – Namespace of the pod

  • value (str) – Number of messages are sent

  • since_time (int) – Number of seconds to required to sent the msg

Returns

True if all messages are sent/received

Return type

bool

ocs_ci.ocs.api_client module

A module for implementing specific api client for interacting with openshift or kubernetes cluster

APIClientBase is an abstract base class which imposes a contract on methods to be implemented in derived classes which are specific to api client

class ocs_ci.ocs.api_client.APIClientBase

Bases: object

Abstract base class for all api-client classes

This is an abstract base class and api-client specific classes should implement all the methods for interacting with openshift cluster

abstract api_create()
abstract api_delete()
abstract api_get()
abstract api_patch()
abstract api_post()
abstract create_service(**kw)

Create an openshift service

Parameters

**kw – ex body=”content”, namespace=’ocnamespace’

Returns

Response from api server

Note: Returns could be tricky because it varies from client to client. If its oc-cli then extra work needs to be done in the specific implementation.

Return type

dict

abstract get_labels(pod_name, pod_namespace)

Get the openshift labels on a given pod

Parameters
  • pod_name (str) – Name of pod for which labels to be fetched

  • pod_namespace (str) – namespace of pod where this pod lives

Raises

NotImplementedError – if function not implemented by client

Returns

Labels associated with pod

Return type

dict

abstract get_pods(**kwargs)

Because of discrepancies in IO format of each client api leaving this to be implemented by specific client

Parameters

**kwargs – ex: namespace=’namespace’,openshift namespace from which we need pods

Raises

NotImplementedError – if client has not implemented this function.

Returns

A list of pod names

Return type

pod_names (list)

abstract property name

Concrete class will have respective api-client name

class ocs_ci.ocs.api_client.KubeClient

Bases: ocs_ci.ocs.api_client.APIClientBase

All activities using upstream kubernetes python client

property name

Concrete class will have respective api-client name

class ocs_ci.ocs.api_client.OCCLIClient

Bases: ocs_ci.ocs.api_client.APIClientBase

All activities using oc-cli.

This implements all functionalities like create, patch, delete using oc commands.

property name

Concrete class will have respective api-client name

class ocs_ci.ocs.api_client.OCRESTClient

Bases: ocs_ci.ocs.api_client.APIClientBase

All activities using openshift REST client

api_create(**kw)
api_delete(**kw)
api_get(**kw)
api_patch(**kw)
api_post(**kw)
create_service(**kw)
Parameters

kw – ex: body={body} for the request which has service spec

Returns

ResourceInstance

get_labels(pod_name, pod_namespace)

Get labels from a specific pod

Parameters
  • pod_name (str) – Name of the pod

  • pod_namespace (str) – namespace where this pod lives

Raises

NotFoundError – If resource not found

Returns

All the labels on a pod

Return type

dict

get_pods(**kwargs)

Get pods in specific namespace or across oc cluster

Parameters

**kwargs – ex: namespace=rook-ceph, label_selector=’x==y’

Returns

of pods names,if no namespace provided then this function

returns all pods across openshift cluster

Return type

list

property name

Concrete class will have respective api-client name

ocs_ci.ocs.api_client.get_api_client(client_name)

Get instance of corresponding api-client object with given name

Parameters

client_name (str) – name of the api client to be instantiated

Returns

api client object

ocs_ci.ocs.bucket_utils module

Helper functions file for working with object buckets

ocs_ci.ocs.bucket_utils.abort_all_multipart_upload(s3_obj, bucketname, object_key)

Abort all Multipart Uploads for this Bucket

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

Returns

List of aborted upload ids

Return type

list

ocs_ci.ocs.bucket_utils.abort_multipart(s3_obj, bucketname, object_key, upload_id)

Aborts a Multipart Upload for this Bucket

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • upload_id (str) – Multipart Upload-ID

Returns

aborted upload id

Return type

str

ocs_ci.ocs.bucket_utils.bucket_read_api(mcg_obj, bucket_name)

Fetches the bucket metadata like size, tiers etc

Parameters
  • mcg_obj (obj) – MCG object

  • bucket_name (str) – Name of the bucket

Returns

Bucket policy response

Return type

dict

ocs_ci.ocs.bucket_utils.check_pv_backingstore_status(backingstore_name, namespace=None, desired_status=['`OPTIMAL`', '`LOW_CAPACITY`'])

check if existing pv backing store is in OPTIMAL state

Parameters
  • backingstore_name (str) – backingstore name

  • namespace (str) – backing store’s namespace

  • desired_status (str) – desired state for the backing store, if None is given then desired

  • the Healthy status (is) –

Returns

True if backing store is in the desired state

Return type

bool

ocs_ci.ocs.bucket_utils.cli_create_aws_backingstore(mcg_obj, cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with aws underlying storage using noobaa cli command

Parameters
  • mcg_obj (MCG) – Used for execution for the NooBaa CLI command

  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.cli_create_azure_backingstore(mcg_obj, cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with aws underlying storage using noobaa cli command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.cli_create_google_backingstore(mcg_obj, cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with GCP underlying storage using a NooBaa CLI command

Parameters
  • mcg_obj (MCG) – Used for execution for the NooBaa CLI command

  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.cli_create_ibmcos_backingstore(mcg_obj, cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with IBM COS underlying storage using a NooBaa CLI command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.cli_create_pv_backingstore(mcg_obj, backingstore_name, vol_num, size, storage_class)

Create a new backingstore with pv underlying storage using noobaa cli command

Parameters
  • backingstore_name (str) – backingstore name

  • vol_num (int) – number of pv volumes

  • size (int) – each volume size in GB

  • storage_class (str) – which storage class to use

ocs_ci.ocs.bucket_utils.cli_create_s3comp_backingstore(cld_mgr, backingstore_name, uls_name, region)
ocs_ci.ocs.bucket_utils.compare_directory(awscli_pod, original_dir, result_dir, amount=2)

Compares object checksums on original and result directories

Args:

awscli_pod (pod): A pod running the AWS CLI tools original_dir (str): original directory name result_dir (str): result directory name amount (int): Number of test objects to create

ocs_ci.ocs.bucket_utils.complete_multipart_upload(s3_obj, bucketname, object_key, upload_id, parts)

Completes the Multipart Upload

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • upload_id (str) – Multipart Upload-ID

  • parts (list) – List containing the uploaded parts which includes ETag and part number

Returns

Dictionary containing the completed multipart upload details

Return type

dict

ocs_ci.ocs.bucket_utils.craft_s3_command(cmd, mcg_obj=None, api=False, signed_request_creds=None)

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

  • signed_request_creds – a dictionary containing AWS S3 creds for a signed request

Returns

The crafted command, ready to be executed on the pod

Return type

str

ocs_ci.ocs.bucket_utils.create_multipart_upload(s3_obj, bucketname, object_key)

Initiates Multipart Upload

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket on which multipart upload to be initiated on

  • object_key (str) – Unique object Identifier

Returns

Multipart Upload-ID

Return type

str

ocs_ci.ocs.bucket_utils.del_objects(uploaded_objects_paths, awscli_pod, mcg_obj)

Deleting objects from bucket

Parameters
  • uploaded_objects_paths (list) – List of object paths

  • awscli_pod (pod) – A pod running the AWSCLI tools

  • mcg_obj (obj) – An MCG object containing the MCG S3 connection credentials

ocs_ci.ocs.bucket_utils.delete_bucket_policy(s3_obj, bucketname)

Deletes bucket policy

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

Returns

Delete Bucket policy response

Return type

dict

ocs_ci.ocs.bucket_utils.get_bucket_available_size(mcg_obj, bucket_name)

Function to get the bucket available size

Parameters
  • mcg_obj (obj) – MCG object

  • bucket_name (str) – Name of the bucket

Returns

Available size in the bucket

Return type

int

ocs_ci.ocs.bucket_utils.get_bucket_policy(s3_obj, bucketname)

Gets bucket policy from a bucket

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

Returns

Get Bucket policy response

Return type

dict

ocs_ci.ocs.bucket_utils.get_full_path_object(downloaded_files, bucket_name)

Getting full of object in the bucket

Parameters
  • downloaded_files (list) – List of downloaded files

  • bucket_name (str) – Name of the bucket

Returns

List of full paths of objects

Return type

uploaded_objects_paths (list)

ocs_ci.ocs.bucket_utils.get_rgw_restart_counts()

Gets the restart count of the RGW pods

Returns

restart counts of RGW pods

Return type

list

ocs_ci.ocs.bucket_utils.list_multipart_upload(s3_obj, bucketname)

Lists the multipart upload details on a bucket

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

Returns

Dictionary containing the multipart upload details

Return type

dict

ocs_ci.ocs.bucket_utils.list_uploaded_parts(s3_obj, bucketname, object_key, upload_id)

Lists uploaded parts and their ETags

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • upload_id (str) – Multipart Upload-ID

Returns

Dictionary containing the multipart upload details

Return type

dict

ocs_ci.ocs.bucket_utils.namespace_bucket_update(mcg_obj, bucket_name, read_resource, write_resource)

Edits MCG namespace bucket resources

Parameters
  • mcg_obj (obj) – An MCG object containing the MCG S3 connection credentials

  • bucket_name (str) – Name of the bucket

  • read_resource (list) – Resource names to provide read access

  • write_resource (str) – Resource name to provide write access

ocs_ci.ocs.bucket_utils.obc_io_create_delete(mcg_obj, awscli_pod, bucket_factory)

Running IOs on OBC interface :param mcg_obj: An MCG object containing the MCG S3 connection credentials :type mcg_obj: obj :param awscli_pod: A pod running the AWSCLI tools :type awscli_pod: pod :param bucket_factory: Calling this fixture creates a new bucket(s)

ocs_ci.ocs.bucket_utils.oc_create_aws_backingstore(cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with aws underlying storage using oc create command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.oc_create_azure_backingstore(cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with Azure underlying storage using oc create command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.oc_create_google_backingstore(cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with GCP underlying storage using oc create command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.oc_create_ibmcos_backingstore(cld_mgr, backingstore_name, uls_name, region)

Create a new backingstore with IBM COS underlying storage using oc create command

Parameters
  • cld_mgr (CloudManager) – holds secret for backingstore creation

  • backingstore_name (str) – backingstore name

  • uls_name (str) – underlying storage name

  • region (str) – which region to create backingstore (should be the same as uls)

ocs_ci.ocs.bucket_utils.oc_create_pv_backingstore(backingstore_name, vol_num, size, storage_class)

Create a new backingstore with pv underlying storage using oc create command

Parameters
  • backingstore_name (str) – backingstore name

  • vol_num (int) – number of pv volumes

  • size (int) – each volume size in GB

  • storage_class (str) – which storage class to use

ocs_ci.ocs.bucket_utils.oc_create_s3comp_backingstore(cld_mgr, backingstore_name, uls_name, region)
ocs_ci.ocs.bucket_utils.put_bucket_policy(s3_obj, bucketname, policy)

Adds bucket policy to a bucket

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • policy (json) – Bucket policy in Json format

Returns

Bucket policy response

Return type

dict

ocs_ci.ocs.bucket_utils.retrieve_anon_s3_resource()

Returns an anonymous boto3 S3 resource by creating one and disabling signing

Disabling signing isn’t documented anywhere, and this solution is based on a comment by an AWS developer: https://github.com/boto/boto3/issues/134#issuecomment-116766812

Returns

An anonymous S3 resource

Return type

boto3.resource()

ocs_ci.ocs.bucket_utils.retrieve_test_objects_to_pod(podobj, target_dir)

Downloads all the test objects to a given directory in a given pod.

Parameters
  • podobj (OCS) – The pod object to download the objects to

  • target_dir – The fully qualified path of the download target folder

Returns

A list of the downloaded objects’ names

Return type

list

ocs_ci.ocs.bucket_utils.retrieve_verification_mode()
ocs_ci.ocs.bucket_utils.rm_object_recursive(podobj, target, mcg_obj, option='')

Remove bucket objects with –recursive option

Parameters
  • podobj (OCS) – The pod on which to execute the commands and download the objects to

  • target (str) – Fully qualified bucket target path

  • mcg_obj (MCG, optional) – The MCG object to use in case the target or source are in an MCG

  • option (str) – Extra s3 remove command option

ocs_ci.ocs.bucket_utils.s3_copy_object(s3_obj, bucketname, source, object_key)

Boto3 client based copy object

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • source (str) – Source object key. eg: ‘<bucket>/<key>

  • object_key (str) – Unique object Identifier for copied object

Returns

Copy object response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_delete_bucket_website(s3_obj, bucketname)

Boto3 client based Delete bucket website function

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

Returns

DeleteBucketWebsite response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_delete_object(s3_obj, bucketname, object_key, versionid=None)

Simple Boto3 client based Delete object

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • versionid (str) – Unique version number of an object

Returns

Delete object response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_delete_objects(s3_obj, bucketname, object_keys)

Boto3 client based delete objects

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_keys (list) – The objects to delete. Format: {‘Key’: ‘object_key’, ‘VersionId’: ‘’}

Returns

delete objects response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_get_bucket_versioning(s3_obj, bucketname, s3_client=None)

Boto3 client based Get Bucket Versioning function

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • s3_client – Any s3 client resource

Returns

GetBucketVersioning response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_get_bucket_website(s3_obj, bucketname)

Boto3 client based Get bucket website function

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

Returns

GetBucketWebsite response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_get_object(s3_obj, bucketname, object_key, versionid='')

Simple Boto3 client based Get object

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • versionid (str) – Unique version number of an object

Returns

Get object response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_get_object_acl(s3_obj, bucketname, object_key)

Boto3 client based get_object_acl operation

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier for copied object

Returns

get object acl response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_head_object(s3_obj, bucketname, object_key)

Boto3 client based head_object operation to retrieve only metadata

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier for copied object

Returns

head object response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_io_create_delete(mcg_obj, awscli_pod, bucket_factory)

Running IOs on s3 bucket :param mcg_obj: An MCG object containing the MCG S3 connection credentials :type mcg_obj: obj :param awscli_pod: A pod running the AWSCLI tools :type awscli_pod: pod :param bucket_factory: Calling this fixture creates a new bucket(s)

ocs_ci.ocs.bucket_utils.s3_list_object_versions(s3_obj, bucketname, prefix='')

Boto3 client based list object Versionfunction

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • prefix (str) – Object key prefix

Returns

List object version response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_list_objects_v1(s3_obj, bucketname, prefix='', delimiter='', max_keys=1000, marker='')

Boto3 client based list object version1

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • prefix (str) – Limits the response to keys that begin with the specified prefix.

  • delimiter (str) – Character used to group keys.

  • max_keys (int) – Maximum number of keys returned in the response. Default 1,000 keys.

  • marker (str) – key to start with when listing objects in a bucket.

Returns

list object v1 response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_list_objects_v2(s3_obj, bucketname, prefix='', delimiter='', max_keys=1000, con_token='', fetch_owner=False)

Boto3 client based list object version2

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • prefix (str) – Limits the response to keys that begin with the specified prefix.

  • delimiter (str) – Character used to group keys.

  • max_keys (int) – Maximum number of keys returned in the response. Default 1,000 keys.

  • con_token (str) – Token used to continue the list

  • fetch_owner (bool) – Unique object Identifier

Returns

list object v2 response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_put_bucket_versioning(s3_obj, bucketname, status='Enabled', s3_client=None)

Boto3 client based Put Bucket Versioning function

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • status (str) – ‘Enabled’ or ‘Suspended’. Default ‘Enabled’

  • s3_client – Any s3 client resource

Returns

PutBucketVersioning response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_put_bucket_website(s3_obj, bucketname, website_config)

Boto3 client based Put bucket website function

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • website_config (dict) – Website configuration info

Returns

PutBucketWebsite response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_put_object(s3_obj, bucketname, object_key, data, content_type='')

Simple Boto3 client based Put object

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • object_key (str) – Unique object Identifier

  • data (str) – string content to write to a new S3 object

  • content_type (str) – Type of object data. eg: html, txt etc,

Returns

Put object response

Return type

dict

ocs_ci.ocs.bucket_utils.s3_upload_part_copy(s3_obj, bucketname, copy_source, object_key, part_number, upload_id)

Boto3 client based upload_part_copy operation

Parameters
  • s3_obj (obj) – MCG or OBC object

  • bucketname (str) – Name of the bucket

  • copy_source (str) – Name of the source bucket and key name. {bucket}/{key}

  • part_number (int) – Part number

  • upload_id (str) – Upload Id

  • object_key (str) – Unique object Identifier for copied object

Returns

upload_part_copy response

Return type

dict

ocs_ci.ocs.bucket_utils.setup_base_objects(awscli_pod, original_dir, result_dir, amount=2)

Prepares two directories and populate one of them with objects

Args:

awscli_pod (Pod): A pod running the AWS CLI tools original_dir (str): original directory name result_dir (str): result directory name amount (Int): Number of test objects to create

ocs_ci.ocs.bucket_utils.sync_object_directory(podobj, src, target, s3_obj=None, signed_request_creds=None)

Syncs objects between a target and source directories

Parameters
  • podobj (OCS) – The pod on which to execute the commands and download the objects to

  • src (str) – Fully qualified object source path

  • target (str) – Fully qualified object target path

  • s3_obj (MCG, optional) – The MCG object to use in case the target or source are in an MCG

  • signed_request_creds (dictionary, optional) – the access_key, secret_key, endpoint and region to use when willing to send signed aws s3 requests

ocs_ci.ocs.bucket_utils.upload_parts(mcg_obj, awscli_pod, bucketname, object_key, body_path, upload_id, uploaded_parts)

Uploads individual parts to a bucket

Parameters
  • mcg_obj (obj) – An MCG object containing the MCG S3 connection credentials

  • awscli_pod (pod) – A pod running the AWSCLI tools

  • bucketname (str) – Name of the bucket to upload parts on

  • object_key (list) – Unique object Identifier

  • body_path (str) – Path of the directory on the aws pod which contains the parts to be uploaded

  • upload_id (str) – Multipart Upload-ID

  • uploaded_parts (list) – list containing the name of the parts to be uploaded

Returns

List containing the ETag of the parts

Return type

list

ocs_ci.ocs.bucket_utils.verify_s3_object_integrity(original_object_path, result_object_path, awscli_pod)

Verifies checksum between original object and result object on an awscli pod

Parameters
  • original_object_path (str) – The Object that is uploaded to the s3 bucket

  • result_object_path (str) – The Object that is downloaded from the s3 bucket

  • awscli_pod (pod) – A pod running the AWSCLI tools

Returns

True if checksum matches, False otherwise

Return type

bool

ocs_ci.ocs.bucket_utils.wait_for_pv_backingstore(backingstore_name, namespace=None)

wait for existing pv backing store to reach OPTIMAL state

Parameters
  • backingstore_name (str) – backingstore name

  • namespace (str) – backing store’s namespace

ocs_ci.ocs.bucket_utils.write_individual_s3_objects(mcg_obj, awscli_pod, bucket_factory, downloaded_files, target_dir, bucket_name=None)

Writes objects one by one to an s3 bucket

Parameters
  • mcg_obj (obj) – An MCG object containing the MCG S3 connection credentials

  • awscli_pod (pod) – A pod running the AWSCLI tools

  • bucket_factory – Calling this fixture creates a new bucket(s)

  • downloaded_files (list) – List of downloaded object keys

  • target_dir (str) – The fully qualified path of the download target folder

  • bucket_name (str) – Name of the bucket (default: none)

ocs_ci.ocs.clients module

class ocs_ci.ocs.clients.WinNode(**kw)

Bases: object

check_disk(number)
connect_to_target(ip, username, password)
create_disk(number)
create_fio_job_options(job_options)
create_new_target(ip, port=3260)
delete_target()
disconnect_from_target()
get_iscsi_initiator_name()
run_fio_test()
start_iscsi_initiator()
win_exec(ps_command, timeout=180)

ocs_ci.ocs.cluster module

A module for all rook functionalities and abstractions.

This module has rook related classes, support for functionalities to work with rook cluster. This works with assumptions that an OCP cluster is already functional and proper configurations are made for interaction.

class ocs_ci.ocs.cluster.CephCluster

Bases: object

Handles all cluster related operations from ceph perspective

This class has depiction of ceph cluster. Contains references to pod objects which represents ceph cluster entities.

pods

A list of ceph cluster related pods

Type

list

cluster_name

Name of ceph cluster

Type

str

namespace

openshift Namespace where this cluster lives

Type

str

calc_trim_mean_throughput(samples=8)

Calculate the cluster average throughput out of a few samples

Parameters

samples (int) – The number of samples to take

Returns

The average cluster throughput

Return type

float

check_ceph_pool_used_space(cbp_name)

Check for the used space of a pool in cluster

Returns:

used_in_gb (float): Amount of used space in pool (in GBs)

Raises:

UnexpectedBehaviour: If used size keeps varying in Ceph status

cluster_health_check(timeout=None)

Check overall cluster health. Relying on health reported by CephCluster.get()

Parameters

timeout (int) – in seconds. By default timeout value will be scaled based on number of ceph pods in the cluster. This is just a crude number. Its been observed that as the number of pods increases it takes more time for cluster’s HEALTH_OK.

Returns

True if “HEALTH_OK” else False

Return type

bool

Raises

CephHealthException – if cluster is not healthy

property cluster_name
create_user(username, caps)

Create a ceph user in the cluster

Parameters
  • username (str) – ex client.user1

  • caps (str) – ceph caps ex: mon ‘allow r’ osd ‘allow rw’

Returns

return value of get_user_key()

get_admin_key()
Returns

base64 encoded key

Return type

adminkey (str)

get_ceph_capacity()

The function gets the total mount of storage capacity of the ocs cluster. the calculation is <Num of OSD> * <OSD size> / <replica number> it will not take into account the current used capacity.

Returns

Total storage capacity in GiB (GiB is for development environment)

Return type

int

get_ceph_cluster_iops()

The function gets the IOPS from the ocs cluster

Returns

Total IOPS in the cluster

get_ceph_health(detail=False)

Exec ceph health cmd on tools pod and return the status of the ceph cluster.

Parameters

detail (bool) – If True the ‘ceph health detail’ is executed

Returns

Output of the ceph health command.

Return type

str

get_ceph_status(format=None)

Exec ceph status cmd on tools pod and return its output.

Parameters

format (str) – Format of the output (e.g. json-pretty, json, plain)

Returns

Output of the ceph status command.

Return type

str

get_cluster_throughput()

Function to get the throughput of ocs cluster

Returns

The write throughput of the cluster in MiB/s

Return type

float

get_iops_percentage(osd_size=2)

The function calculates the IOPS percentage of the cluster depending on number of osds in the cluster

Parameters

osd_size (int) – Size of 1 OSD in Ti

Returns

IOPS percentage of the OCS cluster

get_mons_from_cluster()

Getting the list of mons from the cluster

Returns

Returns the mons from the cluster

Return type

available_mon (list)

get_rebalance_status()

This function gets the rebalance status

Returns

True if rebalance is completed, False otherwise

Return type

bool

get_throughput_percentage()

Function to get throughput percentage of the ocs cluster

Returns

Throughput percentage of the cluster

get_user_key(user)
Parameters

user (str) – ceph username ex: client.user1

Returns

base64 encoded user key

Return type

key (str)

is_health_ok()
Returns

True if “HEALTH_OK” else False

Return type

bool

property mcg_obj
mds_change_count(new_count)

Change mds count in the cluster

Parameters

new_count (int) – Absolute number of active mdss required

mds_health_check(count)

MDS health check based on pod count

Parameters

count (int) – number of pods expected

Raises

MDACountException – if pod count doesn’t match

mon_change_count(new_count)

Change mon count in the cluster

Parameters

new_count (int) – Absolute number of mons required

mon_health_check(count)

Mon health check based on pod count

Parameters

count (int) – Expected number of mon pods

Raises

MonCountException – if mon pod count doesn’t match

property namespace
noobaa_health_check()

Check Noobaa health

property pods
remove_mon_from_cluster()

Removing the mon pod from deployment

Returns

True if removal of mon is successful, False otherwise

Return type

remove_mon(bool)

scan_cluster()

Get accurate info on current state of pods

set_noout()

Set noout flag for maintainance

static set_port(pod)

Set port attribute on pod. port attribute for mon is required for secrets and this attrib is not a member for original pod class.

Parameters

pod (Pod) – Pod object without ‘port’ attribute

Returns

A modified pod object with ‘port’ attribute set

Return type

pod(Pod)

time_taken_to_complete_rebalance(timeout=600)

This function calculates the time taken to complete rebalance

Parameters

timeout (int) – Time to wait for the completion of rebalance

Returns

Time taken in minutes for the completion of rebalance

Return type

int

unset_noout()

unset noout flag for peering

wait_for_noobaa_health_ok(tries=60, delay=5)

Wait for Noobaa health to be OK

wait_for_rebalance(timeout=600)

Wait for re-balance to complete

Parameters

timeout (int) – Time to wait for the completion of re-balance

Returns

True if rebalance completed, False otherwise

Return type

bool

class ocs_ci.ocs.cluster.CephClusterExternal

Bases: ocs_ci.ocs.cluster.CephCluster

Handle all external ceph cluster related functionalities Assumption: Cephcluster Kind resource exists

cluster_health_check(timeout=300)

This would be a comprehensive cluster health check which includes checking pods, external ceph cluster health. raise exceptions.CephHealthException(“Cluster health is NOT OK”)

property cluster_name
property namespace
validate_pvc()

Check whether all PVCs are in bound state

wait_for_cluster_cr()

we have to wait for cluster cr to appear else it leads to list index out of range error

wait_for_nooba_cr()
class ocs_ci.ocs.cluster.CephHealthMonitor(ceph_cluster, sleep=5)

Bases: threading.Thread

Context manager class for monitoring ceph health status of CephCluster. If CephCluster will get to HEALTH_ERROR state it will save the ceph status to health_error_status variable and will stop monitoring.

log_error_status()
run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

ocs_ci.ocs.cluster.calculate_compression_ratio(pool_name)

Calculating the compression of data on RBD pool

Parameters

pool_name (str) – the name of the pool to calculate the ratio on

Returns

the compression ratio in percentage

Return type

int

ocs_ci.ocs.cluster.check_ceph_osd_tree()

Checks whether an OSD tree is created/modified correctly. It is a summary of the previous functions: ‘check_osd_tree_1az_vmware’, ‘check_osd_tree_3az_cloud’, ‘check_osd_tree_1az_cloud’.

Returns

True, if the ceph osd tree is formed correctly. Else False

Return type

bool

ocs_ci.ocs.cluster.check_ceph_osd_tree_after_node_replacement()

Check the ceph osd tree after the process of node replacement.

Returns

True if the ceph osd tree formation is correct, and all the OSD’s are up. Else False

Return type

bool

ocs_ci.ocs.cluster.check_osd_tree_1az_cloud(osd_tree, number_of_osds)

Checks whether an OSD tree is created/modified correctly. This can be used as a verification step for deployment and cluster expansion tests. This function is specifically for ocs cluster created on 1 AZ config

Parameters
  • osd_tree (dict) – Dictionary of the values which represent ‘osd tree’.

  • number_of_osds (int) – total number of osds in the cluster

Returns

True, if the ceph osd tree is formed correctly. Else False

Return type

Boolean

ocs_ci.ocs.cluster.check_osd_tree_1az_vmware(osd_tree, number_of_osds)

Checks whether an OSD tree is created/modified correctly. This can be used as a verification step for deployment and cluster expansion tests. This function is specifically for ocs cluster created on 1 AZ VMWare setup

Parameters
  • osd_tree (dict) – Dictionary of the values which represent ‘osd tree’.

  • number_of_osds (int) – total number of osds in the cluster

Returns

True, if the ceph osd tree is formed correctly. Else False

Return type

bool

ocs_ci.ocs.cluster.check_osd_tree_3az_cloud(osd_tree, number_of_osds)

Checks whether an OSD tree is created/modified correctly. This can be used as a verification step for deployment and cluster expansion tests. This function is specifically for ocs cluster created on 3 AZ config

Parameters
  • osd_tree (dict) – Dictionary of the values which represent ‘osd tree’.

  • number_of_osds (int) – total number of osds in the cluster

Returns

True, if the ceph osd tree is formed correctly. Else False

Return type

Boolean

ocs_ci.ocs.cluster.check_osds_in_hosts_are_up(osd_tree)

Check if all the OSD’s in status ‘up’

Parameters

osd_tree (dict) – The ceph osd tree

Returns

True if all the OSD’s in status ‘up’. Else False

Return type

bool

ocs_ci.ocs.cluster.check_osds_in_hosts_osd_tree(hosts, osd_tree)

Checks if osds are formed correctly after cluster expansion

Parameters
  • hosts (list) – List of hosts

  • osd_tree (str) – ‘ceph osd tree’ command output

Returns

True if osd tree formatted correctly

Return type

bool

ocs_ci.ocs.cluster.count_cluster_osd()

The function returns the number of cluster OSDs

Returns

number of OSD pods in current cluster

Return type

osd_count (int)

ocs_ci.ocs.cluster.get_balancer_eval()

Function to get ceph pg balancer eval value

Returns

Eval output of pg balancer

Return type

eval_out (float)

ocs_ci.ocs.cluster.get_byte_used_by_pool(pool_name)

Check byte_used value for specific pool

Parameters

pool_name (str) – name of the pool to check replica

Returns

The amount of byte stored from pool.

Return type

integer

ocs_ci.ocs.cluster.get_ceph_df_detail()

Get ceph osd df detail

Returns

‘ceph df details’ command output

Return type

dict

ocs_ci.ocs.cluster.get_child_nodes_osd_tree(node_id, osd_tree)

This function finds the children of a node from the ‘ceph osd tree’ and returns them as list

Parameters
  • node_id (int) – the id of the node for which the children to be retrieved

  • osd_tree (dict) – dictionary containing the output of ‘ceph osd tree’

Returns

of ‘children’ of a given node_id

Return type

list

ocs_ci.ocs.cluster.get_osd_pods_memory_sum()

Get the sum of memory of all OSD pods. This is used to determine the size needed for a PVC so when IO will be running over it the OSDs cache will be filled

Returns

The sum of the OSD pods memory in GB

Return type

int

ocs_ci.ocs.cluster.get_osd_utilization()

Get osd utilization value

Returns

Dict of osd name and its used value i.e {‘osd.1’: 15.276289408185841, ‘osd.0’: 15.276289408185841, ‘osd.2’: 15.276289408185841}

Return type

osd_filled (dict)

ocs_ci.ocs.cluster.get_percent_used_capacity()

Function to calculate the percentage of used capacity in a cluster

Returns

The percentage of the used capacity in the cluster

Return type

float

ocs_ci.ocs.cluster.get_pg_balancer_status()

Function to check pg_balancer active and mode is upmap

Returns

True if active and upmap is set else False

Return type

bool

ocs_ci.ocs.cluster.get_pgs_per_osd()

Function to get ceph pg count per OSD

Returns

Dict of osd name and its used value i.e {‘osd.0’: 136, ‘osd.2’: 136, ‘osd.1’: 136}

Return type

osd_dict (dict)

ocs_ci.ocs.cluster.is_lso_cluster()

Check if the cluster is an lso cluster

Returns

True, if the cluster is an lso cluster. False, otherwise

Return type

bool

ocs_ci.ocs.cluster.silence_ceph_osd_crash_warning(osd_pod_name)

Silence the osd crash warning of a specific osd pod

Parameters

osd_pod_name (str) – The name of the osd pod which we need to silence the crash warning

Returns

True if it found the osd crash with name ‘osd_pod_name’. False otherwise

Return type

bool

ocs_ci.ocs.cluster.validate_cluster_on_pvc()

Validate creation of PVCs for MON and OSD pods. Also validate that those PVCs are attached to the OCS pods

Raises

AssertionError – If PVC is not mounted on one or more OCS pods

ocs_ci.ocs.cluster.validate_compression(pool_name)

Check if data was compressed

Parameters

pool_name (str) – name of the pool to check replica

Returns

True if compression works. False if not

Return type

bool

ocs_ci.ocs.cluster.validate_ocs_pods_on_pvc(pods, pvc_names)

Validate if ocs pod has PVC. This validation checking if there is the pvc like: rook-ceph-mon-a for the pod rook-ceph-mon-a-56f67f5968-6j4px.

Parameters
  • pods (list) – OCS pod names

  • pvc_names (list) – names of all PVCs

Raises

AssertionError – If no PVC found for one of the pod

ocs_ci.ocs.cluster.validate_osd_utilization(osd_used=80)

Validates osd utilization matches osd_used value

Parameters

osd_used (int) – osd used value

Returns

True if all osd values is equal or greater to osd_used.

False Otherwise.

Return type

bool

ocs_ci.ocs.cluster.validate_pdb_creation()

Validate creation of PDBs for MON, MDS and OSD pods.

Raises

AssertionError – If required PDBs were not created.

ocs_ci.ocs.cluster.validate_pg_balancer()

Validate either data is equally distributed to OSDs

Returns

True if avg PG’s per osd difference is <=10 else False

Return type

bool

ocs_ci.ocs.cluster.validate_replica_data(pool_name, replica)

Check if data is replica 2 or 3

Parameters
  • replica (int) – size of the replica(2,3)

  • pool_name (str) – name of the pool to check replica

Returns

True if replicated data size is meet rep config and False if dont

Return type

Bool

ocs_ci.ocs.cluster.wait_for_silence_ceph_osd_crash_warning(osd_pod_name, timeout=900)

Wait for ‘timeout’ seconds to check for the ceph osd crash warning, and silence it.

Parameters
  • osd_pod_name (str) – The name of the osd pod which we need to silence the crash warning

  • timeout (int) – time in seconds to wait for silence the osd crash warning

Returns

True if it found the osd crash with name ‘osd_pod_name’. False otherwise

Return type

bool

ocs_ci.ocs.cluster_load module

A module for cluster load related functionalities

class ocs_ci.ocs.cluster_load.ClusterLoad(project_factory=None, pvc_factory=None, sa_factory=None, pod_factory=None, target_percentage=None)

Bases: object

A class for cluster load functionalities

adjust_load_if_needed()

Dynamically adjust the IO load based on the cluster latency. In case the latency goes beyond 250 ms, start deleting FIO pods. Once latency drops back below 100 ms, re-create the FIO pods to make sure that cluster load is around the target percentage

calc_trim_metric_mean(metric, samples=5, mute_logs=False)

Get the trimmed mean of a given metric

Parameters
  • metric (str) – The metric to calculate the average result for

  • samples (int) – The number of samples to take

  • mute_logs (bool) – True for muting the logs, False otherwise

Returns

The average result for the metric

Return type

float

decrease_load(wait=True)

Delete DeploymentConfig with its pods and the PVC. Then, wait for the IO to be stopped

Parameters

wait (bool) – True for waiting for IO to drop after the deletion of the FIO pod, False otherwise

get_query(query, mute_logs=False)

Get query from Prometheus and parse it

Parameters
  • query (str) – Query to be done

  • mute_logs (bool) – True for muting the logs, False otherwise

Returns

the query result

Return type

float

increase_load(rate, wait=True)

Create a PVC, a service account and a DeploymentConfig of FIO pod

Parameters
  • rate (str) – FIO ‘rate’ value (e.g. ‘20M’)

  • wait (bool) – True for waiting for IO to kick in on the newly created pod, False otherwise

increase_load_and_print_data(rate, wait=True)

Increase load and print data

Parameters
  • rate (str) – FIO ‘rate’ value (e.g. ‘20M’)

  • wait (bool) – True for waiting for IO to kick in on the newly created pod, False otherwise

print_metrics(mute_logs=False)

Print metrics

Parameters

mute_logs (bool) – True for muting the Prometheus logs, False otherwise

reach_cluster_load_percentage()

Reach the cluster limit and then drop to the given target percentage. The number of pods needed for the desired target percentage is determined by creating pods one by one, while examining the cluster latency. Once the latency is greater than 250 ms and it is growing exponentially, it means that the cluster limit has been reached. Then, dropping to the target percentage by deleting all pods and re-creating ones with smaller value of FIO ‘rate’ param. This leaves the number of pods needed running IO for cluster load to be around the desired percentage.

reduce_load(pause=True)

Pause the cluster load

resume_load()

Resume the cluster load

ocs_ci.ocs.cluster_load.wrap_msg(msg)

Wrap a log message with ‘=’ marks. Necessary for making cluster load background logging distinguishable

Parameters

msg (str) – The log message to wrap

Returns

The wrapped log message

Return type

str

ocs_ci.ocs.constants module

Constants module.

This module contains any values that are widely used across the framework, utilities, or tests that will predominantly remain unchanged.

In the event values here have to be changed it should be under careful review and with consideration of the entire project.

ocs_ci.ocs.couchbase module

Couchbase workload class

class ocs_ci.ocs.couchbase.CouchBase(**kwargs)

Bases: ocs_ci.ocs.pillowfight.PillowFight

CouchBase workload operation

WAIT_FOR_TIME = 1800
admission_parts = ['/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionServiceAccount.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionClusterRole.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionClusterRoleBinding.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionSecret.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionDeployment.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/admissionService.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/MutatingWebhookConfiguration.yaml', '/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/workloads/couchbase/server/ValidatingWebhookConfiguration.yaml']
admission_pod = []
analyze_run(skip_analyze=False)

Analyzing the workload run logs

Parameters

skip_analyze (bool) – Option to skip logs analysis

cb_examples = <ocs_ci.ocs.resources.ocs.OCS object>
cb_worker = <ocs_ci.ocs.resources.ocs.OCS object>
couchbase_pod = <ocs_ci.ocs.ocp.OCP object>
create_couchbase_worker(replicas=1, sc_name=None)

Deploy a Couchbase server and pillowfight workload using operator

The couchbase workers do not come up unless there is an admission controller running. The admission controller is started from the default project prior to bringing up the operator. Secrets, rolebindings and serviceaccounts need to also be generated.

Once the couchbase operator is running, we need to wait for the three worker pods to also be up. Then a pillowfight task is started.

After the pillowfight task has finished, the log is collected and analyzed.

Raises

Exception – If pillowfight results indicate that a minimum performance level is not reached (1 second response time, less than 1000 ops per second)

get_couchbase_nodes()

Get nodes that contain a couchbase app pod

Returns

List of nodes

Return type

list

is_up_and_running(pod_name, ocp_value)

Test if the pod specified is up and running.

Parameters
  • pod_name (str) – Name of pod being checked.

  • ocp_value (object) – object used for running oc commands

Returns

bool; True if pod is running, False otherwise

ns_obj = <ocs_ci.ocs.ocp.OCP object>
pod_obj = <ocs_ci.ocs.ocp.OCP object>
respin_couchbase_app_pod()

Respin the couchbase app pod

Returns

pod status

run_workload(replicas, num_items=None, num_threads=None, run_in_bg=False)

Running workload with pillow fight operator :param replicas: Number of pods :type replicas: int :param num_items: Number of items to be loaded to the cluster :type num_items: int :param num_threads: Number of threads :type num_threads: int :param run_in_bg: Optional run IOs in background :type run_in_bg: bool

secretsadder = <ocs_ci.ocs.ocp.OCP object>
setup_cb()

Creating admission parts,couchbase operator pod, couchbase worker secret

teardown()

Delete objects created in roughly reverse order of how they were created.

ocs_ci.ocs.defaults module

Defaults module. All the defaults used by OSCCI framework should reside in this module. PYTEST_DONT_REWRITE - avoid pytest to rewrite, keep this msg here please!

ocs_ci.ocs.disruptive_operations module

ocs_ci.ocs.disruptive_operations.get_ocs_operator_node_name()

Getting node’s name that running ocs-operator pod

Returns

node’s name that running ocs-operator pod

Return type

str

ocs_ci.ocs.disruptive_operations.osd_node_reboot()

Rebooting worker node that running OSD

Raises

AssertionError – in case the ceph-tools pod was not recovered

ocs_ci.ocs.disruptive_operations.worker_node_shutdown(abrupt)

Shutdown worker node that running ocs-operator pod

Parameters

abrupt – (bool): True if abrupt shutdown, False for permanent shutdown

Raises

AssertionError – in case the ceph-tools pod was not recovered

ocs_ci.ocs.elasticsearch module

Deploying an Elasticsearch server for collecting logs from ripsaw benchmarks. Interface for the Performance ElasticSearch server

class ocs_ci.ocs.elasticsearch.ElasticSearch

Bases: object

ElasticSearch Environment

cleanup()

Cleanup the environment from all Elasticsearch components, and from the port forwarding process.

dumping_all_data(target_path)

Dump All data from the internal ES server to .tgz file.

Parameters

target_path (str) – the path where the results file will be copy into

Returns

True if the dump operation succeed and return the results data to the host

otherwise False

Return type

bool

get_health()

This method return the health status of the Elasticsearch.

Returns

True if the status is green (OK) otherwise - False

Return type

bool

get_indices()

Getting list of all indices in the ES server - all created by the test, the installation of the ES was without any indexes pre-installed.

Returns

list of all indices defined in the ES server

Return type

list

get_ip()

This function return the IP address of the Elasticsearch cluster. this IP is to use inside the OCP cluster

Return

str : String that represent the Ip Address.

get_password()

This method return the password used to connect the Elasticsearch.

Returns

The password as text

Return type

str

get_port()

This function return the port of the Elasticsearch cluster.

Return

str : String that represent the port.

ocs_ci.ocs.elasticsearch.elasticsearch_load(connection, target_path)

Load all data from target_path/results into an elasticsearch (es) server.

Parameters
  • connection (obj) – an elasticsearch connection object

  • target_path (str) – the path where data was dumped into

Returns

True if loading data succeed, False otherwise

Return type

bool

ocs_ci.ocs.exceptions module

exception ocs_ci.ocs.exceptions.CPUNotSufficientException

Bases: Exception

exception ocs_ci.ocs.exceptions.CSVNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.CephHealthException

Bases: Exception

exception ocs_ci.ocs.exceptions.ChannelNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.ClassCreationException

Bases: Exception

exception ocs_ci.ocs.exceptions.CommandFailed

Bases: Exception

exception ocs_ci.ocs.exceptions.CredReqSecretNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.DeploymentPlatformNotSupported

Bases: Exception

exception ocs_ci.ocs.exceptions.ExternalClusterDetailsException

Bases: Exception

exception ocs_ci.ocs.exceptions.FailedToAddNodeException

Bases: Exception

exception ocs_ci.ocs.exceptions.FailedToDeleteInstance

Bases: Exception

exception ocs_ci.ocs.exceptions.FailedToRemoveNodeException

Bases: Exception

exception ocs_ci.ocs.exceptions.FipsNotInstalledException

Bases: Exception

exception ocs_ci.ocs.exceptions.FlexyDataNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.ImageIsNotDeletedOrNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.InvalidStatusCode

Bases: Exception

exception ocs_ci.ocs.exceptions.MDSCountException

Bases: Exception

exception ocs_ci.ocs.exceptions.MemoryNotSufficientException

Bases: Exception

exception ocs_ci.ocs.exceptions.MissingRequiredConfigKeyError

Bases: Exception

exception ocs_ci.ocs.exceptions.MonCountException

Bases: Exception

exception ocs_ci.ocs.exceptions.NoBucketPolicyResponse

Bases: Exception

exception ocs_ci.ocs.exceptions.NoInstallPlanForApproveFoundException

Bases: Exception

exception ocs_ci.ocs.exceptions.NodeNotFoundError

Bases: Exception

exception ocs_ci.ocs.exceptions.NonUpgradedImagesFoundError

Bases: Exception

exception ocs_ci.ocs.exceptions.NoobaaConditionException

Bases: Exception

exception ocs_ci.ocs.exceptions.NoobaaHealthException

Bases: Exception

exception ocs_ci.ocs.exceptions.NotFoundError

Bases: Exception

exception ocs_ci.ocs.exceptions.NotSupportedFunctionError

Bases: Exception

exception ocs_ci.ocs.exceptions.OpenshiftConsoleSuiteNotDefined

Bases: Exception

exception ocs_ci.ocs.exceptions.PSIVolumeCreationFailed

Bases: Exception

exception ocs_ci.ocs.exceptions.PSIVolumeDeletionFailed

Bases: Exception

exception ocs_ci.ocs.exceptions.PSIVolumeNotInExpectedState

Bases: Exception

exception ocs_ci.ocs.exceptions.PendingCSRException

Bases: Exception

exception ocs_ci.ocs.exceptions.PerformanceException

Bases: Exception

exception ocs_ci.ocs.exceptions.PoolDataNotErased

Bases: Exception

exception ocs_ci.ocs.exceptions.PoolNotCompressedAsExpected

Bases: Exception

exception ocs_ci.ocs.exceptions.PoolNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.PoolNotReplicatedAsNeeded

Bases: Exception

exception ocs_ci.ocs.exceptions.PvcNotDeleted

Bases: Exception

exception ocs_ci.ocs.exceptions.RDMDiskNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.ResourceInUnexpectedState

Bases: Exception

exception ocs_ci.ocs.exceptions.ResourceLeftoversException

Bases: Exception

exception ocs_ci.ocs.exceptions.ResourceNameNotSpecifiedException

Bases: Exception

exception ocs_ci.ocs.exceptions.ResourceNotFoundError

Bases: Exception

exception ocs_ci.ocs.exceptions.ResourceWrongStatusException(resource_name, describe_out)

Bases: Exception

exception ocs_ci.ocs.exceptions.RhcosImageNotFound

Bases: Exception

exception ocs_ci.ocs.exceptions.SameNamePrefixClusterAlreadyExistsException

Bases: Exception

exception ocs_ci.ocs.exceptions.ServiceUnavailable

Bases: Exception

exception ocs_ci.ocs.exceptions.StorageNotSufficientException

Bases: Exception

exception ocs_ci.ocs.exceptions.TagNotFoundException

Bases: Exception

exception ocs_ci.ocs.exceptions.TimeoutException

Bases: Exception

exception ocs_ci.ocs.exceptions.TimeoutExpiredError(*value)

Bases: Exception

message = 'Timed Out'
exception ocs_ci.ocs.exceptions.UnavailableBuildException

Bases: Exception

exception ocs_ci.ocs.exceptions.UnavailableResourceException

Bases: Exception

exception ocs_ci.ocs.exceptions.UnexpectedBehaviour

Bases: Exception

exception ocs_ci.ocs.exceptions.UnexpectedImage

Bases: Exception

exception ocs_ci.ocs.exceptions.UnexpectedVolumeType

Bases: Exception

exception ocs_ci.ocs.exceptions.UnhealthyBucket

Bases: Exception

exception ocs_ci.ocs.exceptions.UnsupportedBrowser

Bases: Exception

exception ocs_ci.ocs.exceptions.UnsupportedFeatureError

Bases: Exception

exception ocs_ci.ocs.exceptions.UnsupportedOSType

Bases: Exception

exception ocs_ci.ocs.exceptions.UnsupportedPlatformError

Bases: Exception

exception ocs_ci.ocs.exceptions.UnsupportedPlatformVersionError

Bases: Exception

exception ocs_ci.ocs.exceptions.VMMaxDisksReachedException

Bases: Exception

ocs_ci.ocs.external_ceph module

class ocs_ci.ocs.external_ceph.Ceph(name='ceph', node_list=None)

Bases: object

property ceph_demon_stat

Retrieves expected numbers for demons of each role

Returns

Ceph demon stats

Return type

dict

get_ceph_demons(role=None)

Get Ceph demons list

Returns

list of CephDemon

Return type

list

get_ceph_object(role, order_id=0)

Returns single ceph object. If order id is provided returns that occurrence from results list, otherwise returns first occurrence

Parameters
  • role (str) – Ceph object’s role

  • order_id (int) – order number of the ceph object

Returns

ceph object

Return type

CephObject

get_ceph_objects(role=None)

Get Ceph Object by role. Returns all objects if role is not defined. Ceph object can be Ceph demon, client, installer or generic entity. Pool role is never assigned to Ceph object and means that node has no Ceph objects

Parameters

role (str) – Ceph object’s role as str

Returns

ceph objects

Return type

list

get_metadata_list(role, client=None)

Returns metadata for demons of specified role

Parameters
  • role (str) – ceph demon role

  • client (CephObject) – Client with keyring and ceph-common

Returns

metadata as json object representation

Return type

list

get_node_by_hostname(hostname)

Returns Ceph node by it’s hostname

Parameters

hostname (str) – hostname

Returns

ceph node object

Return type

CephNode

get_nodes(role=None, ignore=None)

Get node(s) by role. Return all nodes if role is not defined

Parameters
  • role (str, RolesContainer) – node’s role. Takes precedence over ignore

  • ignore (str, RolesContainer) – node’s role to ignore from the list

Returns

nodes

Return type

list

get_osd_by_id(osd_id, client=None)
Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common:

Returns

daemon object or None in case the osd daemon list is

empty

Return type

CephDemon

get_osd_container_name_by_id(osd_id, client=None)
Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common:

get_osd_data_partition(osd_id, client=None)

Returns data partition by given osd id

Parameters
  • osd_id (int) – osd id

  • client (CephObject) – client, optional

Returns

data path

Return type

str

get_osd_data_partition_path(osd_id, client=None)

Returns data partition path by given osd id

Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common:

Returns

data partition path

Return type

str

get_osd_device(osd_id, client=None)
Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common:

Returns

osd device

Return type

str

get_osd_metadata(osd_id, client=None)

Retruns metadata for osd by given id

Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common

Returns

osd metadata like:

{
   "id": 8,
   "arch": "x86_64",
   "back_addr": "172.16.115.29:6801/1672",
   "back_iface": "eth0",
   "backend_filestore_dev_node": "vdd",
   "backend_filestore_partition_path": "/dev/vdd1",
   "ceph_version": "ceph version 12.2.5-42.el7cp (82d52d7efa6edec70f6a0fc306f40b89265535fb) luminous
           (stable)",
   "cpu": "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
   "osd_data": "/var/lib/ceph/osd/ceph-8",
   "osd_journal": "/var/lib/ceph/osd/ceph-8/journal",
   "osd_objectstore": "filestore",
   "rotational": "1"
}

Return type

dict

get_osd_service_name(osd_id, client=None)
Parameters
  • osd_id (int) – osd id

  • client (CephObject) – Client with keyring and ceph-common:

Returns

service name

Return type

str

role_to_node_mapping()

Given a role we should be able to get the corresponding CephNode object

class ocs_ci.ocs.external_ceph.CephClient(role, node)

Bases: ocs_ci.ocs.external_ceph.CephObject

class ocs_ci.ocs.external_ceph.CephDemon(role, node)

Bases: ocs_ci.ocs.external_ceph.CephObject

ceph_demon_by_container_name(container_name)
property container_name
property container_prefix
exec_command(cmd, **kw)

Proxy to node’s exec_command with wrapper to run commands inside the container for containerized demons

Parameters
  • cmd (str) – command to execute

  • **kw – options

Returns

node’s exec_command resut

class ocs_ci.ocs.external_ceph.CephNode(**kw)

Bases: object

connect(timeout=300)

connect to ceph instance using paramiko ssh protocol eg: self.connect() - setup tcp keepalive to max retries for active connection - set up hostname and shortname as attributes for tests to query

create_ceph_object(role)

Create ceph object on the node

Parameters

role (str) – ceph object role

Returns

created ceph object

Return type

CephObject|CephDemon

exec_command(**kw)

execute a command on the vm eg: self.exec_cmd(cmd=’uptime’) or self.exec_cmd(cmd=’background_cmd’, check_ec=False)

check_ec

False will run the command and not wait for exit code

Type

bool

get_allocated_volumes()
get_ceph_demons(role=None)

Get Ceph demons list. Only active (those which will be part of the cluster) demons are shown.

Returns

list of CephDemon

Return type

list

get_ceph_objects(role=None)

Get Ceph objects list on the node

Parameters

role (str) – Ceph object role

Returns

ceph objects

Return type

list

get_free_volumes()
obtain_root_permissions(path)

Transfer ownership of root to current user for the path given. Recursive.

Parameters

path (str) – file path

reconnect()
remove_ceph_object(ceph_object)

Removes ceph object form the node

Parameters

ceph_object (CephObject) – ceph object to remove

property role
search_ethernet_interface(ceph_node_list)

Search interface on the given node node which allows every node in the cluster accesible by it’s shortname.

Parameters

ceph_node_list (list) – list of CephNode

Returns

returns None if no suitable interface found

Return type

eth_interface (str)

set_eth_interface(eth_interface)

set the eth interface

set_internal_ip()

set the internal ip of the vm which differs from floating ip

write_file(**kw)
class ocs_ci.ocs.external_ceph.CephObject(role, node)

Bases: object

exec_command(cmd, **kw)

Proxy to node’s exec_command

Parameters
  • cmd (str) – command to execute

  • **kw – options

Returns

node’s exec_command result

property pkg_type
write_file(**kw)

Proxy to node’s write file

Parameters

**kw – options

Returns

node’s write_file result

class ocs_ci.ocs.external_ceph.CephObjectFactory(node)

Bases: object

CLIENT_ROLES = ['client']
DEMON_ROLES = ['mon', 'osd', 'mgr', 'rgw', 'mds', 'nfs']
create_ceph_object(role)

Create an appropriate Ceph object by role

Parameters

role – role string

Returns

Ceph object based on role

class ocs_ci.ocs.external_ceph.CephOsd(node, device=None)

Bases: ocs_ci.ocs.external_ceph.CephDemon

property container_name
property is_active
class ocs_ci.ocs.external_ceph.NodeVolume(status)

Bases: object

ALLOCATED = 'allocated'
FREE = 'free'
class ocs_ci.ocs.external_ceph.RolesContainer(role='pool')

Bases: object

Container for single or multiple node roles. Can be used as iterable or with equality ‘==’ operator to check if role is present for the node. Note that ‘==’ operator will behave the same way as ‘in’ operator i.e. check that value is present in the role list.

append(object)
clear()
equals(other)
extend(iterable)
remove(object)
update_role(roles_list)
class ocs_ci.ocs.external_ceph.SSHConnectionManager(ip_address, username, password, look_for_keys=False, outage_timeout=300)

Bases: object

property client
get_client()
get_transport()
property transport

ocs_ci.ocs.fio_artefacts module

ocs_ci.ocs.fio_artefacts.get_configmap_dict()

ConfigMap template for fio workloads. Note that you need to add actual configuration to workload.fio file.

Returns

YAML data for a OCP ConfigMap object

Return type

dict

ocs_ci.ocs.fio_artefacts.get_job_dict()

Job template for fio workloads.

Returns

YAML data for a job object

Return type

dict

ocs_ci.ocs.fio_artefacts.get_mcg_conf(mcg_obj, workload_bucket, custom_options=None)

Basic fio configuration for upgrade utilization for NooBaa S3 bucket.

Parameters
  • mcg_obj (obj) – MCG object, it can be found among fixtures

  • workload_bucket (obj) – MCG bucket

  • custom_options (dict) – Dictionary of lists containing tuples with additional configuration for fio in format: {‘section’: [(‘option’, ‘value’),…],…} e.g. {‘global’:[(‘name’,’bucketname’)],’create’:[(‘time_based’,’1’),(‘runtime’,’48h’)]} Those values can be added to the config or rewrite already existing values

Returns

updated fio configuration

Return type

str

ocs_ci.ocs.fio_artefacts.get_pvc_dict()

PVC template for fio workloads. Note that all ‘None’ values needs to be defined before usage.

Returns

YAML data for a PVC object

Return type

dict

ocs_ci.ocs.fiojob module

This module contains functions which implements functionality necessary to run general fio workloads as k8s Jobs in OCP/OCS cluster via workload fixtures (see ocs_ci.utility.workloadfixture).

ocs_ci.ocs.fiojob.delete_fio_data(fio_job_file, delete_check_func)

Delete fio data by removing the fio job resource, with a wait to make sure date were reclaimed on the ceph level.

ocs_ci.ocs.fiojob.fio_to_dict(fio_output)

” Parse fio output and provide parsed dict it as a result.

ocs_ci.ocs.fiojob.get_ceph_storage_stats(ceph_pool_name)

Get ceph storage utilization values from ceph df: total STORED value and MAX AVAIL of given ceph pool, which are important for understanding how much space is already consumed and how much is still available.

Parameters

ceph_pool_name (str) – name of ceph pool where you want to write data

Returns

int: sum of all ceph pool STORED values (Bytes) int: value of MAX AVAIL value of given ceph pool (Bytes)

Return type

tuple

ocs_ci.ocs.fiojob.get_storageutilization_size(target_percentage, ceph_pool_name)

For the purpose of the workload storage utilization fixtures, get expected pvc_size based on STORED and MAX AVAIL values (as reported by ceph df) for given ceph pool and target utilization percentage.

This is only approximate, and it won’t work eg. if each pool has different configuration of replication.

Parameters
  • target_percentage (float) – target total utilization, eg. 0.5 for 50%

  • ceph_pool_name (str) – name of ceph pool where you want to write data

Returns

pvc_size for storage utilization job (in GiB, rounded)

Return type

int

ocs_ci.ocs.fiojob.get_timeout(fio_min_mbps, pvc_size)

Compute how long we will let the job running while writing data to the volume.

Parameters
  • fio_min_mbps (int) – minimal write speed in MiB/s

  • pvc_size (int) – size of PVC in GiB, which will be used to writing

Returns

write_timeout in seconds

Return type

int

ocs_ci.ocs.fiojob.wait_for_job_completion(namespace, timeout, error_msg)

This is a WORKAROUND of particular ocsci design choices: I just wait for one pod in the namespace, and then ask for the pod again to get it’s name (but it would be much better to just wait for the job to finish instead, then ask for a name of the successful pod and use it to get logs …)

Returns

name of Pod resource of the finished job

Return type

str

ocs_ci.ocs.fiojob.workload_fio_storageutilization(fixture_name, project, fio_pvc_dict, fio_job_dict, fio_configmap_dict, measurement_dir, tmp_path, target_percentage=None, target_size=None, with_checksum=False, keep_fio_data=False, minimal_time=480)

This function implements core functionality of fio storage utilization workload fixtures. This is necessary because we can’t parametrize single general fixture over multiple parameters (it would mess with test case id and polarion test case tracking).

It works as a workload fixture, as understood by ocs_ci.utility.workloadfixture module.

When target_percentage is specified, the goal of the fixture is to fill whatever is left so that total cluster utilization reaches the target percentage. This means that in this mode, number of data written depends on both total capacity and current utilization. If the current storage utilization already exceeds the target, the test is skipped.

On the other hand with target_size, you can specify the size of data written by fio directly.

Parameters
  • fixture_name (str) – name of the fixture using this function (for logging and k8s object labeling purposes)

  • project (ocs_ci.ocs.ocp.OCP) – OCP object of project in which the Job is deployed, as created by project_factory or project fixture

  • fio_pvc_dict (dict) – PVC k8s struct for fio target volume

  • fio_job_dict (dict) – Job k8s struct for fio job

  • fio_configmap_dict (dict) – configmap k8s struct with fio config file

  • measurement_dir (str) – reference to a fixture which represents a directory where measurement results are stored, see also ocs_ci.utility.workloadfixture.measure_operation()

  • tmp_path (pathlib.PosixPath) – reference to pytest tmp_path fixture

  • target_percentage (float) – target utilization as percentage wrt all usable OCS space, eg. 0.50 means a request to reach 50% of total OCS storage utilization (wrt usable space)

  • target_size (int) – target size of the PVC for fio to use, eg. 10 means a request for fio to write 10GiB of data

  • with_checksum (bool) – if true, sha1 checksum of the data written by fio is stored on the volume, and reclaim policy of the volume is changed to Retain so that the volume is not removed during test teardown for later verification runs

  • keep_fio_data (bool) – If true, keep the fio data after the fio storage utilization is completed. Else if false, deletes the fio data.

  • minimal_time (int) – Minimal number of seconds to monitor a system. (See more details in the function ‘measure_operation’)

Returns

measurement results with timestamps and other medatada from

ocs_ci.utility.workloadfixture.measure_operation()

Return type

dict

ocs_ci.ocs.fiojob.write_data_via_fio(fio_job_file, write_timeout, pvc_size, target_percentage)

Write data via fio Job (specified in tf tmp file) to reach desired utilization level, and keep this level for minimal_time seconds.

ocs_ci.ocs.flowtest module

class ocs_ci.ocs.flowtest.BackgroundOps

Bases: object

handler(func, *args, **kwargs)

Wraps the function to run specific iterations

Returns

True if function runs successfully

Return type

bool

wait_for_bg_operations(bg_ops, timeout=1200)

Waits for threads to be completed

Parameters
  • bg_ops (list) – Futures

  • timeout (int) – Time in seconds to wait

class ocs_ci.ocs.flowtest.FlowOperations

Bases: object

Flow based operations class

add_capacity_entry_criteria()

Entry criteria verification function for add capacity operation

Returns

containing the params used in add capacity exit operation

Return type

tuple

add_capacity_exit_criteria(restart_count_before, osd_pods_before)

Exit criteria function for Add capacity operation

Parameters
  • restart_count_before (dict) – Restart counts of pods

  • osd_pods_before (list) – List of OSD pods before

node_operations_entry_criteria(node_type, number_of_nodes, operation_name='Node Operation', network_fail_time=None)

Entry criteria function for node related operations

Parameters
  • node_type (str) – Type of node

  • number_of_nodes (int) – Number of nodes

  • operation_name (str) – Name of the node operation

  • network_fail_time (int) – Total time to fail the network in a node

Returns

containing the params used in Node operations

Return type

tuple

validate_cluster(cluster_check=False, node_status=False, pod_status=False, operation_name='')

Validates various ceph and ocs cluster checks

Parameters
  • node_status (bool) – Verifies node is Ready

  • pod_status (bool) – Verifies StorageCluster pods in expected state

  • operation_name (str) – Name of the operation, to Tag

ocs_ci.ocs.hsbench module

class ocs_ci.ocs.hsbench.HsBench

Bases: object

Hotsauce S3 benchmark

cleanup()

Clear all objects in the associated bucket Clean up deployment config, pvc, pod and test user

create_resource_hsbench()
Create resource for hsbench mark test:

Create service account Create PVC Create golang pod

create_test_user()

Create a radosgw test user for S3 access

delete_test_user()

Delete RGW test user and bucket belong to test user

install_hsbench(timeout=2400)

Install HotSauce S3 benchmark: https://github.com/markhpc/hsbench

run_benchmark(num_obj=None, run_mode=None, timeout=None)

Running Hotsauce S3 benchmark Usage detail can be found at: https://github.com/markhpc/hsbench

Parameters
  • num_obj (int) – Maximum number of objects

  • run_mode (string) – mode types

  • timeout (int) – timeout in seconds

validate_reshard_process()

Validate reshard process

Raises

CommandFailed – If reshard process fails

validate_s3_objects()

Validate S3 objects created by hsbench on single bucket

ocs_ci.ocs.jenkins module

Jenkins Class to run jenkins specific tests

class ocs_ci.ocs.jenkins.Jenkins(num_of_projects=1, num_of_builds=1)

Bases: object

Workload operation using Jenkins

Parameters
  • projects (iterable) – project names

  • num_of_builds (int) – number of builds per project

cleanup()

Clean up

create_app_jenkins()

create application jenkins

create_jenkins_build_config()

create jenkins build config

create_jenkins_pvc()

create jenkins pvc

Returns

pvc_objs

Return type

List

create_ocs_jenkins_template()

Create OCS Jenkins Template

create_project_names()

Create project names

export_builds_results_to_googlesheet(sheet_name='E2E Workloads', sheet_index=3)

Collect builds results, output to google spreadsheet

Parameters
  • sheet_name (str) – Name of the sheet

  • sheet_index (int) – Index of sheet

get_build_duration_time(namespace, build_name)

get build duration time

Parameters
  • namespace (str) – get build in namespace

  • build_name (str) – the name of the jenkins build

get_build_name_by_pattern(pattern='client', namespace=None, filter=None)

Get build name by pattern

Returns

build name

Return type

list

get_builds_obj(namespace)

Get all jenkins builds

Returns

jenkins deploy pod objects list

Return type

List

get_builds_sorted_by_number(project)

Get builds per project and sort builds by build name number

Parameters

project (str) – project name

Returns

List of Jenkins build OCS obj

Return type

List

get_jenkins_deploy_pods(namespace)

Get all jenkins deploy pods

Parameters

namespace (str) – get pods in namespace

Returns

jenkins deploy pod objects list

Return type

pod_objs (list)

get_node_name_where_jenkins_pod_not_hosted(node_type='worker', num_of_nodes=1)

get nodes

Parameters
  • node_type (str) – The node type (e.g. worker, master)

  • num_of_nodes (int) – The number of nodes to be returned

Returns

List of compute node names

Return type

list

property number_builds_per_project
property number_projects
print_completed_builds_results()

Get builds logs and print them on table

start_build()

Start build on jenkins

wait_for_build_to_complete(timeout=900)

Wait for build status to reach complete state

Parameters

timeout (int) – Time in seconds to wait

wait_for_jenkins_deploy_status(status, timeout=600)

Wait for jenkins deploy pods status to reach running/completed

Parameters
  • status (str) – status to reach Running or Completed

  • timeout (int) – Time in seconds to wait

ocs_ci.ocs.machine module

ocs_ci.ocs.machine.add_annotation_to_machine(annotation, machine_name)

Add annotation to the machine :param annotation: Annotation to be set on the machine :type annotation: str :param eg: annotation = “machine.openshift.io/exclude-node-draining=’’” :param machine_name: machine name :type machine_name: str

ocs_ci.ocs.machine.add_node(machine_set, count)

Add new node to the cluster

Parameters
  • machine_set (str) – Name of a machine set to get increase replica count

  • count (int) – Count to increase

Returns

True if commands executes successfully

Return type

bool

ocs_ci.ocs.machine.check_machineset_exists(machine_set)

Function to check machineset exists or not

Parameters

machine_set (str) – Name of the machine set

Returns

True if machineset exists, else false

Return type

bool

ocs_ci.ocs.machine.create_custom_machineset(role='app', instance_type='m4.xlarge', labels=None, taints=None, zone='a')

Function to create custom machineset works only for AWS i.e. Using this user can create nodes with different instance type and role. https://docs.openshift.com/container-platform/4.1/machine_management/creating-machineset.html

Parameters
  • role (str) – Role type to be added for node eg: it will be app,worker

  • instance_type (str) – Type of aws instance

  • label (list) – List of Labels (key, val) to be added to the node

  • taints (list) – List of taints to be applied

  • zone (str) – Machineset zone for node creation.

Returns

Created machineset name

Return type

machineset (str)

Raise:

ResourceNotFoundError: Incase machineset creation failed UnsupportedPlatformError: Incase of wrong platform

ocs_ci.ocs.machine.create_ocs_infra_nodes(num_nodes)

Create infra node instances

Parameters

num_nodes (int) – Number of instances to be created

Returns

list of instance names

Return type

list

ocs_ci.ocs.machine.delete_custom_machineset(machine_set)

Function to delete custom machineset

Parameters
  • machine_set (str) – Name of the machine set to be deleted

  • WARN – Make sure it’s not OCS worker node machines set, if so then OCS worker nodes and machine set will be deleted.

Raise:

UnexpectedBehaviour: Incase machineset not deleted

ocs_ci.ocs.machine.delete_machine(machine_name)

Deletes a machine

Parameters

machine_name (str) – Name of the machine you want to delete

Raises

CommandFailed – In case yaml_file and resource_name wasn’t provided

ocs_ci.ocs.machine.delete_machine_and_check_state_of_new_spinned_machine(machine_name)

Deletes a machine and checks the state of the newly spinned machine

Parameters

machine_name (str) – Name of the machine you want to delete

Returns

True in case of success, False otherwise

Return type

bool

ocs_ci.ocs.machine.get_labeled_nodes(label)

Fetches all nodes with specific label.

Parameters

label (str) – node label to look for

Returns

List of names of labeled nodes

Return type

list

ocs_ci.ocs.machine.get_machine_from_machineset(machine_set)

Get the machine name from its associated machineset

Parameters

machine_set (str) – Name of the machine set

Returns

Machine names

Return type

List

ocs_ci.ocs.machine.get_machine_from_node_name(node_name)

Get the associated machine name for the given node name

Parameters

node_name (str) – Name of the node

Returns

Machine name

Return type

str

ocs_ci.ocs.machine.get_machine_objs(machine_names=None)

Get machine objects by machine names

Parameters
  • machine_names (list) – The machine names to get their objects

  • None, will return all cluster machines (If) –

Returns

Cluster machine OCS objects

Return type

list

ocs_ci.ocs.machine.get_machine_type(machine_name)

Get the machine type (e.g. worker, master)

Parameters

machine_name (str) – Name of the machine

Returns

Type of the machine

Return type

str

ocs_ci.ocs.machine.get_machines(machine_type='worker')

Get cluster’s machines according to the machine type (e.g. worker, master)

Parameters

machine_type (str) – The machine type (e.g. worker, master)

Returns

The nodes OCP instances

Return type

list

ocs_ci.ocs.machine.get_machineset_from_machine_name(machine_name)

Get the machineset associated with the machine name

Parameters

machine_name (str) – Name of the machine

Returns

Machineset name

Return type

str

ocs_ci.ocs.machine.get_machineset_objs(machineset_names=None)

Get machineset objects by machineset names

Parameters
  • machineset_names (list) – The machineset names to get their objects

  • None, will return all cluster machines (If) –

Returns

Cluster machineset OCS objects

Return type

list

ocs_ci.ocs.machine.get_machinesets()

Get machine sets

Returns

list of machine sets

Return type

machine_sets (list)

ocs_ci.ocs.machine.get_ready_replica_count(machine_set)

Get replica count which are in ready state in a machine set

Parameters

machine_set (str) – Machineset name

Returns

replica count which are in ready state

Return type

ready_replica (int)

ocs_ci.ocs.machine.get_replica_count(machine_set)

Get replica count of a machine set

Parameters

machine_set (str) – Name of a machine set to get replica count

Returns

replica count of a machine set

Return type

replica count (int)

ocs_ci.ocs.machine.get_storage_cluster(namespace='openshift-storage')

Get storage cluster name

Parameters

namespace (str) – Namespace of the resource

Returns

Storage cluster name

Return type

str

ocs_ci.ocs.machine.wait_for_new_node_to_be_ready(machine_set, timeout=600)

Wait for the new node to reach ready state

Parameters

machine_set (str) – Name of the machine set

Raises

ResourceWrongStatusException – In case the new spun machine fails to reach Ready state or replica count didn’t match

ocs_ci.ocs.mcg_workload module

ocs_ci.ocs.mcg_workload.create_workload_job(job_name, bucket, project, mcg_obj, resource_path, custom_options=None)

Creates kubernetes job that should utilize MCG bucket.

Parameters
  • job_name (str) – Name of the job

  • bucket (objt) – MCG bucket with S3 interface

  • project (obj) – OCP object representing OCP project which will be used for the job

  • mcg_obj (obj) – instance of MCG class

  • resource_path (str) – path to directory where should be created resources

  • custom_options (dict) – Dictionary of lists containing tuples with additional configuration for fio in format: {‘section’: [(‘option’, ‘value’),…],…} e.g. {‘global’:[(‘name’,’bucketname’)],’create’:[(‘time_based’,’1’),(‘runtime’,’48h’)]} Those values can be added to the config or rewrite already existing values

Returns

Job object

Return type

obj

ocs_ci.ocs.mcg_workload.get_configmap_dict(fio_job, mcg_obj, bucket, custom_options=None)

Fio configmap dictionary with configuration set for MCG workload.

Parameters
  • fio_job (dict) – Definition of fio job

  • mcg_obj (obj) – instance of MCG class

  • bucket (obj) – MCG bucket to be used for workload

  • custom_options (dict) – Dictionary of lists containing tuples with additional configuration for fio in format: {‘section’: [(‘option’, ‘value’),…],…} e.g. {‘global’:[(‘name’,’bucketname’)],’create’:[(‘time_based’,’1’),(‘runtime’,’48h’)]} Those values can be added to the config or rewrite already existing values

Returns

Configmap definition

Return type

dict

ocs_ci.ocs.mcg_workload.get_job_dict(job_name)

Fio job dictionary with configuration set for MCG workload.

Parameters

job_name (str) – Name of the workload job

Returns

Specification for the workload job

Return type

dict

ocs_ci.ocs.mcg_workload.mcg_job_factory(request, bucket_factory, project_factory, mcg_obj, resource_path)

MCG IO workload factory. Calling this fixture creates a OpenShift Job.

Parameters
  • request (obj) – request fixture instance

  • bucket_factory (func) – factory function for bucket creation

  • project_factory (func) – factory function for project creation

  • mcg_obj (obj) – instance of MCG class

  • resource_path (str) – path to directory where should be created resources

Returns

MCG workload job factory function

Return type

func

ocs_ci.ocs.mcg_workload.wait_for_active_pods(job, desired_count, timeout=3)

Wait for job to load desired number of active pods in time specified in timeout.

Parameters
  • job (obj) – OCS job object

  • desired_count (str) – Number of desired active pods for provided job

  • timeout (int) – Number of seconds to wait for the job to get into state

Returns

If job has desired number of active pods

Return type

bool

ocs_ci.ocs.metrics module

OCS Metrics module.

Code in this module Supports monitoring test cases dealing with OCS metrics.

ocs_ci.ocs.metrics.get_missing_metrics(prometheus, metrics, current_platform=None)

Using given prometheus instance, check that all given metrics which are expected to be available on current platform are there.

Parameters
  • prometheus (ocs_ci.utility.prometheus.PrometheusAPI) – prometheus instance

  • metrics (list) – list or tuple with metrics to be checked

  • current_platform (str) – name of current platform (optional)

Returns

metrics which were not available but should be

Return type

list

ocs_ci.ocs.monitoring module

ocs_ci.ocs.monitoring.check_ceph_health_status_metrics_on_prometheus(mgr_pod)

Check ceph health status metric is collected on prometheus pod

Parameters

mgr_pod (str) – Name of the mgr pod

Returns

True on success, false otherwise

Return type

bool

ocs_ci.ocs.monitoring.check_ceph_metrics_available()

Check ceph metrics available

Returns

True on success, false otherwise

Return type

bool

ocs_ci.ocs.monitoring.check_pvcdata_collected_on_prometheus(pvc_name)

Checks whether initially pvc related data is collected on pod

Parameters

pvc_name (str) – Name of the pvc

Returns

True on success, raises UnexpectedBehaviour on failures

ocs_ci.ocs.monitoring.create_configmap_cluster_monitoring_pod(sc_name=None, telemeter_server_url=None)

Create a configmap named cluster-monitoring-config based on the arguments.

Parameters
  • sc_name (str) – Name of the storage class which will be used for persistent storage needs of OCP Prometheus and Alert Manager. If not defined, the related options won’t be present in the monitoring config map and the default (non persistent) storage will be used for OCP Prometheus and Alert Manager.

  • telemeter_server_url (str) – URL of Telemeter server where telemeter client (running in the cluster) will send it’s telemetry data. If not defined, related option won’t be present in the monitoring config map and the default (production) telemeter server will receive the metrics data.

ocs_ci.ocs.monitoring.get_list_pvc_objs_created_on_monitoring_pods()

Returns list of pvc objects created on monitoring pods

Returns

List of pvc objs

Return type

list

ocs_ci.ocs.monitoring.get_metrics_persistentvolumeclaims_info()

Returns the created pvc information on prometheus pod

Returns

The pvc metrics collected on prometheus pod

Return type

response.content (dict)

ocs_ci.ocs.monitoring.prometheus_health_check(name='monitoring', kind='ClusterOperator')

Return true if the prometheus cluster is healthy

Parameters
  • name (str) – Name of the resources

  • kind (str) – Kind of the resource

Returns

True on prometheus health is ok, false otherwise

Return type

bool

ocs_ci.ocs.monitoring.validate_pvc_are_mounted_on_monitoring_pods(pod_list)

Validate created pvc are mounted on monitoring pods

Parameters

pod_list (list) – List of the pods where pvc are mounted

ocs_ci.ocs.monitoring.validate_pvc_created_and_bound_on_monitoring_pods()

Validate pvc’s created and bound in state on monitoring pods

Raises

AssertionError – If no PVC are created or if any PVC are not in the Bound state

ocs_ci.ocs.node module

ocs_ci.ocs.node.add_new_node_and_label_it(machineset_name, num_nodes=1, mark_for_ocs_label=True)

Add a new node for ipi and label it

Parameters
  • machineset_name (str) – Name of the machine set

  • num_nodes (int) – number of nodes to add

  • mark_for_ocs_label (bool) – True if label the new node

eg: add_new_node_and_label_it(“new-tdesala-zlqzn-worker-us-east-2a”)

Returns

new spun node names

Return type

list

ocs_ci.ocs.node.add_new_node_and_label_upi(node_type, num_nodes, mark_for_ocs_label=True, node_conf=None)

Add a new node for aws/vmware upi platform and label it

Parameters
  • node_type (str) – Type of node, RHEL or RHCOS

  • num_nodes (int) – number of nodes to add

  • mark_for_ocs_label (bool) – True if label the new node

  • node_conf (dict) – The node configurations.

Returns

new spun node names

Return type

list

ocs_ci.ocs.node.add_new_node_to_lvd_and_lvs(old_node_name, new_node_name)

Replace the old node with the new node in localVolumeDiscovery and localVolumeSet, as described in the documents of node replacement with LSO

Parameters
  • old_node_name (str) – The old node name to remove from the local volume

  • new_node_name (str) – the new node name to add to the local volume

Returns

True in case if changes are applied. False otherwise

Return type

bool

ocs_ci.ocs.node.check_nodes_specs(min_memory, min_cpu)

Check that the cluster worker nodes meet the required minimum CPU and memory

Parameters
  • min_memory (int) – The required minimum memory in bytes

  • min_cpu (int) – The required minimum number of vCPUs

Returns

True if all nodes meet the required minimum specs, False otherwise

Return type

bool

ocs_ci.ocs.node.check_taint_on_ocs_nodes(taint='node.ocs.openshift.io/storage=true:NoSchedule')

Function to check for particular taint on nodes

Parameters

taint (str) – The taint to check on nodes

Returns

True if taint is present on node. False otherwise

Return type

bool

ocs_ci.ocs.node.delete_and_create_osd_node_aws_upi(osd_node_name)

Unschedule, drain and delete osd node, and creating a new osd node. At the end of the function there should be the same number of osd nodes as it was in the beginning, and also ceph health should be OK. This function is for AWS UPI.

Parameters

osd_node_name (str) – the name of the osd node

Returns

The new node name

Return type

str

ocs_ci.ocs.node.delete_and_create_osd_node_ipi(osd_node_name)

Unschedule, drain and delete osd node, and creating a new osd node. At the end of the function there should be the same number of osd nodes as it was in the beginning, and also ceph health should be OK.

This function is for any IPI platform.

Parameters

osd_node_name (str) – the name of the osd node

Returns

The new node name

Return type

str

ocs_ci.ocs.node.delete_and_create_osd_node_vsphere_upi(osd_node_name, use_existing_node=False)

Unschedule, drain and delete osd node, and creating a new osd node. At the end of the function there should be the same number of osd nodes as it was in the beginning, and also ceph health should be OK. This function is for vSphere UPI.

Parameters
  • osd_node_name (str) – the name of the osd node

  • use_existing_node (bool) – If False, create a new node and label it. If True, use an existing node to replace the deleted node and label it.

Returns

The new node name

Return type

str

ocs_ci.ocs.node.delete_and_create_osd_node_vsphere_upi_lso(osd_node_name, use_existing_node=False)

Unschedule, drain and delete osd node, and creating a new osd node. At the end of the function there should be the same number of osd nodes as it was in the beginning, and also ceph health should be OK. This function is for vSphere UPI.

Parameters
  • osd_node_name (str) – the name of the osd node

  • use_existing_node (bool) – If False, create a new node and label it. If True, use an existing node to replace the deleted node and label it.

Returns

The new node name

Return type

str

ocs_ci.ocs.node.drain_nodes(node_names)

Drain nodes

Parameters

node_names (list) – The names of the nodes

Raises

TimeoutExpired – in case drain command fails to complete in time

ocs_ci.ocs.node.get_all_nodes()

Gets the all nodes in cluster

Returns

List of node name

Return type

list

ocs_ci.ocs.node.get_app_pod_running_nodes(pod_obj)

Gets the app pod running node names

Parameters

pod_obj (list) – List of app pod objects

Returns

App pod running node names

Return type

list

ocs_ci.ocs.node.get_both_osd_and_app_pod_running_node(osd_running_nodes, app_pod_running_nodes)

Gets both osd and app pod running node names

Parameters
  • osd_running_nodes (list) – List of osd running node names

  • app_pod_running_nodes (list) – List of app pod running node names

Returns

Both OSD and app pod running node names

Return type

list

ocs_ci.ocs.node.get_compute_node_names(no_replace=False)

Gets the compute node names

Parameters

no_replace (bool) – If False ‘.’ will replaced with ‘-‘

Returns

List of compute node names

Return type

list

ocs_ci.ocs.node.get_master_nodes()

Fetches all master nodes.

Returns

List of names of master nodes

Return type

list

ocs_ci.ocs.node.get_node_az(node)

Get the node availability zone

Parameters

node (ocs_ci.ocs.resources.ocs.OCS) – The node object

Returns

The name of the node availability zone

Return type

str

ocs_ci.ocs.node.get_node_from_machine_name(machine_name)

Get node name from a given machine_name.

Parameters

machine_name (str) – Name of Machine

Returns

Name of Node (or None if not found)

Return type

str

ocs_ci.ocs.node.get_node_hostname_label(node_obj)

Get the hostname label of a node

Parameters

node_obj (ocs_ci.ocs.resources.ocs.OCS) – The node object

Returns

The node’s hostname label

Return type

str

ocs_ci.ocs.node.get_node_index_in_local_block(node_name)

Get the node index in the node values as it appears in the local block resource

Parameters

node_name (str) – The node name to search for his index

Returns

The node index in the nodeSelector values

Return type

int

ocs_ci.ocs.node.get_node_ips(node_type='worker')

Gets the node public IP

Parameters

node_type (str) – The node type (e.g. worker, master)

Returns

Node IP’s

Return type

list

ocs_ci.ocs.node.get_node_logs(node_name)

Get logs from a given node

pod_name (str): Name of the node

Returns

Output of ‘dmesg’ run on node

Return type

str

ocs_ci.ocs.node.get_node_name(node_obj)

Get oc node’s name

Parameters

node_obj (node_obj) – oc node object

Returns

node’s name

Return type

str

ocs_ci.ocs.node.get_node_objs(node_names=None)

Get node objects by node names

Parameters

node_names (list) – The node names to get their objects for. If None, will return all cluster nodes

Returns

Cluster node OCP objects

Return type

list

ocs_ci.ocs.node.get_node_pods(node_name, pods_to_search=None)

Get all the pods of a specified node

Parameters
  • node_name (str) – The node name to get the pods

  • pods_to_search (list) – list of pods to search for the node pods. If not specified, will search in all the pods.

Returns

list of all the pods of the specified node

Return type

list

ocs_ci.ocs.node.get_node_pods_to_scale_down(node_name)

Get the pods of a node to scale down as described in the documents of node replacement with LSO

Parameters

node_name (str) – The node name

Returns

The node’s pods to scale down

Return type

list

ocs_ci.ocs.node.get_node_resource_utilization_from_adm_top(nodename=None, node_type='worker', print_table=False)

Gets the node’s cpu and memory utilization in percentage using adm top command.

Parameters
  • nodename (str) – The node name

  • node_type (str) – The node type (e.g. master, worker)

Returns

Node name and its cpu and memory utilization in

percentage

Return type

dict

ocs_ci.ocs.node.get_node_resource_utilization_from_oc_describe(nodename=None, node_type='worker', print_table=False)

Gets the node’s cpu and memory utilization in percentage using oc describe node

Parameters
  • nodename (str) – The node name

  • node_type (str) – The node type (e.g. master, worker)

Returns

Node name and its cpu and memory utilization in

percentage

Return type

dict

ocs_ci.ocs.node.get_nodes(node_type='worker', num_of_nodes=None)

Get cluster’s nodes according to the node type (e.g. worker, master) and the number of requested nodes from that type

Parameters
  • node_type (str) – The node type (e.g. worker, master)

  • num_of_nodes (int) – The number of nodes to be returned

Returns

The nodes OCP instances

Return type

list

ocs_ci.ocs.node.get_ocs_nodes(num_of_nodes=None)

Gets the ocs nodes

Parameters

num_of_nodes (int) – The number of ocs nodes to return. If not specified, it returns all the ocs nodes.

Returns

List of ocs nodes

Return type

list

ocs_ci.ocs.node.get_osd_running_nodes()

Gets the osd running node names

Returns

OSD node names

Return type

list

ocs_ci.ocs.node.get_osds_per_node()

Gets the osd running pod names per node name

Returns

{“Node name”:[“osd running pod name running on the node”,..,]}

Return type

dict

ocs_ci.ocs.node.get_provider()

Return the OCP Provider (Platform)

Returns

The Provider that the OCP is running on

Return type

str

ocs_ci.ocs.node.get_running_pod_count_from_node(nodename=None, node_type='worker')

Gets the node running pod count using oc describe node

Parameters
  • nodename (str) – The node name

  • node_type (str) – The node type (e.g. master, worker)

Returns

Node name and its pod_count

Return type

dict

ocs_ci.ocs.node.get_typed_worker_nodes(os_id='rhcos')

Get worker nodes with specific OS

Parameters

os_id (str) – OS type like rhcos, RHEL etc…

Returns

list of worker nodes instances having specified os

Return type

list

ocs_ci.ocs.node.get_worker_nodes()

Fetches all worker nodes.

Returns

List of names of worker nodes

Return type

list

ocs_ci.ocs.node.get_worker_nodes_not_in_ocs()

Get the worker nodes that are not ocs labeled.

Returns

list of worker node objects that are not ocs labeled

Return type

list

ocs_ci.ocs.node.is_node_labeled(node_name, label="cluster.ocs.openshift.io/openshift-storage=''")

Check if the node is labeled with a specified label.

Parameters
  • node_name (str) – The node name to check if it has the specific label

  • label (str) – The name of the label. Default value is the OCS label.

Returns

True if the node is labeled with the specified label. False otherwise

Return type

bool

ocs_ci.ocs.node.label_nodes(nodes, label="cluster.ocs.openshift.io/openshift-storage=''")

Label nodes

Parameters
  • nodes (list) – list of node objects need to label

  • label (str) – New label to be assigned for these nodes. Default value is the OCS label

ocs_ci.ocs.node.node_network_failure(node_names, wait=True)

Induce node network failure Bring node network interface down, making the node unresponsive

Parameters
  • node_names (list) – The names of the nodes

  • wait (bool) – True in case wait for status is needed, False otherwise

Returns

True if node network fail is successful

Return type

bool

ocs_ci.ocs.node.node_replacement_verification_steps_ceph_side(old_node_name, new_node_name, new_osd_node_name)

Check the verification steps from the Ceph side, after the process of node replacement as described in the docs

Parameters
  • old_node_name (str) – The name of the old node that has been deleted

  • new_node_name (str) – The name of the new node that has been created

  • new_osd_node_name (str) – The name of the new node that has been added to osd nodes

Returns

True if all the verification steps passed. False otherwise

Return type

bool

ocs_ci.ocs.node.node_replacement_verification_steps_user_side(old_node_name, new_node_name, new_osd_node_name, old_osd_id)

Check the verification steps that the user should perform after the process of node replacement as described in the docs

Parameters
  • old_node_name (str) – The name of the old node that has been deleted

  • new_node_name (str) – The name of the new node that has been created

  • new_osd_node_name (str) – The name of the new node that has been added to osd nodes

  • old_osd_id (str) – The old osd id

Returns

True if all the verification steps passed. False otherwise

Return type

bool

ocs_ci.ocs.node.print_table_node_resource_utilization(utilization_dict, field_names)

Print table of node utilization

Parameters
  • utilization_dict (dict) – CPU and Memory utilization per Node

  • field_names (list) – The field names of the table

ocs_ci.ocs.node.remove_nodes(nodes)

Remove the nodes from cluster

Parameters

nodes (list) – list of node instances to remove from cluster

ocs_ci.ocs.node.scale_down_deployments(node_name)

Scale down the deployments of a node as described in the documents of node replacement with LSO

Parameters

node_name (str) – The node name

ocs_ci.ocs.node.schedule_nodes(node_names)

Change nodes to be scheduled

Parameters

node_names (list) – The names of the nodes

ocs_ci.ocs.node.taint_nodes(nodes, taint_label='node.ocs.openshift.io/storage')

Taint nodes

Parameters
  • nodes (list) – list of node names need to taint

  • taint_label (str) – New taint label to be assigned for these nodes. Default value is the OCS taint

ocs_ci.ocs.node.taint_ocs_nodes(nodes_to_taint=None)

Function to taint nodes with “node.ocs.openshift.io/storage=true:NoSchedule”

Parameters

nodes_to_taint (list) – Nodes to taint

ocs_ci.ocs.node.unschedule_nodes(node_names)

Change nodes to be unscheduled

Parameters

node_names (list) – The names of the nodes

ocs_ci.ocs.node.untaint_ocs_nodes(taint='node.ocs.openshift.io/storage=true:NoSchedule', nodes_to_untaint=None)

Function to remove taints from nodes

Parameters
  • taint (str) – taint to use

  • nodes_to_taint (list) – list of nodes to untaint

Returns

True if untainted, false otherwise

Return type

bool

ocs_ci.ocs.node.wait_for_new_osd_node(old_osd_node_names, timeout=180)

Wait for the new osd node to appear.

Parameters
  • old_osd_node_names (list) – List of the old osd node names

  • timeout (int) – time to wait for the new osd node to appear

Returns

The new osd node name if the new osd node appear in the specific timeout.

Else it returns None

Return type

str

ocs_ci.ocs.node.wait_for_nodes_status(node_names=None, status='Ready', timeout=180)

Wait until all nodes are in the given status

Parameters
  • node_names (list) – The node names to wait for to reached the desired state If None, will wait for all cluster nodes

  • status (str) – The node status to wait for (e.g. ‘Ready’, ‘NotReady’, ‘SchedulingDisabled’)

  • timeout (int) – The number in seconds to wait for the nodes to reach the status

Raises

ResourceWrongStatusException – In case one or more nodes haven’t reached the desired state

ocs_ci.ocs.ocp module

General OCP object

class ocs_ci.ocs.ocp.OCP(api_version='v1', kind='Service', namespace=None, resource_name='', selector=None)

Bases: object

A basic OCP object to run basic ‘oc’ commands

add_label(resource_name, label)

Adds a new label for this pod

Parameters
  • resource_name (str) – Name of the resource you want to label

  • label (str) – New label to be assigned for this pod E.g: “label=app=’rook-ceph-mds’”

property api_version
apply(yaml_file)

Applies configuration changes to a resource

Parameters

yaml_file (str) – Path to a yaml file to use in ‘oc apply -f file.yaml

Returns

Dictionary represents a returned yaml file

Return type

dict

check_function_supported(support_var)

Check if the resource supports the functionality based on the support_var.

Parameters

support_var (bool) – True if functionality is supported, False otherwise.

Raises

NotSupportedFunctionError – If support_var == False

check_name_is_specified(resource_name='')

Check if the name of the resource is specified in class level and if not raise the exception.

Raises

ResourceNameNotSpecifiedException – in case the name is not specified.

check_phase(phase)

Check phase of resource

Parameters

phase (str) – Phase of resource object

Returns

True if phase of object is the same as passed one, False

otherwise.

Return type

bool

Raises
create(yaml_file=None, resource_name='', out_yaml_format=True)

Creates a new resource

Parameters
  • yaml_file (str) – Path to a yaml file to use in ‘oc create -f file.yaml

  • resource_name (str) – Name of the resource you want to create

  • out_yaml_format (bool) – Determines if the output should be formatted to a yaml like string

Returns

Dictionary represents a returned yaml file

Return type

dict

property data
delete(yaml_file=None, resource_name='', wait=True, force=False)

Deletes a resource

Parameters
  • yaml_file (str) – Path to a yaml file to use in ‘oc delete -f file.yaml

  • resource_name (str) – Name of the resource you want to delete

  • wait (bool) – Determines if the delete command should wait to completion

  • force (bool) – True for force deletion with –grace-period=0, False otherwise

Returns

Dictionary represents a returned yaml file

Return type

dict

Raises

CommandFailed – In case yaml_file and resource_name wasn’t provided

delete_project(project_name)

Delete a project. A project created by the new_project function does not have a corresponding yaml file so normal resource deletion calls do not work

Parameters

project_name (str) – Name of the project to be deleted

Returns

True in case project deletion succeeded.

Return type

bool

Raises

CommandFailed – When the project deletion does not succeed.

describe(resource_name='', selector=None, all_namespaces=False)

Get command - ‘oc describe <resource>’

Parameters
  • resource_name (str) – The resource name to fetch

  • selector (str) – The label selector to look for

  • all_namespaces (bool) – Equal to oc describe <resource> -A

Example

describe(‘my-pv1’)

Returns

Dictionary represents a returned yaml file

Return type

dict

exec_oc_cmd(command, out_yaml_format=True, secrets=None, timeout=600, ignore_error=False, **kwargs)

Executing ‘oc’ command

Parameters
  • command (str) – The command to execute (e.g. create -f file.yaml) without the initial ‘oc’ at the beginning

  • out_yaml_format (bool) – whether to return yaml loaded python object or raw output

  • secrets (list) – A list of secrets to be masked with asterisks This kwarg is popped in order to not interfere with subprocess.run(**kwargs)

  • timeout (int) – timeout for the oc_cmd, defaults to 600 seconds

  • ignore_error (bool) – True if ignore non zero return code and do not raise the exception.

Returns

Dictionary represents a returned yaml file. str: If out_yaml_format is False.

Return type

dict

exec_oc_debug_cmd(node, cmd_list, timeout=300)

Function to execute “oc debug” command on OCP node

Parameters
  • node (str) – Node name where the command to be executed

  • cmd_list (list) – List of commands eg: [‘cmd1’, ‘cmd2’]

  • timeout (int) – timeout for the exec_oc_cmd, defaults to 600 seconds

Returns

Returns output of the executed command/commands

Return type

out (str)

Raises

CommandFailed – When failure in command execution

get(resource_name='', out_yaml_format=True, selector=None, all_namespaces=False, retry=0, wait=3, dont_raise=False)

Get command - ‘oc get <resource>’

Parameters
  • resource_name (str) – The resource name to fetch

  • out_yaml_format (bool) – Adding ‘-o yaml’ to oc command

  • selector (str) – The label selector to look for.

  • all_namespaces (bool) – Equal to oc get <resource> -A

  • retry (int) – Number of attempts to retry to get resource

  • wait (int) – Number of seconds to wait between attempts for retry

  • dont_raise (bool) – If True will raise when get is not found

Example

get(‘my-pv1’)

Returns

Dictionary represents a returned yaml file None: Incase dont_raise is True and get is not found

Return type

dict

get_logs(name, container_name=None, all_containers=False, secrets=None, timeout=None, ignore_error=False)

Execute oc logs command to fetch logs for a given k8s resource.

Since the log is stored as a string in memory, this will be problematic when the log is large.

Parameters
  • name (str) – name of the resource to fetch logs from

  • container_name (str) – name of the container (optional)

  • all_containers (bool) – fetch logs from all containers of the resource

  • secrets (list) – A list of secrets to be masked with asterisks

  • timeout (int) – timeout for the oc_cmd

  • ignore_error (bool) – True if ignore non zero return code and do not raise the exception.

Returns

container logs

Return type

str

get_resource(resource_name, column, retry=0, wait=3, selector=None)

Get a column value for a resource based on: ‘oc get <resource_kind> <resource_name>’ command

Parameters
  • resource_name (str) – The name of the resource to get its column value

  • column (str) – The name of the column to retrive

  • retry (int) – Number of attempts to retry to get resource

  • wait (int) – Number of seconds to wait beteween attempts for retry

  • selector (str) – The resource selector to search with.

Returns

The output returned by ‘oc get’ command not in the ‘yaml’

format

Return type

str

get_resource_status(resource_name)

Get the resource STATUS column based on: ‘oc get <resource_kind> <resource_name>’ command

Parameters

resource_name (str) – The name of the resource to get its STATUS

Returns

The status returned by ‘oc get’ command not in the ‘yaml’

format

Return type

str

get_user_token()

Get user access token

Returns

access token

Return type

str

is_exist(resource_name='', selector=None)

Check if at least one of the resource exists.

Parameters
  • resource_name (str) – Name of the resource.

  • selector (str) – Selector of the resource.

Raises

ResourceNameNotSpecifiedException – In case the name is not specified.

Returns

True if the resource exists False otherwise.

Return type

bool

property kind
login(user, password)

Logs user in

Parameters
  • user (str) – Name of user to be logged in

  • password (str) – Password of user to be logged in

Returns

output of login command

Return type

str

login_as_sa()

Logs in as system:admin

Returns

output of login command

Return type

str

property namespace
new_project(project_name)

Creates a new project

Parameters

project_name (str) – Name of the project to be created

Returns

True in case project creation succeeded, False otherwise

Return type

bool

patch(resource_name='', params=None, format_type='')

Applies changes to resources

Parameters
  • resource_name (str) – Name of the resource

  • params (str) – Changes to be added to the resource

  • type (str) – Type of the operation

Returns

True in case if changes are applied. False otherwise

Return type

bool

reload_data()

Reloading data of OCP object

property resource_name
wait_for_delete(resource_name='', timeout=60, sleep=3)

Wait for a resource to be deleted

Parameters
  • resource_name (str) – The name of the resource to wait for (e.g.my-pv1)

  • timeout (int) – Time in seconds to wait

  • sleep (int) – Sampling time in seconds

Raises
  • CommandFailed – If failed to verify the resource deletion

  • TimeoutError – If resource is not deleted within specified timeout

Returns

True in case resource deletion is successful

Return type

bool

wait_for_phase(phase, timeout=300, sleep=5)

Wait till phase of resource is the same as required one passed in the phase parameter.

Parameters
  • phase (str) – Desired phase of resource object

  • timeout (int) – Timeout in seconds to wait for desired phase

  • sleep (int) – Time in seconds to sleep between attempts

Raises
wait_for_resource(condition, resource_name='', column='STATUS', selector=None, resource_count=0, timeout=60, sleep=3, dont_allow_other_resources=False, error_condition=None)

Wait for a resource to reach to a desired condition

Parameters
  • condition (str) – The desired state the resource that is sampled from ‘oc get <kind> <resource_name>’ command

  • resource_name (str) – The name of the resource to wait for (e.g.my-pv1)

  • column (str) – The name of the column to compare with

  • selector (str) – The resource selector to search with. Example: ‘app=rook-ceph-mds’

  • resource_count (int) – How many resources expected to be

  • timeout (int) – Time in seconds to wait

  • sleep (int) – Sampling time in seconds

  • dont_allow_other_resources (bool) – If True it will not allow other resources in different state. For example you are waiting for 2 resources and there are currently 3 (2 in running state, 1 in ContainerCreating) the function will continue to next iteration to wait for only 2 resources in running state and no other exists.

  • error_condition (str) – State of the resource that is sampled from ‘oc get <kind> <resource_name>’ command, which makes this method to fail immediately without waiting for a timeout. This is optional and makes sense only when there is a well defined unrecoverable state of the resource(s) which is not expected to be part of a workflow under test, and at the same time, the timeout itself is large.

Returns

True in case all resources reached desired condition,

False otherwise

Return type

bool

ocs_ci.ocs.ocp.confirm_cluster_operator_version(target_version, cluster_operator)

Check if cluster operator upgrade process is completed:

Parameters
  • cluster_operator – (str): ClusterOperator name

  • target_version (str) – expected OCP client

Returns

True if success, False if failed

Return type

bool

ocs_ci.ocs.ocp.get_all_cluster_operators()

Get all ClusterOperators names in OCP

Returns

cluster-operator names

Return type

list

ocs_ci.ocs.ocp.get_build()

Return the OCP Build Version

Returns

The build version of the OCP

Return type

str

ocs_ci.ocs.ocp.get_cluster_operator_version(cluster_operator_name)

Get image version of selected cluster operator

Parameters

cluster_operator_name (str) – ClusterOperator name

Returns

cluster operator version: ClusterOperator image version

Return type

str

ocs_ci.ocs.ocp.get_clustername()

Return the name (DNS short name) of the cluster

Returns

the short DNS name of the cluster

Return type

str

ocs_ci.ocs.ocp.get_current_oc_version()

Gets Current OCP client version

Returns

current COP client version

Return type

str

ocs_ci.ocs.ocp.get_images(data, images=None)

Get the images from the ocp object like pod, CSV and so on.

Parameters
  • data (dict) – Yaml data from the object.

  • images (dict) – Dict where to put the images (doesn’t have to be set!).

Returns

Images dict like: {‘image_name’: ‘image.url.to:tag’, …}

Return type

dict

ocs_ci.ocs.ocp.get_ocp_channel()

Return the OCP Channel

Returns

The channel of the OCP

Return type

str

ocs_ci.ocs.ocp.get_ocp_upgrade_channel()

Gets OCP upgrade channel

Returns

OCP upgrade channel name

Return type

str

ocs_ci.ocs.ocp.get_ocs_parsed_version()

Returns ocs version as float

Returns

ocs version number as major.minor (for example: 4.5)

Return type

float

ocs_ci.ocs.ocp.get_ocs_version()

Return the OCS Version

Returns

The version of the OCS

Return type

str

ocs_ci.ocs.ocp.patch_ocp_upgrade_channel(channel_variable='candidate-4.7')

Using ‘oc patch clusterversion’ if new OCP upgrade channel is different than current one

Parameters

channel_variable (str) – New OCP upgrade subscription channel

ocs_ci.ocs.ocp.rsync(src, dst, node, dst_node=True, extra_params='')

This function will rsync source folder to destination path. You can rsync local folder to the node or vice versa depends on dst_node parameter. By default the rsync is from local to the node.

Parameters
  • src (str) – Source path of folder to rsync.

  • dst (str) – Destination path where to rsync.

  • node (str) – Node to/from copy.

  • dst_node (bool) – True if the destination (dst) is the node, False when dst is the local folder.

  • extra_params (str) – “See: oc rsync –help for the extra params”

ocs_ci.ocs.ocp.switch_to_default_rook_cluster_project()

Switch to default project

Returns

True on success, False otherwise

Return type

bool

ocs_ci.ocs.ocp.switch_to_project(project_name)

Switch to another project

Parameters

project_name (str) – Name of the project to be switched to

Returns

True on success, False otherwise

Return type

bool

ocs_ci.ocs.ocp.upgrade_ocp(image_path, image)

upgrade OCP version

Parameters
  • image (str) – image to be installed

  • image_path (str) – path to image

ocs_ci.ocs.ocp.validate_cluster_version_status()

Verify OCP upgrade is completed, by checking ‘oc get clusterversion’ status

Returns

False in case that one of condition flags is invalid:

Progressing (should be False), Failing(should be False) or Available (should be True)

Return type

bool

ocs_ci.ocs.ocp.verify_cluster_operator_status(cluster_operator)

Checks if cluster operator status is degraded or progressing, as sign that upgrade not yet completed

Parameters

cluster_operator (str) – OCP cluster operator name

Returns

True if cluster operator status is valid, False if cluster operator status is “degraded” or “progressing”

Return type

bool

ocs_ci.ocs.ocp.verify_images_upgraded(old_images, object_data)

Verify that all images in ocp object are upgraded.

Parameters
  • old_images (set) – Set with old images.

  • object_data (dict) – OCP object yaml data.

Raises

NonUpgradedImagesFoundError – In case the images weren’t upgraded.

ocs_ci.ocs.ocp.verify_ocp_upgrade_channel(channel_variable='candidate-4.7')

When upgrade OCP version, verify that subscription channel is same as current one

Parameters

channel_variable (str) – New OCP upgrade subscription channel

Returns

True when OCP subscription channel is correct,

and no patch needed

Return type

bool

ocs_ci.ocs.ocp.wait_for_cluster_connectivity(tries=200, delay=3)

Wait for the cluster to be reachable

Parameters
  • tries (int) – The number of retries

  • delay (int) – The delay in seconds between retries

Returns

True if cluster is reachable, False otherwise

Return type

bool

Raises

CommandFailed – In case the cluster is unreachable

ocs_ci.ocs.ocs_upgrade module

class ocs_ci.ocs.ocs_upgrade.OCSUpgrade(namespace, version_before_upgrade, ocs_registry_image, upgrade_in_current_source)

Bases: object

OCS Upgrade helper class

check_if_upgrade_completed(channel, csv_name_pre_upgrade)

Checks if OCS operator finishes it’s upgrade

Parameters
  • channel – (str): OCS subscription channel

  • csv_name_pre_upgrade – (str): OCS operator name

Returns

True if upgrade completed, False otherwise

Return type

bool

get_csv_name_pre_upgrade()

Getting OCS operator name as displayed in CSV

Returns

OCS operator name, as displayed in CSV

Return type

str

get_images_post_upgrade(channel, pre_upgrade_images, upgrade_version)
Checks if all images of OCS cluster upgraded,

and return list of all images if upgrade success

Parameters
  • channel – (str): OCS subscription channel

  • pre_upgrade_images – (dict): Contains all OCS cluster images

  • upgrade_version – (str): version to be upgraded

Returns

Contains full path of OCS cluster old images

Return type

set

get_parsed_versions()

Getting parsed version names, current version, and upgrade version

Returns

contains 2 strings with parsed names of current version

and upgrade version

Return type

tuple

get_pre_upgrade_image(csv_name_pre_upgrade)

Getting all OCS cluster images, before upgrade

Parameters

csv_name_pre_upgrade – (str): OCS operator name

Returns

Contains all OCS cluster images

dict keys: Image name dict values: Image full path

Return type

dict

get_upgrade_version()

Getting the required upgrade version

Returns

version to be upgraded

Return type

str

load_version_config_file(upgrade_version)

Loads config file to the ocs-ci config with upgrade version

Parameters

upgrade_version – (str): version to be upgraded

property ocs_registry_image
set_upgrade_channel()

Wait for the new package manifest for upgrade.

Returns

OCS subscription channel

Return type

str

set_upgrade_images()

Set images for upgrade

update_subscription(channel)

Updating OCS operator subscription

Parameters

channel – (str): OCS subscription channel

property version_before_upgrade
ocs_ci.ocs.ocs_upgrade.get_upgrade_image_info(old_csv_images, new_csv_images)

Log the info about the images which are going to be upgraded.

Parameters
  • old_csv_images (dict) – dictionary with the old images from pre upgrade CSV

  • new_csv_images (dict) – dictionary with the post upgrade images

Returns

with three sets which contain those types of images

old_images_for_upgrade - images which should be upgraded new_images_to_upgrade - new images to which upgrade unchanged_images - unchanged images without upgrade

Return type

tuple

ocs_ci.ocs.ocs_upgrade.run_ocs_upgrade(operation=None, *operation_args, **operation_kwargs)

Run upgrade procedure of OCS cluster

Parameters
  • operation – (function): Function to run

  • operation_args – (iterable): Function’s arguments

  • operation_kwargs – (map): Function’s keyword arguments

ocs_ci.ocs.ocs_upgrade.verify_image_versions(old_images, upgrade_version, version_before_upgrade)

Verify if all the images of OCS objects got upgraded

Parameters
  • old_images (set) – set with old images

  • upgrade_version (packaging.version.Version) – version of OCS

  • version_before_upgrade (float) – version of OCS before upgrade

ocs_ci.ocs.openshift_ops module

class ocs_ci.ocs.openshift_ops.OCP

Bases: object

Class which contains various utility functions for interacting with OpenShift

static call_api(method, **kw)

This function makes generic REST calls

Parameters
  • method (str) – one of the GET, CREATE, PATCH, POST, DELETE

  • **kw – Based on context of the call kw will be populated by caller

Returns

ResourceInstance object

create_project(project)

Creates new project

Parameters

project (str) – project name

Returns

True if successful otherwise False

Return type

bool

get_labels(pod_name, pod_namespace)

Get labels from specific pod

Parameters
  • pod_name (str) – Name of pod in oc cluster

  • pod_namespace (str) – pod namespace in which the pod lives

Raises

NotFoundError – If resource not found

Returns

All the openshift labels on a given pod

Return type

dict

get_pods(**kw)

Get pods in specific namespace or across oc cluster.

Parameters

**kw – ex: namespace=rook-ceph, label_selector=’x==y’

Returns

of pods names, if no namespace provided then this function

returns all pods across openshift cluster.

Return type

list

get_projects()

Gets all the projects in the cluster

Returns

List of projects

Return type

list

get_services()

Gets all the services in the cluster

Returns

defaultdict of services, key represents the namespace

and value represents the services

Return type

dict

get_services_in_namespace(namespace)

Gets the services in a namespace

Returns

list of services in a namespace

Return type

list

static set_kubeconfig(kubeconfig_path)

Export environment variable KUBECONFIG for future calls of OC commands or other API calls

Parameters

kubeconfig_path (str) – path to kubeconfig file to be exported

Returns

True if successfully connected to cluster, False otherwise

Return type

boolean

ocs_ci.ocs.openstack module

class ocs_ci.ocs.openstack.CephVMNode(**kw)

Bases: object

attach_floating_ip(timeout=120)
create_node(**kw)
destroy_node()

Relies on the fact that names should be unique. Along the chain we prevent non-unique names to be used/added. TODO: raise an exception if more than one node is matched to the name, that can be propagated back to the client.

destroy_volume(name)
get_driver(**kw)
get_private_ip()

Workaround. self.node.private_ips returns empty list.

get_volume(name)

Return libcloud.compute.base.StorageVolume

exception ocs_ci.ocs.openstack.GetIPError

Bases: Exception

exception ocs_ci.ocs.openstack.InvalidHostName

Bases: Exception

exception ocs_ci.ocs.openstack.NodeErrorState

Bases: Exception

ocs_ci.ocs.parallel module

class ocs_ci.ocs.parallel.ExceptionHolder(exc_info)

Bases: object

ocs_ci.ocs.parallel.capture_traceback(func, *args, **kwargs)

Utility function to capture tracebacks of any exception func raises.

class ocs_ci.ocs.parallel.parallel

Bases: object

This class is a context manager for running functions in parallel.

You add functions to be run with the spawn method:

with parallel() as p:
    for foo in bar:
        p.spawn(quux, foo, baz=True)

You can iterate over the results (which are in arbitrary order):

with parallel() as p:
    for foo in bar:
        p.spawn(quux, foo, baz=True)
    for result in p:
        print result

If one of the spawned functions throws an exception, it will be thrown when iterating over the results, or when the with block ends.

At the end of the with block, the main thread waits until all spawned functions have completed, or, if one exited with an exception, kills the rest and raises the exception.

spawn(func, *args, **kwargs)
ocs_ci.ocs.parallel.resurrect_traceback(exc)

ocs_ci.ocs.perfresult module

Basic Module to manage performance results

class ocs_ci.ocs.perfresult.PerfResult(uuid, crd)

Bases: object

Basic Performance results object for Q-PAS team

add_key(key, value)

Adding (key and value) to this object results dictionary as a new dictionary.

Parameters
  • key (str) – String which will be the key for the value

  • value – value to add, can be any kind of data type

es_connect()

Create Elastic-Search server connection

es_read()

Reading all test results from the elastic-search server

Returns

list of results

Return type

list

Assert:

if no data found in the server

es_write()

Writing the results to the elastic-search server

Raise:

RequestError: in case of error writing data to the server

Create a link to the results of the test in the elasticsearch serer

Returns

http link to the test results in the elastic-search server

Return type

str

ocs_ci.ocs.perftests module

class ocs_ci.ocs.perftests.PASTest

Bases: ocs_ci.framework.testlib.BaseTest

Base class for QPAS team - Performance and Scale tests

This class contain functions which used by performance and scale test, and also can be used by E2E test which used the benchmark-operator (ripsaw)

copy_es_data(elasticsearch)

Copy data from Internal ES (if exists) to the main ES

Parameters

elasticsearch (obj) – elasticsearch object (if exits)

deploy_and_wait_for_wl_to_start(timeout=300, sleep=20)

Deploy the workload and wait until it start working

Parameters
  • timeout (int) – time in second to wait until the benchmark start

  • sleep (int) – Sleep interval seconds

es_info_backup(elasticsearch)

Saving the Original elastic-search IP and PORT - if defined in yaml

Parameters

elasticsearch (obj) – elasticsearch object

get_env_info()

Getting the environment information and update the workload RC if necessary.

pytestmark = [Mark(name='usefixtures', args=('environment_checker',), kwargs={}), Mark(name='performance', args=(), kwargs={}), Mark(name='scale', args=(), kwargs={})]
ripsaw_deploy(ripsaw)

Deploy the benchmark operator (formally ripsaw) CRD

Parameters

ripsaw (obj) – benchmark operator object

set_storageclass(interface)

Setting the benchmark CRD storageclass

Parameters

interface (str) – The interface which will used in the test

setup()

Setting up the environment for each performance and scale test

wait_for_wl_to_finish(timeout=18000, sleep=300)

Waiting until the workload is finished and get the test log

Parameters
  • timeout (int) – time in second to wait until the benchmark start

  • sleep (int) – Sleep interval seconds

ocs_ci.ocs.pgsql module

Postgresql workload class

class ocs_ci.ocs.pgsql.Postgresql(**kwargs)

Bases: ocs_ci.ocs.ripsaw.RipSaw

Postgresql workload operation

attach_pgsql_pod_to_claim_pvc(pvc_objs, postgres_name, run_benchmark=True, pgbench_name=None)

Attaches pgsql pod to created claim PVC

Parameters
  • pvc_objs (list) – List of PVC objs which needs to attached to pod

  • postgres_name (str) – Name of the postgres pod

  • run_benchmark (bool) – On true, runs pgbench benchmark on postgres pod

  • pgbench_name (str) – Name of pgbench benchmark

Returns

List of pod objs created

Return type

pgsql_obj_list (list)

cleanup()

Clean up

create_pgbench_benchmark(replicas, pgbench_name=None, postgres_name=None, clients=None, threads=None, transactions=None, scaling_factor=None, timeout=None, wait=True)

Create pgbench benchmark pods

Parameters
  • replicas (int) – Number of pgbench pods to be deployed

  • pgbench_name (str) – Name of pgbench bechmark

  • postgres_name (str) – Name of postgres pod

  • clients (int) – Number of clients

  • threads (int) – Number of threads

  • transactions (int) – Number of transactions

  • scaling_factor (int) – scaling factor

  • timeout (int) – Time in seconds to wait

  • wait (bool) – On true waits till pgbench reaches Completed state

Returns

pgbench pod objects list

Return type

List

delete_pgbench_pods(pg_obj_list)

Delete all pgbench pods on cluster

Returns

True if deleted, False otherwise

Return type

bool

export_pgoutput_to_googlesheet(pg_output, sheet_name, sheet_index)

Collect pgbench output to google spreadsheet

Parameters
  • pg_output (list) – pgbench outputs in list

  • sheet_name (str) – Name of the sheet

  • sheet_index (int) – Index of sheet

get_pgbech_pod_status_table(pgbench_pods)

Get pgbench pod data and print results on a table

Parameters

pods (pgbench) – List of pgbench pods

get_pgbench_pods()

Get all pgbench pods

Returns

pgbench pod objects list

Return type

List

get_pgbench_status(pgbench_pod_name)

Get pgbench status

Parameters

pgbench_pod_name (str) – Name of the pgbench pod

Returns

state of pgbench pod (running/completed)

Return type

str

get_pgsql_nodes()

Get nodes that contain a pgsql app pod

Returns

Cluster node OCP objects

Return type

list

get_postgres_pods()

Get all postgres pods :returns: postgres pod objects list :rtype: List

get_postgres_pvc()

Get all postgres pvc

Returns

postgres pvc objects list

Return type

List

get_postgres_used_file_space(pod_obj_list)

Get the used file space on a mount point

Parameters

pod_obj_list (POD) – List of pod objects

Returns

List of pod object

Return type

list

is_pgbench_running()

Check if pgbench is running

Returns

True if pgbench is running; False otherwise

Return type

bool

respin_pgsql_app_pod()

Respin the pgsql app pod

Returns

pod status

setup_postgresql(replicas, sc_name=None)

Deploy postgres sql server

Parameters

replicas (int) – Number of postgresql pods to be deployed

Raises

CommandFailed – If PostgreSQL server setup fails

validate_pgbench_run(pgbench_pods, print_table=True)

Validate pgbench run

Parameters

pods (pgbench) – List of pgbench pods

Returns

pgbench outputs in list

Return type

pg_output (list)

wait_for_pgbench_status(status, timeout=None)

Wait for pgbench benchmark pods status to reach running/completed

Parameters
  • status (str) – status to reach Running or Completed

  • timeout (int) – Time in seconds to wait

wait_for_postgres_status(status='Running', timeout=300)

Wait for postgres pods status to reach running/completed

Parameters
  • status (str) – status to reach Running or Completed

  • timeout (int) – Time in seconds to wait

ocs_ci.ocs.pillowfight module

Pillowfight Class to run various workloads and scale tests

class ocs_ci.ocs.pillowfight.PillowFight(**kwargs)

Bases: object

Workload operation using PillowFight This class was modelled after the RipSaw class in this directory.

MAX_ACCEPTABLE_RESPONSE_TIME = 2000
MIN_ACCEPTABLE_OPS_PER_SEC = 2000
WAIT_FOR_TIME = 1800
analyze_all()

Analyze the data extracted into self.logs files

cleanup()

Remove pillowfight pods and temp files

export_pfoutput_to_googlesheet(sheet_name, sheet_index)

Collect pillowfight output to google spreadsheet

Parameters
  • sheet_name (str) – Name of the sheet

  • sheet_index (int) – Index of sheet

parse_pillowfight_log(data_from_log)

Run oc logs on the pillowfight pod passed in. Cleanup the output from oc logs to handle peculiarities in the couchbase log results, and generate a summary of the results.

The dictionary returned has two values; ‘opspersec’ and ‘resptimes’. opspersec is a list of ops per second numbers reported.’ resptimes is a dictionary index by the max response time of a range. Each entry in resptimes contains a minimum response time for that range, and a count of how many messages fall within that range.

Parameters

data_from_log (str) – log data

Returns

ops per sec and response time information

Return type

dict

run_pillowfights(replicas=1, num_items=None, num_threads=None)

loop through all the yaml files extracted from the pillowfight repo and run them. Run oc logs on the results and save the logs in self.logs directory

Parameters
  • replicas (int) – Number of pod replicas

  • num_items (int) – Number of items to be loaded to the cluster

  • num_threads (int) – Number of threads

sanity_check(stats)

Make sure the worst cases for ops per second and response times are within an acceptable range.

ocs_ci.ocs.platform_nodes module

class ocs_ci.ocs.platform_nodes.AWSNodes

Bases: ocs_ci.ocs.platform_nodes.NodesBase

AWS EC2 instances class

all_nodes_found(node_names)

Relying on oc get nodes -o wide to confirm that node is added to cluster

Parameters

node_names (list) – of node names as string

Returns

‘True’ if all the node names appeared in ‘get nodes’ else ‘False’

Return type

bool

approve_all_nodes_csr(node_list)

Make sure that all the newly added nodes are in approved csr state

Parameters

node_list (list) – of AWSUPINode/AWSIPINode objects

Raises

PendingCSRException – If any pending csrs exists

attach_nodes_to_cluster(node_list)

Attach nodes in the list to the cluster

Parameters

node_list (list) – of AWSUPINode/AWSIPINode objects

attach_nodes_to_upi_cluster(node_list)

Attach node to upi cluster Note: For RHCOS nodes, create function itself would have attached the nodes to cluster so nothing to do here

Parameters

node_list (list) – of AWSUPINode objects

attach_rhel_nodes_to_upi_cluster(node_list)

Attach RHEL nodes to upi cluster

Parameters

node_list (list) – of AWSUPINode objects with RHEL os

attach_volume(volume, node)

Attach a data volume to an instance

Parameters
  • volume (Volume) – The volume to delete

  • node (OCS) – The EC2 instance to attach the volume to

build_ansible_inventory(hosts)

Build the ansible hosts file from jinja template

Parameters

hosts (list) – list of private host names

Returns

path of the ansible file created

Return type

str

check_connection(rhel_pod_obj, host, pem_dst_path)

Check whether newly brought up RHEL instances are accepting ssh connections

Parameters
  • rhel_pod_obj (Pod) – object for handling ansible pod

  • host (str) – Node to which we want to try ssh

  • pem_dst_path (str) – path to private key for ssh

create_nodes(node_conf, node_type, num_nodes)

create aws instances of nodes

Parameters
  • node_conf (dict) – of node configuration

  • node_type (str) – type of node to be created RHCOS/RHEL

  • num_nodes (int) – Number of node instances to be created

Returns

of AWSUPINode objects

Return type

list

detach_volume(volume, node=None, delete_from_backend=True)

Detach a volume from an EC2 instance

Parameters
  • volume (Volume) – The volume to delete

  • node (OCS) – The OCS object representing the node

  • delete_from_backend (bool) – True for deleting the disk from the storage backend, False otherwise

get_available_slots(existing_indexes, required_slots)

Get indexes which are free

Parameters
  • existing_indexes (list) – of integers

  • required_slots (int) – required number of integers

Returns

of integers (available slots)

Return type

list

get_data_volumes()

Get the data EBS volumes

Returns

EBS Volume instances

Return type

list

get_ec2_instances(nodes)

Get the EC2 instances dicts

Parameters

nodes (list) – The OCS objects of the nodes

Returns

The EC2 instances dicts (IDs and names)

Return type

dict

get_existing_indexes(index_list)

Extract index suffixes from index_list

Parameters

index_list (list) – of stack names in the form of ‘clustername-no$i’

Returns

sorted list of Integers

Return type

list

get_node_by_attached_volume(volume)

Get node OCS object of the EC2 instance that has the volume attached to

Parameters

volume (Volume) – The volume to get the EC2 according to

Returns

The OCS object of the EC2 instance

Return type

OCS

get_ready_status(node_info)

Get the node ‘Ready’ status

Parameters

node_info (dict) – Node info which includes details

Returns

True if node is Ready else False

Return type

bool

get_stack_name_of_node(node_name)

Get the stack name of a given node

Parameters

node_name (str) – the name of the node

Returns

The stack name of the given node

Return type

str

restart_nodes(nodes, timeout=300, wait=True)

Restart EC2 instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True if need to wait till the restarted node reaches READY state. False otherwise

  • timeout (int) – time in seconds to wait for node to reach ‘not ready’ state, and ‘ready’ state.

restart_nodes_by_stop_and_start(nodes, wait=True, force=True)

Restart nodes by stopping and starting EC2 instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True in case wait for status is needed, False otherwise

  • force (bool) – True for force instance stop, False otherwise

Returns:

restart_nodes_by_stop_and_start_teardown()

Make sure all EC2 instances are up. To be used in the test teardown

start_nodes(instances=None, nodes=None, wait=True)

Start EC2 instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • instances (dict) – instance-id and name dict

  • wait (bool) – True for waiting the instances to start, False otherwise

stop_nodes(nodes, wait=True)

Stop EC2 instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True for waiting the instances to stop, False otherwise

terminate_nodes(nodes, wait=True)

Terminate EC2 instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True for waiting the instances to terminate,

  • otherwise (False) –

verify_nodes_added(hosts)

Verify RHEL workers are added

Parameters

hosts (list) – list of aws private hostnames

Raises

FailedToAddNodeException – if node addition failed

wait_for_volume_attach(volume)

Wait for an EBS volume to be attached to an EC2 instance. This is used as when detaching the EBS volume from the EC2 instance, re-attach should take place automatically

Parameters

volume (Volume) – The volume to wait for to be attached

Returns

True if the volume has been attached to the

instance, False otherwise

Return type

bool

class ocs_ci.ocs.platform_nodes.AWSUPINode(node_conf, node_type)

Bases: ocs_ci.ocs.platform_nodes.AWSNodes

Node object representing AWS upi nodes

add_cert_to_template(worker_template_path)

Add cert to worker template

Parameters

worker_template_path (str) – Path where template file is located

build_stack_params(index, conf)

Build all the params required for a stack creation

Parameters
  • index (int) – An integer index for this stack

  • conf (dict) – Node config

Returns

of param dicts

Return type

list

gather_worker_data(suffix='no0')

Gather various info like vpc, iam role, subnet,security group, cluster tag from existing RHCOS workers

Parameters

suffix (str) – suffix to get resource of worker node, ‘no0’ by default

get_cert_content(worker_ignition_path)

Get the certificate content from worker ignition file

Parameters

worker_ignition_path (str) – Path of the worker ignition file

Returns

certificate content

Return type

formatted_cert (str)

get_kube_tag(tags)

Fetch kubernets.io tag from worker instance

Parameters

tags (dict) – AWS tags from existing worker

Returns

key looks like

”kubernetes.io/cluster/<cluster-name>” and value looks like “share” OR “owned”

Return type

tuple

get_rhcos_worker_template()

Download template and keep it locally

Returns

local path to template file

Return type

path (str)

get_worker_resource_id(resource)

Get the resource ID

Parameters

resource (dict) – a dictionary of stack resource

Returns

ID of worker stack resource

Return type

str

update_template_with_cert(worker_template_path, cert)

Update the template file with cert provided

Parameters
  • worker_template_path (str) – template file path

  • cert (str) – Certificate body

class ocs_ci.ocs.platform_nodes.AZURENodes

Bases: ocs_ci.ocs.platform_nodes.NodesBase

Azure Nodes class

attach_nodes_to_cluster(node_list)
attach_volume(volume, node)
create_and_attach_nodes_to_cluster(node_conf, node_type, num_nodes)

Create nodes and attach them to cluster Use this function if you want to do both creation/attachment in a single call

Parameters
  • node_conf (dict) – of node configuration

  • node_type (str) – type of node to be created RHCOS/RHEL

  • num_nodes (int) – Number of node instances to be created

create_nodes(node_conf, node_type, num_nodes)
detach_volume(volume, node=None, delete_from_backend=True)

Detach a volume from an Azure Vm instance

Parameters
  • volume (Disk) – The disk object required to delete a volume

  • node (OCS) – The OCS object representing the node

  • delete_from_backend (bool) – True for deleting the disk from the storage backend, False otherwise

get_data_volumes()

Get the data Azure disk objects

Returns

azure disk objects

Return type

list

get_node_by_attached_volume(volume)

Get node OCS object of the Azure vm instance that has the volume attached to

Parameters

volume (Disk) – The disk object to get the Azure Vm according to

Returns

The OCS object of the Azure Vm instance

Return type

OCS

restart_nodes(nodes, timeout=900, wait=True)

Restart Azure vm instances

Parameters
  • nodes (list) – The OCS objects of the nodes / Azure Vm instance

  • wait (bool) – True if need to wait till the restarted node reaches READY state. False otherwise

  • timeout (int) – time in seconds to wait for node to reach ‘not ready’ state, and ‘ready’ state.

restart_nodes_by_stop_and_start(nodes, timeout=540, wait=True, force=True)

Restart Azure vm instances by stop and start

Parameters
  • nodes (list) – The OCS objects of the nodes / Azure Vm instance

  • wait (bool) – True if need to wait till the restarted node reaches READY state. False otherwise

  • timeout (int) – time in seconds to wait for node to reach ‘not ready’ state, and ‘ready’ state.

  • force (bool) – True for force VM stop, False otherwise

restart_nodes_by_stop_and_start_teardown()

Make sure all VM instances up by the end of the test

start_nodes(nodes, timeout=540, wait=True)

Start Azure vm instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True for waiting the instances to start, False otherwise

  • timeout (int) – time in seconds to wait for node to reach ‘ready’ state.

stop_nodes(nodes, timeout=540, wait=True, force=True)

Stop Azure vm instances

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – True for waiting the instances to stop, False otherwise

  • timeout (int) – time in seconds to wait for node to reach ‘not ready’ state.

  • force (bool) – True for force VM stop, False otherwise

wait_for_volume_attach(volume)

Wait for a Disk to be attached to an Azure Vm instance. This is used as when detaching the Disk from the Azure Vm instance, re-attach should take place automatically

Parameters

volume (Disk) – The Disk to wait for to be attached

Returns

True if the volume has been attached to the

instance, False otherwise

Return type

bool

class ocs_ci.ocs.platform_nodes.BaremetalNodes

Bases: ocs_ci.ocs.platform_nodes.NodesBase

Baremetal Nodes class

attach_nodes_to_cluster(node_list)
attach_volume(volume, node)
create_and_attach_nodes_to_cluster(node_conf, node_type, num_nodes)

Create nodes and attach them to cluster Use this function if you want to do both creation/attachment in a single call

Parameters
  • node_conf (dict) – of node configuration

  • node_type (str) – type of node to be created RHCOS/RHEL

  • num_nodes (int) – Number of node instances to be created

create_nodes(node_conf, node_type, num_nodes)
detach_volume(volume, node=None, delete_from_backend=True)
get_data_volumes()
get_node_by_attached_volume(volume)
read_default_config(default_config_path)

Commonly used function to read default config

Parameters

default_config_path (str) – Path to default config file

Returns

of default config loaded

Return type

dict

restart_nodes(nodes, force=True)

Restart Baremetal Machine

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force BM stop, False otherwise

restart_nodes_teardown()

Make sure all BMs are up by the end of the test

start_nodes(nodes, wait=True)

Start Baremetal Machine

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – Wait for node status

stop_nodes(nodes, force=True)

Stop Baremetal Machine

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force nodes stop, False otherwise

wait_for_volume_attach(volume)
class ocs_ci.ocs.platform_nodes.IBMPowerNodes

Bases: ocs_ci.ocs.platform_nodes.NodesBase

IBM Power Nodes class

restart_nodes(nodes, timeout=540, wait=True, force=True)

Restart PowerNode

Parameters
  • nodes (list) – The OCS objects of the nodes

  • timeout (int) – time in seconds to wait for node to reach ‘not ready’ state, and ‘ready’ state.

  • wait (bool) – True if need to wait till the restarted node reaches timeout

  • force (bool) – True for force BM stop, False otherwise

restart_nodes_by_stop_and_start(nodes, force=True)

Restart PowerNodes with stop and start

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force node stop, False otherwise

restart_nodes_by_stop_and_start_teardown()

Make sure all PowerNodes are up by the end of the test

start_nodes(nodes, force=True)

Start PowerNode

Parameters
  • nodes (list) – The OCS objects of the nodes

  • wait (bool) – Wait for node status

stop_nodes(nodes, force=True)

Stop PowerNode

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force nodes stop, False otherwise

class ocs_ci.ocs.platform_nodes.NodesBase

Bases: object

A base class for nodes related operations. Should be inherited by specific platform classes

attach_nodes_to_cluster(node_list)
attach_volume(volume, node)
create_and_attach_nodes_to_cluster(node_conf, node_type, num_nodes)

Create nodes and attach them to cluster Use this function if you want to do both creation/attachment in a single call

Parameters
  • node_conf (dict) – of node configuration

  • node_type (str) – type of node to be created RHCOS/RHEL

  • num_nodes (int) – Number of node instances to be created

create_nodes(node_conf, node_type, num_nodes)
detach_volume(volume, node=None, delete_from_backend=True)
get_data_volumes()
get_node_by_attached_volume(volume)
read_default_config(default_config_path)

Commonly used function to read default config

Parameters

default_config_path (str) – Path to default config file

Returns

of default config loaded

Return type

dict

restart_nodes(nodes, wait=True)
restart_nodes_by_stop_and_start(nodes, force=True)
restart_nodes_by_stop_and_start_teardown()
start_nodes(nodes)
stop_nodes(nodes)
wait_for_volume_attach(volume)
class ocs_ci.ocs.platform_nodes.PlatformNodesFactory

Bases: object

A factory class to get specific nodes platform object

get_nodes_platform()
class ocs_ci.ocs.platform_nodes.VMWareLSONodes

Bases: ocs_ci.ocs.platform_nodes.VMWareNodes

VMWare LSO nodes class

detach_volume(volume, node=None, delete_from_backend=True)

Detach disk from a VM and delete from datastore if specified

Parameters
  • volume (str) – Volume path

  • node (OCS) – The OCS object representing the node

  • delete_from_backend (bool) – True for deleting the disk (vmdk) from backend datastore, False otherwise

get_data_volumes(pvs=None)

Get the data vSphere volumes

Parameters

pvs (list) – PV OCS objects

Returns

vSphere volumes

Return type

list

class ocs_ci.ocs.platform_nodes.VMWareNodes

Bases: ocs_ci.ocs.platform_nodes.NodesBase

VMWare nodes class

attach_volume(node, volume)
create_and_attach_nodes_to_cluster(node_conf, node_type, num_nodes)

Create nodes and attach them to cluster Use this function if you want to do both creation/attachment in a single call

Parameters
  • node_conf (dict) – of node configuration

  • node_type (str) – type of node to be created RHCOS/RHEL

  • num_nodes (int) – Number of node instances to be created

create_and_attach_volume(node, size)

Create a new volume and attach it to the given VM

Parameters
  • node (OCS) – The OCS object representing the node

  • size (int) – The size in GB for the new volume

detach_volume(volume, node=None, delete_from_backend=True)

Detach disk from a VM and delete from datastore if specified

Parameters
  • volume (str) – Volume path

  • node (OCS) – The OCS object representing the node

  • delete_from_backend (bool) – True for deleting the disk (vmdk) from backend datastore, False otherwise

get_data_volumes(pvs=None)

Get the data vSphere volumes

Parameters

pvs (list) – PV OCS objects

Returns

vSphere volumes

Return type

list

get_node_by_attached_volume(volume)
get_vms(nodes)

Get vSphere vm objects list

Parameters

nodes (list) – The OCS objects of the nodes

Returns

vSphere vm objects list

Return type

list

restart_nodes(nodes, force=True, timeout=300, wait=True)

Restart vSphere VMs

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for Hard reboot, False for Soft reboot

  • timeout (int) – time in seconds to wait for node to reach READY state

  • wait (bool) – True if need to wait till the restarted OCP node reaches READY state. False otherwise

restart_nodes_by_stop_and_start(nodes, force=True)

Restart vSphere VMs

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force VM stop, False otherwise

restart_nodes_by_stop_and_start_teardown()

Make sure all VMs are up by the end of the test

start_nodes(nodes, wait=True)

Start vSphere VMs

Parameters

nodes (list) – The OCS objects of the nodes

stop_nodes(nodes, force=True)

Stop vSphere VMs

Parameters
  • nodes (list) – The OCS objects of the nodes

  • force (bool) – True for force VM stop, False otherwise

wait_for_volume_attach(volume)
class ocs_ci.ocs.platform_nodes.VSPHEREUPINode(node_conf, node_type, compute_count)

Bases: ocs_ci.ocs.platform_nodes.VMWareNodes

Node object representing VMWARE UPI nodes

add_node(use_terraform=True)

Add nodes to the current cluster

Parameters

use_terraform (bool) – if True use terraform to add nodes, otherwise use manual steps to add nodes

add_nodes_with_terraform()

Add nodes using terraform

add_nodes_without_terraform()

Add nodes without terraform

generate_node_names_for_vsphere(count, prefix='compute-')

Generate the node names for vsphere platform

Parameters
  • count (int) – Number of node names to generate

  • prefix (str) – Prefix for node name

Returns

List of node names

Return type

list

wait_for_connection_and_set_host_name(ip, host_name)

Waits for connection to establish to the node and sets the hostname

Parameters
  • ip (str) – IP of the node

  • host_name (str) – Host name to set for the node

Raises
  • NoValidConnectionsError – Raises if connection is not established

  • AuthenticationException – Raises if credentials are not correct

ocs_ci.ocs.pod_exec module

Dispatcher for proper exec based on api-client config

This class takes care of dispatching a proper api-client instance to take care of command execution.

WHY this class ? Execution of command might happen using various means, as of now we are using kubernetes client but we might also use openshift rest client. To cope with this we might have to dynamically figure out at run time which backend to use.

This module will have all api client class definitions in this file along with dispatcher class Exec.

class ocs_ci.ocs.pod_exec.CmdObj(cmd, timeout, wait, check_ec, long_running)

Bases: tuple

property check_ec

Alias for field number 3

property cmd

Alias for field number 0

property long_running

Alias for field number 4

property timeout

Alias for field number 1

property wait

Alias for field number 2

class ocs_ci.ocs.pod_exec.Exec(oc_client='KubClient')

Bases: object

Dispatcher class for proper api client instantiation

This class has a factory function which returns proper api client instance necessary for command execution

run(podname, namespace, cmd_obj)

actual run happens here Command will be fwd to api client object and it should return a 3 tuple (stdout, stderr, retval)

class ocs_ci.ocs.pod_exec.KubClient

Bases: object

Specific to upstream Kubernetes client library

run(podname, namespace, cmd_obj)
ocs_ci.ocs.pod_exec.register_class(cls)

Decorator for registering a class ‘cls’ in class map

Please make sure that api-client name in config should be same as class name.

ocs_ci.ocs.rados_utils module

class ocs_ci.ocs.rados_utils.RadosHelper(mon, config=None, log=None, cluster='ceph')

Bases: object

create_pool(pool_name, pg_num=16, erasure_code_profile_name=None, min_size=None, erasure_code_use_overwrites=False)

Create a pool named from the pool_name parameter.

Parameters
  • pool_name (str) – name of the pool being created.

  • pg_num (int) – initial number of pgs.

  • erasure_code_profile_name (str) – if set and !None create an erasure coded pool using the profile

  • min_size (int) – minimum size

  • erasure_code_use_overwrites (bool) – if True, allow overwrites

get_mgr_proxy_container(node, docker_image, proxy_container='mgr_proxy')

Returns mgr dummy container to access containerized storage :param node: ceph node :type node: ceph.ceph.CephNode :param docker_image: repository/image:tag :type docker_image: str

Returns

mgr object

Return type

ceph.ceph.CephDemon

get_num_pools()
Returns

number of pools in the cluster

get_osd_dump_json()

osd dump –format=json converted to a python object :returns: the python object

get_pg_primary(pool, pgnum)

get primary for pool, pgnum (e.g. (data, 0)->0

get_pg_random(pool, pgnum)

get random osd for pool, pgnum (e.g. (data, 0)->0

get_pgid(pool, pgnum)
Parameters
  • pool – pool name

  • pgnum – pg number

Returns

a string representing this pg.

get_pool_dump(pool)

get the osd dump part of a pool

get_pool_num(pool)

get number for pool (e.g., data -> 2)

get_pool_property(pool_name, prop)
Parameters
  • pool_name – pool

  • prop – property to be checked.

Returns

property as an int value.

is_up(osd_id)

:return 1 if up, 0 if down

kill_osd(osd_node, osd_service)
Params

id , type of signal, list of osd objects type: “SIGKILL”, “SIGTERM”, “SIGHUP” etc.

Returns

1 or 0

list_pools()

list all pool names

raw_cluster_cmd(*args)
Returns

(stdout, stderr)

revive_osd(osd_node, osd_service)
Returns

0 if revive success,1 if fail

ocs_ci.ocs.registry module

ocs_ci.ocs.registry.add_role_to_user(role_type, user, cluster_role=False, namespace=None)

Function to add a cluster/regular role to user

Parameters
  • role_type (str) – Type of the role to be added

  • user (str) – User to be added for the role

  • cluster_role (bool) – Whether to add a cluster-role or a regular role

  • namespace (str) – Namespace to be used

Raises

AssertionError – When failure in adding new role to user

ocs_ci.ocs.registry.change_registry_backend_to_ocs()

Function to deploy registry with OCS backend.

Raises

AssertionError – When failure in change of registry backend to OCS

ocs_ci.ocs.registry.check_image_exists_in_registry(image_url)

Function to check either image exists in registry or not

Parameters

image_url (str) – Image url to be verified

Returns

True if image exists, else False

Return type

bool

ocs_ci.ocs.registry.enable_route_and_create_ca_for_registry_access()

Function to enable route and to create ca, copy to respective location for registry access

Raises

AssertionError – When failure in enabling registry default route

ocs_ci.ocs.registry.get_build_name_by_pattern(pattern='', namespace=None)

In a given namespace find names of the builds that match the given pattern

Parameters
  • pattern (str) – name of the build with given pattern

  • namespace (str) – Namespace value

Returns

List of build names matching the pattern

Return type

build_list (list)

ocs_ci.ocs.registry.get_default_route_name()

Function to get default route name

Returns

Returns default route name

Return type

route_name (str)

ocs_ci.ocs.registry.get_oc_podman_login_cmd(skip_tls_verify=True)

Function to get oc and podman login commands on node

Parameters

skip_tls_verify (bool) – If true, the server’s certificate will not be checked for validity

Returns

List of cmd for oc/podman login

Return type

cmd_list (list)

ocs_ci.ocs.registry.get_registry_pod_obj()

Function to get registry pod obj

Returns

List of Registry pod objs

Return type

pod_obj (list)

Raises

UnexpectedBehaviour – When image-registry pod is not present.

ocs_ci.ocs.registry.image_list_all()

Function to list the images in the podman registry

Returns

Images present in cluster

Return type

image_list_output (str)

ocs_ci.ocs.registry.image_pull(image_url)

Function to pull images from repositories

Parameters

image_url (str) – Image url container image repo link

ocs_ci.ocs.registry.image_pull_and_push(project_name, template, image='', pattern='', wait=True)

Pull and push images running oc new-app command :param project_name: Name of project :type project_name: str :param template: Name of the template of the image :type template: str :param image: Name of the image with tag :type image: str :param pattern: name of the build with given pattern :type pattern: str :param wait: If true waits till the image pull and push completes. :type wait: bool

ocs_ci.ocs.registry.image_push(image_url, namespace)

Function to push images to destination

Parameters
  • image_url (str) – Image url container image repo link

  • namespace (str) – Image to be uploaded namespace

Returns

Uploaded image path

Return type

registry_path (str)

ocs_ci.ocs.registry.image_rm(registry_path, image_url)

Function to remove images from registry

Parameters
  • registry_path (str) – Image registry path

  • image_url (str) – Image url container image repo link

ocs_ci.ocs.registry.modify_registry_pod_count(count)

Function to modify registry replica count(increase/decrease pod count)

Parameters

count (int) – registry replica count to be changed to

Returns

True in case if changes are applied. False otherwise

Return type

bool

Raises

TimeoutExpiredError – When number of image registry pods doesn’t match the count

ocs_ci.ocs.registry.remove_role_from_user(role_type, user, cluster_role=False, namespace=None)

Function to remove a cluster/regular role from a user

Parameters
  • role_type (str) – Type of the role to be removed

  • user (str) – User of the role

  • cluster_role (bool) – Whether to remove a cluster-role or a regular role

  • namespace (str) – Namespace to be used

Raises

AssertionError – When failure in removing role from user

ocs_ci.ocs.registry.validate_image_exists(namespace=None)

Validate image exists on registries path :param namespace: Namespace where the images/builds are created :type namespace: str

Returns

Dir/Files/Images are listed in string format

Return type

image_list (str)

Raises

Exceptions if dir/folders not found

ocs_ci.ocs.registry.validate_pvc_mount_on_registry_pod()

Function to validate pvc mounted on the registry pod

Raises

AssertionError – When PVC mount not present in the registry pod

ocs_ci.ocs.registry.validate_registry_pod_status()

Function to validate registry pod status

ocs_ci.ocs.ripsaw module

RipSaw Class to run various workloads and scale tests

class ocs_ci.ocs.ripsaw.RipSaw(**kwargs)

Bases: object

Workload operation using RipSaw

apply_crd(crd)

Apply the CRD

Parameters

crd (str) – Name of file to apply

cleanup()
get_uuid(benchmark)
Getting the UUID of the test.

when ripsaw used for running a benchmark tests, each run get its own UUID, so the results in the elastic-search server can be sorted.

Parameters

benchmark (str) – the name of the main pod in the test

Returns

the UUID of the test

Return type

str

ocs_ci.ocs.scale_lib module

class ocs_ci.ocs.scale_lib.FioPodScale(kind='deploymentconfig', pod_dict_path='/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/stable/ocs_ci/templates/app-pods/fedora_dc.yaml', node_selector={'scale-label': 'app-scale'})

Bases: object

FioPodScale Class with required scale library functions and params

cleanup()

Function to tear down

create_and_set_namespace()

Create and set namespace for the pods to be created Create sa_name if Kind if DeploymentConfig

create_multi_pvc_pod(pods_per_iter=5, io_runtime=3600, start_io=False, pvc_size=None)

Function to create PVC of different type and attach them to PODs and start IO.

Parameters
  • pods_per_iter (int) – Number of PVC-POD to be created per PVC type

  • If 2 then 8 PVC+POD will be created with 2 each of 4 PVC types (Example,) –

  • io_runtime (sec) – Fio run time in seconds

  • start_io (bool) – If True start IO else don’t

  • pvc_size (Gi) – size of PVC

Returns

Objs of all the PODs created pvc_objs (obj): Objs of all the PVCs created

Return type

pod_objs (obj)

create_scale_pods(scale_count=1500, pods_per_iter=5, io_runtime=None, pvc_size=None, start_io=None)

Main Function with scale pod creation flow and checks to add nodes. For other platforms will not be considering the instance_type param

Parameters
  • scale_count (int) – Scale pod+pvc count

  • io_runtime (sec) – Fio run time in seconds

  • start_io (bool) – If True start IO else don’t

  • pods_per_iter (int) – Number of PVC-POD to be created per PVC type

  • pvc_size (Gi) – size of PVC

  • If 5 then 20 PVC+POD will be created with 5 each of 4 PVC types (Example,) –

  • value in-between 5-10 (Test) –

property kind
property node_selector
property pod_dict_path
pvc_expansion(pvc_new_size)

Function to expand PVC size and verify the new size is reflected.

ocs_ci.ocs.scale_lib.add_worker_based_on_cpu_utilization(node_count, expected_percent, role_type=None, machineset_name=None)

Function to evaluate CPU utilization of nodes and add node if required.

Parameters
  • machineset_name (list) – Machineset_names to add more nodes if required.

  • node_count (int) – Additional nodes to be added

  • expected_percent (int) – Expected utilization precent

  • role_type (str) – To add type to the nodes getting added

Returns

True if Nodes gets added, else false.

Return type

bool

ocs_ci.ocs.scale_lib.add_worker_based_on_pods_count_per_node(node_count, expected_count, role_type=None, machineset_name=None)

Function to evaluate number of pods up in node and add new node accordingly.

Parameters
  • machineset_name (list) – Machineset_names to add more nodes if required.

  • node_count (int) – Additional nodes to be added

  • expected_count (int) – Expected pod count in one node

  • role_type (str) – To add type to the nodes getting added

Returns

True if Nodes gets added, else false.

Return type

bool

ocs_ci.ocs.scale_lib.check_all_pvc_reached_bound_state_in_kube_job(kube_job_obj, namespace, no_of_pvc, timeout=30)

Function to check either bulk created PVCs reached Bound state using kube_job

Parameters
  • kube_job_obj (obj) – Kube Job Object

  • namespace (str) – Namespace of PVC’s created

  • no_of_pvc (int) – Bulk PVC count

  • timeout – a timeout for all the pvc in kube job to reach bound status

Returns

List of all PVCs which is in Bound state.

Return type

pvc_bound_list (list)

Asserts:

If not all PVC reached to Bound state.

ocs_ci.ocs.scale_lib.check_and_add_enough_worker(worker_count)

Function to check if there is enough workers available to scale pods. IF there is no enough worker then worker will be added based on supported platforms Function also adds scale label to the respective worker nodes.

Parameters

worker_count (int) – Expected worker count to be present in the setup

Returns

True is there is enough worker count else raise exception.

Return type

book

ocs_ci.ocs.scale_lib.check_enough_resource_available_in_workers(ms_name=None, pod_dict_path=None)

Function to check if there is enough resource in worker, if not add worker for automation supported platforms

Parameters
  • ms_name (list) – Require param in-case of aws platform to increase the worker

  • pod_dict_path (str) – Pod dict path for nginx pod.

ocs_ci.ocs.scale_lib.construct_pvc_clone_yaml_bulk_for_kube_job(pvc_dict_list, clone_yaml, sc_name)

Function to construct pvc.yaml to create bulk of pvc clones using kube_job

Parameters
  • pvc_dict_list (list) – List of PVCs for each of them one clone is to be created

  • clone_yaml (str) – Clone yaml which is the template for building clones

  • sc_name (str) – SC name for pvc creation

Returns

List of all PVC.yaml dicts

Return type

pvc_dict_list (list)

ocs_ci.ocs.scale_lib.construct_pvc_creation_yaml_bulk_for_kube_job(no_of_pvc, access_mode, sc_name, pvc_size=None)

Function to construct pvc.yaml to create bulk of pvc’s using kube_job

Parameters
  • no_of_pvc (int) – Bulk PVC count

  • access_mode (str) – PVC access_mode

  • sc_name (str) – SC name for pvc creation

  • pvc_size (str) – size of all pvcs to be created with Gi suffix (e.g. 10Gi). If None, random size pvc will be created

Returns

List of all PVC.yaml dicts

Return type

pvc_dict_list (list)

ocs_ci.ocs.scale_lib.delete_objs_parallel(obj_list, namespace, kind)

Function to delete objs specified in list

Parameters
  • obj_list (list) – List can be obj of pod, pvc, etc

  • namespace (str) – Namespace where the obj belongs to

  • kind (str) – Obj Kind

ocs_ci.ocs.scale_lib.get_expected_worker_count(scale_count=1500)

Function to get expected worker count based on platform to scale pods in cluster

Parameters

scale_count (int) – Scale count of the PVC+POD to be created

Returns

Expected worker count to scale required number of pod

Return type

expected_worker_count (int)

ocs_ci.ocs.scale_lib.get_max_pvc_count()

Return the maximum number of pvcs to test for. This value is 500 times the number of worker nodes.

ocs_ci.ocs.scale_lib.get_rate_based_on_cls_iops(custom_iops_dict=None, osd_size=2048)

Function to check ceph cluster iops and suggest rate param for fio.

Parameters
  • osd_size (int) – Size of the OSD in GB

  • custom_iops_dict (dict) – Dictionary of rate param to be used during IO run.

  • iops_dict = {'usage_below_40%' (Example,) – ‘16k’, ‘usage_40%_60%’: ‘8k’,

  • 'usage_60%_80%' – ‘4k’, ‘usage_80%_95%’: ‘2K’}

  • Make sure dict key is same as above example. (Warning,) –

Returns

Rate parm for fio based on ceph cluster IOPs

Return type

rate_param (str)

ocs_ci.ocs.scale_lib.get_size_based_on_cls_usage(custom_size_dict=None)

Function to check cls capacity suggest IO write to cluster

Parameters
  • custom_size_dict (dict) – Dictionary of size param to be used during IO run.

  • size_dict = {'usage_below_60' (Example,) – ‘2G’, ‘usage_60_70’: ‘512M’,

  • 'usage_70_80' – ‘10M’, ‘usage_80_85’: ‘512K’, ‘usage_above_85’: ‘10K’}

  • Make sure dict key is same as above example. (Warning,) –

Returns

IO size to be considered for cluster env

Return type

size (str)

ocs_ci.ocs.scale_lib.increase_pods_per_worker_node_count(pods_per_node=500, pods_per_core=10)

Function to increase pods per node count, default OCP supports 250 pods per node, from OCP 4.6 limit is going to be 500, but using this function can override this param to create more pods per worker nodes. more detail: https://docs.openshift.com/container-platform/4.5/nodes/nodes/nodes-nodes-managing-max-pods.html

Example: The default value for podsPerCore is 10 and the default value for maxPods is 250. This means that unless the node has 25 cores or more, by default, podsPerCore will be the limiting factor.

WARN: This function will perform Unscheduling of workers and reboot so Please aware if there is any non-dc pods then expected to be terminated.

Parameters
  • pods_per_node (int) – Pods per node limit count

  • pods_per_core (int) – Pods per core limit count

Raise:

UnexpectedBehaviour if machineconfigpool not in Updating state within 40secs.

ocs_ci.ocs.scale_pgsql module

ScalePodPGSQL workload class for scale

class ocs_ci.ocs.scale_pgsql.ScalePodPGSQL(node_selector={'scale-label': 'app-scale'}, **kwargs)

Bases: ocs_ci.ocs.pgsql.Postgresql

Scale Postgresql workload with scale parameters and functions

apply_crd(crd)

Apply the CRD

Parameters

crd (str) – Name of file to apply

cleanup()

Clean up

setup_postgresql(replicas, node_selector=None)

Deploy postgres sql server

Parameters

replicas (int) – Number of postgresql pods to be deployed

Raises

CommandFailed – If PostgreSQL server setup fails

ocs_ci.ocs.scale_pgsql.add_worker_node(instance_type=None)
ocs_ci.ocs.scale_pgsql.delete_worker_node()

ocs_ci.ocs.small_file_workload module

Test to exercise Small File Workload

Note: This test is using the ripsaw and the elastic search, so it start process with port forwarding on port 9200 from the host that run the test (localhost) to the elastic-search within the open-shift cluster, so, if you host is listen to port 9200, this test can not be running in your host.

ocs_ci.ocs.small_file_workload.smallfile_workload(ripsaw, es, file_size, files, threads, samples, interface)

Run SmallFile Workload SmallFile workload uses https://github.com/distributed-system-analysis/smallfile

smallfile is a python-based distributed POSIX workload generator which can be used to quickly measure performance and scaling for a variety of metadata-intensive workloads

Parameters
  • -- Ripsaw fixture to setup/teardown ripsaw (ripsaw) –

  • -- Elastic search fixture (es) –

  • -- size of file to be created (file_siles) –

  • -- number of files to be created (files) –

  • -- number of threads to run (threads) –

  • -- samples taken if running performance tests (samples) –

  • -- CephFileSystem or CephBlockPool (interface) –

Returns

backup_es (str) – backup elastic search location environment (dict) – environment (user is changed at times) sf_data (dict) – small file data extracted from yaml and modified by this routine

ocs_ci.ocs.uninstall module

ocs_ci.ocs.uninstall.remove_cluster_logging_operator_from_ocs()

Function removes cluster logging operator from OCS

ocs_ci.ocs.uninstall.remove_monitoring_stack_from_ocs()

Function removes monitoring stack from OCS

ocs_ci.ocs.uninstall.remove_ocp_registry_from_ocs(platform)

Function removes OCS registry from OCP cluster

Parameters

platform (str) – the platform the cluster deployed on

ocs_ci.ocs.uninstall.uninstall_lso(lso_sc)

Function uninstalls local-volume objects from OCS cluster

ocs_ci.ocs.uninstall.uninstall_ocs()

The function uninstalls the OCS operator from a openshift cluster and removes all its settings and dependencies

ocs_ci.ocs.utils module

ocs_ci.ocs.utils.apply_oc_resource(template_name, cluster_path, _templating, template_data=None, template_dir='ocs-deployment')

Apply an oc resource after rendering the specified template with the rook data from cluster_conf.

Parameters
  • template_name (str) – Name of the ocs-deployment config template

  • cluster_path (str) – Path to cluster directory, where files will be written

  • _templating (Templating) – Object of Templating class used for templating

  • template_data (dict) – Data for render template (default: {})

  • template_dir (str) – Directory under templates dir where template exists (default: ocs-deployment)

ocs_ci.ocs.utils.check_ceph_healthly(ceph_mon, num_osds, num_mons, mon_container=None, timeout=300)

Function to check ceph is in healthy state

Parameters
  • ceph_mon (CephNode) – monitor node

  • num_osds (int) – number of osds in cluster

  • num_mons (int) – number of mons in cluster

  • mon_container (str) – monitor container name if monitor is placed in the container

  • timeout – 300 seconds(default) max time to check if cluster is not healthy within timeout period return 1

Returns

returns 0 when ceph is in healthy state otherwise returns 1

Return type

int

ocs_ci.ocs.utils.cleanup_ceph_nodes(osp_cred, pattern=None, timeout=300)
ocs_ci.ocs.utils.collect_noobaa_db_dump(log_dir_path)

Collect the Noobaa DB dump

Parameters

log_dir_path (str) – directory for dumped Noobaa DB

ocs_ci.ocs.utils.collect_ocs_logs(dir_name, ocp=True, ocs=True, mcg=False, status_failure=True)

Collects OCS logs

Parameters
  • dir_name (str) – directory name to store OCS logs. Logs will be stored in dir_name suffix with _ocs_logs.

  • ocp (bool) – Whether to gather OCP logs

  • ocs (bool) – Whether to gather OCS logs

  • mcg (bool) – True for collecting MCG logs (noobaa db dump)

  • status_failure (bool) – Whether the collection is after success or failure, allows better naming for folders under logs directory

ocs_ci.ocs.utils.collect_prometheus_metrics(metrics, dir_name, start, stop, step=1.0)

Collects metrics from Prometheus and saves them in file in json format. Metrics can be found in OCP Console in Monitoring -> Metrics.

Parameters
  • metrics (list) – list of metrics to get from Prometheus (E.g. ceph_cluster_total_used_bytes, cluster:cpu_usage_cores:sum, cluster:memory_usage_bytes:sum)

  • dir_name (str) – directory name to store metrics. Metrics will be stored in dir_name suffix with _ocs_metrics.

  • start (str) – start timestamp of required datapoints

  • stop (str) – stop timestamp of required datapoints

  • step (float) – step of required datapoints

ocs_ci.ocs.utils.config_ntp(ceph_node)
ocs_ci.ocs.utils.create_ceph_conf(fsid, mon_hosts, pg_num='128', pgp_num='128', size='2', auth='cephx', pnetwork='172.16.0.0/12', jsize='1024')
ocs_ci.ocs.utils.create_ceph_nodes(cluster_conf, inventory, osp_cred, run_id, instances_name=None)
ocs_ci.ocs.utils.create_nodes(conf, inventory, osp_cred, run_id, instances_name=None)
ocs_ci.ocs.utils.create_oc_resource(template_name, cluster_path, _templating, template_data=None, template_dir='ocs-deployment')

Create an oc resource after rendering the specified template with the rook data from cluster_conf.

Parameters
  • template_name (str) – Name of the ocs-deployment config template

  • cluster_path (str) – Path to cluster directory, where files will be written

  • _templating (Templating) – Object of Templating class used for templating

  • template_data (dict) – Data for render template (default: {})

  • template_dir (str) – Directory under templates dir where template exists (default: ocs-deployment)

ocs_ci.ocs.utils.generate_repo_file(base_url, repos)
ocs_ci.ocs.utils.get_ceph_versions(ceph_nodes, containerized=False)

Log and return the ceph or ceph-ansible versions for each node in the cluster.

Parameters
  • ceph_nodes – nodes in the cluster

  • containerized – is the cluster containerized or not

Returns

A dict of the name / version pair for each node or container in the cluster

ocs_ci.ocs.utils.get_cluster_object(external_rhcs_info)

Build a external_ceph.ceph object with all node and role info

Parameters

external_rhcs_info (dict) –

Returns

external_ceph.ceph object

ocs_ci.ocs.utils.get_external_mode_rhcs()

Get external cluster info from config and obtain external cluster object

Returns

external_ceph.Ceph object

ocs_ci.ocs.utils.get_iso_file_url(base_url)
ocs_ci.ocs.utils.get_openstack_driver(yaml)
ocs_ci.ocs.utils.get_pod_name_by_pattern(pattern='client', namespace=None, filter=None)

In a given namespace find names of the pods that match the given pattern

Parameters
  • pattern (str) – name of the pod with given pattern

  • namespace (str) – Namespace value

  • filter (str) – pod name to filter from the list

Returns

List of pod names matching the pattern

Return type

pod_list (list)

ocs_ci.ocs.utils.get_public_network()

Get the configured public network subnet for nodes in the cluster.

Returns

(str) public network subnet

ocs_ci.ocs.utils.get_root_permissions(node, path)

Transfer ownership of root to current user for the path given. Recursive. :param node: :type node: ceph.ceph.CephNode :param path: file path

ocs_ci.ocs.utils.hard_reboot(gyaml, name=None)
ocs_ci.ocs.utils.keep_alive(ceph_nodes)
ocs_ci.ocs.utils.kill_osd_external(ceph_cluster, osd_id, sig_type='SIGTERM')

Kill an osd with given signal

Parameters
  • ceph_cluster (external_cluster.Ceph) – Cluster object

  • osd_id (int) – id of osd

  • sig_type (str) – type of signal to be sent

Raises

CommandFailed exception

ocs_ci.ocs.utils.node_power_failure(gyaml, sleep_time=300, name=None)
ocs_ci.ocs.utils.oc_get_all_obc_names()
Returns

A set of all OBC names

Return type

set

ocs_ci.ocs.utils.open_firewall_port(ceph_node, port, protocol)

Opens firewall ports for given node :param ceph_node: ceph node :type ceph_node: ceph.ceph.CephNode :param port: port :type port: str :param protocol: protocol :type protocol: str

ocs_ci.ocs.utils.reboot_node(ceph_node, timeout=300)

Reboot a node with given ceph_node object

Parameters
  • ceph_node (CephNode) – Ceph node object representing the node.

  • timeout (int) – Wait time in seconds for the node to comeback.

Raises

SSHException – if not able to connect through ssh

ocs_ci.ocs.utils.revive_osd_external(ceph_cluster, osd_id)

Start an already stopped osd

Parameters
  • ceph_cluster (external_cluster.Ceph) – cluster object

  • osd_id (int) – id of osd

Raises

CommandFailed exception in case of failure

ocs_ci.ocs.utils.run_must_gather(log_dir_path, image, command=None)

Runs the must-gather tool against the cluster

Parameters
  • log_dir_path (str) – directory for dumped must-gather logs

  • image (str) – must-gather image registry path

  • command (str) – optional command to execute within the must-gather image

ocs_ci.ocs.utils.search_ethernet_interface(ceph_node, ceph_node_list)

Search interface on the given node node which allows every node in the cluster accesible by it’s shortname.

Parameters
  • ceph_node (ceph.ceph.CephNode) – node where check is performed

  • ceph_node_list (list) – node list to check

ocs_ci.ocs.utils.set_cdn_repo(node, repos)
ocs_ci.ocs.utils.setup_cdn_repos(ceph_nodes, build=None)
ocs_ci.ocs.utils.setup_ceph_toolbox(force_setup=False)

Setup ceph-toolbox - also checks if toolbox exists, if it exists it behaves as noop.

Parameters

force_setup (bool) – force setup toolbox pod

ocs_ci.ocs.utils.setup_deb_cdn_repo(node, build=None)
ocs_ci.ocs.utils.setup_deb_repos(node, ubuntu_repo)
ocs_ci.ocs.utils.setup_repos(ceph, base_url, installer_url=None)
ocs_ci.ocs.utils.setup_vm_node(node, ceph_nodes, **params)
ocs_ci.ocs.utils.store_cluster_state(ceph_cluster_object, ceph_clusters_file_name)
ocs_ci.ocs.utils.update_ca_cert(node, cert_url, timeout=120)
ocs_ci.ocs.utils.write_docker_daemon_json(json_text, node)

Write given string to /etc/docker/daemon/daemon :param json_text: json string :param node: Ceph node object :type node: ceph.ceph.CephNode

ocs_ci.ocs.version module

Version reporting module for OCS QE purposes:

  • logging version of OCS/OCP stack for every test run

  • generating version report directly usable in bug reports

It asks openshift for:

  • ClusterVersion resource

  • image identifiers of all containers running in openshift storage related namespaces

  • rpm package versions of few selected components (such as rook or ceph, if given pod is running)

ocs_ci.ocs.version.get_environment_info()

Getting the environment information, Information that will be collected

Versions:

OCP - version / build / channel OCS - version / build Ceph - version Rook - version

Platform:

BM / VmWare / Cloud provider etc. Instance type / architecture Cluster name User name that run the test

Returns

dictionary that contain the environment information

Return type

dict

ocs_ci.ocs.version.get_ocs_version()

Query OCP to get all information about OCS version.

Returns

ClusterVersion k8s object dict: image_dict with information about images IDs

Return type

dict

ocs_ci.ocs.version.main()

Main fuction of version reporting command line tool. used by entry point report-version from setup.py to invoke this function.

ocs_ci.ocs.version.report_ocs_version(cluster_version, image_dict, file_obj)
Report OCS version via:
  • python logging

  • printing human readable version into file_obj (stdout by default)

Parameters
  • cluster_version (dict) – cluster version dict

  • image_dict (dict) – dict of image objects

  • file_obj (object) – file object to log information

ocs_ci.ocs.workload module

class ocs_ci.ocs.workload.WorkLoad(name=None, path=None, work_load=None, storage_type='fs', pod=None, jobs=1)

Bases: object

run(**conf)

Perform work_load_mod.run in order to run actual io. Every workload module should implement run() function so that we can invoke <workload_module>.run() to run IOs.

Parameters

**conf (dict) – Run configuration a.k.a parameters for workload io runs

Returns

Returns a concurrent.future object

Return type

result (Future)

setup(**setup_conf)

Perform work_load_mod.setup() to setup the workload. Every workload module should implement setup() method so that respective <workload_module>.setup() function can be called from here

Parameters

setup_conf (dict) – Work load setup configuration, varies from workload to workload. Refer constants.TEMPLATE_WORKLOAD_DIR for various available workloads

Returns

True if setup is success else False

Return type

bool

Module contents

Avoid already-imported warning cause of we are importing this package from run wrapper for loading config.

You can see documentation here: https://docs.pytest.org/en/latest/reference.html under section PYTEST_DONT_REWRITE