Skip to content

Commit

Permalink
1043 bug title zos operator is passing wrong value to zoauopercmd (#1044
Browse files Browse the repository at this point in the history
)

* corrected kwarg index value from 'wait_arg' to 'wait'
Also corrected true/false issue in zoaq

* Added and updated changelog.

* update PR number in changelog fragment

* changed test from \$ to \\$ to eliminate warning

* added blocking test to maks sure minimum wait is reached in zoau>1.2.4.5

* removed the else condition from the blocking test, since it is not needed.

* corrected tense grammer in changelog fragment

* corrected capitalization of ZOAU in changelog fragment.
  • Loading branch information
richp405 authored Nov 15, 2023
1 parent 32e6102 commit b100cd9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bugfixes:
- zos_operator - The module was ignoring the wait time argument.
The module now passes the wait time argument to ZOAU.
(https://github.com/ansible-collections/ibm_zos_core/pull/1044).

- zos_operator_action_query - The module was ignoring the wait time argument.
The module now passes the wait time argument to ZOAU.
(https://github.com/ansible-collections/ibm_zos_core/pull/1044).
2 changes: 1 addition & 1 deletion plugins/modules/zos_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def run_operator_command(params):
use_wait_arg = True

if use_wait_arg:
kwargs.update({"wait_arg": True})
kwargs.update({"wait": True})

args = []
rc, stdout, stderr, elapsed = execute_command(cmdtxt, timeout=wait_s, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zos_operator_action_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def run_module():
use_wait_arg = True

if use_wait_arg:
kwargs.update({"wait_arg": False})
kwargs.update({"wait": True})

args = []

Expand Down
31 changes: 25 additions & 6 deletions tests/functional/modules/test_zos_operator_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
import pytest
from pprint import pprint

from ansible_collections.ibm.ibm_zos_core.plugins.module_utils import (
zoau_version_checker
)


__metaclass__ = type


Expand Down Expand Up @@ -103,13 +108,9 @@ def test_zos_operator_positive_verbose_with_full_delay(ansible_zos_module):
def test_zos_operator_positive_verbose_with_quick_delay(ansible_zos_module):
hosts = ansible_zos_module
wait_time_s=10
#startmod = time.time()
results = hosts.all.zos_operator(
cmd="d u,all", verbose=True, wait_time_s=wait_time_s
)
# endmod = time.time()
# timediff = endmod - startmod
# assert timediff < 15

for result in results.contacted.values():
assert result["rc"] == 0
Expand All @@ -119,13 +120,31 @@ def test_zos_operator_positive_verbose_with_quick_delay(ansible_zos_module):
assert result.get('elapsed') <= (2 * wait_time_s)


def test_zos_operator_positive_verbose_blocking(ansible_zos_module):
if zoau_version_checker.is_zoau_version_higher_than("1.2.4.5"):
hosts = ansible_zos_module
wait_time_s=5
results = hosts.all.zos_operator(
cmd="d u,all", verbose=True, wait_time_s=wait_time_s
)

for result in results.contacted.values():
assert result["rc"] == 0
assert result.get("changed") is True
assert result.get("content") is not None
# Account for slower network
assert result.get('elapsed') >= wait_time_s



def test_response_come_back_complete(ansible_zos_module):
hosts = ansible_zos_module
results = hosts.all.zos_operator(cmd="\$dspl")
results = hosts.all.zos_operator(cmd="\\$dspl")
res = dict()
res["stdout"] = []
for result in results.contacted.values():
stdout = result.get('content')
# HASP646 Only appears in the last line that before did not appears
last_line = len(stdout)
assert "HASP646" in stdout[last_line - 1]
assert "HASP646" in stdout[last_line - 1]

0 comments on commit b100cd9

Please sign in to comment.