Skip to content

Commit

Permalink
Validate airflow chart values.yaml & values.schema.json (#11990)
Browse files Browse the repository at this point in the history
* Correct type for multiNamespaceMode chart value
* Updated values.schema.json to reflect the latest change and to be stricter
* Fixed current test
* Added a test to validate the values file against the schema

(cherry picked from commit e238b88)
  • Loading branch information
Florent Chehab authored and kaxil committed Nov 18, 2020
1 parent 25bc6d7 commit 568b439
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 118 deletions.
2 changes: 1 addition & 1 deletion chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ The following tables lists the configurable parameters of the Airflow chart and
| `kerberos.keytabPath` | Path for the Kerberos keytab file | `/etc/airflow.keytab` |
| `kerberos.principal` | Name of the Kerberos principal | `airflow` |
| `kerberos.reinitFrequency` | Frequency of reinitialization of the Kerberos token | `3600` |
| `kerberos.confg` | Content of the configuration file for kerberos (might be templated using Helm templates) | `<see values.yaml>` |
| `kerberos.config` | Content of the configuration file for kerberos (might be templated using Helm templates) | `<see values.yaml>` |
| `workers.replicas` | Replica count for Celery workers (if applicable) | `1` |
| `workers.keda.enabled` | Enable KEDA autoscaling features | `false` |
| `workers.keda.pollingInverval` | How often KEDA should poll the backend database for metrics in seconds | `5` |
Expand Down
4 changes: 2 additions & 2 deletions chart/tests/test_basic_helm_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_basic_deployments(self):
('Secret', 'TEST-BASIC-airflow-metadata'),
('Secret', 'TEST-BASIC-airflow-result-backend'),
('ConfigMap', 'TEST-BASIC-airflow-config'),
('ClusterRole', 'TEST-BASIC-pod-launcher-role'),
('ClusterRoleBinding', 'TEST-BASIC-pod-launcher-rolebinding'),
('Role', 'TEST-BASIC-pod-launcher-role'),
('RoleBinding', 'TEST-BASIC-pod-launcher-rolebinding'),
('Service', 'TEST-BASIC-postgresql-headless'),
('Service', 'TEST-BASIC-postgresql'),
('Service', 'TEST-BASIC-statsd'),
Expand Down
42 changes: 42 additions & 0 deletions chart/tests/test_chart_quality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import json
import os
import unittest
import yaml

from jsonschema import validate


CHART_FOLDER = os.path.dirname(os.path.dirname(__file__))


class ChartQualityTest(unittest.TestCase):
def test_values_validate_schema(self):
with open(os.path.join(CHART_FOLDER, "values.yaml"), "r") as f:
values = yaml.safe_load(f)
with open(os.path.join(CHART_FOLDER, "values.schema.json"), "r") as f:
schema = json.load(f)

# Add extra restrictions just for the tests to make sure
# we don't forget to update the schema if we add a new property
schema["additionalProperties"] = False
schema["minProperties"] = len(schema["properties"].keys())

# shouldn't raise
validate(instance=values, schema=schema)

0 comments on commit 568b439

Please sign in to comment.