Cleanup GitHub workflows (#655)

* Cleanup gha

* test by removing matrix excludes

* Rename sanity tests

* trigger integration tests

* Fix ansible-lint workflow

* Fix concurrency

* Add ansible-lint config

* Add ansible-lint config

* Fix integration and lint issues

* integration wf

* fix yamllint issues

* fix yamllint issues

* update readme and add ignore-2.16.txt

* fix ansible-doc

* Add version

* Use /dev/random to generate random data

The GHA environment has difficultly generating entropy. Trying to read
from /dev/urandom just blocks forever. We don't care if the random data
is cryptographically secure; it's just garbage data for the test. Read
from /dev/random, instead. This is only used during the k8s_copy test
target.

This also removes the custom test module that was being used to generate
the files. It's not worth maintaining this for two task that can be
replaced with some simple command/shell tasks.

* Fix saniry errors

* test github_action fix

* Address review comments

* Remove default types

* review comments

* isort fixes

* remove tags

* Add setuptools to venv

* Test gh changes

* update changelog

* update ignore-2.16

* Fix indentation in inventory plugin example

* Update .github/workflows/integration-tests.yaml

* Update integration-tests.yaml

---------

Co-authored-by: Mike Graves <mgraves@redhat.com>
Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com>
This commit is contained in:
GomathiselviS
2023-11-10 10:33:40 -05:00
committed by GitHub
parent 9e9962bc6c
commit b066a2dda3
80 changed files with 496 additions and 680 deletions

View File

@@ -48,9 +48,10 @@ EXAMPLES = r"""
RETURN = r"""
"""
import subprocess
import json
import subprocess
import time
from ansible.module_utils.basic import AnsibleModule

View File

@@ -52,12 +52,12 @@ result:
"""
import re
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.kubernetes.core.plugins.module_utils.version import (
LooseVersion,
)
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(

View File

@@ -1,93 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2021, Aubin Bikouo <@abikouo>
# 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: k8s_create_file
short_description: Create large file with a defined size.
author:
- Aubin Bikouo (@abikouo)
description:
- This module is used to validate k8s_cp module.
options:
path:
description:
- The destination path for the file to create.
type: path
required: yes
size:
description:
- The size of the output file in MB.
type: int
default: 400
binary:
description:
- If this flag is set to yes, the generated file content binary data.
type: bool
default: False
"""
EXAMPLES = r"""
- name: create 150MB file
k8s_diff:
path: large_file.txt
size: 150
"""
RETURN = r"""
"""
import os
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native
def execute_module(module):
try:
size = module.params.get("size") * 1024 * 1024
path = module.params.get("path")
write_mode = "w"
if module.params.get("binary"):
content = os.urandom(size)
write_mode = "wb"
else:
content = ""
count = 0
while len(content) < size:
content += "This file has been generated using ansible: {0}\n".format(
count
)
count += 1
with open(path, write_mode) as f:
f.write(content)
module.exit_json(changed=True, size=len(content))
except Exception as e:
module.fail_json(msg="failed to create file due to: {0}".format(to_native(e)))
def main():
argument_spec = {}
argument_spec["size"] = {"type": "int", "default": 400}
argument_spec["path"] = {"type": "path", "required": True}
argument_spec["binary"] = {"type": "bool", "default": False}
module = AnsibleModule(argument_spec=argument_spec)
execute_module(module)
if __name__ == "__main__":
main()

View File

@@ -89,10 +89,10 @@ EXAMPLES = r"""
RETURN = r"""
"""
import os
import filecmp
import os
from tempfile import NamedTemporaryFile, TemporaryDirectory
from ansible.module_utils.basic import AnsibleModule
@@ -157,7 +157,6 @@ def compare_directories(dir1, dir2):
def execute_module(module):
args = module.params.get("args")
local_path = module.params.get("local_path")
namespace = module.params.get("namespace")

View File

@@ -10,16 +10,13 @@
path: "{{ test_directory }}"
state: directory
- name: create large text file
k8s_create_file:
path: "{{ test_directory }}/large_text_file.txt"
size: 150
- name: Create a large text file
ansible.builtin.shell:
cmd: base64 /dev/random | head -c 150M > {{ test_directory }}/large_text_file.txt
- name: create large binary file
k8s_create_file:
path: "{{ test_directory }}/large_bin_file.bin"
size: 200
binary: true
- name: Create a large binary file
ansible.builtin.command:
cmd: dd if=/dev/random of={{ test_directory }}/large_bin_file.bin bs=1M count=200
# Copy large text file from/to local filesystem to Pod
- name: copy large file into remote Pod

View File

@@ -52,6 +52,7 @@
name:
- kubernetes
- kubernetes-validate
- setuptools
virtualenv: "{{ virtualenv }}"
virtualenv_command: "{{ virtualenv_command }}"
virtualenv_site_packages: false

View File

@@ -78,7 +78,6 @@ from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import
class K8SInventoryTestModule(AnsibleModule):
def __init__(self):
argument_spec = dict(
kube_config=dict(required=True, type="path"),
dest_dir=dict(required=True, type="path"),
@@ -88,7 +87,6 @@ class K8SInventoryTestModule(AnsibleModule):
self.execute_module()
def execute_module(self):
dest_dir = os.path.abspath(self.params.get("dest_dir"))
kubeconfig_path = self.params.get("kube_config")
if not os.path.isdir(dest_dir):