You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/04/08 20:10:06 UTC
[airflow] branch master updated: Add test to check Valid Affinity,
Tolerations & Node Selector for Cleanup Job (#15278)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new f62e68e Add test to check Valid Affinity, Tolerations & Node Selector for Cleanup Job (#15278)
f62e68e is described below
commit f62e68e989a0f0fbd29d141c48e35307a872df0d
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Thu Apr 8 21:09:53 2021 +0100
Add test to check Valid Affinity, Tolerations & Node Selector for Cleanup Job (#15278)
This commit adds tests to check that affinity, tolerations and
Node Selectors can be applied on cleanup Cron Job
---
chart/tests/test_cleanup_pods.py | 45 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/chart/tests/test_cleanup_pods.py b/chart/tests/test_cleanup_pods.py
index 68f5b7c..dc3eb67 100644
--- a/chart/tests/test_cleanup_pods.py
+++ b/chart/tests/test_cleanup_pods.py
@@ -59,3 +59,48 @@ class CleanupPodsTest(unittest.TestCase):
assert "airflow:test" == jmespath.search(
"spec.jobTemplate.spec.template.spec.containers[0].image", docs[0]
)
+
+ def test_should_create_valid_affinity_tolerations_and_node_selector(self):
+ docs = render_chart(
+ values={
+ "cleanup": {
+ "enabled": True,
+ "affinity": {
+ "nodeAffinity": {
+ "requiredDuringSchedulingIgnoredDuringExecution": {
+ "nodeSelectorTerms": [
+ {
+ "matchExpressions": [
+ {"key": "foo", "operator": "In", "values": ["true"]},
+ ]
+ }
+ ]
+ }
+ }
+ },
+ "tolerations": [
+ {"key": "dynamic-pods", "operator": "Equal", "value": "true", "effect": "NoSchedule"}
+ ],
+ "nodeSelector": {"diskType": "ssd"},
+ }
+ },
+ show_only=["templates/cleanup/cleanup-cronjob.yaml"],
+ )
+
+ assert "CronJob" == jmespath.search("kind", docs[0])
+ assert "foo" == jmespath.search(
+ "spec.jobTemplate.spec.template.spec.affinity.nodeAffinity."
+ "requiredDuringSchedulingIgnoredDuringExecution."
+ "nodeSelectorTerms[0]."
+ "matchExpressions[0]."
+ "key",
+ docs[0],
+ )
+ assert "ssd" == jmespath.search(
+ "spec.jobTemplate.spec.template.spec.nodeSelector.diskType",
+ docs[0],
+ )
+ assert "dynamic-pods" == jmespath.search(
+ "spec.jobTemplate.spec.template.spec.tolerations[0].key",
+ docs[0],
+ )