Skip to content

Commit

Permalink
Merge branch 'master' into update-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
zFernand0 authored Jan 23, 2024
2 parents 709f8bf + 6fef2d5 commit cc9f4eb
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 38 deletions.
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- BugFix: Update zos-files copy dsclp system tests to include large mock files.

## `7.22.0`

- Enhancement: Hid the progress bar if `CI` environment variable is set, or if `FORCE_COLOR` environment variable is set to `0`. [#1845](https://github.com/zowe/zowe-cli/issues/1845)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ toDataSet=$2
options=$3
set -e

echo "================Z/OS FILES COPY DS==============="
zowe zos-files copy data-set $fromDataSet $toDataSet $options
echo "================Z/OS FILES COPY DSCLP==============="
zowe zos-files copy dsclp $fromDataSet $toDataSet $options

if [ $? -gt 0 ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

import { Session } from "@zowe/imperative";
import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils";
import { getRandomBytes } from "../../../../../../../__tests__/__src__/TestUtils";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { Delete, Create, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk";
import { Delete, Create, ICreateDataSetOptions, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk";
import { join } from "path";

let REAL_SESSION: Session;
Expand All @@ -27,6 +28,25 @@ const fromMemberName: string = "mem1";
const toMemberName: string = "mem2";
const responseTimeout = `--responseTimeout 5`;
const replaceOption = `--replace`;
const largeDsSize = 1024 * 1024;
const largeDsOptions: ICreateDataSetOptions = {
alcunit: "CYL",
dsorg: "PS",
primary: 20,
recfm: "FB",
blksize: 6160,
lrecl: 80,
dirblk: 0
} as any;
const largePdsOptions: ICreateDataSetOptions = {
alcunit: "CYL",
dsorg: "PO",
primary: 20,
recfm: "FB",
blksize: 6160,
lrecl: 80,
dirblk: 5
} as any;

describe("Copy data set", () => {
beforeAll(async () => {
Expand All @@ -41,7 +61,6 @@ describe("Copy data set", () => {
user = defaultSystem.zosmf.user.trim().toUpperCase();
fromDataSetName = `${user}.COPY.FROM.SET`;
toDataSetName = `${user}.COPY.TO.SET`;

});
afterAll(async () => {
await TestEnvironment.cleanUp(TEST_ENVIRONMENT);
Expand All @@ -54,13 +73,14 @@ describe("Copy data set", () => {
});
describe("success scenarios", () => {
const data = "1234";
describe("sequential > sequential", () => {
let bigData:Buffer;
describe("sequential > sequential (Large Dataset)", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, fromDataSetName),
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, toDataSetName)
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, fromDataSetName, largeDsOptions)
]);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), fromDataSetName);
bigData = await getRandomBytes(largeDsSize);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(bigData), fromDataSetName, { binary: true });
});
it("should copy a data set from the command", async () => {
let response;
Expand All @@ -73,17 +93,25 @@ describe("Copy data set", () => {
TEST_ENVIRONMENT,
[fromDataSetName, toDataSetName]
);
contents = await Get.dataSet(REAL_SESSION, toDataSetName);
contents = await Get.dataSet(REAL_SESSION, toDataSetName, { binary: true });
} catch(err) {
error = err;
}

expect(error).toBe(undefined);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.toString().trim()).toBe(data);
expect(contents.subarray(0, bigData.length)).toEqual(bigData);
});
it("should copy a data set from the command with response timeout", async () => {
});
describe("sequential > sequential", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, fromDataSetName)
]);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), fromDataSetName);
});
it("should copy a data set from the command", async () => {
let response;
let contents;
let error;
Expand All @@ -92,7 +120,7 @@ describe("Copy data set", () => {
response = runCliScript(
join(__dirname, "__scripts__", "command", "command_copy_data_set_cross_lpar.sh"),
TEST_ENVIRONMENT,
[fromDataSetName, toDataSetName, responseTimeout]
[fromDataSetName, toDataSetName]
);
contents = await Get.dataSet(REAL_SESSION, toDataSetName);
} catch(err) {
Expand All @@ -104,7 +132,7 @@ describe("Copy data set", () => {
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.toString().trim()).toBe(data);
});
it("should copy a data set from the command with replace option", async () => {
it("should copy a data set from the command with response timeout", async () => {
let response;
let contents;
let error;
Expand All @@ -113,7 +141,7 @@ describe("Copy data set", () => {
response = runCliScript(
join(__dirname, "__scripts__", "command", "command_copy_data_set_cross_lpar.sh"),
TEST_ENVIRONMENT,
[fromDataSetName, toDataSetName, replaceOption]
[fromDataSetName, toDataSetName, responseTimeout]
);
contents = await Get.dataSet(REAL_SESSION, toDataSetName);
} catch(err) {
Expand Down Expand Up @@ -171,27 +199,6 @@ describe("Copy data set", () => {
error = err;
}

expect(error).toBe(undefined);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.toString().trim()).toBe(data);
});
it("should copy a data set from the command with replace option", async () => {
let response;
let contents;
let error;

try {
response = runCliScript(
join(__dirname, "__scripts__", "command", "command_copy_data_set_cross_lpar.sh"),
TEST_ENVIRONMENT,
[`${fromDataSetName}(${fromMemberName})`, `${toDataSetName}(${toMemberName})`, replaceOption]
);
contents = await Get.dataSet(REAL_SESSION, `${toDataSetName}(${toMemberName})`);
} catch(err) {
error = err;
}

expect(error).toBe(undefined);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set copied successfully.");
Expand Down Expand Up @@ -273,8 +280,7 @@ describe("Copy data set", () => {
describe("member > sequential", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, fromDataSetName),
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, toDataSetName)
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, fromDataSetName)
]);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), `${fromDataSetName}(${fromMemberName})`);
});
Expand Down Expand Up @@ -320,6 +326,45 @@ describe("Copy data set", () => {
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.toString().trim()).toBe(data);
});
});
describe("sequential > sequential with replace", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, fromDataSetName),
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, toDataSetName)
]);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), fromDataSetName);
});
it("should copy a data set from the command with replace option", async () => {
let response;
let contents;
let error;

try {
response = runCliScript(
join(__dirname, "__scripts__", "command", "command_copy_data_set_cross_lpar.sh"),
TEST_ENVIRONMENT,
[fromDataSetName, toDataSetName, replaceOption]
);
contents = await Get.dataSet(REAL_SESSION, toDataSetName);
} catch(err) {
error = err;
}

expect(error).toBe(undefined);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.toString().trim()).toBe(data);
});
});
describe("member > sequential with replace option", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, fromDataSetName),
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, toDataSetName)
]);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), `${fromDataSetName}(${fromMemberName})`);
});
it("should copy a data set from the command with replace option", async () => {
let response;
let contents;
Expand All @@ -342,5 +387,36 @@ describe("Copy data set", () => {
expect(contents.toString().trim()).toBe(data);
});
});
describe("member > member (Large file)", () => {
beforeEach(async () => {
await Promise.all([
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, fromDataSetName, largePdsOptions),
Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, toDataSetName, largePdsOptions)
]);
bigData = await getRandomBytes(largeDsSize);
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(bigData), `${fromDataSetName}(${fromMemberName})`, { binary: true });
});
it("should copy a member from the command", async () => {
let response;
let contents;
let error;

try {
response = runCliScript(
join(__dirname, "__scripts__", "command", "command_copy_data_set_cross_lpar.sh"),
TEST_ENVIRONMENT,
[`${fromDataSetName}(${fromMemberName})`, `${toDataSetName}(${toMemberName})`]
);
contents = await Get.dataSet(REAL_SESSION, `${toDataSetName}(${toMemberName})`, { binary: true });
} catch(err) {
error = err;
}

expect(error).toBe(undefined);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set copied successfully.");
expect(contents.subarray(0, bigData.length)).toEqual(bigData);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

import { Imperative, Session } from "@zowe/imperative";
import * as path from "path";
import { ZosFilesConstants, ZosmfRestClient, ZosmfHeaders } from "@zowe/cli";
import { ZosFilesConstants, ZosmfRestClient, ZosmfHeaders, Upload } from "@zowe/cli";
import {ITestEnvironment, runCliScript} from "@zowe/cli-test-utils";
import {TestEnvironment} from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { getRandomBytes } from "../../../../../../../__tests__/__src__/TestUtils";
import {ITestPropertiesSchema} from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName} from "../../../../../../../__tests__/__src__/TestUtils";

Expand Down Expand Up @@ -95,6 +96,19 @@ describe("View uss file", () => {
expect(response.status).toBe(0);
expect(response.stdout.toString().trim()).toEqual(data);
});
it("should view large uss file in binary", async () => {
const rawData:Buffer = await getRandomBytes(1024*64);
const data = encodeURIComponent(rawData.toLocaleString());
await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data), { binary: true });

const shellScript = path.join(__dirname, "__scripts__", "command", "command_view_uss_file.sh");
const response = runCliScript(shellScript, testEnvironment, [ussname.substr(1, ussname.length), "--binary"]);
const respdata = response.stdout.toLocaleString();

expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(respdata.trim()).toEqual(data);
});
it("should view uss file with range", async () => {
const data: string = "abcdefghijklmnopqrstuvwxyz\nabcdefghijklmnopqrstuvwxyz\nabcdefghijklmnopqrstuvwxyz\n";
const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname;
Expand Down

0 comments on commit cc9f4eb

Please sign in to comment.