This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 93d88a7d05 Unflake test_volume_mount in k8s tests (#35106)
93d88a7d05 is described below
commit 93d88a7d0550e9d6b46495832fdc6d19b7dcf64c
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sun Oct 22 13:52:14 2023 +0200
Unflake test_volume_mount in k8s tests (#35106)
The `test_volume_mount` in k8s relied on "retrieved from mount\n"
printed to log as retrieved from K8S pod. Howver, due to the way
how logs are retrieved, sometimes the log printed contains the
EOL character and sometimes not - depending on when the strings are
flushed. This PR changes the test to passs regardless if EOL is
included in the log or not.
---
.github/workflows/ci.yml | 1 -
kubernetes_tests/test_base.py | 5 +++++
kubernetes_tests/test_kubernetes_pod_operator.py | 4 ++--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1e258b1857..412bc15512 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -335,7 +335,6 @@ jobs:
${{needs.build-info.outputs.all-python-versions-list-as-string}}
runs-on: "${{needs.build-info.outputs.runs-on}}"
needs: [build-info, build-ci-images]
- if: needs.build-info.outputs.upgrade-to-newer-dependencies != 'false'
env:
RUNS_ON: "${{ needs.build-info.outputs.runs-on }}"
PYTHON_VERSIONS:
${{needs.build-info.outputs.all-python-versions-list-as-string}}
diff --git a/kubernetes_tests/test_base.py b/kubernetes_tests/test_base.py
index 3507848079..715bbbb237 100644
--- a/kubernetes_tests/test_base.py
+++ b/kubernetes_tests/test_base.py
@@ -41,6 +41,11 @@ print(f"Executor: {EXECUTOR}")
print()
+class StringContainingId(str):
+ def __eq__(self, other):
+ return self in other
+
+
class BaseK8STest:
"""Base class for K8S Tests."""
diff --git a/kubernetes_tests/test_kubernetes_pod_operator.py
b/kubernetes_tests/test_kubernetes_pod_operator.py
index 44b4b3df80..477cc4beda 100644
--- a/kubernetes_tests/test_kubernetes_pod_operator.py
+++ b/kubernetes_tests/test_kubernetes_pod_operator.py
@@ -45,7 +45,7 @@ from airflow.utils import timezone
from airflow.utils.context import Context
from airflow.utils.types import DagRunType
from airflow.version import version as airflow_version
-from kubernetes_tests.test_base import BaseK8STest
+from kubernetes_tests.test_base import BaseK8STest, StringContainingId
HOOK_CLASS = "airflow.providers.cncf.kubernetes.operators.pod.KubernetesHook"
POD_MANAGER_CLASS =
"airflow.providers.cncf.kubernetes.utils.pod_manager.PodManager"
@@ -517,7 +517,7 @@ class TestKubernetesPodOperatorSystem:
)
context = create_context(k)
k.execute(context=context)
- mock_logger.info.assert_any_call("[%s] %s", "base", "retrieved
from mount\n")
+ mock_logger.info.assert_any_call("[%s] %s", "base",
StringContainingId("retrieved from mount"))
actual_pod = self.api_client.sanitize_for_serialization(k.pod)
self.expected_pod["spec"]["containers"][0]["args"] = args
self.expected_pod["spec"]["containers"][0]["volumeMounts"] = [