Skip to content

Commit

Permalink
fix all integration tests. missing 8 system tests
Browse files Browse the repository at this point in the history
Signed-off-by: zFernand0 <[email protected]>
  • Loading branch information
zFernand0 committed Mar 5, 2024
1 parent b187943 commit 20836b0
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 79 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import { ZosAccessor } from "zos-node-accessor";

let connection: any;
let connection: ZosAccessor;
let dsnPrefix: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;

Expand Down Expand Up @@ -56,7 +57,7 @@ describe("allocate data set command", () => {
expect(result.status).toEqual(0);
expect(result.stdout.toString()).toContain('Allocated dataset ' + destination + ' successfully!');

const attributes = await connection.listDataset(destination);
const attributes = await connection.listDatasets(destination);
expect(attributes[0].Dsorg).toEqual("PO");
expect(attributes[0].Lrecl).toEqual("100");
expect(attributes[0].Recfm).toEqual("FB");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import { ZosAccessor } from "zos-node-accessor";
import { ITransferMode } from "../../../../../src/api";

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

Expand All @@ -40,7 +42,7 @@ describe("delete data set command", () => {
const memberSuffixLength = 6;
const destination = testDataSet + "(R" + generateRandomAlphaNumericString(memberSuffixLength) + ")";
const randomContentLength = 60;
await connection.uploadDataset(generateRandomAlphaNumericString(randomContentLength), "'" + destination + "'", "ascii");
await connection.uploadDataset(generateRandomAlphaNumericString(randomContentLength), "'" + destination + "'", ITransferMode.ASCII);
const result = runCliScript(__dirname + "/__scripts__/command_delete_data_set.sh", testEnvironment,
[destination]);
expect(result.stderr.toString()).toEqual("");
Expand Down
5 changes: 3 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 @@ -14,8 +14,9 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { CoreUtils } from "../../../../../src/api/CoreUtils";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";
import { ZosAccessor } from "zos-node-accessor";

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

Expand All @@ -41,7 +42,7 @@ describe("delete job command", () => {

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 iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString();
const jobID = await connection.submitJCL(iefbr14Content);
const ONE_SECOND = 1000;
await CoreUtils.sleep(ONE_SECOND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import { ZosAccessor } from "zos-node-accessor";
import { ITransferMode } from "../../../../../src/api";

let connection: any;
let connection: ZosAccessor;
let ussTestDir: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;

Expand All @@ -41,7 +43,7 @@ describe("delete uss file command", () => {
const fileNameLength = 30;
const destination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
const uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
await connection.uploadDataset(uploadContent, destination, "ascii");
await connection.uploadDataset(uploadContent, destination, ITransferMode.ASCII);
const result = runCliScript(__dirname + "/__scripts__/command_delete_uss_file.sh", testEnvironment,
[destination]);
expect(result.stderr.toString()).toEqual("");
Expand Down Expand Up @@ -75,7 +77,7 @@ describe("delete uss file command", () => {

let uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
const file = destination + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
await connection.uploadDataset(uploadContent, file, "ascii");
await connection.uploadDataset(uploadContent, file, ITransferMode.ASCII);

const subDirectoryDestination1 = destination + "/" + generateRandomAlphaNumericString(fileNameLength);
await connection.makeDirectory(subDirectoryDestination1);
Expand All @@ -85,11 +87,11 @@ describe("delete uss file command", () => {

uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
const file1 = subDirectoryDestination1 + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
await connection.uploadDataset(uploadContent, file1, "ascii");
await connection.uploadDataset(uploadContent, file1, ITransferMode.ASCII);

uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
const file2 = subDirectoryDestination2 + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
await connection.uploadDataset(uploadContent, file2, "ascii");
await connection.uploadDataset(uploadContent, file2, ITransferMode.ASCII);

const result = runCliScript(__dirname + "/__scripts__/command_delete_uss_directory_recursively.sh", testEnvironment,
[destination]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("submit job from local file command", () => {
const fileNameLength = 30;
const destination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
const uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
await connection.uploadDataset(uploadContent, destination, ITransferMode.ASCII);
await connection.uploadFile(uploadContent, destination, ITransferMode.ASCII);
const downloadFilePath = testEnvironment.workingDir + "/uss.txt";
const result = runCliScript(__dirname + "/__scripts__/command_download_uss_file.sh", testEnvironment,
[destination, downloadFilePath]);
Expand All @@ -54,14 +54,15 @@ describe("submit job from local file command", () => {
const downloadedContent = IO.readFileSync(downloadFilePath);
expect(downloadedContent.toString()).toContain(uploadContent);
IO.deleteFile(downloadFilePath);
await connection.deleteFile(destination);
});

it("should be able to download a USS file to a local file in binary mode and verify the content", async () => {
const randomContentLength = 6000;
const randomContent = await generateRandomBytes(randomContentLength);
const fileNameLength = 30;
const destination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".bin";
await connection.uploadDataset(randomContent, destination, ITransferMode.BINARY);
await connection.uploadFile(randomContent, destination, ITransferMode.BINARY);
const downloadFilePath = testEnvironment.workingDir + "/iefbr14.txt";
const result = runCliScript(__dirname + "/__scripts__/command_download_uss_file_binary.sh", testEnvironment,
[destination, downloadFilePath]);
Expand All @@ -71,7 +72,7 @@ describe("submit job from local file command", () => {
const uploadedContent = IO.readFileSync(downloadFilePath, undefined, true);
const uploadedContentString = uploadedContent.toString("hex");
expect(uploadedContentString).toEqual(randomContent.toString("hex"));
await connection.deleteDataset(destination);
await connection.deleteFile(destination);
});

it("should give a syntax error if the USS file name is omitted", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import * as path from "path";
import { ZosAccessor } from "zos-node-accessor";
import { ITransferMode } from "../../../../../src/api";

let connection: any;
let connection: ZosAccessor;
let ussTestDir: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;

Expand All @@ -42,12 +44,12 @@ describe("list data-set-classic ftp command", () => {
const fileNameLength = 30;
const destination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
const uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
await connection.uploadDataset(uploadContent, destination, "ascii"); // upload the USS file
await connection.uploadFile(uploadContent, destination, ITransferMode.ASCII); // upload the USS file
const result = runCliScript(__dirname + "/__scripts__/command_list_uss_files.sh", testEnvironment, [ussTestDir]);
expect(result.stderr.toString()).toEqual("");
expect(result.status).toEqual(0);
expect(result.stdout.toString()).toContain(path.basename(destination));
await connection.deleteDataset(destination);
await connection.deleteFile(destination);
});

it("should be able to upload a file to the test directory and be show that newly uploaded file with pattern in the list", async () => {
Expand All @@ -56,7 +58,7 @@ describe("list data-set-classic ftp command", () => {
const fileName = generateRandomAlphaNumericString(fileNameLength);
const destination = ussTestDir + "/" + "prefix_" + fileName + "_suffix.txt";
const uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
await connection.uploadDataset(uploadContent, destination, "ascii"); // upload the USS file
await connection.uploadFile(uploadContent, destination, ITransferMode.ASCII); // upload the USS file

const ussTestDirPattern1 = ussTestDir + "/" + "prefix_*";
let result = runCliScript(__dirname + "/__scripts__/command_list_uss_files.sh", testEnvironment, [ussTestDirPattern1]);
Expand All @@ -81,7 +83,7 @@ describe("list data-set-classic ftp command", () => {
expect(result.stderr.toString()).toEqual("");
expect(result.status).toEqual(0);
expect(result.stdout.toString()).not.toContain(path.basename(destination));
await connection.deleteDataset(destination);
await connection.deleteFile(destination);
});

it("should give a syntax error if the uss file pattern is omitted", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import { ZosAccessor } from "zos-node-accessor";

let connection: any;
let connection: ZosAccessor;
let ussTestDir: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString, randomDsName } from "../../../../__src__/TestUtils";
import { inspect } from "util";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";
import { ZosAccessor } from "zos-node-accessor";
import { ITransferMode } from "../../../../../src/api";

let connection: ZosAccessor;
let user: string;
let connection: any;
let testDataSet: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;
Expand Down Expand Up @@ -45,18 +47,18 @@ describe("rename data set command", () => {
});

it("should be able to upload a file to a data set member then rename the member", async () => {
const iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
const iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString();
const memberSuffixLength = 6;
const originalMember = testDataSet + "(R" + generateRandomAlphaNumericString(memberSuffixLength) + ")";
await connection.uploadDataset(iefbr14Content, "'" + originalMember + "'", "ascii"); // upload the USS file
await connection.uploadDataset(iefbr14Content, "'" + originalMember + "'", ITransferMode.ASCII); // upload the USS file
const renameDestination = testDataSet + "(R" + generateRandomAlphaNumericString(memberSuffixLength) + ")";
const result = runCliScript(__dirname + "/__scripts__/command_rename_data_set.sh", testEnvironment,
[originalMember, renameDestination]);
expect(result.stderr.toString()).toEqual("");
expect(result.stdout.toString()).toContain("renamed");
expect(result.stdout.toString()).toContain("Success");
expect(result.status).toEqual(0);
const renamedContent = (await connection.getDataset("'" + renameDestination + "'")).toString();
const renamedContent = (await connection.downloadDataset("'" + renameDestination + "'")).toString();
expect(renamedContent.trim()).toEqual(iefbr14Content.trim());
await connection.deleteDataset(renameDestination);
});
Expand All @@ -74,7 +76,7 @@ describe("rename data set command", () => {
expect(result.stdout.toString()).toContain("Success");
expect(result.status).toEqual(0);

const renameDataSetListResults: any[] = await connection.listDataset(renameDestination);
const renameDataSetListResults: any[] = await connection.listDatasets(renameDestination);
let renamedDataSet: any;
for (const dataSet of renameDataSetListResults) {
if (dataSet.Dsname === renameDestination.toUpperCase()) {
Expand All @@ -92,7 +94,7 @@ describe("rename data set command", () => {
expect(resetNameResult.status).toEqual(0);

// make sure the original named data set exists
const resetNameResults: any[] = await connection.listDataset(originalName);
const resetNameResults: any[] = await connection.listDatasets(originalName);
let resetDataset: any;
for (const dataSet of resetNameResults) {
if (dataSet.Dsname === originalName.toUpperCase()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { generateRandomAlphaNumericString } from "../../../../__src__/TestUtils";
import { ZosAccessor } from "zos-node-accessor";
import { ITransferMode } from "../../../../../src/api";

let connection: any;
let connection: ZosAccessor;
let ussTestDir: string;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;

Expand All @@ -41,15 +43,15 @@ describe("rename uss file command", () => {
const fileNameLength = 30;
const destination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
const uploadContent = generateRandomAlphaNumericString(CONTENT_LENGTH);
await connection.uploadDataset(uploadContent, destination, "ascii"); // upload the USS file
await connection.uploadDataset(uploadContent, destination, ITransferMode.ASCII); // upload the USS file
const renameDestination = ussTestDir + "/" + generateRandomAlphaNumericString(fileNameLength) + ".txt";
const result = runCliScript(__dirname + "/__scripts__/command_rename_uss_file.sh", testEnvironment,
[destination, renameDestination]);
expect(result.stderr.toString()).toEqual("");
expect(result.stdout.toString()).toContain("renamed");
expect(result.stdout.toString()).toContain("Success");
expect(result.status).toEqual(0);
const renamedContent = (await connection.getDataset(renameDestination)).toString();
const renamedContent = (await connection.downloadFile(renameDestination)).toString();
expect(renamedContent.trim()).toEqual(uploadContent);
await connection.deleteDataset(renameDestination);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { ITestEnvironment, TestEnvironment, runCliScript } from "@zowe/cli-test-
import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSchema";
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";
import { ZosAccessor } from "zos-node-accessor";

let connection: ZosAccessor;
let user: string;
let connection: any;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;
let sleepDataSet: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { IO } from "@zowe/imperative";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";
import { ZosAccessor } from "zos-node-accessor";

let connection: any;
let connection: ZosAccessor;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;
let sleepDataSet: string;
Expand All @@ -36,8 +37,8 @@ describe("submit job from local file command", () => {
const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
sleepDataSet = await prepareTestJclDataSet(connection, pds, "SLEEP");
iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
sleepContent = (await connection.getDataset(sleepDataSet)).toString();
iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString();
sleepContent = (await connection.downloadDataset(sleepDataSet)).toString();
});

afterAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { ITestPropertiesSchema } from "../../../../__src__/doc/ITestPropertiesSc
import { FTPConfig } from "../../../../../src/api/FTPConfig";
import { IO } from "@zowe/imperative";
import { prepareTestJclDataSet } from "../../PrepareTestJclDatasets";
import { ZosAccessor } from "zos-node-accessor";

let connection: any;
let connection: ZosAccessor;
let testEnvironment: ITestEnvironment<ITestPropertiesSchema>;
let iefbr14DataSet: string;
let sleepDataSet: string;
Expand All @@ -36,8 +37,8 @@ describe("submit job from stdin command", () => {
const pds = testEnvironment.systemTestProperties.datasets.writablePDS;
iefbr14DataSet = await prepareTestJclDataSet(connection, pds, "IEFBR14");
sleepDataSet = await prepareTestJclDataSet(connection, pds, "SLEEP");
iefbr14Content = (await connection.getDataset(iefbr14DataSet)).toString();
sleepContent = (await connection.getDataset(sleepDataSet)).toString();
iefbr14Content = (await connection.downloadDataset(iefbr14DataSet)).toString();
sleepContent = (await connection.downloadDataset(sleepDataSet)).toString();
});

afterAll(async () => {
Expand Down
Loading

0 comments on commit 20836b0

Please sign in to comment.