dimberman commented on a change in pull request #10393:
URL: https://github.com/apache/airflow/pull/10393#discussion_r475960847



##########
File path: tests/kubernetes/test_pod_generator.py
##########
@@ -226,238 +186,169 @@ def test_gen_pod_extract_xcom(self, mock_uuid):
             ],
             'resources': {'requests': {'cpu': '1m'}},
         }
-        self.expected['spec']['containers'].append(container_two)
-        self.expected['spec']['containers'][0]['volumeMounts'].insert(0, {
-            'name': 'xcom',
-            'mountPath': '/airflow/xcom'
-        })
-        self.expected['spec']['volumes'].insert(0, {
-            'name': 'xcom', 'emptyDir': {}
-        })
-        result_dict['spec']['containers'][0]['env'].sort(key=lambda x: 
x['name'])
-        self.assertEqual(result_dict, self.expected)
+        self.expected.spec.containers.append(container_two)
+        base_container: k8s.V1Container = self.expected.spec.containers[0]
+        base_container.volume_mounts = base_container.volume_mounts or []
+        base_container.volume_mounts.append(k8s.V1VolumeMount(
+            name="xcom",
+            mount_path="/airflow/xcom"
+        ))
+        self.expected.spec.containers[0] = base_container
+        self.expected.spec.volumes = self.expected.spec.volumes or []
+        self.expected.spec.volumes.append(
+            k8s.V1Volume(
+                name='xcom',
+                empty_dir={},
+            )
+        )
+        result_dict = self.k8s_client.sanitize_for_serialization(result)
+        expected_dict = 
self.k8s_client.sanitize_for_serialization(self.expected)
 
-    def test_from_obj(self):
-        result = PodGenerator.from_obj({
-            "KubernetesExecutor": {
-                "annotations": {"test": "annotation"},
-                "volumes": [
-                    {
-                        "name": "example-kubernetes-test-volume",
-                        "hostPath": {"path": "/tmp/"},
-                    },
-                ],
-                "volume_mounts": [
-                    {
-                        "mountPath": "/foo/",
-                        "name": "example-kubernetes-test-volume",
-                    },
-                ],
-            }
-        })
-        result = self.k8s_client.sanitize_for_serialization(result)
+        self.assertEqual(result_dict, expected_dict)
 
-        self.assertEqual({
-            'apiVersion': 'v1',
-            'kind': 'Pod',
-            'metadata': {
-                'annotations': {'test': 'annotation'},
-            },
-            'spec': {
-                'containers': [{
-                    'args': [],
-                    'command': [],
-                    'env': [],
-                    'envFrom': [],
-                    'name': 'base',
-                    'ports': [],
-                    'volumeMounts': [{
-                        'mountPath': '/foo/',
-                        'name': 'example-kubernetes-test-volume'
-                    }],
-                }],
-                'hostNetwork': False,
-                'imagePullSecrets': [],
-                'volumes': [{
-                    'hostPath': {'path': '/tmp/'},
-                    'name': 'example-kubernetes-test-volume'
-                }],
-            }
-        }, result)
+    def test_from_obj(self):

Review comment:
       @kaxil @ashb @potiuk @turbaszek one remaining question is what do we do 
about the executor_config? Do we force users to inject a k8s.V1Pod object for 
their executor config and just manually delete a few fields (like pod names)? 
Or do we continue to allow this dictionary.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to