def setUp(self): self.watcher = KubernetesJobWatcher( namespace="airflow", multi_namespace_mode=False, watcher_queue=mock.MagicMock(), resource_version="0", scheduler_job_id="123", kube_config=mock.MagicMock(), ) self.kube_client = mock.MagicMock() self.core_annotations = { "dag_id": "dag", "task_id": "task", "execution_date": "dt", "try_number": "1", } self.pod = k8s.V1Pod( metadata=k8s.V1ObjectMeta( name="foo", annotations={ "airflow-worker": "bar", **self.core_annotations }, namespace="airflow", resource_version="456", ), status=k8s.V1PodStatus(phase="Pending"), ) self.events = []
def mock_kubernetes_read_namespaced_pod(*_args, **_kwargs): """ Represents the mocked output of kubernetes.client.read_namespaced_pod """ return models.V1Pod( metadata=models.V1ObjectMeta( namespace="default", name="gordo-test-pod-name-1234", labels={"app": "gordo-model-builder"}, ), status=models.V1PodStatus(phase="Running"), spec=models.V1PodSpec(containers=[ models.V1Container( name="some-generated-test-container-name", env=[ models.V1EnvVar(name="MACHINE_NAME", value="test-machine-name") ], ) ]), )