Skip to content

Commit 20e744d

Browse files
[Enabler][zos_blockinfile]Add_documentation_of_false_negatives_and_ensure_proper_testing (#2025)
* Add validation to avoid false negatives * Add fragment * Fix comment
1 parent 6abede4 commit 20e744d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trivial:
2+
- zos_blockinfile - Updated documentation on zos_blockinfile to notify about false positive
3+
and add test cases to avoid extra cases of false positives.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/2025).

plugins/modules/zos_blockinfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@
202202
the block will be overwritten on each iteration.
203203
- When more then one block should be handled in a file you must change
204204
the I(marker) per task.
205+
- When working with a backup of a sequential dataset, the backup name should also be a sequential dataset.
206+
This will avoid the false positive and error condition during backup.
205207
seealso:
206208
- module: zos_data_set
207209
'''

tests/functional/modules/test_zos_blockinfile_func.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,14 +1330,13 @@ def test_ds_block_insert_with_indentation_level_specified(ansible_zos_module, ds
13301330
def test_ds_block_insertafter_eof_with_backup(ansible_zos_module, dstype, backup_name):
13311331
hosts = ansible_zos_module
13321332
ds_type = dstype
1333-
backup_ds_name = ""
13341333
params = {
13351334
"block":"export ZOAU_ROOT\nexport ZOAU_HOME\nexport ZOAU_DIR",
13361335
"state":"present",
13371336
"backup":True
13381337
}
13391338
if backup_name:
1340-
if backup_ds_name == "SEQ":
1339+
if backup_name == "SEQ":
13411340
params["backup_name"] = get_tmp_ds_name()
13421341
else:
13431342
params["backup_name"] = get_tmp_ds_name() + "(MEM)"
@@ -1355,6 +1354,14 @@ def test_ds_block_insertafter_eof_with_backup(ansible_zos_module, dstype, backup
13551354
results = hosts.all.shell(cmd="cat \"//'{0}'\" ".format(params["path"]))
13561355
for result in results.contacted.values():
13571356
assert result.get("stdout") == EXPECTED_INSERTAFTER_EOF
1357+
backup_ds_name = backup_ds_name.replace('$','\$')
1358+
bk_results = hosts.all.shell(cmd="cat \"//'{0}'\" ".format(backup_ds_name))
1359+
if backup_name == "MEM" and dstype == "seq":
1360+
for result in bk_results.contacted.values():
1361+
assert result.get("stdout") == ""
1362+
else:
1363+
for result in bk_results.contacted.values():
1364+
assert result.get("stdout") == TEST_CONTENT
13581365
finally:
13591366
remove_ds_environment(ansible_zos_module, ds_name)
13601367
if backup_ds_name != "":

0 commit comments

Comments
 (0)