Skip to content

Commit

Permalink
Added running end2end tests against mocked environments
Browse files Browse the repository at this point in the history
Details:

* Added a new target 'end2end_mocked' to the Makefile that runs the end2end
  tests against mock environments defined with a new HMC inventory file
  (mocked_inventory.yaml) and a new HMC vault file (mocked_vault.yaml).

* Added the new make target to the GitHub Actions test workflow.

* Added new mock files that define a mocked HMC for thee tests:
  * mocked_z14_classic.yaml - for an HMC managing a z14 in classic mode
  * mocked_z14_dpm.yaml - for an HMC managing a z14 in DPM mode

* Enabled testing with mock support in the existing end2end testcases:
  * test_zhmc_partition.py
  * test_zhmc_user.py

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Jun 26, 2022
1 parent b0e4b9d commit 4623c6a
Show file tree
Hide file tree
Showing 8 changed files with 1,251 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ jobs:
# TESTCASES: test_partition.py
run: |
make test
- name: Run mocked end2end test
env:
PACKAGE_LEVEL: ${{ matrix.package_level }}
# TESTCASES: test_partition.py
run: |
make end2end_mocked
- name: Send coverage result to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ help:
@echo ' docslocal - Build the documentation from local repo contents in: $(doc_build_local_dir)'
@echo ' linkcheck - Check links in documentation'
@echo ' all - Do all of the above'
@echo ' end2end - Run end2end tests'
@echo ' end2end - Run end2end tests using environment defined by TESTINVENTORY'
@echo ' end2end_mocked - Run end2end tests using mocked environment'
@echo ' upload - Publish the collection to Ansible Galaxy'
@echo ' uploadhub - Publish the collection to Ansible AutomationHub'
@echo ' clobber - Remove any produced files'
Expand Down Expand Up @@ -245,6 +246,11 @@ end2end: _check_version develop_$(pymn).done
bash -c 'PYTHONWARNINGS=default ANSIBLE_LIBRARY=$(module_py_dir) PYTHONPATH=. TESTEND2END_LOAD=true pytest -v $(pytest_opts) $(test_dir)/end2end'
@echo '$@ done.'

.PHONY: end2end_mocked
end2end_mocked: _check_version develop_$(pymn).done
bash -c 'PYTHONWARNINGS=default ANSIBLE_LIBRARY=$(module_py_dir) PYTHONPATH=. TESTEND2END_LOAD=true TESTINVENTORY=$(test_dir)/end2end/mocked_inventory.yaml TESTVAULT=$(test_dir)/end2end/mocked_vault.yaml pytest -v $(pytest_opts) $(test_dir)/end2end'
@echo '$@ done.'

.PHONY: upload
upload: _check_version $(dist_file)
ifneq ($(findstring dev,$(collection_version)),)
Expand Down
54 changes: 54 additions & 0 deletions tests/end2end/mocked_inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# HMC inventory file with mocked HMCs for end2end tests run by GitHub Actions
#
# This file defines only mocked HMCs (using the zhmcclient mock
# support) for the purpose of end2end tests against these HMCs.
# The file must have the format defined in
# zhmcclient/testutils/hmc_inventory_file.py of the python-zhmcclient project.
#
# HMC inventory files conform to the format of HMC inventory files in YAML
# format and define specific additional variables for HMCs.
#
# Brief description of the HMC inventory file format:
#
# all: # the top-level HMC group
# hosts:
# <hmc_name>: # DNS hostname, IP address, or nickname of HMC
# description: <string>
# contact: <string>
# access_via: <string>
# ansible_host: <host> # if real HMC and nickname is used
# mock_file: <path_name> # if mocked HMC
# cpcs:
# <cpc_name>:
# <prop_name>: <prop_value>
# <var_name>: <var_value> # additional variables for HMC
# vars:
# <var_name>: <var_value> # additional variables for all HMCs in group
# children:
# <group_name>: # a child HMC group
# hosts: ... # variables are inherited from parent group
# vars: ...
# children: ...

all:
hosts:
mocked_z14_classic:
description: "Mocked z14 in classic mode"
mock_file: "mocked_z14_classic.yaml"
cpcs:
CPC1:
machine_type: "2964"
dpm_enabled: false
mocked_z14_dpm:
description: "Mocked z14 in DPM mode"
mock_file: "mocked_z14_dpm.yaml"
cpcs:
CPC1:
machine_type: "3906"
dpm_enabled: true
children:
default:
hosts:
mocked_z14_classic:
mocked_z14_dpm:
35 changes: 35 additions & 0 deletions tests/end2end/mocked_vault.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# HMC vault file with mocked HMCs for end2end tests run by GitHub Actions
#
# This file defines the credentials for mocked HMCs for use by the
# zhmcclient.testutils module of the python-zhmcclient project.
#
# The file must have the format defined in
# zhmcclient/testutils/hmc_vault_file.py of the python-zhmcclient project.
#
# HMC vault files conform to the format of Ansible vault files in YAML
# format and define specific variables for HMC authentication.
#
# Brief description of the file format:
#
# hmc_auth:
# <hmc_name>: # DNS hostname, IP address, or nickname of HMC
# userid: <userid>
# password: <password>
# verify: <verify>
# ca_certs: <ca_certs>
# <var_name>: <var_value> # allowed but ignored
#
# Notes for this example file:
# * To use this example file, copy it to `~/.zhmc_vault.yaml` which is the
# default path name used.

hmc_auth:
mocked_z14_classic:
userid: ensadmin
password: password
verify: false
mocked_z14_dpm:
userid: ensadmin
password: password
verify: false
Loading

0 comments on commit 4623c6a

Please sign in to comment.