Add test for render_kubefiles
This commit is contained in:
parent
bc2740029d
commit
f012651501
4 changed files with 86 additions and 7 deletions
|
|
@ -4,7 +4,7 @@ RUNBOAT_API_ADMIN_PASSWD="admin"
|
||||||
RUNBOAT_BUILD_NAMESPACE=runboat-builds
|
RUNBOAT_BUILD_NAMESPACE=runboat-builds
|
||||||
RUNBOAT_BUILD_DOMAIN=runboat.odoo-community.org
|
RUNBOAT_BUILD_DOMAIN=runboat.odoo-community.org
|
||||||
RUNBOAT_BUILD_ENV={}
|
RUNBOAT_BUILD_ENV={}
|
||||||
RUNBOAT_BUILD_SECRET_ENV={}
|
RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "thepgpassword"}
|
||||||
RUNBOAT_GITHUB_TOKEN=
|
RUNBOAT_GITHUB_TOKEN=
|
||||||
RUNBOAT_LOG_CONFIG=log-config.yaml
|
RUNBOAT_LOG_CONFIG=log-config.yaml
|
||||||
RUNBOAT_BUILD_IMAGES={"15.0": "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"}
|
RUNBOAT_BUILD_IMAGES={"15.0": "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ Home = "https://github.com/sbidoul/runboat"
|
||||||
profile = 'black'
|
profile = 'black'
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
env_override_existing_values = 1
|
||||||
env_files = [".env.test"]
|
env_files = [".env.test"]
|
||||||
|
|
||||||
# flake8 config is in .flake8
|
# flake8 config is in .flake8
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
resources:
|
resources:
|
||||||
{% if mode == 'deployment' -%}
|
{%- if mode == 'deployment' %}
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
- service.yaml
|
- service.yaml
|
||||||
- ingress.yaml
|
- ingress.yaml
|
||||||
{% elif mode == "initialize" -%}
|
{%- elif mode == "initialize" %}
|
||||||
- initialize.yaml
|
- initialize.yaml
|
||||||
{% elif mode == "cleanup" -%}
|
{%- elif mode == "cleanup" %}
|
||||||
- cleanup.yaml
|
- cleanup.yaml
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
namespace: {{ namespace }}
|
namespace: {{ namespace }}
|
||||||
|
|
||||||
|
|
@ -50,11 +50,11 @@ configMapGenerator:
|
||||||
- runboat-initialize.sh
|
- runboat-initialize.sh
|
||||||
- runboat-cleanup.sh
|
- runboat-cleanup.sh
|
||||||
- runboat-start.sh
|
- runboat-start.sh
|
||||||
{% if mode == 'deployment' -%}
|
{%- if mode == 'deployment' %}
|
||||||
- name: vars
|
- name: vars
|
||||||
literals:
|
literals:
|
||||||
- HOSTNAME={{ build_slug }}.{{ build_domain }}
|
- HOSTNAME={{ build_slug }}.{{ build_domain }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
generatorOptions:
|
generatorOptions:
|
||||||
disableNameSuffixHash: true
|
disableNameSuffixHash: true
|
||||||
|
|
|
||||||
78
tests/test_render_kubefiles.py
Normal file
78
tests/test_render_kubefiles.py
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
from runboat.k8s import DeploymentMode, _render_kubefiles, make_deployment_vars
|
||||||
|
|
||||||
|
EXPECTED = """\
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
|
||||||
|
namespace: runboat-builds
|
||||||
|
|
||||||
|
namePrefix: "build-name-"
|
||||||
|
|
||||||
|
commonLabels:
|
||||||
|
runboat/build: "build-name"
|
||||||
|
|
||||||
|
commonAnnotations:
|
||||||
|
runboat/repo: "oca/mis-builder"
|
||||||
|
runboat/target-branch: "15.0"
|
||||||
|
runboat/pr: ""
|
||||||
|
runboat/git-commit: "abcdef123456789"
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: odoo
|
||||||
|
newName: "ghcr.io/oca/oca-ci"
|
||||||
|
newTag: "py3.8-odoo15.0"
|
||||||
|
|
||||||
|
secretGenerator:
|
||||||
|
- name: odoosecretenv
|
||||||
|
literals:
|
||||||
|
- PGPASSWORD=thepgpassword
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: odooenv
|
||||||
|
literals:
|
||||||
|
- PGDATABASE=build-name
|
||||||
|
- ADDONS_DIR=/build
|
||||||
|
- RUNBOAT_GIT_REPO=https://github.com/oca/mis-builder
|
||||||
|
- RUNBOAT_GIT_REF=abcdef123456789
|
||||||
|
- name: runboat-scripts
|
||||||
|
files:
|
||||||
|
- runboat-clone-and-install.sh
|
||||||
|
- runboat-initialize.sh
|
||||||
|
- runboat-cleanup.sh
|
||||||
|
- runboat-start.sh
|
||||||
|
- name: vars
|
||||||
|
literals:
|
||||||
|
- HOSTNAME=build-slug.runboat.odoo-community.org
|
||||||
|
|
||||||
|
generatorOptions:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
|
||||||
|
vars:
|
||||||
|
- name: HOSTNAME
|
||||||
|
objref:
|
||||||
|
name: vars
|
||||||
|
kind: ConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
fieldref:
|
||||||
|
fieldpath: data.HOSTNAME
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def test_render_kubefiles():
|
||||||
|
deployment_vars = make_deployment_vars(
|
||||||
|
mode=DeploymentMode.deployment,
|
||||||
|
build_name="build-name",
|
||||||
|
slug="build-slug",
|
||||||
|
repo="oca/mis-builder",
|
||||||
|
target_branch="15.0",
|
||||||
|
pr=None,
|
||||||
|
git_commit="abcdef123456789",
|
||||||
|
image="ghcr.io/oca/oca-ci:py3.8-odoo15.0",
|
||||||
|
)
|
||||||
|
with _render_kubefiles(deployment_vars) as tmp_path:
|
||||||
|
assert (tmp_path / "kustomization.yaml").is_file()
|
||||||
|
assert (tmp_path / "deployment.yaml").is_file()
|
||||||
|
kustomization = (tmp_path / "kustomization.yaml").read_text()
|
||||||
|
assert kustomization == EXPECTED
|
||||||
Loading…
Reference in a new issue