Skip to content

Commit

Permalink
Added oc-zoscloudbroker module, overhauled tests (Ansible Sanity, Uni…
Browse files Browse the repository at this point in the history
…t, and Integration tests, and refactored Molecule tests) and added shell scriptes to make testing locally easier.

Signed-off-by: Yemi Kelani <Yemi.Kelani@ibm.com>
  • Loading branch information
Yemi Kelani authored and Yemi Kelani committed May 3, 2024
1 parent b6d37e5 commit e0de1fa
Show file tree
Hide file tree
Showing 59 changed files with 1,990 additions and 159 deletions.
131 changes: 116 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ name: Test
on:
push:
branches:
- '**'
- "**"
paths-ignore:
- 'docs/**'
- '**.md'
- "docs/**"
- "**.md"
tags-ignore:
- '**'
- "**"
pull_request_target:

concurrency:
group: >-
${{ github.workflow }}-${{
github.event.pull_request.number || github.sha
}}
cancel-in-progress: true

jobs:
authorize:
name: Authorize
Expand All @@ -39,8 +46,8 @@ jobs:
- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
python-version: "3.10"
cache: "pip"

- name: Perform PIP installs
run: pip install ansible-lint==6.16.0
Expand All @@ -53,8 +60,100 @@ jobs:
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.yml
ansible-lint --config-file ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/.ansible-lint --project-dir ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/playbooks/ --exclude ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/playbooks/molecule/
test:
name: Test
sanity:
name: Run Sanity Tests (Ⓐ${{ matrix.ansible }})
needs: [lint, authorize]
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
strategy:
matrix:
ansible:
- stable-2.16
# - milestone
steps:
- name: Perform sanity testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
collection-root: /ibm/operator_collection_sdk/
ansible-core-version: stable-2.16
testing-type: sanity

unit:
name: Run Unit Tests (Ⓐ${{ matrix.ansible }})
needs: [lint, authorize]
runs-on: >-
${{ contains(fromJson(
'["stable-2.9", "stable-2.10", "stable-2.11"]'
), matrix.ansible) && 'ubuntu-20.04' || 'ubuntu-latest' }}
strategy:
matrix:
ansible:
- stable-2.16
steps:
- name: Perform unit testing with ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
collection-root: /ibm/operator_collection_sdk/
ansible-core-version: stable-2.16
target-python-version: 3.11
testing-type: units
test-deps: >-
kubernetes.core
integration:
name: Run Integration Tests
needs: [lint, authorize]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Log into OCP
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}

- name: Setup Cluster Environment before integration Tests
continue-on-error: true
run: |
chmod +x ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_setup.sh
bash ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_setup.sh \
--collection-root=${GITHUB_WORKSPACE}/ibm/operator_collection_sdk
env:
OCP_NAMESPACE: integration-${GITHUB_REF_NAME}-${RUNNER_OS}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}

- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"

- name: Perform PIP and Collection Installs
run: |
pip install -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/requirements.txt
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/requirements.yml
ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force
- name: Perform Integration Testing with ansible-test
run: |
cd ~/.ansible/collections/ansible_collections/ibm/operator_collection_sdk
ansible-test integration -v
- name: Cleanup Cluster Environment after integration Tests
if: always()
run: |
chmod +x ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_clean.sh
bash ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/tests/integration/integration_clean.sh \
--collection-root=${GITHUB_WORKSPACE}/ibm/operator_collection_sdk
env:
OCP_NAMESPACE: integration-${GITHUB_REF_NAME}-${RUNNER_OS}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}

molecule-tests:
name: Run Molecule Tests
needs: [lint, authorize]
runs-on: ${{matrix.os}}
strategy:
Expand All @@ -75,15 +174,17 @@ jobs:
- name: Install Python Requirements
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
python-version: "3.10"
cache: "pip"

- name: Perform PIP installs
run: pip install -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.txt

- name: Perform collection installs
run: ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force

run: |
ansible-galaxy collection install --force -r ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk/requirements.yml
ansible-galaxy collection install ${GITHUB_WORKSPACE}/ibm/operator_collection_sdk --force
- name: Install oc cli
uses: redhat-actions/openshift-tools-installer@v1
with:
Expand All @@ -101,6 +202,6 @@ jobs:
export ANSIBLE_PYTHON_INTERPRETER="$(which python)"
OCP_NAMESPACE=molecule-${GITHUB_REF_NAME}-${RUNNER_OS} molecule test --all
env:
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
ZOSCB_RELEASE: ibm-zoscb.${{ vars.ZOSCB_RELEASE }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ ibm/operator_collection_sdk/local/*
examples/racf-operator/local/*
.DS_Store
.vscode/*
*.idea/
*.idea/
__pycache__
integration_config.yml
2 changes: 1 addition & 1 deletion examples/racf-operator/inventories/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
source_system:
hosts:
zos_host:
ansible_host: ***HOST_REMOVED***
ansible_host: ""
ansible_user: omvsadm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ print_pass: true
##################################################################################################################
# Specifies the SMTP server to use for sending email, if sending email is desired.
##################################################################################################################
smtp_server: ***HOST_REMOVED***
smtp_server: ""

##################################################################################################################
# Specifies the SMTP port to use for sending email, if sending email is desired.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ print_pass: true
##################################################################################################################
# Specifies the SMTP server to use for sending email, if sending email is desired.
##################################################################################################################
smtp_server: ***HOST_REMOVED***
smtp_server: ""

##################################################################################################################
# Specifies the SMTP port to use for sending email, if sending email is desired.
Expand Down
73 changes: 73 additions & 0 deletions ibm/operator_collection_sdk/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,76 @@ build_ignore:
# with 'build_ignore'
# manifest: null

### REQUIRED
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
# content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with
# underscores or numbers and cannot contain consecutive underscores
namespace: ibm

# The name of the collection. Has the same character restrictions as 'namespace'
name: operator_collection_sdk

# The version of the collection. Must be compatible with semantic versioning
version: 2.0.0-alpha.2

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
# @nicks:irc/im.site#channel'
authors:
- Latrell Freeman <latrell.freeman@us.ibm.com>


### OPTIONAL but strongly recommended
# A short summary description of the collection
description: The IBM Operator Collection SDK provides the resources and tools that are needed to develop Operator Collections against the IBM® z/OS® Cloud Broker as part of the IBM Z® and Cloud Modernization Stack.

# The path to the license file for the collection. This path is relative to the root of the collection. This key is
# mutually exclusive with 'license'
license_file: LICENSE

# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags:
- ibm
- operator_collection
- operator_collection_sdk
- zos
- z_os
- z

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
# range specifiers can be set and are separated by ','
dependencies: {}

# The URL of the originating SCM repository
repository: https://github.com/IBM/operator-collection-sdk

# The URL to any online docs
documentation: https://github.com/IBM/operator-collection-sdk/blob/main/ibm/operator_collection_sdk/README.md

# The URL to the homepage of the collection/project
homepage: https://github.com/IBM/operator-collection-sdk/blob/main/ibm/operator_collection_sdk

# The URL to the collection issue tracker
issues: https://github.com/IBM/operator-collection-sdk/issues

# A list of file glob-like patterns used to filter any files or directories that should not be included in the build
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered. Mutually exclusive with 'manifest'
build_ignore:
- .gitignore
- playbooks/molecule
- ansible_venv

# A dict controlling use of manifest directives used in building the collection artifact. The key 'directives' is a
# list of MANIFEST.in style
# L(directives,https://packaging.python.org/en/latest/guides/using-manifest-in/#manifest-in-commands). The key
# 'omit_default_directives' is a boolean that controls whether the default directives are used. Mutually exclusive
# with 'build_ignore'
# manifest: null

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@

---
- name: Clean Test Environment
hosts: all
hosts: localhost
connection: local
gather_facts: false
gather_facts: false
tasks:
- name: Install dependency # necessary for gh-actions use
pip:
name:
- kubernetes

- name: Get SubOperatorConfigs
kubernetes.core.k8s_info:
api_version: zoscb.ibm.com/v2beta2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@

---
- name: Test Environment Setup
hosts: all
hosts: localhost
connection: local
gather_facts: false
gather_facts: false
tasks:
- name: Install dependency # necessary for gh-actions use
pip:
name:
- kubernetes

- name: Create Namespace
kubernetes.core.k8s:
state: present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
ansible.builtin.file:
path: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator-test"
state: absent

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
- name: Assert that requirements.yml contains correct ansible requirements
ansible.builtin.assert:
that:
- "zos_core_filename in requirementsyml.collections[0].name"
- "zos_core_filename in requirementsyml.collections[0].name"

- name: Search for wheelhouse directory
ansible.builtin.find:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
ansible.builtin.file:
path: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/../../../examples/racf-operator-test"
state: absent

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
- name: Assert that requirements.yml contains correct ansible requirements
ansible.builtin.assert:
that:
- "zos_core_filename in requirementsyml.collections[0].name"
- "zos_core_filename in requirementsyml.collections[0].name"


Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- name: Assert that the galaxy.yml file exists
ansible.builtin.assert:
that:
- galaxyyml.matched == 1
- galaxyyml.matched == 1

- name: Read galaxy.yml
ansible.builtin.set_fact:
Expand All @@ -33,7 +33,7 @@
- name: Assert that the operator-config.yml file exists
ansible.builtin.assert:
that:
- operatorconfig.matched == 1
- operatorconfig.matched == 1

- name: Read operator-config
ansible.builtin.set_fact:
Expand All @@ -42,18 +42,18 @@
- name: Assert that operator-config.yml contains correct values
ansible.builtin.assert:
that:
- operatorconfigdata.description == galaxydata.description
- operatorconfigdata.version == galaxydata.version
- operatorconfigdata.displayName is defined
- operatorconfigdata.domain == "{{ collection_namespace | lower | replace('_','-') }}"
- operatorconfigdata.name == "{{ collection_name | lower | replace('_','-') }}"
- operatorconfigdata.resources[0].description is defined
- operatorconfigdata.resources[0].displayName is defined
- operatorconfigdata.resources[0].kind is defined
- operatorconfigdata.resources[0].playbook == 'playbooks/playbook.yml'
- operatorconfigdata.resources[0].vars[0].description is defined
- operatorconfigdata.resources[0].vars[0].displayName is defined
- operatorconfigdata.resources[0].vars[0].name is defined
- operatorconfigdata.resources[0].vars[0].type is defined
- operatorconfigdata.description == galaxydata.description
- operatorconfigdata.version == galaxydata.version
- operatorconfigdata.displayName is defined
- operatorconfigdata.domain == "{{ collection_namespace | lower | replace('_','-') }}"
- operatorconfigdata.name == "{{ collection_name | lower | replace('_','-') }}"
- operatorconfigdata.resources[0].description is defined
- operatorconfigdata.resources[0].displayName is defined
- operatorconfigdata.resources[0].kind is defined
- operatorconfigdata.resources[0].playbook == 'playbooks/playbook.yml'
- operatorconfigdata.resources[0].vars[0].description is defined
- operatorconfigdata.resources[0].vars[0].displayName is defined
- operatorconfigdata.resources[0].vars[0].name is defined
- operatorconfigdata.resources[0].vars[0].type is defined


0 comments on commit e0de1fa

Please sign in to comment.