当前位置: 首页>>代码示例>>Python>>正文


Python WorkerConfiguration._get_volumes_and_mounts方法代码示例

本文整理汇总了Python中airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration._get_volumes_and_mounts方法的典型用法代码示例。如果您正苦于以下问题:Python WorkerConfiguration._get_volumes_and_mounts方法的具体用法?Python WorkerConfiguration._get_volumes_and_mounts怎么用?Python WorkerConfiguration._get_volumes_and_mounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration的用法示例。


在下文中一共展示了WorkerConfiguration._get_volumes_and_mounts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_worker_git_dags

# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import _get_volumes_and_mounts [as 别名]
    def test_worker_git_dags(self):
        # Tests persistence volume config created when `git_repo` is set
        self.kube_config.dags_volume_claim = None
        self.kube_config.dags_volume_host = None
        self.kube_config.dags_folder = '/usr/local/airflow/dags'
        self.kube_config.worker_dags_folder = '/usr/local/airflow/dags'

        self.kube_config.git_sync_container_repository = 'gcr.io/google-containers/git-sync-amd64'
        self.kube_config.git_sync_container_tag = 'v2.0.5'
        self.kube_config.git_sync_container = 'gcr.io/google-containers/git-sync-amd64:v2.0.5'
        self.kube_config.git_sync_init_container_name = 'git-sync-clone'
        self.kube_config.git_subpath = 'dags_folder'
        self.kube_config.git_sync_root = '/git'
        self.kube_config.git_dags_folder_mount_point = '/usr/local/airflow/dags/repo/dags_folder'

        worker_config = WorkerConfiguration(self.kube_config)
        volumes, volume_mounts = worker_config._get_volumes_and_mounts()

        dag_volume = [volume for volume in volumes.values() if volume['name'] == 'airflow-dags']
        dag_volume_mount = [mount for mount in volume_mounts.values() if mount['name'] == 'airflow-dags']

        self.assertTrue('emptyDir' in dag_volume[0])
        self.assertEqual(self.kube_config.git_dags_folder_mount_point, dag_volume_mount[0]['mountPath'])
        self.assertTrue(dag_volume_mount[0]['readOnly'])

        init_container = worker_config._get_init_containers()[0]
        init_container_volume_mount = [mount for mount in init_container['volumeMounts']
                                       if mount['name'] == 'airflow-dags']

        self.assertEqual('git-sync-clone', init_container['name'])
        self.assertEqual('gcr.io/google-containers/git-sync-amd64:v2.0.5', init_container['image'])
        self.assertEqual(1, len(init_container_volume_mount))
        self.assertFalse(init_container_volume_mount[0]['readOnly'])
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:35,代码来源:test_kubernetes_executor.py

示例2: test_worker_configuration_no_subpaths

# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import _get_volumes_and_mounts [as 别名]
 def test_worker_configuration_no_subpaths(self):
     worker_config = WorkerConfiguration(self.kube_config)
     volumes, volume_mounts = worker_config._get_volumes_and_mounts()
     volumes_list = [value for value in volumes.values()]
     volume_mounts_list = [value for value in volume_mounts.values()]
     for volume_or_mount in volumes_list + volume_mounts_list:
         if volume_or_mount['name'] != 'airflow-config':
             self.assertNotIn(
                 'subPath', volume_or_mount,
                 "subPath shouldn't be defined"
             )
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:13,代码来源:test_kubernetes_executor.py

示例3: test_worker_container_dags

# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import _get_volumes_and_mounts [as 别名]
    def test_worker_container_dags(self):
        # Tests that the 'airflow-dags' persistence volume is NOT created when `dags_in_image` is set
        self.kube_config.dags_in_image = True

        worker_config = WorkerConfiguration(self.kube_config)
        volumes, volume_mounts = worker_config._get_volumes_and_mounts()

        dag_volume = [volume for volume in volumes.values() if volume['name'] == 'airflow-dags']
        dag_volume_mount = [mount for mount in volume_mounts.values() if mount['name'] == 'airflow-dags']

        init_containers = worker_config._get_init_containers()

        self.assertEqual(0, len(dag_volume))
        self.assertEqual(0, len(dag_volume_mount))
        self.assertEqual(0, len(init_containers))
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:17,代码来源:test_kubernetes_executor.py

示例4: test_worker_pvc_dags

# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import _get_volumes_and_mounts [as 别名]
    def test_worker_pvc_dags(self):
        # Tests persistence volume config created when `dags_volume_claim` is set
        self.kube_config.dags_volume_claim = 'airflow-dags'

        worker_config = WorkerConfiguration(self.kube_config)
        volumes, volume_mounts = worker_config._get_volumes_and_mounts()

        init_containers = worker_config._get_init_containers()

        dag_volume = [volume for volume in volumes.values() if volume['name'] == 'airflow-dags']
        dag_volume_mount = [mount for mount in volume_mounts.values() if mount['name'] == 'airflow-dags']

        self.assertEqual('airflow-dags', dag_volume[0]['persistentVolumeClaim']['claimName'])
        self.assertEqual(1, len(dag_volume_mount))
        self.assertTrue(dag_volume_mount[0]['readOnly'])
        self.assertEqual(0, len(init_containers))
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:18,代码来源:test_kubernetes_executor.py

示例5: test_worker_with_subpaths

# 需要导入模块: from airflow.contrib.kubernetes.worker_configuration import WorkerConfiguration [as 别名]
# 或者: from airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration import _get_volumes_and_mounts [as 别名]
    def test_worker_with_subpaths(self):
        self.kube_config.dags_volume_subpath = 'dags'
        self.kube_config.logs_volume_subpath = 'logs'
        worker_config = WorkerConfiguration(self.kube_config)
        volumes, volume_mounts = worker_config._get_volumes_and_mounts()

        for volume in [value for value in volumes.values()]:
            self.assertNotIn(
                'subPath', volume,
                "subPath isn't valid configuration for a volume"
            )

        for volume_mount in [value for value in volume_mounts.values()]:
            if volume_mount['name'] != 'airflow-config':
                self.assertIn(
                    'subPath', volume_mount,
                    "subPath should've been passed to volumeMount configuration"
                )
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:20,代码来源:test_kubernetes_executor.py


注:本文中的airflow.contrib.kubernetes.worker_configuration.WorkerConfiguration._get_volumes_and_mounts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。