From e3590bc37e950933726461927e9c7237cc2fe449 Mon Sep 17 00:00:00 2001 From: Alex Dumitru Date: Tue, 29 Jan 2019 12:00:57 +0100 Subject: [PATCH] adding system test for cli --- .../command_upload_dtu_dir/ascii_file.txt | Bin 0 -> 78 bytes .../command_upload_dtu_dir/bin_file.pax | Bin 0 -> 32256 bytes .../subdir_ascii_file1.txt | Bin 0 -> 88 bytes .../subdir_ascii_file2.txt | Bin 0 -> 88 bytes .../subdir_bin_file1.pax | Bin 0 -> 32256 bytes .../subdir_bin_file2.pax.Z | Bin 0 -> 32256 bytes .../__scripts__/command/command_upload_dtu.sh | 9 ++ .../command_upload_dtu_fully_qualified.sh | 9 ++ .../dtu/cli.dir.upload.dtu.system.test.ts | 144 ++++++++++++++++++ 9 files changed, 162 insertions(+) create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/ascii_file.txt create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/bin_file.pax create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file1.txt create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file2.txt create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file1.pax create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file2.pax.Z create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu.sh create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu_fully_qualified.sh create mode 100644 packages/zosfiles/__tests__/__system__/cli/upload/dtu/cli.dir.upload.dtu.system.test.ts diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/ascii_file.txt b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/ascii_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..b2825897ec12475e13612e95c2d2f5e6452c0fd5 GIT binary patch literal 78 zcmezW&ygXR!I{Am2o)I87%~}h7*ZK{8Mqh%fT9WvML=FLP&5Td=P{IkWr`T`fv^Ou NJ|CzaBv%BM0RUg>4c!0$ literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/bin_file.pax b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/bin_file.pax new file mode 100644 index 0000000000000000000000000000000000000000..b48b086ce1c1ab7f8a40fc3a8dde7a377639e22b GIT binary patch literal 32256 zcmeIuyGjE=6b9haS@{mz*vigsE^Pt<8zUlE$9RK)RW4vHDp-p`N~13#Rz88fPvS%n zY|^Dr_|6u?ocU)t^G#;Qr=#&;I5`=O2Ir%Tv$Q?EoW@$KEX!7_ETYj$sjeDT-d9z- zh`fGRs+vWr8&#uBb*k#3OwD##=kv8rvEpa5$#gi*qx25@-Q6;+NJVse{k`7K!Tzd1 z9y~wh=TXI~*k9{!JiW$eyv2L|I&m9!aUVCaxfLI|*@=1HEOPTYuMhFOJoueo#7kVo zQNH(>?=3^~WkeAmK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ x009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oU(E0$=jrGsXY_ literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file1.txt b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file1.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b3a1477cff419a70f8f838c623fee4d2e911a2d GIT binary patch literal 88 zcmezW&ygXR!I{Am2o)I87%~}h7*ZK{8Mqh%fT9WvML=FLP&5Td=P{IkWsr3gGn6tU RG3Wwy<^y$tR26~M0083*4*388 literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file2.txt b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file2.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b3a1477cff419a70f8f838c623fee4d2e911a2d GIT binary patch literal 88 zcmezW&ygXR!I{Am2o)I87%~}h7*ZK{8Mqh%fT9WvML=FLP&5Td=P{IkWsr3gGn6tU RG3Wwy<^y$tR26~M0083*4*388 literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file1.pax b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file1.pax new file mode 100644 index 0000000000000000000000000000000000000000..b48b086ce1c1ab7f8a40fc3a8dde7a377639e22b GIT binary patch literal 32256 zcmeIuyGjE=6b9haS@{mz*vigsE^Pt<8zUlE$9RK)RW4vHDp-p`N~13#Rz88fPvS%n zY|^Dr_|6u?ocU)t^G#;Qr=#&;I5`=O2Ir%Tv$Q?EoW@$KEX!7_ETYj$sjeDT-d9z- zh`fGRs+vWr8&#uBb*k#3OwD##=kv8rvEpa5$#gi*qx25@-Q6;+NJVse{k`7K!Tzd1 z9y~wh=TXI~*k9{!JiW$eyv2L|I&m9!aUVCaxfLI|*@=1HEOPTYuMhFOJoueo#7kVo zQNH(>?=3^~WkeAmK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ x009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oU(E0$=jrGsXY_ literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file2.pax.Z b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file2.pax.Z new file mode 100644 index 0000000000000000000000000000000000000000..481184601be24a0e35dc4ef771c78a48202207df GIT binary patch literal 32256 zcmeIuTT7Dx0D$4oLrY0yk%(xZLfB?qtUTaF7inWu6U`6_5==7NET~YVpo^6@XP#!7 zhtkv(+YE#bsO1qYGcyeY6FNAzxqWk$#Yhbk`wRVm_xTA=c(XBo*$`Qynyy#mk9QpN zyiN{{KbO`HHZZOZv>o=jPc*YWGyzE>)neTG@%1j(}E zel$gTa#L!xw#jC7Z}*pq?Md5wA_7Mg!dt;d@E(!sltPr3%(pesU-gp@BaharSZ6%+TP*+E3fNmek>) z&5d=BdtqjHcxy|L$SgYFV2$O5UzEvmGaz2H6iHRG#p0k0&El<)T+^a{ccHjg5}}t_ z4SVV|)>2ug$$EQ#k7zAZjLU50v2z+*MS{a*t30$S+NusquA(;njQBp_P8APFOSQeO$BpWXY*Bu z+4|7;lSGTH#ld-En<1)8d{`d8EVdg}(XNi#j67F~00tOffB^;=V1NMz7+`<_ z1{h#~0R|XgfB^;=V1NMz7+`<_1{h#~0R|XgfB^;=V1NMz7+`<_1{h#~0R|XgfB^;= zV1NMz7+`<_1{h#~0R|XgfB^;=V1NMz7+`<_1{h#~0R|XgfB^;=V1NMz7+`<_1{h#~ o0R|XgfB^;=V1NMz7+`<_1{h#~0R|XgfB^;=V1NMz82I0Te>^z(cK`qY literal 0 HcmV?d00001 diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu.sh b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu.sh new file mode 100644 index 0000000000..b7699f7aac --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +echo "================ Z/OS FILES UPLOAD LOCAL DIRECTORY TO USS DIRECTORY===============" +zowe zos-files upload dir-to-uss $* +if [ $? -gt 0 ] +then + exit $? +fi \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu_fully_qualified.sh b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu_fully_qualified.sh new file mode 100644 index 0000000000..870ee86d6d --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu_fully_qualified.sh @@ -0,0 +1,9 @@ +#!/bin/bash +dir=$1 +uss=$2 +HOST=$3 +PORT=$4 +USER=$5 +PASS=$6 +zowe zos-files upload dir-to-uss "$dir" "$uss" --host $HOST --port $PORT --user $USER --password $PASS --ru=false +exit $? \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/cli/upload/dtu/cli.dir.upload.dtu.system.test.ts b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/cli.dir.upload.dtu.system.test.ts new file mode 100644 index 0000000000..c0a6baed50 --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/cli/upload/dtu/cli.dir.upload.dtu.system.test.ts @@ -0,0 +1,144 @@ +/* +* 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 { Imperative, IO, Session } from "@brightside/imperative"; +import * as path from "path"; +import { runCliScript } from "../../../../../../../__tests__/__src__/TestUtils"; +import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/doc/response/ITestEnvironment"; +import { TestProperties } from "../../../../../../../__tests__/__src__/properties/TestProperties"; +import { ITestSystemSchema } from "../../../../../../../__tests__/__src__/properties/ITestSystemSchema"; +// import { Create, CreateDataSetTypeEnum, Delete, ZosFilesMessages } from "../../../../../../zosfiles"; +import { Get, ZosFilesConstants } from "../../../../../index"; +import { ZosmfRestClient } from "../../../../../../rest"; + +let REAL_SESSION: Session; +// Test Environment populated in the beforeAll(); +let TEST_ENVIRONMENT: ITestEnvironment; +let TEST_ENVIRONMENT_NO_PROF: ITestEnvironment; +let systemProps: TestProperties; +let defaultSystem: ITestSystemSchema; +let ussname: string; +let binaryFiles: string; +let asciiFiles: string; + +describe("Upload directory to USS", () => { + + beforeAll(async () => { + + TEST_ENVIRONMENT = await TestEnvironment.setUp({ + tempProfileTypes: ["zosmf"], + testName: "zos_files_upload_directory_to_uss_with_profile" + }); + + systemProps = new TestProperties(TEST_ENVIRONMENT.systemTestProperties); + defaultSystem = systemProps.getDefaultSystem(); + + REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); + ussname = `${defaultSystem.unix.testdir}`.substring(1); + Imperative.console.info("Using ussDir:" + ussname); + binaryFiles = "bin_file.pax"; + asciiFiles = "ascii_file.txt"; + }); + + afterAll(async () => { + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); + }); + + describe("without profiles", () => { + let sysProps; + let defaultSys: ITestSystemSchema; + + // Create the unique test environment + beforeAll(async () => { + TEST_ENVIRONMENT_NO_PROF = await TestEnvironment.setUp({ + testName: "zos_files_upload_directory_to_uss_without_profile" + }); + + sysProps = new TestProperties(TEST_ENVIRONMENT_NO_PROF.systemTestProperties); + defaultSys = sysProps.getDefaultSystem(); + }); + + it("should upload local directory to USS directory", async () => { + const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir"); + const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtu_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, + [ + localDirName, + ussname, + defaultSys.zosmf.host, + defaultSys.zosmf.port, + defaultSys.zosmf.user, + defaultSys.zosmf.pass + ]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Directory uploaded successfully."); + }); + }); + + describe("Success scenarios", () => { + + afterEach(async () => { + let error; + let response; + + const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; + + try { + response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint, ["X-IBM-Option:recursive"]); + } catch (err) { + error = err; + } + }); + + it("should upload from local directory to USS directory", async () => { + const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir"); + const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtu_fully_qualified.sh"); + const response = runCliScript(shellScript, TEST_ENVIRONMENT, [localDirName, ussname]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Directory uploaded successfully."); + }); + + it("should upload from recursively local directory to USS directory", async () => { + const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir"); + const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtu_fully_qualified.sh"); + const response = runCliScript(shellScript, TEST_ENVIRONMENT, [localDirName, ussname, "--recursive"]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Directory uploaded successfully."); + }); + + it("should upload local directory with response-format-json flag", async () => { + const shellScript = path.join(__dirname, "__scripts__", "command", "command_upload_dtu.sh"); + const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir"); + const response = runCliScript(shellScript, TEST_ENVIRONMENT, [localDirName, ussname, "--rfj"]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + const stdoutText = response.stdout.toString(); + expect(stdoutText).toContain("\"stdout\": \"success: true"); + expect(stdoutText).toContain( + "\"commandResponse\": \"Directory uploaded successfully.\""); + }); + }); +}); +