|
13 | 13 |
|
14 | 14 | from __future__ import absolute_import, division, print_function
|
15 | 15 |
|
16 |
| -from ibm_zos_core.tests.helpers.users import ManagedUserType, ManagedUser |
17 | 16 | import pytest
|
18 | 17 | import os
|
19 | 18 | import shutil
|
@@ -2089,113 +2088,6 @@ def test_copy_dest_lock(ansible_zos_module, ds_type, f_lock ):
|
2089 | 2088 | hosts.all.zos_data_set(name=data_set_2, state="absent")
|
2090 | 2089 |
|
2091 | 2090 |
|
2092 |
| -def test_copy_dest_lock_test_with_no_opercmd_access_pds_without_force_lock(ansible_zos_module, z_python_interpreter): |
2093 |
| - """ |
2094 |
| - This tests the module exeception raised 'msg="Unable to determine if the source {0} is in use.".format(dataset_name)'. |
2095 |
| - This this a wrapper for the actual test case `managed_user_copy_dest_lock_test_with_no_opercmd_access`. |
2096 |
| - """ |
2097 |
| - managed_user = None |
2098 |
| - managed_user_test_case_name = "managed_user_copy_dest_lock_test_with_no_opercmd_access" |
2099 |
| - try: |
2100 |
| - # Initialize the Managed user API from the pytest fixture. |
2101 |
| - managed_user = ManagedUser.from_fixture(ansible_zos_module, z_python_interpreter) |
2102 |
| - |
2103 |
| - # Important: Execute the test case with the managed users execution utility. |
2104 |
| - managed_user.execute_managed_user_test( |
2105 |
| - managed_user_test_case = managed_user_test_case_name,debug = True, |
2106 |
| - verbose = False, managed_user_type=ManagedUserType.ZOAU_LIMITED_ACCESS_OPERCMD) |
2107 |
| - |
2108 |
| - finally: |
2109 |
| - # Delete the managed user on the remote host to avoid proliferation of users. |
2110 |
| - managed_user.delete_managed_user() |
2111 |
| - |
2112 |
| -@pytest.mark.parametrize("ds_type, f_lock",[ |
2113 |
| - ( "pds", False), # Module exception raised msg="Unable to determine if the source {0} is in use.".format(dataset_name) |
2114 |
| - ( "pdse", False), # Module exception raised msg="Unable to determine if the source {0} is in use.".format(dataset_name) |
2115 |
| - ( "seq", False), # Module exception raised msg="Unable to determine if the source {0} is in use.".format(dataset_name) |
2116 |
| - ( "seq", True), # Opercmd is not called so a user with limited UACC will not matter and will succeed |
2117 |
| -]) |
2118 |
| -def managed_user_copy_dest_lock_test_with_no_opercmd_access(ansible_zos_module, ds_type, f_lock ): |
2119 |
| - """ |
2120 |
| - When force_lock option is false, it exercises the opercmd call which requires RACF universal access. |
2121 |
| - This negative test will ensure that if the user does not have RACF universal access that the module |
2122 |
| - not halt execution and instead bubble up the ZOAU exception. |
2123 |
| - """ |
2124 |
| - hosts = ansible_zos_module |
2125 |
| - |
2126 |
| - data_set_1 = get_tmp_ds_name() |
2127 |
| - data_set_2 = get_tmp_ds_name() |
2128 |
| - member_1 = "MEM1" |
2129 |
| - |
2130 |
| - if ds_type == "pds" or ds_type == "pdse": |
2131 |
| - src_data_set = data_set_1 + "({0})".format(member_1) |
2132 |
| - dest_data_set = data_set_2 + "({0})".format(member_1) |
2133 |
| - else: |
2134 |
| - src_data_set = data_set_1 |
2135 |
| - dest_data_set = data_set_2 |
2136 |
| - try: |
2137 |
| - hosts.all.zos_data_set(name=data_set_1, state="present", type=ds_type, replace=True) |
2138 |
| - hosts.all.zos_data_set(name=data_set_2, state="present", type=ds_type, replace=True) |
2139 |
| - if ds_type == "pds" or ds_type == "pdse": |
2140 |
| - hosts.all.zos_data_set(name=src_data_set, state="present", type="member", replace=True) |
2141 |
| - hosts.all.zos_data_set(name=dest_data_set, state="present", type="member", replace=True) |
2142 |
| - # copy text_in source |
2143 |
| - hosts.all.shell(cmd="decho \"{0}\" \"{1}\"".format(DUMMY_DATA, src_data_set)) |
2144 |
| - # copy/compile c program and copy jcl to hold data set lock for n seconds in background(&) |
2145 |
| - temp_dir = get_random_file_name(dir=TMP_DIRECTORY) |
2146 |
| - hosts.all.zos_copy(content=c_pgm, dest=f'{temp_dir}/pdse-lock.c', force=True) |
2147 |
| - hosts.all.zos_copy( |
2148 |
| - content=call_c_jcl.format(temp_dir, dest_data_set), |
2149 |
| - dest=f'{temp_dir}/call_c_pgm.jcl', |
2150 |
| - force=True |
2151 |
| - ) |
2152 |
| - hosts.all.shell(cmd="xlc -o pdse-lock pdse-lock.c", chdir=f"{temp_dir}/") |
2153 |
| - # submit jcl |
2154 |
| - hosts.all.shell(cmd="submit call_c_pgm.jcl", chdir=f"{temp_dir}/") |
2155 |
| - # pause to ensure c code acquires lock |
2156 |
| - time.sleep(10) |
2157 |
| - results = hosts.all.zos_copy( |
2158 |
| - src = src_data_set, |
2159 |
| - dest = dest_data_set, |
2160 |
| - remote_src = True, |
2161 |
| - force=True, |
2162 |
| - force_lock=f_lock, |
2163 |
| - ) |
2164 |
| - for result in results.contacted.values(): |
2165 |
| - if f_lock: |
2166 |
| - assert result.get("changed") == True |
2167 |
| - assert result.get("msg") is None |
2168 |
| - # verify that the content is the same |
2169 |
| - verify_copy = hosts.all.shell( |
2170 |
| - cmd="dcat \"{0}\"".format(dest_data_set), |
2171 |
| - executable=SHELL_EXECUTABLE, |
2172 |
| - ) |
2173 |
| - for vp_result in verify_copy.contacted.values(): |
2174 |
| - verify_copy_2 = hosts.all.shell( |
2175 |
| - cmd="dcat \"{0}\"".format(src_data_set), |
2176 |
| - executable=SHELL_EXECUTABLE, |
2177 |
| - ) |
2178 |
| - for vp_result_2 in verify_copy_2.contacted.values(): |
2179 |
| - assert vp_result_2.get("stdout") == vp_result.get("stdout") |
2180 |
| - elif not f_lock: |
2181 |
| - assert result.get("failed") is True |
2182 |
| - assert result.get("changed") == False |
2183 |
| - assert "Unable to determine if the dest" in result.get("msg") |
2184 |
| - assert "BGYSC0819E Insufficient security authorization for resource MVS.MCSOPER.ZOAU in class OPERCMDS" in result.get("stderr") |
2185 |
| - assert result.get("rc") == 6 |
2186 |
| - finally: |
2187 |
| - # extract pid |
2188 |
| - ps_list_res = hosts.all.shell(cmd="ps -e | grep -i 'pdse-lock'") |
2189 |
| - # kill process - release lock - this also seems to end the job |
2190 |
| - pid = list(ps_list_res.contacted.values())[0].get('stdout').strip().split(' ')[0] |
2191 |
| - hosts.all.shell(cmd="kill 9 {0}".format(pid.strip())) |
2192 |
| - # clean up c code/object/executable files, jcl |
2193 |
| - hosts.all.shell(cmd=f'rm -r {temp_dir}') |
2194 |
| - # remove pdse |
2195 |
| - hosts.all.zos_data_set(name=data_set_1, state="absent") |
2196 |
| - hosts.all.zos_data_set(name=data_set_2, state="absent") |
2197 |
| - |
2198 |
| - |
2199 | 2091 | @pytest.mark.uss
|
2200 | 2092 | @pytest.mark.seq
|
2201 | 2093 | def test_copy_file_record_length_to_sequential_data_set(ansible_zos_module):
|
|
0 commit comments