Skip to content

Commit

Permalink
finishin clizosjobslistspoolfiles
Browse files Browse the repository at this point in the history
Signed-off-by: ATorrise <[email protected]>
  • Loading branch information
ATorrise committed Aug 22, 2024
1 parent e356ac8 commit 123c7f9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
# TODO - delete the job from spool
# Submit the job and ensure the RC is 0
JOBID="$(zowe jobs submit ds "$1" --rff jobid --rft string)"
CMDRC=$?
Expand All @@ -9,12 +8,13 @@ then
echo "Submit returned a non-zero return code" 1>&2
exit $CMDRC
fi
echo $JOBID

# Echo the JOBID for retrieval in tests
echo "Submitted job ID: $JOBID"

# Loop until the status is output
STATUS=""
while [ "$STATUS" != "OUTPUT" ]; do

# get the status
while [ "$STATUS" != "OUTPUT" ]; do
STATUS="$(zowe zos-jobs view job-status-by-jobid $JOBID --rff status --rft string)"
RC=$?
if [ $RC -gt 0 ]
Expand All @@ -23,7 +23,7 @@ while [ "$STATUS" != "OUTPUT" ]; do
echo "The submit data set command returned a non-zero return code: $RC" 1>&2
exit $RC
fi
done
done

zowe zos-jobs list spool-files-by-jobid $JOBID
exit $?
exit $?
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ PORT=$3
USER=$4
PASS=$5

# TODO - delete the job from spool
# Submit the job and ensure the RC is 0
JOBID="$(zowe jobs submit ds "$JCL" --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string)"
CMDRC=$?
Expand All @@ -16,12 +15,13 @@ then
echo "Submit returned a non-zero return code" 1>&2
exit $CMDRC
fi
echo $JOBID

# Echo the JOBID for retrieval in tests
echo "Submitted job ID: $JOBID"

# Loop until the status is output
STATUS=""
while [ "$STATUS" != "OUTPUT" ]; do

# get the status
while [ "$STATUS" != "OUTPUT" ]; do
STATUS="$(zowe zos-jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string)"
RC=$?
if [ $RC -gt 0 ]
Expand All @@ -30,7 +30,7 @@ while [ "$STATUS" != "OUTPUT" ]; do
echo "The submit data set command returned a non-zero return code: $RC" 1>&2
exit $RC
fi
done
done

zowe zos-jobs list spool-files-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false
exit $?
exit $?
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
*
*/

import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils";
import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-utils";
import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { AbstractSession, TextUtils } from "@zowe/imperative";
import { IJob, GetJobs, SubmitJobs } from "@zowe/zos-jobs-for-zowe-sdk";
import * as fs from "fs";
import { Session, TextUtils } from "@zowe/imperative";
import { IJob, SubmitJobs } from "@zowe/zos-jobs-for-zowe-sdk";
import { TEST_RESOURCES_DIR } from "../../../../../../packages/zosjobs/__tests__/__src__/ZosJobsTestConstants";
import { join } from "path";
import { TEST_RESOURCES_DIR } from "@zowe/zos-jobs-for-zowe-sdk/__tests__/__src__/ZosJobsTestConstants";

// Test Environment populated in the beforeAll();
let TEST_ENVIRONMENT: ITestEnvironment<ITestPropertiesSchema>;
let IEFBR14_JOB: string;
let REAL_SESSION: Session;
let REAL_SESSION: AbstractSession;
let ACCOUNT: string;
let JOB_NAME: string;
let NON_HELD_JOBCLASS: string;
Expand All @@ -31,7 +30,6 @@ const LONG_TIMEOUT = 100000;

const trimMessage = (message: string) => {
// don't use more than one space or tab when checking error details
// this allows us to expect things like "reason: 6" regardless of how prettyjson aligns the text
return message.replace(/( {2,})|\t/g, " ");
};

Expand All @@ -41,12 +39,11 @@ describe("zos-jobs list spool-files-by-jobid command", () => {
TEST_ENVIRONMENT = await TestEnvironment.setUp({
testName: "zos_jobs_list_spool_files_by_jobid_command",
tempProfileTypes: ["zosmf"]
});
}, REAL_SESSION = await TestEnvironment.createSession());

IEFBR14_JOB = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member;
const defaultSystem = TEST_ENVIRONMENT.systemTestProperties;

REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT);

ACCOUNT = defaultSystem.tso.account;
const JOB_LENGTH = 6;
JOB_NAME = REAL_SESSION.ISession.user.substring(0, JOB_LENGTH).toUpperCase() + "SF";
Expand Down Expand Up @@ -82,19 +79,29 @@ describe("zos-jobs list spool-files-by-jobid command", () => {
});

describe("response", () => {
it("should display the ddnames for a job", () => {
it("should display the ddnames for a job", async () => {
const response = runCliScript(__dirname + "/__scripts__/spool-files-by-jobid/submit_and_list_dds.sh",
TEST_ENVIRONMENT, [IEFBR14_JOB]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// TODO: Hopefully these DDs are deterministic on all of our test systems.
// TODO: Once available, we can submit from a local file via command
// TODO: with certain DDs (wanted this test to be entirely script driven
// TODO: to capture a "real world" scenario)
// Extract the JOBID using regex
const jobidRegex = /Submitted job ID: (JOB\d+)/;
const match = response.stdout.toString().match(jobidRegex);
const jobId = match ? match[1] : null;

// Ensure the JOBID was captured correctly
expect(jobId).not.toBeNull();

// Retrieve job details using the Zowe SDK
const job: IJob = await GetJobs.getJob(REAL_SESSION, jobId);

// Validate DDs and output
expect(response.stdout.toString()).toContain("JESMSGLG");
expect(response.stdout.toString()).toContain("JESJCL");
expect(response.stdout.toString()).toContain("JESYSMSG");

TEST_ENVIRONMENT.resources.jobs.push(job);
});

it("should display the the procnames and ddnames for a job", async () => {
Expand All @@ -116,6 +123,8 @@ describe("zos-jobs list spool-files-by-jobid command", () => {
expect(response.stdout.toString()).toContain("SYSTSPRT");
expect(response.stdout.toString()).toContain("TSOSTEP1");
expect(response.stdout.toString()).toContain("TSOSTEP2");

TEST_ENVIRONMENT.resources.jobs.push(job);
}, LONG_TIMEOUT);

describe("without profiles", () => {
Expand All @@ -127,7 +136,7 @@ describe("zos-jobs list spool-files-by-jobid command", () => {
beforeAll(async () => {
TEST_ENVIRONMENT_NO_PROF = await TestEnvironment.setUp({
testName: "zos_jobs_list_spool_files_by_jobid_without_profiles"
});
}, REAL_SESSION = await TestEnvironment.createSession());

SYSTEM_PROPS = TEST_ENVIRONMENT_NO_PROF.systemTestProperties;
});
Expand Down Expand Up @@ -156,9 +165,24 @@ describe("zos-jobs list spool-files-by-jobid command", () => {
]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// Extract the JOBID using regex
const jobidRegex = /Submitted job ID: (JOB\d+)/;
const match = response.stdout.toString().match(jobidRegex);
const jobId = match ? match[1] : null;

// Ensure the JOBID was captured correctly
expect(jobId).not.toBeNull();

// Retrieve job details using the Zowe SDK
const job: IJob = await GetJobs.getJob(REAL_SESSION, jobId);

// Validate DDs and output
expect(response.stdout.toString()).toContain("JESMSGLG");
expect(response.stdout.toString()).toContain("JESJCL");
expect(response.stdout.toString()).toContain("JESYSMSG");

TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(job);
}, LONG_TIMEOUT);
});
});
Expand Down

0 comments on commit 123c7f9

Please sign in to comment.