Skip to content

Commit fe06de3

Browse files
committed
fix(chart): Add pdbs for triggerer and workers
1 parent 85b067b commit fe06de3

File tree

3 files changed

+128
-2
lines changed

3 files changed

+128
-2
lines changed

chart/templates/workers/worker-poddisruptionbudget.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
################################
2121
## Airflow Worker PodDisruptionBudget
2222
#################################
23-
{{- if .Values.workers.enabled }}
2423
{{- if .Values.workers.podDisruptionBudget.enabled }}
2524
apiVersion: policy/v1
2625
kind: PodDisruptionBudget
@@ -43,4 +42,3 @@ spec:
4342
release: {{ .Release.Name }}
4443
{{- toYaml .Values.workers.podDisruptionBudget.config | nindent 2 }}
4544
{{- end }}
46-
{{- end }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
from __future__ import annotations
18+
19+
import jmespath
20+
from chart_utils.helm_template_generator import render_chart
21+
22+
23+
class TestTriggererPdb:
24+
"""Tests Triggerer PDB."""
25+
26+
def test_should_pass_validation_with_just_pdb_enabled_v1(self):
27+
render_chart(
28+
values={"triggerer": {"podDisruptionBudget": {"enabled": True}}},
29+
show_only=["templates/triggerer/triggerer-poddisruptionbudget.yaml"],
30+
) # checks that no validation exception is raised
31+
32+
def test_should_pass_validation_with_just_pdb_enabled_v1beta1(self):
33+
render_chart(
34+
values={"triggerer": {"podDisruptionBudget": {"enabled": True}}},
35+
show_only=["templates/triggerer/triggerer-poddisruptionbudget.yaml"],
36+
kubernetes_version="1.16.0",
37+
) # checks that no validation exception is raised
38+
39+
def test_should_add_component_specific_labels(self):
40+
docs = render_chart(
41+
values={
42+
"triggerer": {
43+
"podDisruptionBudget": {"enabled": True},
44+
"labels": {"test_label": "test_label_value"},
45+
},
46+
},
47+
show_only=["templates/triggerer/triggerer-poddisruptionbudget.yaml"],
48+
)
49+
50+
assert "test_label" in jmespath.search("metadata.labels", docs[0])
51+
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
52+
53+
def test_should_pass_validation_with_pdb_enabled_and_min_available_param(self):
54+
render_chart(
55+
values={
56+
"triggerer": {
57+
"podDisruptionBudget": {
58+
"enabled": True,
59+
"config": {"maxUnavailable": None, "minAvailable": 1},
60+
}
61+
}
62+
},
63+
show_only=["templates/triggerer/triggerer-poddisruptionbudget.yaml"],
64+
) # checks that no validation exception is raised
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
from __future__ import annotations
18+
19+
import jmespath
20+
from chart_utils.helm_template_generator import render_chart
21+
22+
23+
class TestWorkerPdb:
24+
"""Tests Worker PDB."""
25+
26+
def test_should_pass_validation_with_just_pdb_enabled_v1(self):
27+
render_chart(
28+
values={"workers": {"podDisruptionBudget": {"enabled": True}}},
29+
show_only=["templates/workers/worker-poddisruptionbudget.yaml"],
30+
) # checks that no validation exception is raised
31+
32+
def test_should_pass_validation_with_just_pdb_enabled_v1beta1(self):
33+
render_chart(
34+
values={"workers": {"podDisruptionBudget": {"enabled": True}}},
35+
show_only=["templates/workers/worker-poddisruptionbudget.yaml"],
36+
kubernetes_version="1.16.0",
37+
) # checks that no validation exception is raised
38+
39+
def test_should_add_component_specific_labels(self):
40+
docs = render_chart(
41+
values={
42+
"workers": {
43+
"podDisruptionBudget": {"enabled": True},
44+
"labels": {"test_label": "test_label_value"},
45+
},
46+
},
47+
show_only=["templates/workers/worker-poddisruptionbudget.yaml"],
48+
)
49+
50+
assert "test_label" in jmespath.search("metadata.labels", docs[0])
51+
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"
52+
53+
def test_should_pass_validation_with_pdb_enabled_and_min_available_param(self):
54+
render_chart(
55+
values={
56+
"workers": {
57+
"podDisruptionBudget": {
58+
"enabled": True,
59+
"config": {"maxUnavailable": None, "minAvailable": 1},
60+
},
61+
}
62+
},
63+
show_only=["templates/workers/worker-poddisruptionbudget.yaml"],
64+
) # checks that no validation exception is raised

0 commit comments

Comments
 (0)