Skip to content

Commit

Permalink
adding system test for cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dumitru authored and Alex Dumitru committed Jan 29, 2019
1 parent 4497358 commit e3590bc
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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 $?
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.\"");
});
});
});

0 comments on commit e3590bc

Please sign in to comment.