Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download record range flag #2411

Merged
merged 23 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- Enhancement: Added `--recordRange` flag to `zowe jobs download output` command to allow users to select a specific range of records to output from a spool file. [#2411](https://github.com/zowe/zowe-cli/pull/2411)
- BugFix: The `zowe zos-files copy data-set` command overwrites the contents of the target data set without user confirmation. A `--safe-replace` option was added which prompts the user to confirm before overwriting the contents of the target data set. [#2369] (https://github.com/zowe/zowe-cli/issues/2369)

## `8.12.0`
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Object {
"description": "Download all the output of the job with job ID JOB00234 to an automatically generated directory.",
"options": "JOB00234",
},
Object {
"description": "Download the records in the range of 0 to 100 from a job spool.",
"options": "--record-range '0-100'",
},
],
"name": "output",
"options": Array [
Expand Down Expand Up @@ -92,6 +96,15 @@ Object {
"name": "wait-for-output",
"type": "boolean",
},
Object {
"aliases": Array [
"rr",
],
"description": "Zero indexed range of records to download from a spool file. (example: 0-100)",
"name": "record-range",
"optional": true,
"type": "string",
},
],
"positionals": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,22 @@ export const OutputDefinition: ICommandDefinition = {
type: "boolean",
conflictsWith: ["wait-for-active"]
},
{
name: "record-range",
aliases: ["rr"],
description: "Zero indexed range of records to download from a spool file. (example: 0-100)",
type: "string",
optional: true
}
] as ICommandOptionDefinition[]),
examples: [
{
description: "Download all the output of the job with job ID JOB00234 to an automatically generated directory.",
options: "JOB00234"
},
{
description: "Download the records in the range of 0 to 100 from a job spool.",
options: "--record-range '0-100'"
}
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default class OutputHandler extends ZosmfBaseHandler {
const encoding: string = this.mArguments.encoding;
const waitForActive: boolean = this.mArguments.waitForActive;
const waitForOutput: boolean = this.mArguments.waitForOutput;
const recordRange: string = this.mArguments.recordRange;

// Get the job details
const job: IJob = await GetJobs.getJob(this.mSession, jobid);
const options: IDownloadAllSpoolContentParms = {
Expand All @@ -49,7 +51,8 @@ export default class OutputHandler extends ZosmfBaseHandler {
record,
encoding,
waitForActive,
waitForOutput
waitForOutput,
recordRange
};
// Download 'em all
await DownloadJobs.downloadAllSpoolContentCommon(this.mSession, options);
Expand Down
4 changes: 4 additions & 0 deletions packages/zosjobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe z/OS jobs SDK package will be documented in this file.

## Recent Changes

- Enhancement: Added `--recordRange` flag logic handling to `DownloadJobs.downloadSpoolContentCommon()` to to allow users to select a specific range of records to output from a spool file. [#2411](https://github.com/zowe/zowe-cli/pull/2411)

## `8.10.2`

- BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding (GetJobs.ts). [#2392] (https://github.com/zowe/zowe-cli/pull/2392).
Expand Down
261 changes: 260 additions & 1 deletion packages/zosjobs/__tests__/__system__/DownloadJobs.system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe("Download Jobs - System tests", () => {
const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {
jcl: iefbr14JCL
});

testEnvironment.resources.jobs.push(job);
jobid = job.jobid;
jobname = job.jobname;
Expand Down Expand Up @@ -289,8 +290,89 @@ describe("Download Jobs - System tests", () => {
}
}
}, LONG_TIMEOUT);
});

it("should be able to download all DDs from job output with a record range (0-5)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0-5"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).not.toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(6);
});

it("should be able to download all DDs from job output with a record range (2-8)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "2-8"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).not.toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).not.toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(7);
});

it("should be able to download all DDs from job output with a record range (0-100)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0-100"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString()).toContain("MINUTES EXECUTION TIME");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(16); //only 16 records in spool file
});
});

describe("Negative tests", () => {
let badJobFile: IJobFile;
Expand Down Expand Up @@ -345,6 +427,101 @@ describe("Download Jobs - System tests", () => {
expect(JSON.parse(err.causeErrors).message).toContain("does not contain spool file");
});

it("should be able to download all DDs from job output with a record range (0-0)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}
let err;
let expectedFile;
try{
await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0-0"
});
expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
}
catch(e){
err = e;
}

expect(err).toBeDefined();
expect(err.message).toEqual('Invalid record range specified: 0-0. Ensure the format is x-y with x < y.');
expect(expectedFile).toBeUndefined();
});

it("should be able to download all DDs from job output with a record range (2-1)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}
let err;
let expectedFile;
try{
await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "2-1"
});
expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
}
catch(e){
err = e;
}

expect(err).toBeDefined();
expect(err.message).toEqual('Invalid record range specified: 2-1. Ensure the format is x-y with x < y.');
expect(expectedFile).toBeUndefined();
});

it("should be able to download all DDs from job output with a record range (0 50)", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}
let err;
let expectedFile;
try{
await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0 50"
});
expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
}
catch(e){
err = e;
}

expect(err).toBeDefined();
expect(err.message).toEqual('Invalid record range format: 0 50. Expected format is x-y.');
expect(expectedFile).toBeUndefined();
});
});
});

Expand Down Expand Up @@ -531,5 +708,87 @@ describe("Download Jobs - System tests - Encoded", () => {
}
}
}, LONG_TIMEOUT);

it("should be able to download all DDs from job output with a record range (0-5) - encoded", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0-5"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).not.toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(6);
});

it("should be able to download all DDs from job output with a record range (2-8) - encoded", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "2-8"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).not.toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).not.toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(7);
});

it("should be able to download all DDs from job output with a record range (0-100) - encoded", async () => {
for (const file of jobFiles) {
if (file.ddname === "JESMSGLG") {
jesJCLJobFile = file;
}
}

await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, {
outDir: outputDirectory,
jobid,
jobname,
recordRange: "0-100"
});
const expectedFile = DownloadJobs.getSpoolDownloadFilePath(
{
jobFile: jesJCLJobFile,
omitJobidDirectory: false,
outDir: outputDirectory
}
);
expect(IO.existsSync(expectedFile)).toEqual(true);
expect(IO.readFileSync(expectedFile).toString()).toBeDefined();
expect(IO.readFileSync(expectedFile).toString()).toContain("J E S 2 J O B L O G");
expect(IO.readFileSync(expectedFile).toString()).toContain("0------ JES2 JOB STATISTICS ------");
expect(IO.readFileSync(expectedFile).toString()).toContain("MINUTES EXECUTION TIME");
expect(IO.readFileSync(expectedFile).toString().trim().split('\n').length).toEqual(16); //only 16 records in spool file
});
});
});
Loading