@@ -142,6 +142,7 @@ def create_multiple_members(ansible_zos_module, pds_name, member_base_name, n):
142
142
# - test_uss_unarchive_list
143
143
# - test_uss_unarchive_copy_to_remote
144
144
# - test_uss_unarchive_encoding
145
+ # - test_uss_unarchive_encoding_skip_encoding
145
146
146
147
# Core functionality tests
147
148
# Test unarchive with no options
@@ -433,6 +434,55 @@ def test_uss_unarchive_encoding(ansible_zos_module, ds_format):
433
434
finally :
434
435
hosts .all .file (path = f"{ USS_TEMP_DIR } " , state = "absent" )
435
436
437
+
438
+ @pytest .mark .uss
439
+ @pytest .mark .parametrize ("ds_format" , USS_FORMATS )
440
+ def test_uss_unarchive_encoding_skip_encoding (ansible_zos_module , ds_format ):
441
+ try :
442
+ hosts = ansible_zos_module
443
+ hosts .all .file (path = f"{ USS_TEMP_DIR } " , state = "absent" )
444
+ hosts .all .file (path = USS_TEMP_DIR , state = "directory" )
445
+ set_uss_test_env (hosts , USS_TEST_FILES )
446
+ dest = f"{ USS_TEMP_DIR } /archive.{ ds_format } "
447
+ hosts .all .zos_archive (
448
+ src = list (USS_TEST_FILES .keys ()),
449
+ dest = dest ,
450
+ format = {
451
+ "name" :ds_format
452
+ }
453
+ )
454
+ # remove files
455
+ for file in USS_TEST_FILES .keys ():
456
+ hosts .all .file (path = file , state = "absent" )
457
+ #specify encoding and skip_encoding file
458
+ first_file_to_skip = [next (iter (USS_TEST_FILES .keys ()))]
459
+ encoding = {
460
+ "from" : TO_ENCODING ,
461
+ "to" : FROM_ENCODING ,
462
+ "skip_encoding" : first_file_to_skip
463
+ }
464
+ #unarchive files
465
+ unarchive_result = hosts .all .zos_unarchive (
466
+ src = dest ,
467
+ format = {
468
+ "name" :ds_format
469
+ },
470
+ remote_src = True ,
471
+ encoding = encoding ,
472
+ )
473
+ hosts .all .shell (cmd = f"ls { USS_TEMP_DIR } " )
474
+
475
+ for result in unarchive_result .contacted .values ():
476
+ assert result .get ("failed" , False ) is False
477
+ assert result .get ("changed" ) is True
478
+ # Command to assert the file is in place
479
+ cmd_result = hosts .all .shell (cmd = f"ls { USS_TEMP_DIR } " )
480
+ for c_result in cmd_result .contacted .values ():
481
+ for file in USS_TEST_FILES .keys ():
482
+ assert file [len (USS_TEMP_DIR )+ 1 :] in c_result .get ("stdout" )
483
+ finally :
484
+ hosts .all .file (path = f"{ USS_TEMP_DIR } " , state = "absent" )
485
+
436
486
######################################################################
437
487
#
438
488
# MVS data sets tests
@@ -450,6 +500,7 @@ def test_uss_unarchive_encoding(ansible_zos_module, ds_format):
450
500
# - test_mvs_unarchive_remote_src
451
501
# - test_mvs_unarchive_encoding
452
502
# - test_mvs_unarchive_multiple_data_set_use_adrdssu_encoding
503
+ # - test_mvs_unarchive_encoding_skip_encoding
453
504
454
505
455
506
@pytest .mark .ds
@@ -1434,6 +1485,136 @@ def test_mvs_unarchive_encoding(
1434
1485
hosts .all .zos_data_set (name = mvs_dest_archive , state = "absent" )
1435
1486
1436
1487
1488
+ @pytest .mark .ds
1489
+ @pytest .mark .parametrize (
1490
+ "ds_format" , [
1491
+ "terse" ,
1492
+ "xmit"
1493
+ ])
1494
+ @pytest .mark .parametrize (
1495
+ "data_set" , [
1496
+ {
1497
+ "dstype" :"seq" ,
1498
+ "members" :["" ]
1499
+ },
1500
+ {
1501
+ "dstype" :"pds" ,
1502
+ "members" :["MEM1" , "MEM2" ]
1503
+ },
1504
+ ]
1505
+ )
1506
+ @pytest .mark .parametrize (
1507
+ "record_length" , [80 ]
1508
+ )
1509
+ @pytest .mark .parametrize (
1510
+ "encoding" , [
1511
+ {"from" : "IBM-1047" , "to" : "ISO8859-1" },
1512
+ ]
1513
+ )
1514
+ def test_mvs_unarchive_encoding_skip_encoding (
1515
+ ansible_zos_module ,
1516
+ ds_format ,
1517
+ data_set ,
1518
+ record_length ,
1519
+ encoding
1520
+ ):
1521
+ try :
1522
+ hosts = ansible_zos_module
1523
+ mvs_dest_archive = get_tmp_ds_name ()
1524
+ dataset = get_tmp_ds_name (3 )
1525
+ hlq = "ANSIBLE"
1526
+ record_format = "fb"
1527
+ # Clean env
1528
+ hosts .all .zos_data_set (name = mvs_dest_archive , state = "absent" )
1529
+ # Create source data set
1530
+ hosts .all .zos_data_set (
1531
+ name = dataset ,
1532
+ type = data_set .get ("dstype" ),
1533
+ state = "present" ,
1534
+ record_length = record_length ,
1535
+ record_format = record_format ,
1536
+ replace = True
1537
+ )
1538
+ # Create members if needed
1539
+ if data_set .get ("dstype" ) in ["pds" , "pdse" ]:
1540
+ for member in data_set .get ("members" ):
1541
+ hosts .all .zos_data_set (
1542
+ name = f"{ dataset } ({ member } )" ,
1543
+ type = "member" ,
1544
+ state = "present" ,
1545
+ replace = True
1546
+ )
1547
+ test_line = "a" * record_length
1548
+ for member in data_set .get ("members" ):
1549
+ if member == "" :
1550
+ ds_to_write = f"{ dataset } "
1551
+ else :
1552
+ ds_to_write = f"{ dataset } ({ member } )"
1553
+ hosts .all .shell (cmd = f"decho '{ test_line } ' \" { ds_to_write } \" " )
1554
+
1555
+ format_dict = {
1556
+ "name" :ds_format
1557
+ }
1558
+ if ds_format == "terse" :
1559
+ format_dict ["format_options" ] = {
1560
+ "terse_pack" :"spack"
1561
+ }
1562
+ archive_result = hosts .all .zos_archive (
1563
+ src = dataset ,
1564
+ dest = mvs_dest_archive ,
1565
+ format = format_dict ,
1566
+ dest_data_set = {
1567
+ "name" :dataset ,
1568
+ "type" :"seq" ,
1569
+ "record_format" :record_format ,
1570
+ "record_length" :record_length
1571
+ },
1572
+ )
1573
+ # assert response is positive
1574
+ for result in archive_result .contacted .values ():
1575
+ assert result .get ("changed" ) is True
1576
+ assert result .get ("dest" ) == mvs_dest_archive
1577
+ assert dataset in result .get ("archived" )
1578
+ cmd_result = hosts .all .shell (cmd = f"""dls "{ hlq } .*" """ )
1579
+ for c_result in cmd_result .contacted .values ():
1580
+ assert mvs_dest_archive in c_result .get ("stdout" )
1581
+
1582
+ hosts .all .zos_data_set (name = dataset , state = "absent" )
1583
+
1584
+ if ds_format == "terse" :
1585
+ del format_dict ["format_options" ]["terse_pack" ]
1586
+
1587
+ #skipping some files to encode
1588
+ skip_encoding_list = [dataset ]
1589
+ current_encoding_config = encoding .copy ()
1590
+ current_encoding_config ["skip_encoding" ] = skip_encoding_list
1591
+
1592
+ # Unarchive action
1593
+ unarchive_result = hosts .all .zos_unarchive (
1594
+ src = mvs_dest_archive ,
1595
+ format = format_dict ,
1596
+ remote_src = True ,
1597
+ dest_data_set = {
1598
+ "name" :dataset ,
1599
+ "type" :data_set .get ("dstype" ),
1600
+ "record_format" :record_format ,
1601
+ "record_length" :record_length
1602
+ },
1603
+ encoding = encoding ,
1604
+ )
1605
+ # assert response is positive
1606
+ for result in unarchive_result .contacted .values ():
1607
+ assert result .get ("changed" ) is True
1608
+ assert result .get ("failed" , False ) is False
1609
+ # assert result.get("dest") == mvs_dest_archive
1610
+ # assert data_set.get("name") in result.get("archived")
1611
+ cmd_result = hosts .all .shell (cmd = f"""dls "{ hlq } .*" """ )
1612
+ for c_result in cmd_result .contacted .values ():
1613
+ assert dataset in c_result .get ("stdout" )
1614
+ finally :
1615
+ hosts .all .zos_data_set (name = dataset , state = "absent" )
1616
+ hosts .all .zos_data_set (name = mvs_dest_archive , state = "absent" )
1617
+
1437
1618
1438
1619
@pytest .mark .ds
1439
1620
@pytest .mark .parametrize (
0 commit comments