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

Select members enhancement #2359

Merged
merged 30 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d8dca55
code updates for #2175
pujal0909 Nov 1, 2024
dcfb5b9
AllMembersMatching unit tests
pujal0909 Nov 4, 2024
7806594
updated membersMatchingPattern method
pujal0909 Nov 5, 2024
af7788c
added unit test List.ts
pujal0909 Nov 5, 2024
9fc192b
updates to functionality
pujal0909 Nov 7, 2024
df6b251
updates to functionality
pujal0909 Nov 7, 2024
7956251
imports edit
pujal0909 Nov 7, 2024
10bf997
updated unit test download.ts
pujal0909 Nov 8, 2024
cfdb2ac
updated list.ts unit tests
pujal0909 Nov 11, 2024
87d3810
updated unit tests
pujal0909 Nov 11, 2024
d918c49
updated handler unit tests
pujal0909 Nov 11, 2024
af0cf5f
updated system tests
pujal0909 Nov 12, 2024
743f3f5
fixed lint errors
pujal0909 Nov 12, 2024
00771e4
fixed snapshot errors
pujal0909 Nov 12, 2024
0cae97b
updates to list.membersMatchingPattern method
pujal0909 Nov 14, 2024
9607c43
updated download system tests
pujal0909 Nov 18, 2024
63c9a9a
merged master into branch
pujal0909 Nov 18, 2024
ff36bf1
removed unsused line
pujal0909 Nov 18, 2024
d65789d
updated List.ts membersMatchingPattern method description
pujal0909 Nov 19, 2024
fd55e6d
updated help text - PR comment
pujal0909 Nov 20, 2024
2080f9f
updated help text - PR comment
pujal0909 Nov 20, 2024
1205b1a
uncommented a line on dsm system test
pujal0909 Nov 21, 2024
5e013e4
updated branch with master
pujal0909 Nov 21, 2024
a8dbb66
updated help text - PR comment
pujal0909 Nov 21, 2024
72acb95
Updated changelogs
pujal0909 Nov 21, 2024
a4d3e7a
updated changelog
pujal0909 Nov 21, 2024
d9bd2f7
updated changelog
pujal0909 Nov 21, 2024
1c5aff5
merged master
pujal0909 Nov 21, 2024
017ae44
updated changelog
pujal0909 Nov 21, 2024
d6f4767
fixed typos
pujal0909 Nov 22, 2024
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
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

-Enhancement: Added new command zowe zos-files download all-members-matching, (zowe files dl amm), to download members matching specified pattern(s). The success message for the Download.allMembers API was changed from originally "Data set downloaded successfully" to "Member(s) downloaded successfully." The change also alters the commandResponse when using the --rfj flag. [#2359](https://github.com/zowe/zowe-cli/pull/2359)

## `8.8.0`

- Enhancement: Pass a `.zosattributes` file path for the download encoding format by adding the new `--attributes` flag to the `zowe zos-files upload` command. [#2322](https://github.com/zowe/zowe-cli/issues/2322)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe("Download All Member", () => {
if (defaultSys.zosmf.basePath != null) {
TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = defaultSys.zosmf.basePath;
}

const response = runCliScript(shellScript,
TEST_ENVIRONMENT_NO_PROF,
[dsname,
Expand All @@ -89,7 +88,7 @@ describe("Download All Member", () => {
defaultSys.zosmf.password]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});
});

Expand All @@ -109,39 +108,39 @@ describe("Download All Member", () => {
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds in binary format", () => {
const shellScript = path.join(__dirname, "__scripts__", "command", "command_download_all_member.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, "--binary"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds in record format", () => {
const shellScript = path.join(__dirname, "__scripts__", "command", "command_download_all_member.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, "--record"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds with response timeout", () => {
const shellScript = path.join(__dirname, "__scripts__", "command", "command_download_all_member.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, "--responseTimeout 5"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set members with --max-concurrent-requests 2", () => {
const shellScript = path.join(__dirname, "__scripts__", "command", "command_download_all_member_mcr.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, 2]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set members of a large data set with --max-concurrent-requests 2", async () => {
Expand All @@ -156,7 +155,7 @@ describe("Download All Member", () => {
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [bigDsname, 2]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
await Delete.dataSet(REAL_SESSION, bigDsname);
});

Expand All @@ -165,7 +164,7 @@ describe("Download All Member", () => {
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, "--rfj"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member to specified directory", () => {
Expand All @@ -174,7 +173,7 @@ describe("Download All Member", () => {
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, `-d ${testDir}`, "--rfj"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Data set downloaded successfully.");
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
expect(response.stdout.toString()).toContain(testDir);
});

Expand All @@ -186,7 +185,7 @@ describe("Download All Member", () => {
const expectedResult = {member: "TEST"};
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(result.stdout).toContain("Data set downloaded successfully.");
expect(result.stdout).toContain("Member(s) downloaded successfully.");
expect(result.stdout).toContain(testDir);
expect(result.data.apiResponse.items[0]).toEqual(expectedResult);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
dsn=$1
pattern=$2
rfj=$3
set -e

echo "================Z/OS FILES DOWNLOAD ALL MEMBER DATA SET==============="
zowe zos-files download amm "$1" "$2" $3 $4
if [ $? -gt 0 ]
then
exit $?
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
dsn=$1
pattern=$2
HOST=$3
PORT=$4
USER=$5
PASS=$6
zowe zos-files download amm "$dsn" "$pattern" --host $HOST --port $PORT --user $USER --password $PASS --ru=false
exit $?
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
dsn=$1
pattern=$2
mcr=$3
set -e

echo "================Z/OS FILES DOWNLOAD ALL MEMBER DATA SET==============="
zowe zos-files download amm "$dsn" "$pattern" --max-concurrent-requests "$mcr"
if [ $? -gt 0 ]
then
exit $?
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
dsn=$1
pattern=$2
rfj=$3
set -e

# echo "================Z/OS FILES DOWNLOAD ALL MEMBER DATA SET==============="
zowe zos-files download amm "$1" "$2" -e "" $3
if [ $? -gt 0 ]
then
exit $?
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*
* 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 { Session } from "@zowe/imperative";
import * as path from "path";
import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment";
import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment";
import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema";
import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils";
import { Create, CreateDataSetTypeEnum, Delete, Upload } from "@zowe/zos-files-for-zowe-sdk";
import { runCliScript } from "@zowe/cli-test-utils";

let REAL_SESSION: Session;
// Test Environment populated in the beforeAll();
let TEST_ENVIRONMENT: ITestEnvironment<ITestPropertiesSchema>;
let TEST_ENVIRONMENT_NO_PROF: ITestEnvironment<ITestPropertiesSchema>;
let defaultSystem: ITestPropertiesSchema;
let dsname: string;
const pattern = "M*";
const members = ["M1", "M2", "M3"];

describe("Download Members Matching Pattern", () => {

beforeAll(async () => {
TEST_ENVIRONMENT = await TestEnvironment.setUp({
tempProfileTypes: ["zosmf"],
testName: "download_all_data_set_member_pattern"
});

defaultSystem = TEST_ENVIRONMENT.systemTestProperties;

REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT);
dsname = getUniqueDatasetName(defaultSystem.zosmf.user);
});

afterAll(async () => {
await TestEnvironment.cleanUp(TEST_ENVIRONMENT);
});
describe("without profiles", () => {
let defaultSys: ITestPropertiesSchema;

// Create the unique test environment
beforeAll(async () => {
TEST_ENVIRONMENT_NO_PROF = await TestEnvironment.setUp({
testName: "zos_files_download_all_members_matching_without_profile"
});

defaultSys = TEST_ENVIRONMENT_NO_PROF.systemTestProperties;
});

afterAll(async () => {
await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF);
});

beforeEach(async () => {
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname);
for(const mem of members) {
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(mem), `${dsname}(${mem})`);
}
});

afterEach(async () => {
await Delete.dataSet(REAL_SESSION, dsname);
});

it("should download matching members of a pds", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm_fully_qualified.sh");

const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH";

// if API Mediation layer is being used (basePath has a value) then
// set an ENVIRONMENT variable to be used by zowe.
if (defaultSys.zosmf.basePath != null) {
TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = defaultSys.zosmf.basePath;
}
const response = runCliScript(shellScript,
TEST_ENVIRONMENT_NO_PROF,
[dsname, pattern,
defaultSys.zosmf.host,
defaultSys.zosmf.port,
defaultSys.zosmf.user,
defaultSys.zosmf.password]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain(`${members.length} members(s) were found matching pattern`);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});
});

describe("Success scenarios", () => {

beforeEach(async () => {
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname);
for(const mem of members) {
await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(mem), `${dsname}(${mem})`);
}
});

afterEach(async () => {
await Delete.dataSet(REAL_SESSION, dsname);
});

it("should download all data set member of pds", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain(`${members.length} members(s) were found matching pattern`);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds in binary format", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname,pattern, "--binary"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds in record format", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern, "--record"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member of pds with response timeout", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern, "--responseTimeout 5"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set members with --max-concurrent-requests 2", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm_mcr.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern, 2]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set members of a large data set with --max-concurrent-requests 2", async () => {
const bigDsname = getUniqueDatasetName(defaultSystem.zosmf.user);
const pattern = "a*";
await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, bigDsname);
const members = ["a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "a10", "a11", "a12", "a13", "b1", "b2"];
const memberContent = Buffer.from("ABCDEFGHIJKLMNOPQRSTUVWXYZ\nABCDEFGHIJKLMNOPQRSTUVWXYZ\nABCDEFGHIJKLMNOPQRSTUVWXYZ");
for (const mem of members) {
await Upload.bufferToDataSet(REAL_SESSION, memberContent, `${bigDsname}(${mem})`);
}
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm_mcr.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [bigDsname, pattern, 2]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
await Delete.dataSet(REAL_SESSION, bigDsname);
});

it("should download all data set member with response-format-json flag", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern, "--rfj"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
});

it("should download all data set member to specified directory", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm.sh");
const testDir = "test/folder";
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern,`-d ${testDir}`, "--rfj"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Member(s) downloaded successfully.");
expect(response.stdout.toString()).toContain(testDir);
});

it("should download all data set member with extension = \"\"", () => {
const shellScript = path.join(__dirname, "__scripts__", "command_download_amm_no_extension.sh");
const testDir = "test/folder";
const response = runCliScript(shellScript, TEST_ENVIRONMENT, [dsname, pattern,`-d ${testDir} --rfj`]);
const result = JSON.parse(response.stdout.toString());
const expectedResult = {member: "M1"};
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(result.stdout).toContain("Member(s) downloaded successfully.");
expect(result.stdout).toContain(testDir);
expect(result.data.apiResponse.items[0]).toEqual(expectedResult);
});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe("Download Dataset Matching", () => {
expect(result.stdout).toContain(`${dsnames.length} data set(s) downloaded successfully to ${testDir}`);

for (const apiResp of result.data.apiResponse) {
expect(apiResp.status).toContain("Data set downloaded successfully.");
expect(apiResp.status).toContain("Member(s) downloaded successfully.");
expect(apiResp.status).toContain("Destination:");
expect(apiResp.status).toContain(testDir);
expect(apiResp.status).toContain("Members: TEST;");
Expand Down
Loading