Skip to content

Commit ccba751

Browse files
committed
Removed some excess content from previous iteration.
Signed-off-by: Ali <[email protected]>
1 parent 376740a commit ccba751

File tree

2 files changed

+93
-192
lines changed

2 files changed

+93
-192
lines changed

COBOL Programming Course #4 - Testing/COBOL Programming Course #4 - Testing.md

Lines changed: 93 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ The typical automated check follows these steps:
291291
You can take a look at the COBOL Check wiki page for better understanding: https://github.com/openmainframeproject/cobol-check/wiki/A-Brief-Example
292292

293293

294+
//
295+
294296
## Lab
295297

296298
In this lab exercise, you will learn to set up and automate the COBOL Check environment using GitHub Actions. You'll create a GitHub repository that connects to an IBM Z system, accesses USS (Unix System Services), and automates the process of running COBOL Check on sample programs.
@@ -328,8 +330,6 @@ Note: While many steps are automated, you'll still interact directly with the ma
328330

329331
By the end of this lab, you'll have practical experience in setting up an automated testing environment for COBOL programs, bridging the gap between mainframe development and modern DevOps practices.
330332

331-
//
332-
333333
### Set up a GitHub repository with necessary workflows and scripts
334334
1. **Create a new GitHub repository**
335335
- Log into your GitHub account
@@ -438,227 +438,128 @@ By the end of this lab, you'll have practical experience in setting up an automa
438438
439439
```
440440
#!/bin/bash
441-
# mainframe_operations.sh
442-
443-
# Set up environment
444-
export PATH=$PATH:/usr/lpp/java/J8.0_64/bin
445-
export JAVA_HOME=/usr/lpp/java/J8.0_64
446-
export PATH=$PATH:/usr/lpp/zowe/cli/node/bin
447-
448-
# Check Java availability
449-
java -version
450-
451-
# Change to the appropriate directory
452-
cd /z/$ZOWE_USERNAME/cobolcheck
453-
ls -al
454-
chmod +x cobolcheck
455-
ls -al
456-
cd scripts
457-
ls -al
458-
chmod +x linux_gnucobol_run_tests
459-
cd ..
460-
pwd
461-
462-
# Run COBOL check on NUMBERS
463-
./cobolcheck -p NUMBERS
464-
465-
# Copy NUMBERS files to datasets
466-
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(NUMBERS)'"
467-
cp NUMBERS.JCL "//'${ZOWE_USERNAME}.JCL(NUMBERS)'"
468-
469-
# Run COBOL check on EMPPAY
470-
./cobolcheck -p EMPPAY
471-
472-
# Copy EMPPAY files to datasets
473-
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(EMPPAY)'"
474-
cp EMPPAY.JCL "//'${ZOWE_USERNAME}.JCL(EMPPAY)'"
475-
476-
# Run COBOL check on DEPTPAY
477-
./cobolcheck -p DEPTPAY
478-
479-
# Copy DEPTPAY files to datasets
480-
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(DEPTPAY)'"
481-
cp DEPTPAY.JCL "//'${ZOWE_USERNAME}.JCL(DEPTPAY)'"
482-
483-
echo "Mainframe operations completed"
441+
# mainframe_operations.sh
442+
443+
# Set up environment
444+
export PATH=$PATH:/usr/lpp/java/J8.0_64/bin
445+
export JAVA_HOME=/usr/lpp/java/J8.0_64
446+
export PATH=$PATH:/usr/lpp/zowe/cli/node/bin
447+
448+
# Check Java availability
449+
java -version
450+
451+
# Change to the appropriate directory
452+
cd /z/$ZOWE_USERNAME/cobolcheck || { echo "Directory not found"; exit 1; }
453+
ls -al
454+
455+
# Check if cobolcheck exists and make it executable
456+
if [ -f cobolcheck ]; then
457+
chmod +x cobolcheck
458+
ls -al
459+
else
460+
echo "cobolcheck file not found"
461+
exit 1
462+
fi
463+
464+
# Check and make linux_gnucobol_run_tests executable
465+
if [ -d scripts ] && [ -f scripts/linux_gnucobol_run_tests ]; then
466+
cd scripts
467+
chmod +x linux_gnucobol_run_tests
468+
cd ..
469+
else
470+
echo "scripts directory or linux_gnucobol_run_tests not found"
471+
exit 1
472+
fi
473+
474+
pwd
475+
476+
# Function to run COBOL check and copy files
477+
run_cobol_check() {
478+
local program=$1
479+
if [ -f "${program}.CBL" ] && [ -f "${program}.JCL" ]; then
480+
./cobolcheck -p "$program"
481+
if [ -f CC##99.CBL ]; then
482+
cp CC##99.CBL "//'${ZOWE_USERNAME}.CBL(${program})'"
483+
cp "${program}.JCL" "//'${ZOWE_USERNAME}.JCL(${program})'"
484+
echo "${program} processed successfully"
485+
else
486+
echo "CC##99.CBL not generated for ${program}"
487+
fi
488+
else
489+
echo "${program}.CBL or ${program}.JCL not found"
490+
fi
491+
}
492+
493+
# Run COBOL check on NUMBERS, EMPPAY, and DEPTPAY
494+
for program in NUMBERS EMPPAY DEPTPAY; do
495+
run_cobol_check "$program"
496+
done
497+
498+
echo "Mainframe operations completed"
484499
485500
```
486501
- Ensure both scripts have Unix-style line endings (LF, not CRLF)
487502
488503
7. **Add COBOL Check files**
489-
- Download the latest COBOL Check distribution from the official repository
490-
- Extract the contents into your `cobol-check` directory
491-
492-
8. **Commit and push your changes**
493-
- Stage your new files: `git add .`
494-
- Commit the changes: `git commit -m \"Initial setup for COBOL Check automation\"`
495-
- Push to GitHub: `git push origin main`
496-
497-
9. **Verify workflow**
498-
- Go to the \"Actions\" tab in your GitHub repository
499-
- You should see the workflow running (triggered by your push)
500-
- Wait for it to complete and check the logs for any errors
501-
502-
503-
By following these steps, you'll have set up a GitHub repository with the necessary workflow and scripts to automate COBOL Check operations. This setup forms the foundation for the rest of the lab exercises, where you'll use this automation to interact with the mainframe and run COBOL Check on your programs."
504-
505-
//
506-
507-
1. Get the latest COBOL Check distribution from the GitHub repository of the COBOL Check https://github.com/openmainframeproject/cobol-check/tree/Developer/build/distributions.
508-
Click on the “View raw” button or the download button on the right most corner. You will get the .zip of COBOL Check.
509-
510-
![](Images/image209.png)
511-
512-
*Figure 1. Download COBOL Check distribution*
513-
514-
![](Images/image210.png)
515-
516-
*Figure 2. Button to download the .zip file*
517-
518-
2. Check your download location to view the .zip file and then extract it.
519-
520-
![](Images/image211.png)
521-
522-
*Figure 3. COBOL Check folder*
523-
524-
3. Open your VS Code with the same team configuration file with the Learn Cobol folder which you have used in course 2. If not, you can also download it from https://github.com/openmainframeproject/cobol-programming-course/releases/latest
525-
526-
4. click on the icon of Zowe Explore of VS Code.
527-
528-
![](Images/image212.png)
529-
530-
*Figure 4. Zowe Explorer*
531-
532-
In the DATA SETS section, you can view all the PDS (Partitioned datasets) and sequential files present. In the USS (Unix System Services) section, you can view the files or folder that is stored in the USS. USS is a posix compliant linux like environment which makes it easy for developers to interact with previous knowledge of using linux terminals and commands. In the JOBS section, you can view all about the running or completed jobs.
533-
534-
535-
5. Put your username and password in all the three sections by clicking on the search icon to view the files (DATA SETS, USS, JOBS) which you have learned in the previous chapters.
536-
537-
![](Images/image213.png)
504+
* Get the latest COBOL Check distribution from the GitHub repository of the COBOL Check https://github.com/openmainframeproject/cobol-check/tree/Developer/build/distributions. Click on the “View raw” button or the download button on the right most corner. You will get the .zip of COBOL Check.
538505
539-
*Figure 5. Enter your username*
506+
![](Images/image209.png)
540507
541-
![](Images/image214.png)
508+
*Figure 1. Download COBOL Check distribution*
542509
543-
*Figure 6. Enter your password*
510+
![](Images/image210.png)
544511
545-
6. After entering your username and password for the USS section search for `/z/z999XX` . put your username in place of z999XX. Now you can view all the files that are present in the USS.
512+
*Figure 2. Button to download the .zip file*
546513
547-
![](Images/image215.png)
514+
* Check your download location to view the .zip file and then extract it to the root of your local repository.
548515
549-
*Figure 7. Search for /z/z999XX*
516+
![](Images/image211.png)
550517
551-
7. Another way of interacting with the USS is through the SSH connection. Open your terminal in the vs code window. Issue the command `ssh [email protected]` , in the place of z99998 use your own username. You can find the ip address in the zowe.config file that comes with the team configuration folder.
552-
553-
![](Images/image216.png)
554-
555-
*Figure 8. ssh connection*
556-
557-
8. Enter your password to view the directories in the USS. Issue your first command `pwd` which will show the directory you are currently in, that is your root directory. Issue the command `ls` to list all the files and folders in this directory.
558-
559-
![](Images/image217.png)
560-
561-
*Figure 9. present working directory*
562-
563-
9. You need to create a directory for COBOL Check and copy the contents of the COBOL Check distribution that you have downloaded earlier. Issue the command `mkdir cobolcheck` - This will create an empty directory. Then use `ls` command to view the created directory.
564-
565-
![](Images/image218.png)
566-
567-
*Figure 10. Create COBOL Check directory in the USS*
568-
569-
10. Issue `cd cobolcheck` to enter into the directory.
570-
571-
![](Images/image219.png)
572-
573-
*Figure 11. Enter into COBOL Check directory in the USS*
574-
575-
Note: If you left your terminal idle for some time, you need to kill that terminal, again you have to ssh into the mainframe. you can follow from step 8 again.
576-
577-
11. Open another terminal tab and go to the file location where the files and folders of COBOL Check are present. Then use `ls` to see those.
578-
579-
![](Images/image220.png)
580-
581-
*Figure 12. COBOL Check directory on the local system*
582-
583-
12. To copy all the files and folders from this directory, you need to use the command : `zowe zos-files upload dir-to-uss "." "/z/z99998/cobolcheck" --recursive --binary-files "cobol-check-0.2.8.jar"` . Then enter your username and password. (Remember to type all the alphabets in small letters).
584-
585-
586-
`Note: Use the latest version (or the version you are using) of the COBOL Check on the above command.`
518+
*Figure 3. COBOL Check folder*
587519
520+
* Open your VS Code with the same team configuration file with the Learn Cobol folder which you have used in course 2. If not, you can also download it from https://github.com/openmainframeproject/cobol-programming-course/releases/latest
588521
589-
In this command the `.` represents the current directory
590-
and the flag `--recursive` is used for copying all the folders which are even inside other folders.
591-
By default, this command will copy all the files in ascii mode,
592-
but you need to copy `the cobol-check-0.2.8.jar` in binary mode that's why the flag `--binary-files` is used.
593-
You can look into your `/bin` folder of COBOL Check to see the latest version and name which need to use there.
594-
At the time of writing this course material, it is version 0.2.8.
595-
596-
To know more about copying the files from local machine to USS, you can refer to zowe cli docs: https://docs.zowe.org/v2.4.x/web_help/index.html?p=zowe_zos-files_upload_dir-to-uss.
597-
598-
![](Images/image221.png)
599-
600-
*Figure 13. Command to copy the files from local machine to USS*
601-
602-
After entering the command, you will get a message uploaded successfully.
603-
604-
![](Images/image222.png)
522+
* click on the icon of Zowe Explore of VS Code.
605523
606-
*Figure 14. Successfully uploaded message*
524+
![](Images/image212.png)
607525
608-
13. Now again open your terminal and ssh into the mainframe to view the files and folders in the COBOL Check directory. You can see the contents of uploaded.
526+
*Figure 4. Zowe Explorer*
609527
610-
![](Images/image223.png)
528+
In the DATA SETS section, you can view all the PDS (Partitioned datasets) and sequential files present. In the USS (Unix System Services) section, you can view the files or folder that is stored in the USS. USS is a posix compliant linux like environment which makes it easy for developers to interact with previous knowledge of using linux terminals and commands. In the JOBS section, you can view all about the running or completed jobs.
611529
612-
*Figure 15. View the contents in the directory*
613530
614-
14. you can use the USS tab of your vs code to view the COBOL Check directory.
531+
* Put your username and password in all the three sections by clicking on the search icon to view the files (DATA SETS, USS, JOBS) which you have learned in the previous chapters.
615532
616-
![](Images/image224.png)
533+
![](Images/image213.png)
617534
618-
*Figure 16. Locate the directories on the USS section in the zowe*
535+
*Figure 5. Enter your username*
619536
620-
15. Issue `ls -al` command to see the file permission of COBOL Check then issue `chmod +x cobolcheck`. This will give COBOL Check file the executable permission.
537+
![](Images/image214.png)
621538
622-
![](Images/image225.png)
623-
624-
*Figure 17. Providing executable permission*
625-
626-
16. Do the same as done above in the `/scripts` folder. Issue command : `cd scripts` to enter into scripts directory then use `chmod +x linux_gnucobol_run_tests` to make this file executable.
627-
628-
![](Images/image226.png)
629-
630-
*Figure 18. Providing executable permission*
631-
632-
Then issue command `cd ..` to come back to the parent directory.
633-
634-
17. View the COBOL source code and the test case files. You can also use the USS tab.
635-
636-
![](Images/image227.png)
637-
638-
*Figure 19. view files in the USS tab*
639-
640-
18. You can see it comes with some source code and test files. You need to run COBOL Check using the NUMBERS.CBL to check whether COBOL Check is working correctly.
641-
Issue the command `./cobolcheck -p NUMBERS`.
642-
643-
`Note: You may see the NullPointerException, but that can be ignored.`
644-
645-
![](Images/image228.png)
539+
*Figure 6. Enter your password*
540+
541+
* After entering your username and password for the USS section search for `/z/z999XX` . put your username in place of z999XX. Now you can view all the files that are present in the USS.
646542
647-
*Figure 20. Run a COBOL program with the cobolcheck command*
543+
![](Images/image215.png)
648544
649-
19. After running the command, the COBOL Check will generate a new source code named `CC##99.CBL` which includes the COBOL source code along with the test cases embedded.
545+
*Figure 7. Search for /z/z999XX*
650546
651-
![](Images/image229.png)
547+
8. **Commit and push your changes**
548+
- Stage your new files: `git add .`
549+
- Commit the changes: `git commit -m \"Initial setup for COBOL Check automation\"`
550+
- Push to GitHub: `git push origin main`
652551
653-
*Figure 21. Output: A new COBOL program with the test cases embedded as statements*
552+
9. **Verify workflow**
553+
- Go to the \"Actions\" tab in your GitHub repository
554+
- You should see the workflow running (triggered by your push)
555+
- Wait for it to complete and check the logs for any errors
654556
655-
20. You need to copy this file to the MVS data sets (Z99998.CBL) which you can view in your DATA SETS tab. Use the command `cp CC##99.CBL "//'Z99998.CBL(NUMBERS)'"`
656557
657-
![](Images/image230.png)
558+
By following these steps, you'll have set up a GitHub repository with the necessary workflow and scripts to automate COBOL Check operations. This setup forms the foundation for the rest of the lab exercises, where you'll use this automation to interact with the mainframe and run COBOL Check on your programs."
658559
659-
*Figure 22. Copy the newly generate COBOL program to the mainframe*
560+
//
660561
661-
21. view the files in the DATA SETS tab, you can see NUMBERS in Z99998.CBL.
562+
1. view the files in the DATA SETS tab, you can see NUMBERS in Z99998.CBL.
662563
663564
![](Images/image231.png)
664565
-23.4 KB
Loading

0 commit comments

Comments
 (0)