def setup(self, add_nodes): """ Check that we have the right configurations before we start the test """ osd_pods_before = pod_helpers.get_osd_pods() number_of_osd_pods_before = len(osd_pods_before) if number_of_osd_pods_before >= constants.MAX_OSDS: pytest.skip("We have maximum of OSDs in the cluster") # If we use vSphere we may need to add more worker nodes # to the cluster before starting the test if (config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM and number_of_osd_pods_before >= 9): num_of_expected_wnodes = 6 wnodes = node.get_worker_nodes() num_of_wnodes = len(wnodes) logging.info( f"We have {number_of_osd_pods_before} OSDs in the cluster, " f"and {num_of_wnodes} worker nodes in the cluster") if num_of_wnodes < num_of_expected_wnodes: num_of_wnodes_to_add = num_of_expected_wnodes - num_of_wnodes logging.info( f"Adding more {num_of_wnodes_to_add} worker nodes to the cluster" ) add_nodes(ocs_nodes=False, node_count=num_of_wnodes_to_add) wnodes_not_in_ocs = node.get_worker_nodes_not_in_ocs() if wnodes_not_in_ocs: logging.info("Label the worker nodes that are not in OCS") node.label_nodes(wnodes_not_in_ocs)
def test_ceph_csidriver_runs_on_non_ocs_nodes( self, pvc_factory, pod_factory, add_nodes ): """ 1. Add non ocs nodes 2. Taint new nodes with app label 3. Check if plugin pods running on new nodes 4. Create app-pods on app_nodes """ # Add worker nodes and tainting it as app_nodes add_nodes(ocs_nodes=False, taint_label="nodetype=app:NoSchedule") # Checks for new plugin pod respinning on new app-nodes app_nodes = [node.name for node in get_worker_nodes_not_in_ocs()] interfaces = [constants.CEPHFILESYSTEM, constants.CEPHBLOCKPOOL] logger.info("Checking for plugin pods on non-ocs worker nodes") for interface in interfaces: pod_objs = get_plugin_pods(interface) for pod_obj in pod_objs: node_obj = get_pod_node(pod_obj) try: if node_obj.name in app_nodes: logger.info( f"The plugin pod {pod_obj.name} is running on app_node {node_obj.name}" ) continue except Exception as e: logging.info(f"Plugin pod was not found on {node_obj.name} - {e}") # Creates app-pods on app-nodes for node in app_nodes: pvc_obj = pvc_factory() pod_factory(pvc=pvc_obj, node_name=node)
def delete_and_create_osd_node(osd_node_name): """ Delete an osd node, and create a new one to replace it Args: osd_node_name (str): The osd node name to delete """ new_node_name = None # error message for invalid deployment configuration msg_invalid = ( "ocs-ci config 'deployment_type' value " f"'{config.ENV_DATA['deployment_type']}' is not valid, " f"results of this test run are all invalid." ) # TODO: refactor this so that AWS is not a "special" platform if config.ENV_DATA["platform"].lower() == constants.AWS_PLATFORM: if config.ENV_DATA["deployment_type"] == "ipi": new_node_name = node.delete_and_create_osd_node_ipi(osd_node_name) elif config.ENV_DATA["deployment_type"] == "upi": new_node_name = node.delete_and_create_osd_node_aws_upi(osd_node_name) else: log.error(msg_invalid) pytest.fail(msg_invalid) elif config.ENV_DATA["platform"].lower() in constants.CLOUD_PLATFORMS: if config.ENV_DATA["deployment_type"] == "ipi": new_node_name = node.delete_and_create_osd_node_ipi(osd_node_name) else: log.error(msg_invalid) pytest.fail(msg_invalid) elif config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM: worker_nodes_not_in_ocs = node.get_worker_nodes_not_in_ocs() if not worker_nodes_not_in_ocs: pytest.skip( "Skipping the test because we don't have an " "extra worker node that not in ocs" ) else: log.info( "Perform delete and create ocs node in Vmware using one " "of the existing extra worker nodes that not in ocs" ) new_node_name = node.delete_and_create_osd_node_vsphere_upi( osd_node_name, use_existing_node=True ) assert node.node_replacement_verification_steps_ceph_side( osd_node_name, new_node_name ) assert node.node_replacement_verification_steps_user_side( osd_node_name, new_node_name )