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

Simplify the preparation for JCL testing #151

Merged
merged 4 commits into from
Feb 5, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to the z/OS FTP Plug-in for Zowe CLI will be documented in this file.


## Recent Changes

- Simplify the preparation for JCL system tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this requires a new patch to be published.
However we can combine the contents of this PR (after merged) with:



## `2.1.7`

- Update the version of zos-node-accessor to 1.0.16
Expand Down
21 changes: 6 additions & 15 deletions __tests__/__resources__/properties/default_properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# my-writable-pds - this is a PDS on the system that we can write new #
# members too. member names are randomized, so it's #
# possible for existing members to be overwritten #
# ds-iefbr14-pds - PDS qualified by an IEFBR14 member JCL to submit #
# ds-sleep-pds - PDS qualified by an SLEEP member JCL to submit
# ds-iefbr14-ps - PS with an IEFBR14 JCL to submit #
# ftp-host - The host name for the LPAR with FTP #
# ftp-port - The FTP port #
# uss-dir - directory which we can upload files to and then #
Expand Down Expand Up @@ -40,24 +37,18 @@ datasets:
# if this fails an error should be thrown and you may have to
# re-create this data set
renamablePDS: my-renamable-pds
# a Loadlib dataset name
dsnLoadLib: my-loadlib-dsn
# a Loadlib dataset name. It's supposed SYS1.NUCLEUS exists on every z/OS.
dsnLoadLib: SYS1.NUCLEUS
# data set name prefix like "HLQ.ZFTPTEST"
# all datasets generated by system test have this prefix in DSN
dsnPrefix: my-dsn-prefix
#-----------------------------------------------------------------------------#
# Set of properties for testing jobs #
#-----------------------------------------------------------------------------#
jobs:
# a PDS member containing IEFBR14 JCL that your user ID can submit
iefbr14Member: ds-iefbr14-pds
# a PDS member containing SLEEP JCL that your user ID can submit
sleepMember: ds-sleep-pds
#-----------------------------------------------------------------------------#
# Set of properties for testing USS functionality #
#-----------------------------------------------------------------------------#
uss:
# directory to try to list, upload, download, delete files from
# directory to try to list, upload, download, delete files from.
# Run "mkdir uss-dir" from the home directory on z/OS USS.
ussTestDirectory: uss-dir
# symbolic link of ussTestDirectory, created with "ln -s <ussTestDirectory> <ussTestDirectoryLink>"
# symbolic link of ussTestDirectory.
# Run "ln -s uss-dir uss-dir-link" from the home directory on z/OS USS.
ussTestDirectoryLink: uss-dir-link
26 changes: 26 additions & 0 deletions __tests__/__system__/cli/PrepareTestJclDatasets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

import { DataSetUtils } from "../../../src/api/DataSetUtils";
import { TRANSFER_TYPE_ASCII } from "../../../src/api/CoreUtils";

export async function prepareTestJclDataSet(connection: any, pds: string, jclName: string): Promise<string> {
const datasetName = `${pds}(${jclName})`;
const filteredMembers = await DataSetUtils.listMembers(connection, pds);
if (filteredMembers.find(member => member === jclName) === undefined) {
const options = {
localFile: `${__dirname}/../../../__tests__/__resources__/${jclName}.JCL`,
transferType: TRANSFER_TYPE_ASCII,
};
await DataSetUtils.uploadDataSet(connection, datasetName, options);
}
return datasetName;
}
8 changes: 6 additions & 2 deletions __tests__/__system__/cli/delete/job/cli.delete.job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { CoreUtils } from "../../../../../src/api/CoreUtils";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;

describe("delete job command", () => {
// Create the unique test environment
Expand All @@ -27,16 +29,18 @@ describe("delete job command", () => {
});
expect(testEnvironment).toBeDefined();
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to submit a job from a local file and then delete the job", async () => {
// download the appropriate JCL content from the data set
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const jobID = await connection.submitJCL(iefbr14Content);
const ONE_SECOND = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { IO } from "@zowe/imperative";
import { CoreUtils } from "../../../../../src/api/CoreUtils";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;

describe("download all-spool-by-jobid command", () => {
// Create the unique test environment
Expand All @@ -28,16 +30,18 @@ describe("download all-spool-by-jobid command", () => {
});
expect(testEnvironment).toBeDefined();
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to submit an IEFBR14 job and then download the jobid", async () => {
// download the appropriate JCL content from the data set
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const jobid = await connection.submitJCL(iefbr14Content.toString());
const JOB_WAIT = 2000;
Expand All @@ -56,7 +60,6 @@ describe("download all-spool-by-jobid command", () => {

it("should be able to submit a job from a local file and then download the spool, omitting the jobid directory", async () => {
// download the appropriate JCL content from the data set
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const jobid = await connection.submitJCL(iefbr14Content.toString());
const JOB_WAIT = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString, generateRandomBytes } from "../../../../__src__/TestUtils";
import { IO } from "@zowe/imperative";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;

describe("submit job from local file command", () => {
// Create the unique test environment
Expand All @@ -28,16 +30,18 @@ describe("submit job from local file command", () => {
});
expect(testEnvironment).toBeDefined();
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to download a data set to a local file in text mode and verify the content", async () => {
// download the appropriate JCL content from the data set
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const downloadFilePath = testEnvironment.workingDir + "/iefbr14.txt";
const result = runCliScript(__dirname + "/__scripts__/command_download_data_set.sh", testEnvironment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { CoreUtils } from "../../../../../src/api/CoreUtils";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;

describe("list spool-files-by-jobid command", () => {
// Create the unique test environment
Expand All @@ -27,16 +29,18 @@ describe("list spool-files-by-jobid command", () => {
});
expect(testEnvironment).toBeDefined();
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to submit a job and then list spool files for the job ID", async () => {
// download the appropriate JCL content from the data set
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
expect(iefbr14Content).toContain("IEFBR14");
const jobid = await connection.submitJCL(iefbr14Content);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString, randomDsName } from "../../../../__src__/TestUtils";
import { inspect } from "util";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let user: string;
let connection: any;
let testDataSet: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;

describe("rename data set command", () => {
// Create the unique test environment
Expand All @@ -32,15 +34,17 @@ describe("rename data set command", () => {
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);
user = testEnvironment.systemTestProperties.zftp.user.trim().toUpperCase();
testDataSet = testEnvironment.systemTestProperties.datasets.renamablePDS;

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to upload a file to a data set member then rename the member", async () => {
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member.toUpperCase();
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const memberSuffixLength = 6;
const originalMember = testDataSet + "(R" + generateRandomAlphaNumericString(memberSuffixLength) + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-utils";
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";

let user: string;
let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;
let sleepDataSet: string;

describe("submit job from data set command", () => {
// Create the unique test environment
Expand All @@ -28,15 +31,18 @@ describe("submit job from data set command", () => {
expect(testEnvironment).toBeDefined();
connection = await FTPConfig.connectFromArguments(testEnvironment.systemTestProperties.zftp);
user = testEnvironment.systemTestProperties.zftp.user.trim().toUpperCase();

const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
sleepDataSet = await prepareTestJclDataSet(connection, pds, "SLEEP");
});

afterAll(async () => {
connection.close();
connection?.close();
await TestEnvironment.cleanUp(testEnvironment);
});

it("should be able to submit a job from a data set and see the job name and job id", async () => {
const iefbr14DataSet = testEnvironment.systemTestProperties.jobs.iefbr14Member;
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set.sh", testEnvironment, [iefbr14DataSet]);
expect(result.stderr.toString()).toEqual("");
expect(result.status).toEqual(0);
Expand All @@ -45,7 +51,6 @@ describe("submit job from data set command", () => {
});

it("should be able to submit a job from a data set with wait option and get rc successfully", async () => {
const sleepDataSet = testEnvironment.systemTestProperties.jobs.sleepMember;
const option = "--wait";
const wait = "3,10";
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set_wait.sh", testEnvironment, [sleepDataSet,option,wait]);
Expand All @@ -58,7 +63,6 @@ describe("submit job from data set command", () => {
});

it("should give a syntax error if the wait value is invalid", async () => {
const sleepDataSet = testEnvironment.systemTestProperties.jobs.sleepMember;
const option = "--wait";
const wait = "3,";
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set_wait.sh", testEnvironment, [sleepDataSet,option,wait]);
Expand All @@ -68,7 +72,6 @@ describe("submit job from data set command", () => {
});

it("should be able to submit a job from a data set but not finished within specified wait option", async () => {
const sleepDataSet = testEnvironment.systemTestProperties.jobs.sleepMember;
const option = "--wait";
const wait = "1,2";
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set_wait.sh", testEnvironment, [sleepDataSet,option,wait]);
Expand All @@ -80,7 +83,6 @@ describe("submit job from data set command", () => {
});

it("should be able to submit a job from a data set with wait-for-output option and get rc successfully", async () => {
const sleepDataSet = testEnvironment.systemTestProperties.jobs.sleepMember;
const option = "--wait-for-output";
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set_wait.sh", testEnvironment, [sleepDataSet,option]);
expect(result.stderr.toString()).toEqual("");
Expand All @@ -91,7 +93,6 @@ describe("submit job from data set command", () => {
});

it("should be able to submit a job from a data set with wait-for-active option and get rc successfully", async () => {
const sleepDataSet = testEnvironment.systemTestProperties.jobs.sleepMember;
const option = "--wait-for-active";
const result = runCliScript(__dirname + "/__scripts__/command_submit_data_set_wait.sh", testEnvironment, [sleepDataSet,option]);
expect(result.stderr.toString()).toEqual("");
Expand Down
Loading
Loading