forked from zowe/zowe-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Dumitru
authored and
Alex Dumitru
committed
Jan 29, 2019
1 parent
4497358
commit e3590bc
Showing
9 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+78 Bytes
...sfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/ascii_file.txt
Binary file not shown.
Binary file added
BIN
+31.5 KB
...zosfiles/__tests__/__system__/cli/upload/dtu/__data__/command_upload_dtu_dir/bin_file.pax
Binary file not shown.
Binary file added
BIN
+88 Bytes
...tu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file1.txt
Binary file not shown.
Binary file added
BIN
+88 Bytes
...tu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_ascii/subdir_ascii_file2.txt
Binary file not shown.
Binary file added
BIN
+31.5 KB
...ad/dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file1.pax
Binary file not shown.
Binary file added
BIN
+31.5 KB
.../dtu/__data__/command_upload_dtu_dir/command_upload_dtu_subdir_bin/subdir_bin_file2.pax.Z
Binary file not shown.
9 changes: 9 additions & 0 deletions
9
...es/zosfiles/__tests__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
9 changes: 9 additions & 0 deletions
9
...sts__/__system__/cli/upload/dtu/__scripts__/command/command_upload_dtu_fully_qualified.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 $? |
144 changes: 144 additions & 0 deletions
144
packages/zosfiles/__tests__/__system__/cli/upload/dtu/cli.dir.upload.dtu.system.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.\""); | ||
}); | ||
}); | ||
}); | ||
|