def test_step_3_delete_pods(self): for i in range(TestConfig.NumberOfVolumes): pod_name = 'consumer-{}'.format(i) KubeUtils.delete_pod(pod_name) for i in range(TestConfig.NumberOfVolumes): pod_name = 'consumer-{}'.format(i) KubeUtils.wait_for_pod_to_delete(pod_name)
def _delete_pods(num_of_volumes): for i in range(num_of_volumes): pod_name = 'consumer-{}'.format(i) KubeUtils.delete_pod(pod_name) for i in range(num_of_volumes): pod_name = 'consumer-{}'.format(i) KubeUtils.wait_for_pod_to_delete(pod_name)
def test_migration(self): # create the PVC pvc_name = 'pvc-migration-test' sc_name = 'nvmesh-raid10' KubeUtils.create_pvc_and_wait_to_bound(self, pvc_name, sc_name) # Create Deployment dep_name = 'test-pod-migration' pod = KubeUtils.get_fs_consumer_pod_template(dep_name, pvc_name) deployment = KubeUtils.get_deployment_template(dep_name, pod['spec']) KubeUtils.create_deployment(deployment) self.addCleanup(lambda: KubeUtils.delete_deployment(dep_name)) attempts = 10 pod = None while attempts: logger.debug('Waiting for deployment pods to be scheduled') pod_list = KubeUtils.get_pods_for_deployment(dep_name) if len(pod_list): pod = pod_list[0] break attempts = attempts - 1 self.assertNotEqual(attempts, 0, 'Timed out waiting for deployment pod to be scheduled') time.sleep(1) initial_pod_name = pod.metadata.name # Set node as NoSchedule initial_node = pod.spec.node_name logger.debug("Tainting node %s with noSchedule" % initial_node) KubeUtils.node_prevent_schedule(initial_node) self.addCleanup(lambda: KubeUtils.node_allow_schedule(initial_node)) # Delete the pod (it is expected to be re-created on a different node KubeUtils.delete_pod(initial_pod_name) KubeUtils.wait_for_pod_to_delete(initial_pod_name, attempts=120) # Get the second Pod pods = KubeUtils.get_pods_for_deployment(dep_name) pod = pods[0] second_pod_name = pod.metadata.name self.assertNotEqual(initial_pod_name, second_pod_name) self.assertNotEqual(pod.spec.node_name, initial_node) KubeUtils.wait_for_pod_to_be_running(second_pod_name)
def test_read_only_many(self): pvc_name = 'pvc-rox' KubeUtils.create_pvc_and_wait_to_bound(self, pvc_name, TestAccessModes.StorageClass, access_modes=['ReadOnlyMany'], volumeMode='Block') # First Pod Should Succeed pod1_name = 'pod-1-node-1' self._create_pod_on_specific_node(pod1_name, pvc_name, node_index=1) KubeUtils.wait_for_pod_to_be_running(pod1_name) # Second Pod on the same Node should Succeed pod2_name = 'pod-2-node-1' self._create_pod_on_specific_node(pod2_name, pvc_name, node_index=1) KubeUtils.wait_for_pod_to_be_running(pod2_name) # Third Pod on a different Node should Succeed pod3_name = 'pod-3-node-2' self._create_pod_on_specific_node(pod3_name, pvc_name, node_index=2) KubeUtils.wait_for_pod_to_be_running(pod3_name) KubeUtils.delete_pod(pod1_name) KubeUtils.delete_pod(pod2_name) KubeUtils.delete_pod(pod3_name)
def pods_cleanup(): for pod_name in pod_names: KubeUtils.delete_pod(pod_name) for pod_name in pod_names: KubeUtils.wait_for_pod_to_delete(pod_name)
def cleanup_pod(): KubeUtils.delete_pod(pod_name) KubeUtils.wait_for_pod_to_delete(pod_name)