Example #1
0
    def _check_pods_using_same_pvc_are_on_same_zone(self, storage_class_name):
        pod_names = set()
        for i in range(5):
            pod_names.add('pod-' + str(i))

        # create PVC
        pvc_name = 'topology-single-pvc-' + storage_class_name
        KubeUtils.create_pvc_with_cleanup(self,
                                          pvc_name,
                                          storage_class_name,
                                          volumeMode='Block')

        # Create Pods
        for pod_name in pod_names:
            pod = KubeUtils.get_block_consumer_pod_template(pod_name, pvc_name)
            KubeUtils.create_pod(pod)

        # cleanup
        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)

        self.addCleanup(pods_cleanup)

        for pod_name in pod_names:
            KubeUtils.wait_for_pod_to_be_running(pod_name, attempts=15)

        # collect Pod, Node and Zone data
        info = self._collect_pods_info(pod_names)

        # at least 2 different zones
        all_zones = set()

        for pod_name, pod_info in info.iteritems():
            all_zones.add(pod_info['zone'])

        print('all_zones = %s' % all_zones)
        self.assertEqual(len(all_zones), 1)
Example #2
0
    def _create_multiple_pods_each_with_own_pvc(self,
                                                storage_class_name,
                                                num_of_pods=6):
        pod_names = set()
        pvc_names = set()

        for i in range(num_of_pods):
            pod_names.add('pod-' + str(i))
            pvc_names.add('pvc-' + str(i))

        # create PVCs
        for pvc_name in pvc_names:
            KubeUtils.create_pvc_with_cleanup(self,
                                              pvc_name,
                                              storage_class_name,
                                              volumeMode='Block')

        # Create Pods
        for i in range(num_of_pods):
            pod_name = 'pod-' + str(i)
            pvc_name = 'pvc-' + str(i)
            pod = KubeUtils.get_block_consumer_pod_template(pod_name, pvc_name)
            KubeUtils.create_pod(pod)

        # pods cleanups
        def 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)

        self.addCleanup(cleanup)

        for pod_name in pod_names:
            KubeUtils.wait_for_pod_to_be_running(pod_name, attempts=30)

        return pod_names