def test_add_node(self): """ Test for adding worker nodes to the cluster while IOs """ new_nodes = 3 if config.ENV_DATA['platform'].lower() in constants.CLOUD_PLATFORMS: dt = config.ENV_DATA['deployment_type'] if dt == 'ipi': machines = machine_utils.get_machinesets() logger.info( f'The worker nodes number before expansion {len(helpers.get_worker_nodes())}' ) for machine in machines: add_new_node_and_label_it(machine) logger.info( f'The worker nodes number after expansion {len(helpers.get_worker_nodes())}' ) else: logger.info( f'The worker nodes number before expansion {len(helpers.get_worker_nodes())}' ) if config.ENV_DATA.get('rhel_workers'): node_type = constants.RHEL_OS else: node_type = constants.RHCOS assert add_new_node_and_label_upi(node_type, new_nodes), "Add node failed" logger.info( f'The worker nodes number after expansion {len(helpers.get_worker_nodes())}' ) elif config.ENV_DATA['platform'].lower() == constants.VSPHERE_PLATFORM: pytest.skip("Skipping add node in Vmware platform due to " "https://bugzilla.redhat.com/show_bug.cgi?id=1844521")
def test_add_node(self): """ Test for adding worker nodes to the cluster while IOs """ new_nodes = 3 if config.ENV_DATA["platform"].lower() in constants.CLOUD_PLATFORMS: dt = config.ENV_DATA["deployment_type"] if dt == "ipi": machines = machine_utils.get_machinesets() logger.info( f"The worker nodes number before expansion {len(node.get_worker_nodes())}" ) for machine in machines: add_new_node_and_label_it(machine) logger.info( f"The worker nodes number after expansion {len(node.get_worker_nodes())}" ) else: logger.info( f"The worker nodes number before expansion {len(node.get_worker_nodes())}" ) if config.ENV_DATA.get("rhel_workers"): node_type = constants.RHEL_OS else: node_type = constants.RHCOS assert add_new_node_and_label_upi(node_type, new_nodes), "Add node failed" logger.info( f"The worker nodes number after expansion {len(node.get_worker_nodes())}" ) elif config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM: pytest.skip("Skipping add node in Vmware platform due to " "https://bugzilla.redhat.com/show_bug.cgi?id=1844521") # Issue to remove skip code https://github.com/red-hat-storage/ocs-ci/issues/2403 # logger.info(f'The worker nodes number before expansion {len(node.get_worker_nodes())}') # if config.ENV_DATA.get('rhel_user'): # pytest.skip("Skipping add RHEL node, code unavailable") # node_type = constants.RHCOS # assert add_new_node_and_label_upi(node_type, new_nodes), "Add node failed" # logger.info(f'The worker nodes number after expansion {len(node.get_worker_nodes())}') ceph_cluster_obj = CephCluster() assert ceph_cluster_obj.wait_for_rebalance( timeout=3600), "Data re-balance failed to complete"
def test_add_node_aws(self): """ Test for adding worker nodes to the cluster while IOs """ dt = config.ENV_DATA['deployment_type'] if dt == 'ipi': machines = machine_utils.get_machinesets() logger.info(f'The worker nodes number before expansion {len(helpers.get_worker_nodes())}') for machine in machines: add_new_node_and_label_it(machine) logger.info(f'The worker nodes number after expansion {len(helpers.get_worker_nodes())}') else: new_nodes = 3 logger.info(f'The worker nodes number before expansion {len(helpers.get_worker_nodes())}') if config.ENV_DATA.get('rhel_workers'): node_type = constants.RHEL_OS else: node_type = constants.RHCOS assert add_new_node_and_label_upi(node_type, new_nodes), "Add node failed" logger.info(f'The worker nodes number after expansion {len(helpers.get_worker_nodes())}')
def test_add_node(self): """ Test for adding worker nodes to the cluster while IOs """ dt = config.ENV_DATA['deployment_type'] if dt == 'ipi': before_replica_counts = dict() count = 2 machines = machine_utils.get_machinesets() for machine in machines: before_replica_counts.update( {machine: machine_utils.get_replica_count(machine)}) worker_nodes_before = helpers.get_worker_nodes() logger.info( f'The worker nodes number before adding a new node is {len(worker_nodes_before)}' ) after_replica_counts = dict() for machine in machines: machine_utils.add_node(machine, count=count) after_replica_counts.update(({ machine: machine_utils.get_replica_count(machine) })) logger.info(after_replica_counts) for sample in TimeoutSampler(timeout=300, sleep=3, func=helpers.get_worker_nodes): if len(sample) == count * len(machines): break worker_nodes_after = helpers.get_worker_nodes() logger.info( f'The worker nodes number after adding a new node is {len(worker_nodes_after)}' ) wait_for_nodes_status(node_names=worker_nodes_after, status=constants.NODE_READY) else: pytest.skip("UPI not yet supported")
def factory(ocs_nodes=False, node_count=3, taint_label=None): """ Args: ocs_nodes (bool): True if new nodes are OCS, False otherwise node_count (int): Number of nodes to be added taint_label (str): Taint label to be added """ new_nodes = [] if config.ENV_DATA["platform"].lower() in constants.CLOUD_PLATFORMS: dt = config.ENV_DATA["deployment_type"] if dt == "ipi": machines = machine_utils.get_machinesets() log.info( f"The worker nodes number before expansion {len(get_worker_nodes())}" ) for machine in machines: new_nodes.append( add_new_node_and_label_it( machine, mark_for_ocs_label=ocs_nodes)) log.info( f"The worker nodes number after expansion {len(get_worker_nodes())}" ) else: log.info( f"The worker nodes number before expansion {len(get_worker_nodes())}" ) if config.ENV_DATA.get("rhel_workers"): node_type = constants.RHEL_OS else: node_type = constants.RHCOS new_nodes.append( add_new_node_and_label_upi(node_type, node_count, mark_for_ocs_label=ocs_nodes)) log.info( f"The worker nodes number after expansion {len(get_worker_nodes())}" ) elif config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM: log.info( f"The worker nodes number before expansion {len(get_worker_nodes())}" ) if config.ENV_DATA.get("rhel_user"): node_type = constants.RHEL_OS else: node_type = constants.RHCOS new_nodes.append( add_new_node_and_label_upi(node_type, node_count, mark_for_ocs_label=ocs_nodes)) log.info( f"The worker nodes number after expansion {len(get_worker_nodes())}" ) nodes = [node for sublist in new_nodes for node in sublist] if taint_label: taint_nodes(nodes=nodes, taint_label=taint_label), "Failed to taint nodes" log.info(f"Successfully Tainted nodes {new_nodes} with {taint_label}")
def factory(ocs_nodes=False, node_count=3, taint_label=None): """ Args: ocs_nodes (bool): True if new nodes are OCS, False otherwise node_count (int): Number of nodes to be added taint_label (str): Taint label to be added """ new_nodes = [] if config.ENV_DATA["platform"].lower() in constants.CLOUD_PLATFORMS: dt = config.ENV_DATA["deployment_type"] if dt == "ipi": machines = machine_utils.get_machinesets() log.info( f"The worker nodes number before expansion {len(get_worker_nodes())}" ) for machine in machines: new_nodes.append( add_new_node_and_label_it( machine, mark_for_ocs_label=ocs_nodes)) log.info( f"The worker nodes number after expansion {len(get_worker_nodes())}" ) else: log.info( f"The worker nodes number before expansion {len(get_worker_nodes())}" ) if config.ENV_DATA.get("rhel_workers"): node_type = constants.RHEL_OS else: node_type = constants.RHCOS new_nodes.append( add_new_node_and_label_upi(node_type, node_count, mark_for_ocs_label=ocs_nodes)) log.info( f"The worker nodes number after expansion {len(get_worker_nodes())}" ) elif config.ENV_DATA["platform"].lower() == constants.VSPHERE_PLATFORM: pytest.skip("Skipping add node in Vmware platform due to " "https://bugzilla.redhat.com/show_bug.cgi?id=1844521") # Issue to remove skip code https://github.com/red-hat-storage/ocs-ci/issues/2403 # log.info( # f"The worker nodes number before expansion {len(get_worker_nodes())}" # ) # if config.ENV_DATA.get("rhel_user"): # pytest.skip("Skipping add RHEL node, code unavailable") # node_type = constants.RHCOS # new_nodes.append( # add_new_node_and_label_upi(node_type, num_nodes=node_count) # ) # log.info( # f"The worker nodes number after expansion {len(get_worker_nodes())}" # ) nodes = [node for sublist in new_nodes for node in sublist] if taint_label: taint_nodes(nodes=nodes, taint_label=taint_label), "Failed to taint nodes" log.info(f"Successfully Tainted nodes {new_nodes} with {taint_label}")
def setup( self, request, scenario, nodes, multi_pvc_factory, service_account_factory, dc_pod_factory, ): """ Identify the nodes and start multiple dc pods for the test Args: scenario (str): Scenario of app pods running on OCS or dedicated nodes (eg., 'colocated', 'dedicated') nodes: A fixture to get instance of the relevant platform nodes class multi_pvc_factory: A fixture create a set of new PVCs service_account_factory: A fixture to create a service account dc_pod_factory: A fixture to create dc pod Returns: list: dc pod objs """ worker_nodes = node.get_worker_nodes() ocs_nodes = machine.get_labeled_nodes(constants.OPERATOR_NODE_LABEL) non_ocs_nodes = list(set(worker_nodes) - set(ocs_nodes)) def finalizer(): helpers.remove_label_from_worker_node(node_list=worker_nodes, label_key="nodetype") # Check ceph health ceph_health_check(tries=80) request.addfinalizer(finalizer) if (scenario == "dedicated") and len(non_ocs_nodes) == 0: if config.ENV_DATA.get("deployment_type").lower() == "ipi": machines = machine.get_machinesets() node.add_new_node_and_label_it(machines[0], num_nodes=1, mark_for_ocs_label=False) else: if (config.ENV_DATA.get("platform").lower() == constants.VSPHERE_PLATFORM): pytest.skip( "Skipping add node in VSPHERE due to https://bugzilla.redhat.com/show_bug.cgi?id=1844521" ) is_rhel = config.ENV_DATA.get( "rhel_workers") or config.ENV_DATA.get("rhel_user") node_type = constants.RHEL_OS if is_rhel else constants.RHCOS node.add_new_node_and_label_upi(node_type=node_type, num_nodes=1, mark_for_ocs_label=False) non_ocs_nodes = list(set(node.get_worker_nodes()) - set(ocs_nodes)) app_pod_nodes = ocs_nodes if (scenario == "colocated") else non_ocs_nodes # Label nodes to be able to run app pods helpers.label_worker_node(node_list=app_pod_nodes, label_key="nodetype", label_value="app-pod") access_modes_rbd = [ constants.ACCESS_MODE_RWO, f"{constants.ACCESS_MODE_RWX}-Block", ] access_modes_cephfs = [ constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX ] pvcs_rbd = multi_pvc_factory( interface=constants.CEPHBLOCKPOOL, size=self.pvc_size, access_modes=access_modes_rbd, status=constants.STATUS_BOUND, num_of_pvc=len(access_modes_rbd), ) project = pvcs_rbd[0].project pvcs_cephfs = multi_pvc_factory( interface=constants.CEPHFILESYSTEM, project=project, size=self.pvc_size, access_modes=access_modes_cephfs, status=constants.STATUS_BOUND, num_of_pvc=len(access_modes_cephfs), ) pvcs = pvcs_cephfs + pvcs_rbd # Set volume mode on PVC objects for pvc_obj in pvcs: pvc_info = pvc_obj.get() setattr(pvc_obj, "volume_mode", pvc_info["spec"]["volumeMode"]) sa_obj = service_account_factory(project=project) pods = [] # Create pods for pvc_obj in pvcs: if constants.CEPHFS_INTERFACE in pvc_obj.storageclass.name: interface = constants.CEPHFILESYSTEM else: interface = constants.CEPHBLOCKPOOL num_pods = 2 if pvc_obj.access_mode == constants.ACCESS_MODE_RWX else 1 logger.info("Creating app pods") for _ in range(num_pods): pods.append( dc_pod_factory( interface=interface, pvc=pvc_obj, node_selector={"nodetype": "app-pod"}, raw_block_pv=pvc_obj.volume_mode == "Block", sa_obj=sa_obj, )) logger.info( f"Created {len(pods)} pods using {len(pvcs_cephfs)} cephfs, {len(pvcs_rbd)} rbd PVCs." ) return pods