Example #1
0
    def test_mounts_file_disabled(self):

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        pprint(f.getVolumeMounts())

        self.assertEquals(f.getVolumeMounts(), [])
        self.assertEquals(f.getVolumes(), [])
Example #2
0
    def create(self):

        logging.debug('Creating PVC...')
        logging.debug(pprint(self.spec))

        return self.cv1.create_namespaced_persistent_volume_claim(
            self.namespace, self.spec)
Example #3
0
    def test_env_vars(self):

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        self.assertEquals(f.getEnv(), [{
            'name': 'JSON_INPUT',
            'value': '{"a": 1}'
        }, {
            'name': 'HOST_BASE_PATH',
            'value': '/home/tfga/workspace/cwl-tes'
        }, {
            'name': 'CONTAINER_BASE_PATH',
            'value': '/transfer'
        }])
Example #4
0
    def test_mounts(self):
        '''
        kind: Pod
        apiVersion: v1
        metadata:
          name: tfga-pod
        spec:
          containers:
            - name: tfga-container
              image: eu.gcr.io/tes-wes/filer:testing
              volumeMounts:
                - mountPath: /transfer
                  name: transfer-volume
          volumes:
            - name: transfer-volume
              hostPath:
                path: /transferAtNode
              # persistentVolumeClaim:
              #  claimName: task-pv-claim
        '''

        f = Filer('name', {'a': 1})

        pprint(f.spec)

        pprint(f.getVolumeMounts())

        self.assertEquals(f.getVolumeMounts(),
                          [{
                              "name": 'transfer-volume',
                              'mountPath': path.CONTAINER_BASE_PATH
                          }])

        self.assertEquals(f.getVolumes(), [{
            "name": 'transfer-volume',
            'persistentVolumeClaim': {
                'claimName': 'transfer-pvc'
            }
        }])
Example #5
0
    def run_to_completion(self, poll_interval, check_cancelled, pod_timeout):

        logging.debug("Creating job '{}'...".format(self.name))
        logging.debug(pprint(self.body))
        self.timeout = pod_timeout
        self.bv1.create_namespaced_job(self.namespace, self.body)
        is_all_pods_running = False
        status, is_all_pods_running = self.get_status(is_all_pods_running)
        while status == 'Running':
            if check_cancelled():
                self.delete()
                return 'Cancelled'
            time.sleep(poll_interval)
            status, is_all_pods_running = self.get_status(is_all_pods_running)
        return status
Example #6
0
    def create(self):

        logging.debug('Creating PVC...')
        logging.debug(pprint(self.spec))
        try:
            return self.cv1.create_namespaced_persistent_volume_claim(
                self.namespace, self.spec)
        except ApiException as ex:
            if ex.status == 409:
                logging.debug(f"Reading existing PVC: {self.name}")
                return self.cv1.read_namespaced_persistent_volume_claim(
                    self.name, self.namespace)
            else:
                logging.debug(ex.body)
                raise ApiException(ex.status, ex.reason)
Example #7
0
    def run_to_completion(self, poll_interval, check_cancelled, pod_timeout):

        logging.debug("Creating job '{}'...".format(self.name))
        logging.debug(pprint(self.body))
        self.timeout = pod_timeout
        try:
            self.bv1.create_namespaced_job(self.namespace, self.body)
        except ApiException as ex:
            if ex.status == 409:
                logging.debug(f"Reading existing job: {self.name} ")
                self.bv1.read_namespaced_job(self.name, self.namespace)
            else:
                logging.debug(ex.body)
                raise ApiException(ex.status, ex.reason)
        is_all_pods_running = False
        status, is_all_pods_running = self.get_status(is_all_pods_running)
        while status == 'Running':
            if check_cancelled():
                self.delete()
                return 'Cancelled'
            time.sleep(poll_interval)
            status, is_all_pods_running = self.get_status(is_all_pods_running)
        return status