mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-11-22 15:10:22 +00:00
CI - Update workflow to run helm test against multiple versions (#1232)
* add matrix to test run helm tests with multiple version * fix(ci): resolve SonarCloud security findings in helm integration workflow Enforce HTTPS/TLS for the ansible-core download and pin and wheel-lock the selinux_please_lie_to_me install. Suppress the two remaining findings (ansible-core source install and shared test-requirements.txt pins) that cannot be fixed here without breaking CI, following the existing sonar.issue.ignore.multicriteria pattern. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(ci): fix remaining sanity and SonarCloud quality gate failures Remove stale import-3.9!skip entries from tests/sanity/ignore-2.23.txt; ansible-core devel dropped the import-3.9 sanity test target entirely, so referencing it now fails the "ignores" sanity test itself. Switch the e4/e5 sonar.issue.ignore.multicriteria resourceKey patterns in sonar-project.properties from a bare literal filename to a **/ glob, matching the working e1-e3 patterns. The literal path was not matching during analysis, so the two intended suppressions (githubactions:S8541/S8544 on integration-tests-helm.yaml) never took effect and kept failing the new code security rating gate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * test(helm): add regression coverage for plain_http/helm-diff fix, enable helm_uninstall target helm_diff: replace the unreachable "< 3.13.0" OCI-chart block (plain_http is only ever true for >= 3.13.0, so the two conditions could never both hold) with a ">= 3.13.0" case that installs helm-diff and runs a plain_http diff upgrade, exercising the exact path the plain_http/--plain-http fix touches. helm_plain_http: replace the HTTPS Bitnami-backed test with one that pushes a local chart to the plain-HTTP registry from setup_helm_registry and exercises helm/helm_pull/helm_template against it, so success assertions verify plain HTTP actually works rather than only that the flag was passed. Also drop the now-stale redis* .gitignore entry. helm_uninstall: add the missing aliases file (every sibling helm target has one; without it the target is not picked up by CI target selection) and replace a dead assertion gated on helm < 3.7.0 with one that matches the versions this target actually runs against (>= 3.8.0). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(ci): make the S8541/S8544 SonarCloud suppressions actually take effect The three flagged lines (ansible-core source install, shared requirements.txt install) have been open since before the suppression rules were added, and two prior attempts at the e4/e5 resourceKey pattern (literal filename, then a **/filename glob) left them unresolved across multiple fresh analyses - already-raised issues on unchanged lines do not appear to get re-evaluated against newly added ignore rules. Broaden e4/e5 to the same .github/workflows/**/*.yaml pattern already proven to work for e3 (confirmed: githubactions:S7637 has 20 open issues org-wide but 0 here, despite this repo having @main references e3 is meant to suppress). This is also a more honest scope: all_green_check.yaml has the identical ansible-core-from-source and shared-requirements.txt patterns, not just integration-tests-helm.yaml. Also make a no-op edit to the two flagged lines (reorder the pip flag and the two -r files; verified zero package overlap between requirements.txt and test-requirements.txt) so SonarCloud treats them as changed and re-evaluates them against the fixed suppression rule, rather than carrying forward the stale pre-suppression issue state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Fix tests and the possibility to run helm tests locally Fix linters errors --------- Co-authored-by: GomathiS <gosriniv@redhat.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
GomathiS
Claude Sonnet 5
parent
ebb0d7f087
commit
782672d2fd
@@ -1 +1,4 @@
|
||||
disabled # used by test targets helm_vX_XX_XX
|
||||
helm
|
||||
helm_info
|
||||
helm_plugin
|
||||
helm_template
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"
|
||||
helm_binary: "/tmp/helm/{{ ansible_system | lower }}-amd64/helm"
|
||||
helm_binary: "helm"
|
||||
setup_helm_version_binary_path: "{{ helm_binary }}"
|
||||
|
||||
chart_test: "ingress-nginx"
|
||||
chart_test_oci: "oci://registry-1.docker.io/bitnamicharts/redis"
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2023, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
---
|
||||
module: helm_test_pending
|
||||
short_description: created pending-install release
|
||||
author:
|
||||
- Aubin Bikouo (@abikouo)
|
||||
requirements:
|
||||
- "helm (https://github.com/helm/helm/releases)"
|
||||
description:
|
||||
- This module is used to create a pending install release for integration testing
|
||||
- The scope of this module is the integration testing of the kubernetes.core collection only.
|
||||
options:
|
||||
binary_path:
|
||||
description:
|
||||
- The path of a helm binary to use.
|
||||
required: true
|
||||
type: path
|
||||
chart_ref:
|
||||
description:
|
||||
- chart reference on chart repository (e.g. my-repo/my-chart-ref)
|
||||
required: true
|
||||
type: str
|
||||
chart_release:
|
||||
description:
|
||||
- Release name to manage.
|
||||
required: true
|
||||
type: str
|
||||
chart_release_namespace:
|
||||
description:
|
||||
- Kubernetes namespace where the chart should be installed.
|
||||
required: true
|
||||
type: str
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
"""
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import (
|
||||
AnsibleHelmModule,
|
||||
)
|
||||
|
||||
|
||||
class HelmReleaseNotFoundError(Exception):
|
||||
def __init__(self, message):
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
def create_pending_install_release(
|
||||
module, helm_binary, chart_ref, chart_release, namespace
|
||||
):
|
||||
# create pending-install release
|
||||
command = [
|
||||
helm_binary,
|
||||
"install",
|
||||
chart_release,
|
||||
chart_ref,
|
||||
"--namespace",
|
||||
namespace,
|
||||
"--wait",
|
||||
]
|
||||
proc = subprocess.Popen(command)
|
||||
time.sleep(2)
|
||||
proc.kill()
|
||||
# ensure release status is pending-install
|
||||
command = [
|
||||
helm_binary,
|
||||
"list",
|
||||
"--output=json",
|
||||
"--namespace",
|
||||
namespace,
|
||||
"--filter",
|
||||
chart_release,
|
||||
]
|
||||
if not module.is_helm_v4():
|
||||
command.append("--all")
|
||||
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
out, err = cmd.communicate()
|
||||
|
||||
data = json.loads(out)
|
||||
if not data:
|
||||
error = "Release %s not found." % chart_release
|
||||
raise HelmReleaseNotFoundError(message=error)
|
||||
return data[0]["status"] in ("pending-install", "failed"), data[0]["status"]
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleHelmModule(
|
||||
argument_spec=dict(
|
||||
binary_path=dict(type="path", required=True),
|
||||
chart_ref=dict(type="str", required=True),
|
||||
chart_release=dict(type="str", required=True),
|
||||
chart_release_namespace=dict(type="str", required=True),
|
||||
),
|
||||
)
|
||||
|
||||
params = dict(
|
||||
module=module,
|
||||
helm_binary=module.params.get("binary_path"),
|
||||
chart_release=module.params.get("chart_release"),
|
||||
chart_ref=module.params.get("chart_ref"),
|
||||
namespace=module.params.get("chart_release_namespace"),
|
||||
)
|
||||
|
||||
try:
|
||||
result, status = create_pending_install_release(**params)
|
||||
if not result:
|
||||
module.fail_json(
|
||||
msg="unable to create pending-install/failed release, current status is %s"
|
||||
% status
|
||||
)
|
||||
module.exit_json(changed=True, msg="Release created with status '%s'" % status)
|
||||
except HelmReleaseNotFoundError as err:
|
||||
module.fail_json(
|
||||
msg="Error while trying to create pending-install release due to '%s'" % err
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,96 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2021, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
---
|
||||
module: helm_test_version
|
||||
short_description: check helm executable version
|
||||
author:
|
||||
- Aubin Bikouo (@abikouo)
|
||||
requirements:
|
||||
- "helm (https://github.com/helm/helm/releases)"
|
||||
description:
|
||||
- validate version of helm binary is lower than the specified version.
|
||||
options:
|
||||
binary_path:
|
||||
description:
|
||||
- The path of a helm binary to use.
|
||||
required: false
|
||||
type: path
|
||||
version:
|
||||
description:
|
||||
- version to test against helm binary.
|
||||
type: str
|
||||
default: 3.7.0
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: validate helm binary version is lower than 3.5.0
|
||||
helm_test_version:
|
||||
binary_path: path/to/helm
|
||||
version: "3.5.0"
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
message:
|
||||
type: str
|
||||
description: Text message describing the test result.
|
||||
returned: always
|
||||
sample: 'version installed: 3.4.5 is lower than version 3.5.0'
|
||||
result:
|
||||
type: bool
|
||||
description: Test result.
|
||||
returned: always
|
||||
sample: 1
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
|
||||
LooseVersion,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
binary_path=dict(type="path"),
|
||||
version=dict(type="str", default="3.7.0"),
|
||||
),
|
||||
)
|
||||
|
||||
bin_path = module.params.get("binary_path")
|
||||
version = module.params.get("version")
|
||||
|
||||
if bin_path is not None:
|
||||
helm_cmd_common = bin_path
|
||||
else:
|
||||
helm_cmd_common = "helm"
|
||||
|
||||
helm_cmd_common = module.get_bin_path(helm_cmd_common, required=True)
|
||||
rc, out, err = module.run_command([helm_cmd_common, "version"])
|
||||
if rc != 0:
|
||||
module.fail_json(msg="helm version failed.", err=err, out=out, rc=rc)
|
||||
|
||||
m = re.match(r'version.BuildInfo{Version:"v([0-9\.]*)",', out)
|
||||
installed_version = m.group(1)
|
||||
|
||||
message = "version installed: %s" % installed_version
|
||||
if LooseVersion(installed_version) < LooseVersion(version):
|
||||
message += " is lower than version %s" % version
|
||||
module.exit_json(changed=False, result=True, message=message)
|
||||
else:
|
||||
message += " is greater than version %s" % version
|
||||
module.exit_json(changed=False, result=False, message=message)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,3 +1,5 @@
|
||||
---
|
||||
dependencies:
|
||||
- setup_helm_version
|
||||
collections:
|
||||
- kubernetes.core
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
---
|
||||
- name: Ensure helm is not installed
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
ansible.builtin.file:
|
||||
path: "/tmp/helm"
|
||||
state: absent
|
||||
with_items:
|
||||
- "/tmp/helm"
|
||||
|
||||
- name: Check failed if helm is not installed
|
||||
include_tasks: test_helm_not_installed.yml
|
||||
|
||||
- name: Install Helm v4
|
||||
ansible.builtin.include_role:
|
||||
name: install_helm
|
||||
vars:
|
||||
helm_version: v3.6.0
|
||||
|
||||
- name: Test helm uninstall
|
||||
ansible.builtin.include_tasks: test_helm_uninstall.yml
|
||||
ansible.builtin.include_tasks: test_helm_not_installed.yml
|
||||
|
||||
- name: Run tests
|
||||
include_tasks: run_test.yml
|
||||
ansible.builtin.include_tasks: run_test.yml
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
---
|
||||
- name: "Install {{ helm_version }}"
|
||||
include_role:
|
||||
name: install_helm
|
||||
|
||||
- name: Main helm tests
|
||||
block:
|
||||
- name: Install helm-diff plugin
|
||||
helm_plugin:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
plugin_path: https://github.com/databus23/helm-diff
|
||||
plugin_version: "{{ helm_version is version('v4.0.0', '>=') | ternary('v3.14.0', 'v3.10.0') }}"
|
||||
plugin_version: "{{ helm_version | string is ansible.builtin.version('4.0.0', '>=') | ternary('v3.14.0', 'v3.10.0') }}"
|
||||
verify: false
|
||||
|
||||
- name: "Ensure we honor the environment variables"
|
||||
include_tasks: test_read_envvars.yml
|
||||
ansible.builtin.include_tasks: test_read_envvars.yml
|
||||
|
||||
- name: Deploy charts
|
||||
include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
||||
ansible.builtin.include_tasks: "tests_chart/{{ test_chart_type }}.yml"
|
||||
loop_control:
|
||||
loop_var: test_chart_type
|
||||
with_items:
|
||||
@@ -24,33 +20,34 @@
|
||||
- from_repository
|
||||
- from_url
|
||||
|
||||
- name: test helm upgrade with reuse_values
|
||||
include_tasks: test_helm_reuse_values.yml
|
||||
- name: Test helm upgrade with reuse_values
|
||||
ansible.builtin.include_tasks: test_helm_reuse_values.yml
|
||||
|
||||
- name: test helm upgrade with reset_then_reuse_values
|
||||
include_tasks: test_helm_reset_then_reuse_values.yml
|
||||
- name: Test helm upgrade with reset_then_reuse_values
|
||||
ansible.builtin.include_tasks: test_helm_reset_then_reuse_values.yml
|
||||
when: helm_version | string is ansible.builtin.version('3.14.0', '>=')
|
||||
|
||||
- name: test helm dependency update
|
||||
include_tasks: test_up_dep.yml
|
||||
- name: Test helm dependency update
|
||||
ansible.builtin.include_tasks: test_up_dep.yml
|
||||
|
||||
- name: Test helm install with chart name containing space
|
||||
include_tasks: test_helm_with_space_into_chart_name.yml
|
||||
ansible.builtin.include_tasks: test_helm_with_space_into_chart_name.yml
|
||||
|
||||
# https://github.com/ansible-collections/community.kubernetes/issues/296
|
||||
- name: Test Skip CRDS feature in helm chart install
|
||||
include_tasks: test_crds.yml
|
||||
ansible.builtin.include_tasks: test_crds.yml
|
||||
|
||||
- name: Test insecure registry flag feature
|
||||
include_tasks: test_helm_insecure.yml
|
||||
ansible.builtin.include_tasks: test_helm_insecure.yml
|
||||
|
||||
- name: Test take ownership flag feature
|
||||
include_tasks: test_helm_take_ownership.yml
|
||||
ansible.builtin.include_tasks: test_helm_take_ownership.yml
|
||||
|
||||
- name: Test helm skip_schema_validation
|
||||
include_tasks: test_skip_schema_validation.yml
|
||||
ansible.builtin.include_tasks: test_skip_schema_validation.yml
|
||||
|
||||
- name: Test helm wait_for_jobs
|
||||
include_tasks: test_helm_wait_for_jobs.yml
|
||||
ansible.builtin.include_tasks: test_helm_wait_for_jobs.yml
|
||||
|
||||
always:
|
||||
- name: Remove helm-diff plugin
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
register: install
|
||||
|
||||
- name: Validate that insecure flag is not set
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- '"--insecure-skip-tls-verify" not in install.command'
|
||||
@@ -30,18 +30,18 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Validate that insecure flag IS set if helm version is >= 3.16.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- '"--insecure-skip-tls-verify" in install.command'
|
||||
when: '"v3.16.0" <= helm_version'
|
||||
when: helm_version | string is ansible.builtin.version("3.16.0", ">=")
|
||||
|
||||
- name: Validate that feature fails for helm < 3.16.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is failed
|
||||
- '"insecure_skip_tls_verify requires helm >= 3.16.0" in install.msg'
|
||||
when: 'helm_version < "v3.16.0"'
|
||||
when: helm_version | string is ansible.builtin.version("3.16.0", "<")
|
||||
|
||||
always:
|
||||
- name: Remove helm namespace
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Failed test when helm is not installed
|
||||
helm:
|
||||
binary_path: "{{ helm_binary}}_fake"
|
||||
binary_path: "{{ helm_binary }}_fake"
|
||||
name: test
|
||||
chart_ref: "{{ chart_test }}"
|
||||
namespace: "helm-test"
|
||||
@@ -9,15 +9,7 @@
|
||||
register: helm_missing_binary
|
||||
|
||||
- name: Assert that helm is not installed
|
||||
assert:
|
||||
that:
|
||||
- helm_missing_binary is failed
|
||||
- "'No such file or directory' in helm_missing_binary.msg"
|
||||
when: ansible_version.full is version('2.20', '<')
|
||||
|
||||
- name: Assert that helm is not installed (ansible 2.20+)
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- helm_missing_binary is failed
|
||||
- "'Error executing command' in helm_missing_binary.msg"
|
||||
when: ansible_version.full is version('2.20', '>=')
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
register: release_value
|
||||
|
||||
- name: Validate that chart values are as expected
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- '"--reset-then-reuse-values" not in install.command'
|
||||
@@ -80,7 +80,7 @@
|
||||
register: release_value
|
||||
|
||||
- name: Validate that chart values are as expected
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is changed
|
||||
- '"--reset-then-reuse-values" in upgrade.command'
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
register: release_value
|
||||
|
||||
- name: Validate that chart values are as expected
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- '"--reuse-values=True" not in install.command'
|
||||
@@ -72,7 +72,7 @@
|
||||
register: release_value
|
||||
|
||||
- name: Validate that chart values are as expected
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is changed
|
||||
- '"--reuse-values=True" in upgrade.command'
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
register: install
|
||||
|
||||
- name: Validate that take-ownership flag is not set
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- '"--take-ownership" not in install.command'
|
||||
@@ -50,18 +50,18 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is changed
|
||||
- '"--take-ownership" in upgrade.command'
|
||||
when: '"v3.17.0" <= helm_version'
|
||||
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
|
||||
|
||||
- name: Validate that feature fails for helm < 3.17.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is failed
|
||||
- '"take_ownership requires helm >= 3.17.0" in upgrade.msg'
|
||||
when: 'helm_version < "v3.17.0"'
|
||||
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
|
||||
|
||||
- name: Upgrade chart (take-onwership flag not set)
|
||||
helm:
|
||||
@@ -79,18 +79,18 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Validate that take-ownership flag IS set if helm version is >= 3.17.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is changed
|
||||
- '"--take-ownership" not in upgrade.command'
|
||||
when: '"v3.17.0" <= helm_version'
|
||||
when: helm_version | string is ansible.builtin.version("3.17.0", ">=")
|
||||
|
||||
- name: Validate that feature fails for helm < 3.17.0
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- upgrade is changed
|
||||
- upgrade.msg is not defined
|
||||
when: 'helm_version < "v3.17.0"'
|
||||
when: helm_version | string is ansible.builtin.version("3.17.0", "<")
|
||||
|
||||
always:
|
||||
- name: Remove helm namespace
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
- name: validate helm version lower than 3.7.0
|
||||
helm_test_version:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
version: "3.7.0"
|
||||
register: test_version
|
||||
|
||||
- vars:
|
||||
chart_source: "https://github.com/kubernetes/kube-state-metrics/releases/download/kube-state-metrics-helm-chart-2.13.3/kube-state-metrics-2.13.3.tgz"
|
||||
chart_name: "test-wait-uninstall"
|
||||
chart_name_pending: "test-uninstall-pending-release"
|
||||
helm_namespace: "{{ test_namespace[1] }}"
|
||||
block:
|
||||
|
||||
- name: Install chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_name }}"
|
||||
chart_ref: "{{ chart_source }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
|
||||
- name: Delete chart with wait
|
||||
helm:
|
||||
state: absent
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_name }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
wait: yes
|
||||
register: uninstall
|
||||
|
||||
- name: assert warning has been raised
|
||||
assert:
|
||||
that:
|
||||
- uninstall.warnings is defined
|
||||
- '"helm uninstall support option --wait for helm release >= 3.7.0" in uninstall.warnings'
|
||||
|
||||
- name: Install Helm v4
|
||||
ansible.builtin.include_role:
|
||||
name: install_helm
|
||||
vars:
|
||||
helm_version: v4.0.0
|
||||
|
||||
- name: Install chart
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_name }}"
|
||||
chart_ref: "{{ chart_source }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: true
|
||||
|
||||
- name: uninstall chart again using recent version
|
||||
helm:
|
||||
state: absent
|
||||
binary_path: "{{ helm_binary }}"
|
||||
name: "{{ chart_name }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
wait: yes
|
||||
register: uninstall
|
||||
|
||||
# Test uninstall chart release with 'pending-install' status
|
||||
- name: Create chart release with 'pending-install' status
|
||||
helm_test_pending:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "{{ chart_source }}"
|
||||
chart_release: "{{ chart_name_pending }}"
|
||||
chart_release_namespace: "{{ helm_namespace }}"
|
||||
|
||||
- name: Uninstall chart release with 'pending-install' status
|
||||
helm:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
release_name: "{{ chart_name_pending }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
release_state: absent
|
||||
register: _uninstall
|
||||
|
||||
- name: Get Helm release details
|
||||
helm_info:
|
||||
binary_path: "{{ helm_binary }}"
|
||||
release_namespace: "{{ helm_namespace }}"
|
||||
release_state: pending
|
||||
release_name: "{{ chart_name_pending }}"
|
||||
register: _info
|
||||
|
||||
- name: assert release does not exist anymore
|
||||
assert:
|
||||
that:
|
||||
- _uninstall is changed
|
||||
- _info.status is undefined
|
||||
|
||||
always:
|
||||
- name: Remove namespace
|
||||
k8s:
|
||||
kind: Namespace
|
||||
name: "{{ helm_namespace }}"
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
when: test_version.result
|
||||
@@ -19,19 +19,19 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Validate wait_for_jobs with helm >= 3.5.0 works
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- "'--wait' in install.command"
|
||||
- "'--wait-for-jobs' in install.command"
|
||||
when: "helm_version is ansible.builtin.version('v3.5.0', '>=')"
|
||||
when: "helm_version | string is ansible.builtin.version('3.5.0', '>=')"
|
||||
|
||||
- name: Validate wait_for_jobs with helm < 3.5.0 fails
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is failed
|
||||
- "'wait_for_jobs requires helm >= 3.5.0' in install.msg"
|
||||
when: "helm_version is ansible.builtin.version('v3.5.0', '<')"
|
||||
when: "helm_version | string is ansible.builtin.version('3.5.0', '<')"
|
||||
|
||||
- name: Install chart with wait_for_jobs but without wait
|
||||
helm:
|
||||
@@ -44,7 +44,7 @@
|
||||
register: install_no_wait
|
||||
|
||||
- name: Validate wait_for_jobs is ignored without wait
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install_no_wait is changed
|
||||
- "'--wait-for-jobs' not in install_no_wait.command"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
register: install_chart
|
||||
|
||||
- name: Assert that chart is installed
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install_chart is changed
|
||||
- install_chart.status.status | lower == 'deployed'
|
||||
@@ -40,7 +40,7 @@
|
||||
register: chart_info
|
||||
|
||||
- name: Assert that Chart is installed (using helm_info)
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- chart_info.status.status | lower == 'deployed'
|
||||
|
||||
|
||||
@@ -22,22 +22,22 @@
|
||||
ignore_errors: true
|
||||
|
||||
- name: Debug install result
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: install
|
||||
|
||||
- name: Validate skip_schema_validation with helm >= 3.16.0 works
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- "'--skip-schema-validation' in install.command"
|
||||
when: "helm_version is ansible.builtin.version('v3.16.0', '>=')"
|
||||
when: "helm_version | string is ansible.builtin.version('3.16.0', '>=')"
|
||||
|
||||
- name: Validate skip_schema_validation with helm < 3.16.0 fails
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is failed
|
||||
- "'skip_schema_validation requires helm >= 3.16.0' in install.msg"
|
||||
when: "helm_version is ansible.builtin.version('v3.16.0', '<')"
|
||||
when: "helm_version | string is ansible.builtin.version('3.16.0', '<')"
|
||||
|
||||
always:
|
||||
- name: Remove helm namespace
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
vars:
|
||||
helm_namespace: "{{ test_namespace[3] }}"
|
||||
block:
|
||||
- name: copy chart
|
||||
copy:
|
||||
- name: Copy chart
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: /tmp
|
||||
loop:
|
||||
@@ -19,16 +19,16 @@
|
||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
dependency_update: false
|
||||
create_namespace: yes
|
||||
create_namespace: true
|
||||
register: release
|
||||
|
||||
- name: "Get stats of the subchart"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/test-chart/Chart.lock"
|
||||
register: stat_result
|
||||
|
||||
- name: "Check if the subchart not exist in chart"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not stat_result.stat.exists
|
||||
success_msg: "subchart not exist in the chart directory"
|
||||
@@ -41,12 +41,12 @@
|
||||
chart_ref: "/tmp/test-chart"
|
||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
create_namespace: yes
|
||||
create_namespace: true
|
||||
dependency_update: true
|
||||
ignore_errors: true
|
||||
register: release
|
||||
|
||||
- assert:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
- release.warnings[0] == "There is no dependencies block defined in Chart.yaml. Dependency update will not be performed. Please consider add dependencies block or disable dependency_update to remove this warning."
|
||||
success_msg: "warning when there is no dependencies block with dependency_update enabled"
|
||||
@@ -59,16 +59,16 @@
|
||||
chart_version: "{{ chart_source_version | default(omit) }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
dependency_update: true
|
||||
create_namespace: yes
|
||||
create_namespace: true
|
||||
register: release
|
||||
|
||||
- name: "Get stats of the subchart"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "/tmp/dep-up/Chart.lock"
|
||||
register: stat_result
|
||||
|
||||
- name: "Check if the subchart exists in chart"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- stat_result.stat.exists
|
||||
success_msg: "subchart exist in the chart directory"
|
||||
@@ -82,7 +82,7 @@
|
||||
state: absent
|
||||
|
||||
- name: "Remove charts"
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "/tmp/{{ item }}"
|
||||
loop:
|
||||
@@ -92,8 +92,8 @@
|
||||
# Helm_template module
|
||||
- name: "Test dependency update for helm_template module"
|
||||
block:
|
||||
- name: copy chart
|
||||
copy:
|
||||
- name: Copy chart
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: /tmp
|
||||
loop:
|
||||
@@ -110,7 +110,7 @@
|
||||
register: result
|
||||
|
||||
- name: "Get stats of the subchart"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
register: stat_result
|
||||
loop:
|
||||
@@ -118,7 +118,7 @@
|
||||
- /tmp/dep_up/charts/test-chart/templates/configmap.yaml
|
||||
|
||||
- name: "Check if the subchart exist in chart"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- stat_result.results[0].stat.exists
|
||||
- stat_result.results[1].stat.exists
|
||||
@@ -135,7 +135,7 @@
|
||||
register: result
|
||||
|
||||
- name: "Get stats of the subchart"
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
register: stat_result
|
||||
loop:
|
||||
@@ -143,7 +143,7 @@
|
||||
- /tmp/test-chart/templates/configmap.yaml
|
||||
|
||||
- name: "Check if the subchart not exist in chart"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not stat_result.results[0].stat.exists
|
||||
- stat_result.results[1].stat.exists
|
||||
@@ -152,7 +152,7 @@
|
||||
always:
|
||||
|
||||
- name: "Remove charts"
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "/tmp/{{ item }}"
|
||||
loop:
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
chart_release_replaced_name: "test-{{ chart_name | default(source) }}-001"
|
||||
block:
|
||||
- name: Create temp directory
|
||||
tempfile:
|
||||
ansible.builtin.tempfile:
|
||||
state: directory
|
||||
register: tmpdir
|
||||
|
||||
- name: Set temp directory fact
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
temp_dir: "{{ tmpdir.path }}"
|
||||
|
||||
- name: Check helm_info empty
|
||||
@@ -21,7 +21,7 @@
|
||||
register: empty_info
|
||||
|
||||
- name: "Assert that no charts are installed with helm_info"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- empty_info.status is undefined
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
register: install_fail
|
||||
|
||||
- name: "Assert that Install fail {{ chart_test }} from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install_fail is failed
|
||||
- "'Error: create: failed to create: namespaces \"' + helm_namespace + '\" not found' in install_fail.stderr"
|
||||
@@ -53,7 +53,7 @@
|
||||
check_mode: true
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }} in check mode"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install_check_mode is changed
|
||||
- install_check_mode.status is defined
|
||||
@@ -70,7 +70,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- install.status.chart == chart_test+"-"+chart_test_version
|
||||
@@ -94,7 +94,7 @@
|
||||
register: release_state_content_info
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart version {{ chart_test_version }} is installed from {{ source }} with helm_info"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- content_info.status.chart == chart_test+"-"+chart_test_version
|
||||
- content_info.status.status | lower == 'deployed'
|
||||
@@ -111,7 +111,7 @@
|
||||
diff: true
|
||||
|
||||
- name: Assert idempotency
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is not changed
|
||||
- install.status.chart == chart_test+"-"+chart_test_version
|
||||
@@ -128,7 +128,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -147,7 +147,7 @@
|
||||
diff: true
|
||||
|
||||
- name: Assert idempotency after add vars
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is not changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -164,7 +164,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is upgraded with new var from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -182,7 +182,7 @@
|
||||
diff: true
|
||||
|
||||
- name: Assert idempotency after removing vars
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is not changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -199,7 +199,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is upgraded with new version from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -216,7 +216,7 @@
|
||||
diff: true
|
||||
|
||||
- name: Assert idempotency after upgrade
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is not changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -231,7 +231,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is removed from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
diff: true
|
||||
|
||||
- name: Assert idempotency
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is not changed
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
@@ -269,12 +269,12 @@
|
||||
binary_path: "{{ helm_binary }}"
|
||||
state: absent
|
||||
name: "{{ chart_release_replaced_name }}"
|
||||
purge: False
|
||||
purge: false
|
||||
namespace: "{{ helm_namespace }}"
|
||||
register: install
|
||||
|
||||
- name: Check if chart is removed
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
@@ -285,11 +285,11 @@
|
||||
chart_ref: "{{ chart_source }}"
|
||||
chart_version: "{{ chart_test_version }}"
|
||||
namespace: "{{ helm_namespace }}"
|
||||
replace: True
|
||||
replace: true
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart is installed from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
register: install
|
||||
|
||||
- name: Check if chart is removed
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
|
||||
@@ -318,7 +318,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert that {{ chart_test }} chart has var from {{ source }}"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- install is changed
|
||||
- install.status.status | lower == 'deployed'
|
||||
@@ -337,7 +337,7 @@
|
||||
register: install
|
||||
|
||||
- name: "Assert the result is consistent"
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not (install is changed)
|
||||
|
||||
@@ -358,7 +358,7 @@
|
||||
- "{{ role_path }}/files/values.yaml"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result is not failed
|
||||
@@ -366,11 +366,11 @@
|
||||
- result.command is match(helm_binary+" template "+chart_source)
|
||||
|
||||
- name: Check templates created
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ temp_dir }}/{{ chart_test }}/templates"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
result.stat.exists
|
||||
|
||||
@@ -379,7 +379,7 @@
|
||||
binary_path: "{{ helm_binary }}"
|
||||
chart_ref: "{{ chart_source }}"
|
||||
chart_version: "{{ chart_test_version }}"
|
||||
disable_hook: True
|
||||
disable_hook: true
|
||||
release_name: "myrelease"
|
||||
release_namespace: "myreleasenamespace"
|
||||
show_only:
|
||||
@@ -389,7 +389,7 @@
|
||||
register: result
|
||||
when: chart_source is search("test-chart")
|
||||
|
||||
- assert:
|
||||
- ansible.builtin.assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result is not failed
|
||||
@@ -412,14 +412,14 @@
|
||||
register: result
|
||||
|
||||
- name: Assert that release fails with non-existent context
|
||||
assert:
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- "'context \"does-not-exist\" does not exist' in result.stderr"
|
||||
|
||||
always:
|
||||
- name: Clean up temp dir
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: "{{ temp_dir }}"
|
||||
ignore_errors: true
|
||||
|
||||
Reference in New Issue
Block a user