Skip to content

Added oc-zoscloudbroker module, overhauled tests (Ansible Sanity, Uni… #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 0 additions & 1 deletion ibm/operator_collection_sdk/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ build_ignore:
# '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 ansible tests
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 ansible tests
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


Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@

- name: Converge
import_playbook: ../../create_operator.yml
vars:
filepath: "{{ operator_path }}"
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
- name: Assert ZosEndpoint configuration
ansible.builtin.assert:
that:
- zosendpoint_results.resources[0].status.phase == 'Successful'
- zosendpoint_results.resources[0].status.suboperatorconfigs | length == 1
- zosendpoint_results.resources[0].spec.endpointType == "local"
- zosendpoint_results.resources[0].status.phase == 'Successful'
- zosendpoint_results.resources[0].status.suboperatorconfigs | length == 1
- zosendpoint_results.resources[0].spec.endpointType == "local"

- name: Validate SubOperatorConfig
kubernetes.core.k8s_info:
Expand All @@ -35,15 +35,15 @@
- name: Assert SubOperatorConfig configuration
ansible.builtin.assert:
that:
- suboperatorconfig_results.resources[0].spec.credentialType == 'shared'
- suboperatorconfig_results.resources[0].spec.mapping[0].namespace == '{{ ocpnamespace }}'
- suboperatorconfig_results.resources[0].spec.mapping[0].zosendpoints[0].name == '{{ zosendpoint_name }}'
- suboperatorconfig_results.resources[0].spec.mapping[0].zosendpoints[0].credentialName is undefined
- suboperatorconfig_results.resources[0].spec.operatorCollection is defined
- suboperatorconfig_results.resources[0].status.phase == 'Successful'
- suboperatorconfig_results.resources[0].status.clusterserviceversion is defined
- suboperatorconfig_results.resources[0].status.customresourcedefinition | length > 0
- suboperatorconfig_results.resources[0].status.packages is defined
- suboperatorconfig_results.resources[0].spec.credentialType == 'shared'
- suboperatorconfig_results.resources[0].spec.mapping[0].namespace == '{{ ocpnamespace }}'
- suboperatorconfig_results.resources[0].spec.mapping[0].zosendpoints[0].name == '{{ zosendpoint_name }}'
- suboperatorconfig_results.resources[0].spec.mapping[0].zosendpoints[0].credentialName is undefined
- suboperatorconfig_results.resources[0].spec.operatorCollection is defined
- suboperatorconfig_results.resources[0].status.phase == 'Successful'
- suboperatorconfig_results.resources[0].status.clusterserviceversion is defined
- suboperatorconfig_results.resources[0].status.customresourcedefinition | length > 0
- suboperatorconfig_results.resources[0].status.packages is defined

- name: Validate OperatorCollection
kubernetes.core.k8s_info:
Expand All @@ -56,10 +56,10 @@
- name: Assert OperatorCollection configuration
ansible.builtin.assert:
that:
- operatorcollection_results.resources[0].spec.skipSignatureVerification is true
- operatorcollection_results.resources[0].status.config.collectionPath is defined
- operatorcollection_results.resources[0].status.phase == 'Successful'
- operatorcollection_results.resources[0].status.subOperatorConfigMappingStatus | length == 1
- operatorcollection_results.resources[0].spec.skipSignatureVerification is true
- operatorcollection_results.resources[0].status.config.collectionPath is defined
- operatorcollection_results.resources[0].status.phase == 'Successful'
- operatorcollection_results.resources[0].status.subOperatorConfigMappingStatus | length == 1

- name: Validate CSV
kubernetes.core.k8s_info:
Expand All @@ -76,4 +76,4 @@
- name: Assert CSV configuration
ansible.builtin.assert:
that:
- csv_results.resources[0].status.phase == 'Succeeded'
- csv_results.resources[0].status.phase == 'Succeeded'
Loading