http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/58213208/tests/contrib/kubernetes/__init__.py ---------------------------------------------------------------------- diff --git a/tests/contrib/kubernetes/__init__.py b/tests/contrib/kubernetes/__init__.py new file mode 100644 index 0000000..759b563 --- /dev/null +++ b/tests/contrib/kubernetes/__init__.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#
http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/58213208/tests/contrib/kubernetes/test_kubernetes_job.py ---------------------------------------------------------------------- diff --git a/tests/contrib/kubernetes/test_kubernetes_job.py b/tests/contrib/kubernetes/test_kubernetes_job.py new file mode 100644 index 0000000..9921696 --- /dev/null +++ b/tests/contrib/kubernetes/test_kubernetes_job.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/58213208/tests/contrib/kubernetes/test_kubernetes_job_launcher.py ---------------------------------------------------------------------- diff --git a/tests/contrib/kubernetes/test_kubernetes_job_launcher.py b/tests/contrib/kubernetes/test_kubernetes_job_launcher.py new file mode 100644 index 0000000..3353390 --- /dev/null +++ b/tests/contrib/kubernetes/test_kubernetes_job_launcher.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and + +import unittest +from airflow.contrib.kubernetes.kubernetes_job_builder import KubernetesJobBuilder +from airflow.contrib.kubernetes.kubernetes_request_factory import SimpleJobRequestFactory +from airflow import configuration +import json + +secrets = {} +labels = {} +base_job = {'kind': 'Job', + 'spec': { + 'template': { + 'spec': { + 'restartPolicy': 'Never', + 'volumes': [{'hostPath': {'path': '/tmp/dags'}, 'name': 'shared-data'}], + 'containers': [ + {'command': ['try', 'this', 'first'], + 'image': 'foo.image', 'volumeMounts': [ + { + 'mountPath': '/usr/local/airflow/dags', + 'name': 'shared-data'} + ], + 'name': 'base', + 'imagePullPolicy': 'Never'} + ] + }, + 'metadata': {'name': 'name'} + } + }, + 'apiVersion': 'batch/v1', 'metadata': {'name': None} + } + + +class KubernetesJobRequestTest(unittest.TestCase): + job_to_load = None + job_req_factory = SimpleJobRequestFactory() + + def setUp(self): + configuration.load_test_config() + self.job_to_load = KubernetesJobBuilder( + image='foo.image', + cmds=['try', 'this', 'first'] + ) + + def test_job_creation_with_base_values(self): + base_job_result = self.job_req_factory.create(self.job_to_load) + self.assertEqual(base_job_result, base_job)
