diff --git a/__tests__/__src__/TestUtils.ts b/__tests__/__src__/TestUtils.ts index 759a3ac256..15d1533878 100644 --- a/__tests__/__src__/TestUtils.ts +++ b/__tests__/__src__/TestUtils.ts @@ -10,9 +10,83 @@ */ import { randomBytes } from "crypto"; -import { ZosFilesConstants } from "../../packages/zosfiles/src"; +import * as fs from "fs"; import { Imperative, Headers, AbstractSession } from "@zowe/imperative"; import { ZosmfRestClient } from "../../packages/core/src"; +import { ZosFilesConstants, Delete } from "../../packages/zosfiles/src"; +import { DeleteJobs, GetJobs, ICommonJobParms, IDeleteJobParms, IJob } from "../../packages/zosjobs/src"; +import { promisify } from "util"; + +/** + * Delete a local testing file after use + * @param {string} filePath - File path of temporary file + */ +export function deleteLocalFile(filePath: string): void { + try { + fs.unlinkSync(filePath); + } catch { + throw new Error(`Error deleting local file: ${filePath}`); + } +} + +/** + * Delete local directories after use + * @param {string[]} directories - Array of directories to delete + */ +export function deleteLocalDirectories(directories: string[]): void { + directories.forEach((dir) => { + try { + if (fs.existsSync(dir)) { + fs.rmdirSync(dir, { recursive: true }); + } + } catch { + throw new Error(`Error deleting directory: ${dir}`); + } + }); +} + +/** + * Deletes a USS file from the mainframe + * @param {AbstractSession} session - The session object + * @param {string} fileName - The name of the file to delete + * @returns {Promise} A promise that resolves when the file is deleted + */ +export async function deleteFiles(session: AbstractSession, fileName: string): Promise { + await Delete.ussFile(session, fileName, true); //recursive = true +} + +/** + * Deletes a data set from the mainframe + * @param {AbstractSession} session - The session object + * @param {string} dataSetName - The name of the data set to delete. + * @returns {Promise} A promise that resolves when the data set is deleted + */ +export async function deleteDataset(session: AbstractSession, dataSetName: string): Promise { + await Delete.dataSet(session, dataSetName); +} + +/** + * Delete a job from the mainframe using Zowe SDKs - IJob + * @param {AbstractSession} session - z/OSMF connection info + * @param {IJob | string} job - the job or job ID that you want to delete + * @returns {Promise} A promise that resolves when the job is deleted. + */ +export async function deleteJob(session: AbstractSession, job: IJob | string): Promise { + if (typeof job === "string") { + job = await GetJobs.getJob(session, job); + } + await DeleteJobs.deleteJobForJob(session, job); +} + +/** + * Delete a job from the mainframe using Zowe SDKs - jobid, jobname + * @param {AbstractSession} session - z/OSMF connection info + * @param {params} ICommonJobParms - constains jobname and jobid for job to delete + * @returns {Promise} A promise that resolves when the job is deleted. + */ +export async function deleteJobCommon(session: AbstractSession, params: ICommonJobParms): Promise { + await DeleteJobs.deleteJobCommon(session, params as IDeleteJobParms); +} /** * This function strips any new lines out of the string passed. @@ -32,14 +106,14 @@ export function stripNewLines(str: string): string { * @param {string} hlq User specified high level qualify * @returns {string} A generated data set name */ -export function getUniqueDatasetName(hlq: string, encoded = false): string { +export function getUniqueDatasetName(hlq: string, encoded = false, maxNodes = 2): string { let generatedName: string = ""; const randomNumber = Math.random(); const timestampInMsNum = Date.now(); let timestampInMs = Math.floor(randomNumber * timestampInMsNum).toString(); let tempStr: string; const MAX_NODE_LENGTH = 7; - let MAX_NODES = 2; + let MAX_NODES = maxNodes; let currNodes = 0; if (encoded) {MAX_NODES = 1;} @@ -100,11 +174,13 @@ export async function getTag(session: AbstractSession, ussPath: string) { return response.stdout[0]; } -export function delay(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms) ); -} - -export const delTime = 500; +/** + * Pauses execution for a given number of milliseconds. + * @param {number} ms - Number of milliseconds to wait + * @returns {Promise} - Resolves after the specified time has passed + */ +export const wait = promisify(setTimeout); +export const waitTime = 2000; //wait 2 seconds /** * Use instead of `util.inspect` to get consistently formatted output that can be used in snapshots. diff --git a/__tests__/__src__/environment/ITestEnvironment.ts b/__tests__/__src__/environment/ITestEnvironment.ts new file mode 100644 index 0000000000..7424d5b4ac --- /dev/null +++ b/__tests__/__src__/environment/ITestEnvironment.ts @@ -0,0 +1,27 @@ +/* +* 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 { ITestEnvironment as IBaseTestEnvironment } from "../../__packages__/cli-test-utils/src/environment/doc/response/ITestEnvironment"; +import { ITestEnvironmentResources } from "./ITestEnvironmentResources"; + +/** + * The test environment for your test. + * @export + * @interface ITestEnvironment + */ +export interface ITestEnvironment extends IBaseTestEnvironment{ + /** + * A collection of resources used within the test environment that need to be cleaned up once test finishes. + * @type {ITestEnvironmentResources} + * @memberof ITestEnvironment + */ + resources?: ITestEnvironmentResources; +} \ No newline at end of file diff --git a/__tests__/__src__/environment/ITestEnvironmentResources.ts b/__tests__/__src__/environment/ITestEnvironmentResources.ts new file mode 100644 index 0000000000..756238096d --- /dev/null +++ b/__tests__/__src__/environment/ITestEnvironmentResources.ts @@ -0,0 +1,50 @@ +/* +* 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 { AbstractSession } from "@zowe/imperative"; +import { IJob } from "../../../packages/zosjobs"; + +/** + * Represents the resources used within the test environment. + * @export + * @interface ITestEnvironmentResources + */ +export interface ITestEnvironmentResources { + /** + * Array of local file paths used within the test environment. + * @type {string[]} + */ + localFiles: string[]; + + /** + * Array of mainframe uss files used within the test environment. + * @type {string[]} + */ + files: string[]; + + /** + * Array of job objects or job IDs representing jobs submitted to the mainframe during the test. + * @type {IJob[]} + */ + jobs: (IJob | string)[]; + + /** + * Array of dataset names used within the test environment. + * @type {string[]} + */ + datasets: string[]; + + /** + * The session used for interacting with z/OS systems during the test, if applicable. + * @type {AbstractSession} + */ + session?: AbstractSession; +} diff --git a/__tests__/__src__/environment/TestEnvironment.ts b/__tests__/__src__/environment/TestEnvironment.ts index ad81b91189..20c6b67aa1 100644 --- a/__tests__/__src__/environment/TestEnvironment.ts +++ b/__tests__/__src__/environment/TestEnvironment.ts @@ -11,11 +11,13 @@ import * as nodePath from "path"; -import { AbstractSession, Session } from "@zowe/imperative"; +import { AbstractSession, Imperative, ImperativeError, Session } from "@zowe/imperative"; import { ITestPropertiesSchema } from "../properties/ITestPropertiesSchema"; -import { ISetupEnvironmentParms, ITestEnvironment, TestEnvironment as BaseTestEnvironment } from "../../__packages__/cli-test-utils"; +import { ISetupEnvironmentParms, TestEnvironment as BaseTestEnvironment } from "../../__packages__/cli-test-utils"; +import { ITestEnvironment } from "./ITestEnvironment"; import { SshSession } from "../../../packages/zosuss/src/SshSession"; +import { deleteLocalFile, deleteFiles, deleteJob, deleteJobCommon, deleteDataset } from "../TestUtils"; /** * Use the utility methods here to setup the test environment for running APIs @@ -36,7 +38,7 @@ export class TestEnvironment extends BaseTestEnvironment { * @memberof TestEnvironment */ public static async setUp(params: ISetupEnvironmentParms): Promise> { - const result = await super.setUp(params); + const result: ITestEnvironment = await super.setUp(params); // Ensure correct path separator for windows or linux like systems. const separator = process.platform === "win32" ? ";" : ":"; @@ -45,11 +47,56 @@ export class TestEnvironment extends BaseTestEnvironment { nodePath.resolve(__dirname, "../../__resources__/application_instances"), process.env.PATH ].join(separator); - + result.resources = { + localFiles: [], + datasets: [], + files: [], + jobs: [], + session: params.skipProperties ? null : TestEnvironment.createZosmfSession(result) + }; // Return the test environment including working directory that the tests should be using return result; } + /** + * Clean up your test environment. + * Deletes any temporary profiles that have been created + * @params {ITestEnvironment} testEnvironment - the test environment returned by createTestEnv + * + * @returns {Promise} - promise fulfilled when cleanup is complete + * @throws errors if profiles fail to delete + * @memberof TestEnvironment + */ + public static async cleanUp(testEnvironment: ITestEnvironment) { + // Delete profiles and plugindir + await super.cleanUp(testEnvironment); + + // Deleting resources (if they exist) + if (testEnvironment?.resources?.session) { + const session = testEnvironment.resources.session; + for (const file of testEnvironment.resources.localFiles) { + deleteLocalFile(file); + } + for (const dataset of testEnvironment.resources.datasets) { + await deleteDataset(session, dataset); + } + for (const file of testEnvironment.resources.files) { + await deleteFiles(session, file); + } + for (const job of testEnvironment.resources.jobs) { + await deleteJob(session, job); + } + + testEnvironment.resources = { + localFiles: [], + datasets: [], + files: [], + jobs: [], + session: testEnvironment.resources.session + }; + } + } + /** * Create a ZOSMF session from properties present in your test environment * @param testEnvironment - your test environment with system test properties populated @@ -100,4 +147,4 @@ export class TestEnvironment extends BaseTestEnvironment { handshakeTimeout: defaultSystem.ssh.handshakeTimeout }); } -} +} \ No newline at end of file diff --git a/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts index 7f8a9e6b2f..46d2c78b12 100644 --- a/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/activeWorkflowDetails/cli.workflows.list.active.details.system.test.ts @@ -11,13 +11,14 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName, delay } from "../../../../../../../__tests__/__src__/TestUtils"; +import { getUniqueDatasetName, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { CreateWorkflow, DeleteWorkflow } from "@zowe/zos-workflows-for-zowe-sdk"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -29,7 +30,6 @@ let system: string; let owner: string; let wfName: string; const workflow = join(__dirname, "../../../../../../workflows/__tests__/__system__/testfiles/demo.xml"); -const delayTime = 2000; describe("List active workflow details cli system tests", () => { beforeAll(async () => { @@ -45,7 +45,7 @@ describe("List active workflow details cli system tests", () => { fakeDefFile = definitionFile + "fakefile"; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterAll(async () => { @@ -53,48 +53,29 @@ describe("List active workflow details cli system tests", () => { }); describe("Create workflow using uss file", () => { beforeAll(async () => { - let error; - // Upload files only for successful scenarios - try { - await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - await delay(delayTime); - } catch (err) { - error = err; - } + await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); + await wait(waitTime); //wait 2 seconds + testEnvironment.resources.files.push(definitionFile); // Create a workflow instance in zOS/MF to list const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds wfKey = response.workflowKey; }); afterAll(async () => { - let error; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } - // deleting wf instance const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { - wfKey = element.workflowKey; try { - await DeleteWorkflow.deleteWorkflow(REAL_SESSION, wfKey); - } catch (err) { - error = err; - } + await DeleteWorkflow.deleteWorkflow(REAL_SESSION, element.workflowKey); + } catch { /* Do nothing */ } } - }); + } }); describe("Success Scenarios", () => { - it("Should list active workflow details using wf key.", async () => { + it("Should list active workflow details using wf key.", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_key_details.sh", testEnvironment, [wfKey]); expect(response.stderr.toString()).toBe(""); @@ -102,7 +83,7 @@ describe("List active workflow details cli system tests", () => { expect(response.stdout.toString()).toContain("Workflow Details"); }); - it("Should list active workflow details using wf name.", async () => { + it("Should list active workflow details using wf name.", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_name_details.sh", testEnvironment, [wfName]); expect(response.stderr.toString()).toBe(""); @@ -111,14 +92,14 @@ describe("List active workflow details cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the workflow does not exist", async () => { + it("Should throw error if the workflow does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_key_details.sh", testEnvironment, [fakeDefFile]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("does not exist."); }); - it("Should throw error if the workflow name does not exist", async () => { + it("Should throw error if the workflow name does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/list_active_workflow_name_details.sh", testEnvironment, [fakeDefFile]); expect(response.status).toBe(1); diff --git a/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts index 2bacd0116d..7769bbc0cf 100644 --- a/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/activeWorkflows/cli.workflows.list.activeWorkflows.system.test.ts @@ -64,16 +64,16 @@ describe("List workflow cli system tests", () => { } }); describe("Success Scenarios", () => { - it("Should return list of workflows in zOSMF.", async () => { + it("Should return list of workflows in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", testEnvironment, [wfName]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(`${wfName}`); }); - it("Should return a message if search does not match any existing workflows", async () => { + it("Should return a message if search does not match any existing workflows", () => { const fakeName = `${wfName}${wfName}${wfName}`; - const response = await runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_list_workflow.sh", testEnvironment, [fakeName]); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("No workflows match the requested querry"); diff --git a/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts b/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts index d3020da689..67d2d79e0d 100644 --- a/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/List/retrieveWorkflowDefinition/cli.workflows.list.retrieveWorkflowDefinition.system.test.ts @@ -9,14 +9,14 @@ * */ -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -49,38 +49,26 @@ describe("Retrieve workflow definition cli system tests", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); describe("Success Scenarios", () => { - it("Should return the details of a workflow definition file.", async () => { + it("Should return the details of a workflow definition file.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [`/${defaultSystem.unix.testdir.toLocaleLowerCase()}/${uniqueFileName}.xml`]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(`success": true`); }); - it("Should return a message if search does not match any existing files", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", + it("Should return a message if search does not match any existing files", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [`/${defaultSystem.unix.testdir.toLocaleLowerCase()}/${uniqueFileName}`]); expect(response.status).toBe(1); expect(response.stdout.toString()).toContain("not found or cannot be accessed."); }); - it("Should return a message if search is for a diectory", async () => { + it("Should return a message if search is for a diectory", () => { const fakeName = `/${defaultSystem.unix.testdir.toLocaleLowerCase()}`; - const response = await runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_definition_file_details.sh", testEnvironment, [fakeName]); expect(response.status).toBe(1); expect(response.stdout.toString()).toContain("is not a UNIX file"); diff --git a/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts index db1762b2eb..7517ebed7b 100644 --- a/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/create/cli.workflows.create.common.system.test.ts @@ -11,13 +11,14 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { DeleteWorkflow } from "@zowe/zos-workflows-for-zowe-sdk"; -import { Upload, Create, CreateDataSetTypeEnum, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload, Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -57,25 +58,13 @@ describe("Create workflow cli system tests", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); describe("Success Scenarios", () => { afterEach(async () => { let error; const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { wfKey = element.workflowKey; try { @@ -84,25 +73,25 @@ describe("Create workflow cli system tests", () => { error = err; } } - }); + } }); - it("Should create workflow in zOSMF.", async () => { + it("Should create workflow in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", + it("Should throw error if workflow with the same name already exists", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, definitionFile, system, owner, "--overwrite"]); @@ -112,7 +101,7 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the uss file does not exist", async () => { + it("Should throw error if the uss file does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_uss.sh", testEnvironment, [wfName, fakeDefFile, system, owner]); expect(response.status).toBe(1); @@ -124,7 +113,7 @@ describe("Create workflow cli system tests", () => { describe("Success Scenarios", () => { afterEach(async () =>{ let error; - const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); + const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); let deleteWorkflow: any; for (deleteWorkflow of response.workflows) { if(deleteWorkflow.workflowName===wfName){ @@ -137,25 +126,25 @@ describe("Create workflow cli system tests", () => { } } }); - it("Should create workflow in zOSMF.", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should create workflow in zOSMF.", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should throw error if workflow with the same name already exists", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner]); - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, workflow, system, owner, "--overwrite"]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); @@ -163,8 +152,8 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the local file does not exist", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", + it("Should throw error if the local file does not exist", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_local_file.sh", testEnvironment, [wfName, fakeLocalFile, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("no such file or directory"); @@ -184,26 +173,13 @@ describe("Create workflow cli system tests", () => { error = err; } await Upload.fileToDataset(REAL_SESSION, workflowDs, definitionDs); - - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + "/" + definitionDs; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.datasets.push(definitionDs); }); describe("Success Scenarios", () => { afterEach(async () => { let error; const response: any = await ZosmfRestClient.getExpectJSON(REAL_SESSION, "/zosmf/workflow/rest/1.0/workflows?workflowName=" + wfName); - response.workflows.forEach(async (element: any) => { + for (const element of response.workflows) { if (element.workflowName === wfName) { wfKey = element.workflowKey; try { @@ -212,25 +188,25 @@ describe("Create workflow cli system tests", () => { error = err; } } - }); + } }); - it("Should create workflow in zOSMF.", async () => { + it("Should create workflow in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("workflowKey"); }); - it("Should throw error if workflow with the same name already exists", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", + it("Should throw error if workflow with the same name already exists", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("already exists."); }); - it("Should not throw error if workflow with the same name already exists and there is overwrite", async () => { - const createWf = await runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", + it("Should not throw error if workflow with the same name already exists and there is overwrite", () => { + runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner]); const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, definitionDs, system, owner, "--overwrite"]); @@ -240,7 +216,7 @@ describe("Create workflow cli system tests", () => { }); }); describe("Failure Scenarios", () => { - it("Should throw error if the dataset does not exist", async () => { + it("Should throw error if the dataset does not exist", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_create_workflow_ds.sh", testEnvironment, [wfName, fakeDefFile, system, owner]); expect(response.status).toBe(1); diff --git a/packages/cli/__tests__/workflows/__system__/delete/cli.workflows.delete.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/delete/cli.workflows.delete.common.system.test.ts index 72bb9d25af..76ffabce59 100644 --- a/packages/cli/__tests__/workflows/__system__/delete/cli.workflows.delete.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/delete/cli.workflows.delete.common.system.test.ts @@ -9,15 +9,15 @@ * */ -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; +import { deleteFiles, getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { CreateWorkflow } from "@zowe/zos-workflows-for-zowe-sdk"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -56,17 +56,7 @@ describe("Delete workflow cli system tests", () => { await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true}); }); afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); @@ -108,17 +98,7 @@ describe("Delete workflow cli system tests", () => { await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); }); afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, definitionFile); }); beforeEach(async () => { await CreateWorkflow.createWorkflow(REAL_SESSION, wfName + "a", definitionFile, system, owner); diff --git a/packages/cli/__tests__/workflows/__system__/deleteArchived/cli.workflows.delete.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/deleteArchived/cli.workflows.delete.common.system.test.ts index e08ec69fa4..240b2ffcfe 100644 --- a/packages/cli/__tests__/workflows/__system__/deleteArchived/cli.workflows.delete.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/deleteArchived/cli.workflows.delete.common.system.test.ts @@ -9,15 +9,15 @@ * */ -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { ArchiveWorkflow, CreateWorkflow } from "@zowe/zos-workflows-for-zowe-sdk"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -54,19 +54,7 @@ describe("Delete workflow cli system tests", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts b/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts index ba3664273e..699a9d2e84 100644 --- a/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts +++ b/packages/cli/__tests__/workflows/__system__/start/cli.workflows.start.common.system.test.ts @@ -9,16 +9,16 @@ * */ -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Session, Imperative } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; import { CreateWorkflow, PropertiesWorkflow, DeleteWorkflow, startT, IWorkflowInfo, WorkflowConstants, IStepInfo } from "@zowe/zos-workflows-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; const resolveConflict: startT = "outputFileValue"; const stepName = "echo"; @@ -56,19 +56,7 @@ describe("Start workflow cli system tests", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); describe("Success Scenarios", () => { afterEach(async () => { @@ -97,42 +85,42 @@ describe("Start workflow cli system tests", () => { Imperative.console.info(err); } }); - it("Should start full workflow using wf key in zOSMF.", async () => { + it("Should start full workflow using wf key in zOSMF.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_full.sh", testEnvironment, [wfKey, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow"); }); - it("Should start full workflow using wf Name in zOSMF.", async () => { - const response = await runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_full.sh", + it("Should start full workflow using wf Name in zOSMF.", () => { + const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_full.sh", testEnvironment, [wfName, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow"); }); - it("Should start one workflow using wf Key and step.", async () => { + it("Should start one workflow using wf Key and step.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_step.sh", testEnvironment, [stepName, wfKey, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow using wf Name and step.", async () => { + it("Should start one workflow using wf Name and step.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_step.sh", testEnvironment, [stepName, wfName, resolveConflict]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow step using wf Key.", async () => { + it("Should start one workflow step using wf Key.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_key_step_plus_following.sh", testEnvironment, [stepName, wfKey, resolveConflict, "--perform-following-steps"]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Workflow step started."); }); - it("Should start one workflow step using wf Name.", async () => { + it("Should start one workflow step using wf Name.", () => { const response = runCliScript(__dirname + "/__scripts__/command/command_start_workflow_name_step_plus_following.sh", testEnvironment, [stepName, wfName, resolveConflict, "--perform-following-steps"]); expect(response.stderr.toString()).toBe(""); diff --git a/packages/cli/__tests__/zosfiles/__system__/compare/ds/Compare.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/compare/ds/Compare.ds.system.test.ts index 5b0060e0cc..03394dea43 100644 --- a/packages/cli/__tests__/zosfiles/__system__/compare/ds/Compare.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/compare/ds/Compare.ds.system.test.ts @@ -12,10 +12,11 @@ import { Session } from "@zowe/imperative"; import { Create, Delete, CreateDataSetTypeEnum, Upload } from "@zowe/cli"; import * as path from "path"; -import {ITestEnvironment, runCliScript} from "@zowe/cli-test-utils"; -import {TestEnvironment} from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; -import {ITestPropertiesSchema} from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName} from "../../../../../../../__tests__/__src__/TestUtils"; +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 { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/copy/ds/cli.files.copy.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/copy/ds/cli.files.copy.ds.system.test.ts index 35a866c9c0..402ae9571c 100644 --- a/packages/cli/__tests__/zosfiles/__system__/copy/ds/cli.files.copy.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/copy/ds/cli.files.copy.ds.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; 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 { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/copy/dsclp/cli.files.copy.dsclp.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/copy/dsclp/cli.files.copy.dsclp.system.test.ts index 8e4b753aec..07967beefc 100644 --- a/packages/cli/__tests__/zosfiles/__system__/copy/dsclp/cli.files.copy.dsclp.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/copy/dsclp/cli.files.copy.dsclp.system.test.ts @@ -10,12 +10,13 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; -import { getRandomBytes } from "../../../../../../../__tests__/__src__/TestUtils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Delete, Create, ICreateDataSetOptions, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; +import { getRandomBytes } from "../../../../../../../__tests__/__src__/TestUtils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/create/binaryPds/cli.files.create.dataset.binary.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/binaryPds/cli.files.create.dataset.binary.system.test.ts index 0c525a387c..14fa3b10e6 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/binaryPds/cli.files.create.dataset.binary.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/binaryPds/cli.files.create.dataset.binary.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -67,7 +68,7 @@ describe("Create Binary Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); @@ -102,7 +103,7 @@ describe("Create Binary Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/cPds/cli.files.create.dataset.c.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/cPds/cli.files.create.dataset.c.system.test.ts index c0293ac07f..051aee635c 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/cPds/cli.files.create.dataset.c.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/cPds/cli.files.create.dataset.c.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -67,7 +68,7 @@ describe("Create C Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); @@ -103,7 +104,7 @@ describe("Create C Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/classicPds/cli.files.create.dataset.classic.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/classicPds/cli.files.create.dataset.classic.system.test.ts index 25f97d3c21..8834fd3be8 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/classicPds/cli.files.create.dataset.classic.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/classicPds/cli.files.create.dataset.classic.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -67,7 +68,7 @@ describe("Create Classic Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); @@ -103,7 +104,7 @@ describe("Create Classic Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/ds/cli.files.create.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/ds/cli.files.create.ds.system.test.ts index 51df7e2d96..5f532ced13 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/ds/cli.files.create.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/ds/cli.files.create.ds.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -60,7 +61,7 @@ describe("Create Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/pds/cli.files.create.dataset.pds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/pds/cli.files.create.dataset.pds.system.test.ts index e550311677..3ceea68fd3 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/pds/cli.files.create.dataset.pds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/pds/cli.files.create.dataset.pds.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { stripNewLines, delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { stripNewLines, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -68,7 +69,7 @@ describe("Create Partitioned Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); @@ -104,7 +105,7 @@ describe("Create Partitioned Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/ps/cli.files.create.dataset.ps.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/ps/cli.files.create.dataset.ps.system.test.ts index 71d3b1fd80..03292e6a16 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/ps/cli.files.create.dataset.ps.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/ps/cli.files.create.dataset.ps.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { stripNewLines, delay, delTime } from "../../../../../../../__tests__/__src__/TestUtils"; +import { stripNewLines, wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -68,7 +69,7 @@ describe("Create Physical Sequential Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); @@ -104,7 +105,7 @@ describe("Create Physical Sequential Data Set", () => { afterEach(async () => { // use DELETE APIs if (dsnameSuffix !== "") { - await delay(delTime); + await wait(waitTime); //wait 2 seconds const response = await Delete.dataSet(REAL_SESSION, dsname + "." + dsnameSuffix); } }); diff --git a/packages/cli/__tests__/zosfiles/__system__/create/ussDir/cli.files.create.uss.dir.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/ussDir/cli.files.create.uss.dir.system.test.ts index c0a4a6c66d..52aa7d6789 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/ussDir/cli.files.create.uss.dir.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/ussDir/cli.files.create.uss.dir.system.test.ts @@ -10,10 +10,11 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; diff --git a/packages/cli/__tests__/zosfiles/__system__/create/ussFile/cli.files.create.uss.file.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/ussFile/cli.files.create.uss.file.system.test.ts index b8a656f828..a20b58bac1 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/ussFile/cli.files.create.uss.file.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/ussFile/cli.files.create.uss.file.system.test.ts @@ -10,10 +10,11 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; diff --git a/packages/cli/__tests__/zosfiles/__system__/create/vsam/cli.files.create.dataset.vsam.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/vsam/cli.files.create.dataset.vsam.system.test.ts index 688e3bb6bf..f4780a1079 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/vsam/cli.files.create.dataset.vsam.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/vsam/cli.files.create.dataset.vsam.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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 { Delete, IDeleteVsamOptions } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; diff --git a/packages/cli/__tests__/zosfiles/__system__/create/zfs/cli.files.create.zfs.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/create/zfs/cli.files.create.zfs.system.test.ts index ee69a0155f..33095b9af8 100644 --- a/packages/cli/__tests__/zosfiles/__system__/create/zfs/cli.files.create.zfs.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/create/zfs/cli.files.create.zfs.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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 { Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts index 969016086a..19a5dd259b 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/ds/cli.files.delete.ds.system.test.ts @@ -10,9 +10,10 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/mds/cli.files.delete.mds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/mds/cli.files.delete.mds.system.test.ts index 74661c9039..319c2eaa85 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/mds/cli.files.delete.mds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/mds/cli.files.delete.mds.system.test.ts @@ -9,9 +9,10 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; import { join } from "path"; import { Session, Imperative } from "@zowe/imperative"; import { inspect } from "util"; diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.directory.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.directory.system.test.ts index 3b57f25dbe..e002720dad 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.directory.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.directory.system.test.ts @@ -12,9 +12,10 @@ import { Imperative, Session } from "@zowe/imperative"; import { Create } from "@zowe/zos-files-for-zowe-sdk"; import { inspect } from "util"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts index c921bd5e0d..7b01434797 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/uss/cli.files.delete.file.system.test.ts @@ -12,9 +12,10 @@ import { Imperative, Session } from "@zowe/imperative"; import { Create } from "@zowe/zos-files-for-zowe-sdk"; import { inspect } from "util"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts index e65d1024c5..b8207771b7 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/vsam/cli.files.delete.vsam.system.test.ts @@ -10,10 +10,11 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName, stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts index 08f9250bb7..a8df1eed3e 100644 --- a/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/delete/zfs/cli.files.delete.zfs.system.test.ts @@ -10,10 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName, stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; + const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; diff --git a/packages/cli/__tests__/zosfiles/__system__/download/am/cli.files.download.am.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/download/am/cli.files.download.am.system.test.ts index b7a71e0c8f..6ea4e5eccb 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/am/cli.files.download.am.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/download/am/cli.files.download.am.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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(); diff --git a/packages/cli/__tests__/zosfiles/__system__/download/ds/cli.files.download.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/download/ds/cli.files.download.ds.system.test.ts index aa8d5a65b5..ee9152a0f9 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/ds/cli.files.download.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/download/ds/cli.files.download.ds.system.test.ts @@ -11,11 +11,12 @@ import { IO, Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getRandomBytes, 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(); diff --git a/packages/cli/__tests__/zosfiles/__system__/download/dsm/cli.files.download.dsm.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/download/dsm/cli.files.download.dsm.system.test.ts index ca1d9b381d..9c6f1b1963 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/dsm/cli.files.download.dsm.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/download/dsm/cli.files.download.dsm.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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(); diff --git a/packages/cli/__tests__/zosfiles/__system__/download/uss/cli.files.download.uss.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/download/uss/cli.files.download.uss.system.test.ts index f5152a178e..89f97840a5 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/uss/cli.files.download.uss.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/download/uss/cli.files.download.uss.system.test.ts @@ -11,12 +11,12 @@ import { Imperative, Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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 { ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { deleteFiles, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { 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(); @@ -59,32 +59,11 @@ describe("Download USS File", () => { defaultSys = TEST_ENVIRONMENT_NO_PROF.systemTestProperties; const data: string = "abcdefghijklmnopqrstuvwxyz"; - const endpoint: string = - ZosFilesConstants.RESOURCE + - ZosFilesConstants.RES_USS_FILES + - ussname; - await ZosmfRestClient.putExpectString( - REAL_SESSION, - endpoint, - [], - data - ); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); }); afterAll(async () => { - const endpoint: string = - ZosFilesConstants.RESOURCE + - ZosFilesConstants.RES_USS_FILES + - ussname; - - try { - await ZosmfRestClient.deleteExpectString( - REAL_SESSION, - endpoint - ); - } catch (err) { - Imperative.console.error(err); - } + await deleteFiles(REAL_SESSION, ussname); await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); @@ -128,32 +107,11 @@ describe("Download USS File", () => { describe("Success scenarios", () => { beforeAll(async () => { const data: string = "abcdefghijklmnopqrstuvwxyz"; - const endpoint: string = - ZosFilesConstants.RESOURCE + - ZosFilesConstants.RES_USS_FILES + - ussname; - await ZosmfRestClient.putExpectString( - REAL_SESSION, - endpoint, - [], - data - ); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); }); afterAll(async () => { - const endpoint: string = - ZosFilesConstants.RESOURCE + - ZosFilesConstants.RES_USS_FILES + - ussname; - - try { - await ZosmfRestClient.deleteExpectString( - REAL_SESSION, - endpoint - ); - } catch (err) { - Imperative.console.error(err); - } + await deleteFiles(REAL_SESSION, ussname); }); it("should download an uss file", () => { diff --git a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/cli.files.download.ussdir.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/cli.files.download.ussdir.system.test.ts index 17ceb6a81e..10ae9227dd 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/cli.files.download.ussdir.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/cli.files.download.ussdir.system.test.ts @@ -12,11 +12,12 @@ import { Imperative, Session } from "@zowe/imperative"; import * as path from "path"; import * as fs from "fs"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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, 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(); diff --git a/packages/cli/__tests__/zosfiles/__system__/edit/ds/Edit.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/edit/ds/Edit.ds.system.test.ts index d73276c77b..6fd09a4870 100644 --- a/packages/cli/__tests__/zosfiles/__system__/edit/ds/Edit.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/edit/ds/Edit.ds.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; 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; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/edit/uss/Edit.uss.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/edit/uss/Edit.uss.system.test.ts index 1f998b430a..4669ecf402 100644 --- a/packages/cli/__tests__/zosfiles/__system__/edit/uss/Edit.uss.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/edit/uss/Edit.uss.system.test.ts @@ -12,11 +12,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import {ITestEnvironment, runCliScript} from "@zowe/cli-test-utils"; -import {TestEnvironment} from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; -import {ITestPropertiesSchema} from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName} from "../../../../../../../__tests__/__src__/TestUtils"; +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, Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/hMigrate/ds/cli.files.HMigrate.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/hMigrate/ds/cli.files.HMigrate.ds.system.test.ts index 05ca6ce91f..ad7d12503f 100644 --- a/packages/cli/__tests__/zosfiles/__system__/hMigrate/ds/cli.files.HMigrate.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/hMigrate/ds/cli.files.HMigrate.ds.system.test.ts @@ -9,9 +9,10 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; import { join } from "path"; import { Session, Imperative } from "@zowe/imperative"; import { List, Delete, Create, CreateDataSetTypeEnum, IListOptions, IMigrateOptions } from "@zowe/zos-files-for-zowe-sdk"; diff --git a/packages/cli/__tests__/zosfiles/__system__/hRecall/ds/cli.files.HRecall.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/hRecall/ds/cli.files.HRecall.ds.system.test.ts index 216a3091f9..d3ce7cfc06 100644 --- a/packages/cli/__tests__/zosfiles/__system__/hRecall/ds/cli.files.HRecall.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/hRecall/ds/cli.files.HRecall.ds.system.test.ts @@ -9,9 +9,10 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; import { join } from "path"; import { Session, Imperative } from "@zowe/imperative"; import { List, Delete, Create, CreateDataSetTypeEnum, IListOptions, IRecallOptions, HMigrate } from "@zowe/zos-files-for-zowe-sdk"; diff --git a/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts index 6e73a2a6f7..dfaa85ddd0 100644 --- a/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/invoke/amsFile/cli.files.invoke.amsFile.system.test.ts @@ -11,11 +11,12 @@ import * as fs from "fs"; import { Session, TextUtils } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName, stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; import { ZosFilesMessages } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); @@ -27,12 +28,16 @@ let volume: string; describe("Invoke AMS CLI", () => { - function createTestAMSStatementFileFromTemplate(templateFile: string, dsname?: string) { + function createTestAMSStatementFileFromTemplate(templateFile: string, testEnvironment: ITestEnvironment, dsname?: string) { // replace high-level-qualifier with user value const AMSStatement = fs.readFileSync(templateFile).toString(); const updatedStatement = TextUtils.renderWithMustache(AMSStatement, {DSN: dsname, VOL: volume}); - fs.writeFileSync(templateFile + ".temp", updatedStatement); - return templateFile + ".temp"; + const filename = templateFile + ".temp"; + fs.writeFileSync(filename, updatedStatement); + if (!testEnvironment.resources.localFiles.includes(filename)) { + testEnvironment.resources.localFiles.push(filename); + } + return filename; } // Create the unique test environment @@ -80,7 +85,7 @@ describe("Invoke AMS CLI", () => { // create a temporary file from the template file that has the proper high level qualifier to create the VSAM file let controlStatementFile: string = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DefineVSAM.ams", - dsname); + TEST_ENVIRONMENT_NO_PROF, dsname); const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -102,13 +107,10 @@ describe("Invoke AMS CLI", () => { let testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DeleteVSAM.ams", - dsname); + TEST_ENVIRONMENT_NO_PROF, dsname); response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_file_fully_qualified.sh", TEST_ENVIRONMENT_NO_PROF, @@ -121,9 +123,6 @@ describe("Invoke AMS CLI", () => { expect(response.status).toBe(0); testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); }); @@ -135,7 +134,7 @@ describe("Invoke AMS CLI", () => { // create a temporary file from the template file that has the proper high level qualifier to create the VSAM file let controlStatementFile: string = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DefineVSAM.ams", - dsname); + TEST_ENVIRONMENT, dsname); let response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_file.sh", TEST_ENVIRONMENT, [controlStatementFile]); @@ -144,13 +143,10 @@ describe("Invoke AMS CLI", () => { let testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DeleteVSAM.ams", - dsname); + TEST_ENVIRONMENT, dsname); response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_file.sh", TEST_ENVIRONMENT, [controlStatementFile]); @@ -158,9 +154,6 @@ describe("Invoke AMS CLI", () => { expect(response.status).toBe(0); testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); it("should invoke ams to create and then delete a VSAM cluster using files with response timeout", async () => { const dsname = getUniqueDatasetName(defaultSystem.zosmf.user); @@ -168,7 +161,7 @@ describe("Invoke AMS CLI", () => { // create a temporary file from the template file that has the proper high level qualifier to create the VSAM file let controlStatementFile: string = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DefineVSAM.ams", - dsname); + TEST_ENVIRONMENT, dsname); let response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_file.sh", TEST_ENVIRONMENT, [controlStatementFile, "--responseTimeout 5"]); @@ -177,13 +170,10 @@ describe("Invoke AMS CLI", () => { let testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate( process.cwd() + "/packages/zosfiles/__tests__/__system__/methods/invoke/DeleteVSAM.ams", - dsname); + TEST_ENVIRONMENT, dsname); response = runCliScript(__dirname + "/__scripts__/command/command_invoke_ams_file.sh", TEST_ENVIRONMENT, [controlStatementFile, "--responseTimeout 5"]); @@ -191,9 +181,6 @@ describe("Invoke AMS CLI", () => { expect(response.status).toBe(0); testOutput = stripNewLines(response.stdout.toString()); expect(testOutput).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); }); diff --git a/packages/cli/__tests__/zosfiles/__system__/invoke/amsStatements/cli.files.invoke.amsStatements.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/invoke/amsStatements/cli.files.invoke.amsStatements.system.test.ts index edab1ab4cc..3ff350298f 100644 --- a/packages/cli/__tests__/zosfiles/__system__/invoke/amsStatements/cli.files.invoke.amsStatements.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/invoke/amsStatements/cli.files.invoke.amsStatements.system.test.ts @@ -10,11 +10,12 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; import { ZosFilesMessages } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/list/am/cli.files.list.am.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/list/am/cli.files.list.am.system.test.ts index 7e9637b099..a0f5cb4496 100644 --- a/packages/cli/__tests__/zosfiles/__system__/list/am/cli.files.list.am.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/list/am/cli.files.list.am.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; import { Create, CreateDataSetTypeEnum, Upload, Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/list/ds/cli.files.list.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/list/ds/cli.files.list.ds.system.test.ts index e8b463e90a..b3755750a5 100644 --- a/packages/cli/__tests__/zosfiles/__system__/list/ds/cli.files.list.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/list/ds/cli.files.list.ds.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; import { Create, CreateDataSetTypeEnum, Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/list/fs/cli.files.list.fs.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/list/fs/cli.files.list.fs.system.test.ts index ea5a4d9812..37bac544c6 100644 --- a/packages/cli/__tests__/zosfiles/__system__/list/fs/cli.files.list.fs.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/list/fs/cli.files.list.fs.system.test.ts @@ -11,10 +11,11 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/list/uss/cli.files.list.uss.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/list/uss/cli.files.list.uss.system.test.ts index 5233d00855..0220397b41 100644 --- a/packages/cli/__tests__/zosfiles/__system__/list/uss/cli.files.list.uss.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/list/uss/cli.files.list.uss.system.test.ts @@ -12,9 +12,10 @@ import { Imperative, Session } from "@zowe/imperative"; import * as path from "path"; import { inspect } from "util"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; import { Delete, Create } from "@zowe/zos-files-for-zowe-sdk"; let REAL_SESSION: Session; diff --git a/packages/cli/__tests__/zosfiles/__system__/mount/fs/__scripts__/command/command_teardown.sh b/packages/cli/__tests__/zosfiles/__system__/mount/fs/__scripts__/command/command_teardown.sh index 859ea282c2..ae9cad8fa5 100755 --- a/packages/cli/__tests__/zosfiles/__system__/mount/fs/__scripts__/command/command_teardown.sh +++ b/packages/cli/__tests__/zosfiles/__system__/mount/fs/__scripts__/command/command_teardown.sh @@ -15,5 +15,5 @@ then fi echo "================Z/OS FILES DELETE ZOS-FILE-SYSTEM===============" -zowe zos-files delete zos-file-system "$fsn" +zowe zos-files delete zos-file-system "$fsn" -f exit $? diff --git a/packages/cli/__tests__/zosfiles/__system__/mount/fs/cli.files.mount.fs.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/mount/fs/cli.files.mount.fs.system.test.ts index 705c181e88..20ec011b99 100644 --- a/packages/cli/__tests__/zosfiles/__system__/mount/fs/cli.files.mount.fs.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/mount/fs/cli.files.mount.fs.system.test.ts @@ -1,3 +1,4 @@ + /* * 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 @@ -10,10 +11,11 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -45,7 +47,7 @@ describe("Mount and unmount file system", () => { mountPoint = "//tmp/" + dirname; const sshCommand = "mkdir " + mountPoint; - const response = runCliScript(__dirname + "/__scripts__/command/command_setup.sh", + runCliScript(__dirname + "/__scripts__/command/command_setup.sh", TEST_ENVIRONMENT, [sshCommand, fsname, defaultSystem.ssh.host, defaultSystem.ssh.port, @@ -55,7 +57,7 @@ describe("Mount and unmount file system", () => { afterAll(async () => { const sshCommand = "rmdir " + mountPoint; - const response = runCliScript(__dirname + "/__scripts__/command/command_teardown.sh", + runCliScript(__dirname + "/__scripts__/command/command_teardown.sh", TEST_ENVIRONMENT, [sshCommand, fsname, defaultSystem.ssh.host, defaultSystem.ssh.port, diff --git a/packages/cli/__tests__/zosfiles/__system__/rename/ds/cli.files.rename.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/rename/ds/cli.files.rename.ds.system.test.ts index 01b5c75224..f6b764eae2 100644 --- a/packages/cli/__tests__/zosfiles/__system__/rename/ds/cli.files.rename.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/rename/ds/cli.files.rename.ds.system.test.ts @@ -10,12 +10,13 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete, Create, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; @@ -24,7 +25,6 @@ let beforeDataSetName: string; let afterDataSetName: string; let user: string; const memberName = "mem"; -const delayTime = 2000; describe("Rename data set", () => { beforeAll(async () => { @@ -67,7 +67,7 @@ describe("Rename data set", () => { TEST_ENVIRONMENT, [beforeDataSetName, afterDataSetName] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, afterDataSetName); } catch(err) { error = err; @@ -89,7 +89,7 @@ describe("Rename data set", () => { TEST_ENVIRONMENT, [beforeDataSetName, afterDataSetName, "--responseTimeout 5"] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, afterDataSetName); } catch(err) { error = err; @@ -117,7 +117,7 @@ describe("Rename data set", () => { TEST_ENVIRONMENT, [beforeDataSetName, afterDataSetName] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, `${afterDataSetName}(${memberName})`); } catch(err) { error = err; @@ -139,7 +139,7 @@ describe("Rename data set", () => { TEST_ENVIRONMENT, [beforeDataSetName, afterDataSetName, "--responseTimeout 5"] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, `${afterDataSetName}(${memberName})`); } catch(err) { error = err; diff --git a/packages/cli/__tests__/zosfiles/__system__/rename/dsm/cli.files.rename.dsm.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/rename/dsm/cli.files.rename.dsm.system.test.ts index ac4184fca8..2996df596e 100644 --- a/packages/cli/__tests__/zosfiles/__system__/rename/dsm/cli.files.rename.dsm.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/rename/dsm/cli.files.rename.dsm.system.test.ts @@ -10,12 +10,13 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { delay } from "../../../../../../../__tests__/__src__/TestUtils"; +import { wait, waitTime } from "../../../../../../../__tests__/__src__/TestUtils"; import { Delete, Create, CreateDataSetTypeEnum, Upload, Get } from "@zowe/zos-files-for-zowe-sdk"; import { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; @@ -24,7 +25,6 @@ let dataSetName: string; let user: string; const beforeMemberName = "mem1"; const afterMemberName = "mem2"; -const delayTime = 2000; describe("Rename data set member", () => { beforeAll(async () => { @@ -61,7 +61,7 @@ describe("Rename data set member", () => { TEST_ENVIRONMENT, [dataSetName, beforeMemberName, afterMemberName] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, `${dataSetName}(${afterMemberName})`); } catch(err) { error = err; @@ -83,7 +83,7 @@ describe("Rename data set member", () => { TEST_ENVIRONMENT, [dataSetName, beforeMemberName, afterMemberName, "--responseTimeout 5"] ); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds contents = await Get.dataSet(REAL_SESSION, `${dataSetName}(${afterMemberName})`); } catch(err) { error = err; diff --git a/packages/cli/__tests__/zosfiles/__system__/search/ds/cli.files.search.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/search/ds/cli.files.search.ds.system.test.ts index c12d37f735..dbe4bf7144 100644 --- a/packages/cli/__tests__/zosfiles/__system__/search/ds/cli.files.search.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/search/ds/cli.files.search.ds.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; 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(); diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/dtp/cli.files.upload.dtp.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/dtp/cli.files.upload.dtp.system.test.ts index a67d0d5602..9c98337b4e 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/dtp/cli.files.upload.dtp.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/dtp/cli.files.upload.dtp.system.test.ts @@ -11,11 +11,12 @@ import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; import { Create, CreateDataSetTypeEnum, Delete, ZosFilesMessages } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts index 7f666208d2..1b44460015 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/dtu/cli.dir.upload.dtu.system.test.ts @@ -12,15 +12,14 @@ import { Imperative, Session } from "@zowe/imperative"; import * as path from "path"; import * as fs from "fs"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName, getTag } from "../../../../../../../__tests__/__src__/TestUtils"; -import { Get, ZosFilesConstants, ZosFilesUtils } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { deleteFiles, getTag, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { Get, ZosFilesUtils } 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; let TEST_ENVIRONMENT_NO_PROF: ITestEnvironment; let defaultSystem: ITestPropertiesSchema; @@ -34,7 +33,6 @@ let dsname: string; describe("Upload directory to USS", () => { beforeAll(async () => { - TEST_ENVIRONMENT = await TestEnvironment.setUp({ tempProfileTypes: ["zosmf"], testName: "zos_files_upload_directory_to_uss_with_profile" @@ -59,7 +57,6 @@ describe("Upload directory to USS", () => { describe("without profiles", () => { let defaultSys: ITestPropertiesSchema; - // Create the unique test environment beforeAll(async () => { TEST_ENVIRONMENT_NO_PROF = await TestEnvironment.setUp({ testName: "upload_dir_to_uss" @@ -71,16 +68,7 @@ describe("Upload directory to USS", () => { }); 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; - } + await deleteFiles(REAL_SESSION, ussname); }); afterAll(async () => { @@ -93,7 +81,7 @@ describe("Upload directory to USS", () => { const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; - // if API Mediation layer is being used (basePath has a value) then + // 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; @@ -117,16 +105,7 @@ describe("Upload directory to USS", () => { 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; - } + await deleteFiles(REAL_SESSION, ussname); }); it("should upload local directory to USS directory", async () => { @@ -227,13 +206,7 @@ describe("Upload directory to USS", () => { ussname ]); - - // const downloadResponse = await Download.ussFile(REAL_SESSION, path.posix.join(ussname, "bin_file.pax"), { file: localFileLocation }); - // expect(downloadResponse.success).toBe(true); - // // fs.readFileSync(localFileLocation).toString(); returns an empty buffer ???? Getting the file directly seems to work consistently - // const downloadedFileContents = fs.readFileSync(localFileLocation).toString(); - - const downloadedFileContents = (await Get.USSFile(REAL_SESSION, path.posix.join(ussname, "bin_file.pax"), {binary: false})).toString(); + const downloadedFileContents = (await Get.USSFile(REAL_SESSION, path.posix.join(ussname, "bin_file.pax"), { binary: false })).toString(); expect(downloadedFileContents).toContain("00000000125"); expect(downloadedFileContents).toContain("13424013123"); expect(response.stderr.toString()).not.toContain("Rest API failure with HTTP(S) status 500"); @@ -287,6 +260,10 @@ describe("Upload directory to USS", () => { }); describe("Scenarios using the .zosattributes file", () => { + afterEach(async () => { + await deleteFiles(REAL_SESSION, ussname); + }); + it("should ignore files marked with a -", async () => { const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir/dir_with_ignored_files"); testSuccessfulUpload(localDirName); @@ -310,14 +287,13 @@ describe("Upload directory to USS", () => { expect(err).toBeDefined(); } - let tag = await getTag(REAL_SESSION,ussname + "/I%20have%20a%20space.txt"); + let tag = await getTag(REAL_SESSION, ussname + "/I%20have%20a%20space.txt"); expect(tag).toMatch("t IBM-1140"); - tag = await getTag(REAL_SESSION,ussname + "/dir_with%20spaces/file%20withSpaceinName.txt"); + tag = await getTag(REAL_SESSION, ussname + "/dir_with%20spaces/file%20withSpaceinName.txt"); expect(tag).toMatch("t IBM-1140"); }); - it("should upload files in binary or text as indicated", async () => { const localDirName = path.join(__dirname, "__data__", "command_upload_dtu_dir/dir_with_mixed_files"); @@ -328,7 +304,7 @@ describe("Upload directory to USS", () => { expect(ZosFilesUtils.normalizeNewline(remoteTextFileBuffer)).toEqual(ZosFilesUtils.normalizeNewline(localTextFileBuffer)); - const remoteBinaryFileBuffer = await Get.USSFile(REAL_SESSION, ussname + "/bar.binary", {binary: true}); + const remoteBinaryFileBuffer = await Get.USSFile(REAL_SESSION, ussname + "/bar.binary", { binary: true }); const localBinaryFileBuffer = fs.readFileSync(path.join(localDirName, "bar.binary")); expect(remoteBinaryFileBuffer).toEqual(localBinaryFileBuffer); }); @@ -338,13 +314,13 @@ describe("Upload directory to USS", () => { testSuccessfulUpload(localDirName); - let tag = await getTag(REAL_SESSION,ussname + "/baz.asciitext"); + let tag = await getTag(REAL_SESSION, ussname + "/baz.asciitext"); expect(tag).toMatch("t ISO8859-1"); - tag = await getTag(REAL_SESSION,ussname + "/foo.text"); + tag = await getTag(REAL_SESSION, ussname + "/foo.text"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/bar.binary"); + tag = await getTag(REAL_SESSION, ussname + "/bar.binary"); expect(tag).toMatch("b binary"); }); @@ -353,10 +329,10 @@ describe("Upload directory to USS", () => { testSuccessfulUpload(localDirName, ["--include-hidden"]); - let tag = await getTag(REAL_SESSION,ussname + "/.project"); + let tag = await getTag(REAL_SESSION, ussname + "/.project"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/.hidden"); + tag = await getTag(REAL_SESSION, ussname + "/.hidden"); expect(tag).toMatch("b binary"); }); @@ -399,31 +375,31 @@ describe("Upload directory to USS", () => { testSuccessfulUpload(localDirName, ["--recursive --binary"]); - let tag = await getTag(REAL_SESSION,ussname + "/piccpy.png"); + let tag = await getTag(REAL_SESSION, ussname + "/piccpy.png"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/picCopyMe.png"); + tag = await getTag(REAL_SESSION, ussname + "/picCopyMe.png"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/picCopyMeToo.png"); + tag = await getTag(REAL_SESSION, ussname + "/picCopyMeToo.png"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/picCopy.png"); + tag = await getTag(REAL_SESSION, ussname + "/picCopy.png"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/picCopyNoTagPlease.png"); + tag = await getTag(REAL_SESSION, ussname + "/picCopyNoTagPlease.png"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/copyMe.txt"); + tag = await getTag(REAL_SESSION, ussname + "/copyMe.txt"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/copyMeToo.txt"); + tag = await getTag(REAL_SESSION, ussname + "/copyMeToo.txt"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/copyAndMeToo.txt"); + tag = await getTag(REAL_SESSION, ussname + "/copyAndMeToo.txt"); expect(tag).toMatch("t IBM-1140"); - tag = await getTag(REAL_SESSION,ussname + "/copyButDontTagMe.text"); + tag = await getTag(REAL_SESSION, ussname + "/copyButDontTagMe.text"); expect(tag).toMatch("b binary"); let error: Error; @@ -458,8 +434,6 @@ describe("Upload directory to USS", () => { error = err; } expect(error).toBeDefined(); - - }); it("should accept zosattributes path as an argument to a nested attributes file (the attribute file should not be uploaded)", async () => { @@ -468,20 +442,19 @@ describe("Upload directory to USS", () => { "command_upload_dtu_dir/dir_with_nested_attributefile/nest_attribute_folder/.attributes"); testSuccessfulUpload(localDirName, ["--r --attributes", path.relative(TEST_ENVIRONMENT.workingDir, attributesPath)]); - let tag = await getTag(REAL_SESSION,ussname + "/baz.asciitext"); + let tag = await getTag(REAL_SESSION, ussname + "/baz.asciitext"); expect(tag).toMatch("t ISO8859-1"); - tag = await getTag(REAL_SESSION,ussname + "/foo.text"); + tag = await getTag(REAL_SESSION, ussname + "/foo.text"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/bar.binary"); + tag = await getTag(REAL_SESSION, ussname + "/bar.binary"); expect(tag).toMatch("b binary"); - tag = await getTag(REAL_SESSION,ussname + "/nest_attribute_folder/baz.asciitext"); + tag = await getTag(REAL_SESSION, ussname + "/nest_attribute_folder/baz.asciitext"); expect(tag).toMatch("t ISO8859-1"); - tag = await getTag(REAL_SESSION,ussname + "/nest_attribute_folder/foo.text"); + tag = await getTag(REAL_SESSION, ussname + "/nest_attribute_folder/foo.text"); expect(tag).toMatch("t IBM-1047"); - tag = await getTag(REAL_SESSION,ussname + "/nest_attribute_folder/bar.binary"); + tag = await getTag(REAL_SESSION, ussname + "/nest_attribute_folder/bar.binary"); expect(tag).toMatch("b binary"); - let error: Error; try { await Get.USSFile(REAL_SESSION, ussname + "/dir_with_nested_attributefile/nest_attribute_folder/.attributes"); diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/ftds/cli.files.upload.ftds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/ftds/cli.files.upload.ftds.system.test.ts index 61b73755a1..2bdc381e95 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/ftds/cli.files.upload.ftds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/ftds/cli.files.upload.ftds.system.test.ts @@ -11,11 +11,12 @@ import { IO, Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getRandomBytes, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; import { Create, CreateDataSetTypeEnum, ICreateDataSetOptions, Delete, Get } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/ftu/cli.files.upload.ftu.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/ftu/cli.files.upload.ftu.system.test.ts index 426e14fd0c..8ef46cf73b 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/ftu/cli.files.upload.ftu.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/ftu/cli.files.upload.ftu.system.test.ts @@ -11,11 +11,12 @@ import { Imperative, IO, Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { Get, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; +import { Get } from "@zowe/zos-files-for-zowe-sdk"; +import { deleteFiles } from "../../../../../../../__tests__/__src__/TestUtils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; @@ -87,16 +88,7 @@ describe("Upload uss file", () => { 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); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, ussname); }); it("should upload USS file from local file", async () => { diff --git a/packages/cli/__tests__/zosfiles/__system__/upload/stds/cli.files.upload.stds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/upload/stds/cli.files.upload.stds.system.test.ts index fca9f1821f..a723db9453 100644 --- a/packages/cli/__tests__/zosfiles/__system__/upload/stds/cli.files.upload.stds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/upload/stds/cli.files.upload.stds.system.test.ts @@ -11,11 +11,12 @@ import { IO, Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getRandomBytes, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; import { Create, CreateDataSetTypeEnum, Delete, Get } from "@zowe/zos-files-for-zowe-sdk"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/view/ds/View.ds.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/view/ds/View.ds.system.test.ts index 94d832ccd8..190b96f248 100644 --- a/packages/cli/__tests__/zosfiles/__system__/view/ds/View.ds.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/view/ds/View.ds.system.test.ts @@ -12,10 +12,11 @@ import { Session } from "@zowe/imperative"; import { Create, Delete, CreateDataSetTypeEnum } from "@zowe/cli"; import * as path from "path"; -import {ITestEnvironment, runCliScript} from "@zowe/cli-test-utils"; -import {TestEnvironment} from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; -import {ITestPropertiesSchema} from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName} from "../../../../../../../__tests__/__src__/TestUtils"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/cli/__tests__/zosfiles/__system__/view/uss/View.uss.system.test.ts b/packages/cli/__tests__/zosfiles/__system__/view/uss/View.uss.system.test.ts index c36f5ab897..3a12e98b20 100644 --- a/packages/cli/__tests__/zosfiles/__system__/view/uss/View.uss.system.test.ts +++ b/packages/cli/__tests__/zosfiles/__system__/view/uss/View.uss.system.test.ts @@ -12,12 +12,12 @@ import { Imperative, Session } from "@zowe/imperative"; import * as path from "path"; -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"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { deleteFiles, getRandomBytes, getUniqueDatasetName } from "../../../../../../../__tests__/__src__/TestUtils"; +import { runCliScript } from "@zowe/cli-test-utils"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -47,35 +47,13 @@ describe("View uss file", () => { }); describe("Success scenarios", () => { - beforeEach(async () => { - let response; - let error; - const data = "{\"type\":\"file\",\"mode\":\"RWXRW-RW-\"}"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - try { - response = await ZosmfRestClient.postExpectString(REAL_SESSION, endpoint, [], data); - } catch (err) { - error = err; - } - }); - afterEach(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, ussname); }); it("should view uss file", async () => { const data: string = "abcdefghijklmnopqrstuvwxyz"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); const shellScript = path.join(__dirname, "__scripts__", "command", "command_view_uss_file.sh"); const response = runCliScript(shellScript, testEnvironment, [ussname.substring(1, ussname.length)]); @@ -86,8 +64,7 @@ describe("View uss file", () => { }); it("should view uss file in binary", async () => { const data: string = "abcdefghijklmnopqrstuvwxyz"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [ZosmfHeaders.X_IBM_BINARY], data); + 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.substring(1, ussname.length), "--binary"]); @@ -97,7 +74,7 @@ describe("View uss file", () => { expect(response.stdout.toString().trim()).toEqual(data); }); it("should view large uss file in binary", async () => { - const rawData:Buffer = await getRandomBytes(1024*64); + const rawData: Buffer = await getRandomBytes(1024*64); const data = encodeURIComponent(rawData.toLocaleString()); await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data), { binary: true }); @@ -111,8 +88,7 @@ describe("View uss file", () => { }); 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; - await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); const shellScript = path.join(__dirname, "__scripts__", "command", "command_view_uss_file.sh"); const response = runCliScript(shellScript, testEnvironment, [ussname.substring(1, ussname.length), "--range", "0,1"]); diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/submit_job.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/submit_job.sh index 7ae64e877c..67035c9236 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/submit_job.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/submit_job.sh @@ -14,4 +14,7 @@ then echo $JOBID 1>&2 echo "Submit returned a non-zero return code" 1>&2 exit $RC -fi \ No newline at end of file +fi + +# Echo the JOBID for retrieval in tests +echo "Submitted job ID: $JOBID" diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts index f83b35c13a..06bc908393 100644 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts @@ -9,8 +9,9 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { JobTestsUtils } from "../../../../../zosjobs/__tests__/__system__/JobTestsUtils"; import { IO } from "@zowe/imperative"; @@ -18,6 +19,8 @@ import { IO } from "@zowe/imperative"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; const LOCAL_JCL_FILE: string = __dirname + "/" + "testFileOfLocalJCL.txt"; +const jobDataRegexV1 = /Successfully submitted request to cancel job (\w+) \((JOB\d+)\)/; +const jobDataRegex = /Successfully canceled job (\w+) \((JOB\d+)\)/; describe("zos-jobs cancel job command", () => { // Create the unique test environment @@ -32,16 +35,18 @@ describe("zos-jobs cancel job command", () => { const bufferJCL: Buffer = Buffer.from(jcl); IO.createFileSync(LOCAL_JCL_FILE); IO.writeFile(LOCAL_JCL_FILE, bufferJCL); + TEST_ENVIRONMENT.resources.localFiles.push(LOCAL_JCL_FILE); }); afterAll(async () => { - IO.deleteFile(LOCAL_JCL_FILE); + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); describe("error handling", () => { it("should surface an error from z/OSMF if the jobid doesn't exist", () => { const response = runCliScript(__dirname + "/__scripts__/job/not_found.sh", TEST_ENVIRONMENT); + expect(response.status).toBe(1); expect(response.stdout.toString()).toBe(""); expect(response.stderr.toString()).toContain("Cannot obtain job info for job id = JOB00000"); @@ -49,8 +54,15 @@ describe("zos-jobs cancel job command", () => { }); it("should surface an error from z/OSMF if the jobid was already canceled", () => { - runCliScript(__dirname + "/__scripts__/job/submit_job.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); - const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v2_bad.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); + let response = runCliScript(__dirname + "/__scripts__/job/submit_job.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); + const jobidRegex = /Submitted job ID: (JOB\d+)/; + let jobid = response.stdout.toString().match(jobidRegex).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + + response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v2_bad.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); + jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + expect(response.status).toBe(1); expect(response.stderr.toString()).toContain("Failed to cancel job"); expect(response.stderr.toString()).toContain("Job not cancellable or purgeable"); @@ -65,6 +77,9 @@ describe("zos-jobs cancel job command", () => { expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); + + const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); }); it("should cancel a job v2", () => { @@ -73,6 +88,9 @@ describe("zos-jobs cancel job command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully canceled job"); expect(response.stdout.toString()).not.toContain("Failed to cancel job"); + + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); }); it("should cancel a job default", () => { @@ -81,6 +99,10 @@ describe("zos-jobs cancel job command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully canceled job"); expect(response.stdout.toString()).not.toContain("Failed to cancel job"); + expect(response.stdout.toString()).not.toContain("Failed to cancel job"); + + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); }); describe("without profiles", () => { @@ -114,6 +136,9 @@ describe("zos-jobs cancel job command", () => { expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); + + const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); }); it("cancel a job without a profile 2.0", async () => { @@ -129,6 +154,9 @@ describe("zos-jobs cancel job command", () => { expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully canceled job"); + + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); }); it("cancel a job without a profile default", async () => { @@ -144,6 +172,9 @@ describe("zos-jobs cancel job command", () => { expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Successfully canceled job"); + + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); }); }); }); diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts index 9d8d74af0d..e34559b5fe 100644 --- a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts @@ -9,8 +9,9 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; // Test Environment populated in the beforeAll(); diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts index 3b3d493ef2..be09c0dfaf 100644 --- a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts @@ -9,9 +9,10 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh index a8f477a047..8563a01a94 100755 --- a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh +++ b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh @@ -16,6 +16,9 @@ then exit $RC fi +# Echo the job ID for further use +echo "Submitted job ID: $JOBID" + # Loop until the job goes to the output queue until [ $ATTEMPTS -gt 0 ] do diff --git a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh index f86e5b1d36..cb7def1726 100755 --- a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh @@ -22,6 +22,9 @@ then exit $RC fi +# Echo the job ID for further use +echo "Submitted job ID: $JOBID" + # Loop until the job goes to the output queue until [ $ATTEMPTS -gt 0 ] do diff --git a/packages/cli/__tests__/zosjobs/__system__/download/cli.zos-jobs.download.output.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/download/cli.zos-jobs.download.output.system.test.ts index f553570fc9..32ad3be62d 100644 --- a/packages/cli/__tests__/zosjobs/__system__/download/cli.zos-jobs.download.output.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/download/cli.zos-jobs.download.output.system.test.ts @@ -9,8 +9,9 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import * as fs from "fs"; @@ -28,6 +29,10 @@ describe("zos-jobs download output command", () => { IEFBR14_JCL = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member; }); + afterAll(async () => { + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); + }); + describe("error handling", () => { it("should surface an error from z/OSMF if the jobid doesn't exist", () => { const response = runCliScript(__dirname + "/__scripts__/download-output/not_found.sh", TEST_ENVIRONMENT); @@ -43,6 +48,16 @@ describe("zos-jobs download output command", () => { const outdir: string = TEST_ENVIRONMENT.workingDir + "/output/JES2"; const response = runCliScript(__dirname + "/__scripts__/download-output/download.sh", TEST_ENVIRONMENT, [IEFBR14_JCL]); + + // Extract the JOBID from the response output + const jobidRegex = /Submitted job ID: (JOB\d+)/; + const match = response.stdout.toString().match(jobidRegex); + const jobid = match ? match[1] : null; + + // Ensure the job ID was captured correctly + expect(jobid).not.toBeNull(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + expect(response.status).toBe(0); expect(response.stderr.toString()).toBe(""); expect(fs.existsSync(`${outdir}/JESMSGLG.txt`)).toBeTruthy(); @@ -69,7 +84,7 @@ describe("zos-jobs download output command", () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); - it("should download all spool files of a job", async () => { + it("should download all spool files of a job", () => { const outdir: string = TEST_ENVIRONMENT.workingDir + "/output/JES2"; const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; @@ -88,6 +103,16 @@ describe("zos-jobs download output command", () => { DEFAULT_SYSTEM_PROPS.zosmf.user, DEFAULT_SYSTEM_PROPS.zosmf.password, ]); + + // Extract the JOBID from the response output + const jobidRegex = /Submitted job ID: (JOB\d+)/; + const match = response.stdout.toString().match(jobidRegex); + const jobid = match ? match[1] : null; + + // Ensure the job ID was captured correctly + expect(jobid).not.toBeNull(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(fs.existsSync(`${outdir}/JESMSGLG.txt`)).toBeTruthy(); diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh index 524086b7b8..fc6f6e9979 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh @@ -1,8 +1,7 @@ #!/bin/bash set -e -# arguments: $1 is a data set name with JCL inside to submit - +# Submit two jobs and capture their IDs JOBID1=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` JOBID2=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` @@ -21,6 +20,9 @@ if echo $LIST_JOB_OUTPUT | grep -q $JOBID2 then echo "Second job ID $JOBID2 found" else - echo "Could not find secon job ID $JOBID2" + echo "Could not find second job ID $JOBID2" exit 1 -fi \ No newline at end of file +fi + +# Echo both job IDs for later retrieval +echo "Submitted jobs: $JOBID1 $JOBID2" \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh index 198dcf8b91..922016bd87 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh @@ -7,8 +7,7 @@ PORT=$3 USER=$4 PASS=$5 -# arguments: $1 is a data set name with JCL inside to submit - +# Submit two jobs and capture their IDs JOBID1=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` JOBID2=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` @@ -24,10 +23,13 @@ else exit 1 fi -if echo $LIST_JOB_OUTPUT | grep -q $JOBID1 +if echo $LIST_JOB_OUTPUT | grep -q $JOBID2 then echo "Second job ID $JOBID2 found" else - echo "Could not find secon job ID $JOBID2" + echo "Could not find second job ID $JOBID2" exit 1 -fi \ No newline at end of file +fi + +# Echo both job IDs for later retrieval +echo "Submitted jobs: $JOBID1 $JOBID2" \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_no_match.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_no_match.sh index 3b1463f3c4..9f7ca8ba04 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_no_match.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_no_match.sh @@ -1,8 +1,7 @@ #!/bin/bash set -e -# arguments: $1 is a data set name with JCL inside to submit - +# Submit one job and capture its ID JOBID1=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` echo "Listing jobs to find job IDs $JOBID1" @@ -15,3 +14,6 @@ then else echo "No match - test passed" fi + +# Echo the job ID for later retrieval +echo "Submitted job: $JOBID1" \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds.sh index e41a62609c..7eb453b4f4 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds.sh @@ -1,5 +1,4 @@ #!/bin/bash -# TODO - delete the job from spool # Submit the job and ensure the RC is 0 JOBID="$(zowe jobs submit ds "$1" --rff jobid --rft string)" CMDRC=$? @@ -9,12 +8,13 @@ then echo "Submit returned a non-zero return code" 1>&2 exit $CMDRC fi -echo $JOBID + +# Echo the JOBID for retrieval in tests +echo "Submitted job ID: $JOBID" + # Loop until the status is output STATUS="" -while [ "$STATUS" != "OUTPUT" ]; do - - # get the status +while [ "$STATUS" != "OUTPUT" ]; do STATUS="$(zowe zos-jobs view job-status-by-jobid $JOBID --rff status --rft string)" RC=$? if [ $RC -gt 0 ] @@ -23,7 +23,7 @@ while [ "$STATUS" != "OUTPUT" ]; do echo "The submit data set command returned a non-zero return code: $RC" 1>&2 exit $RC fi -done +done zowe zos-jobs list spool-files-by-jobid $JOBID -exit $? +exit $? \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds_fully_qualified.sh index 5f36f30092..7ef8a4761d 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/spool-files-by-jobid/submit_and_list_dds_fully_qualified.sh @@ -6,7 +6,6 @@ PORT=$3 USER=$4 PASS=$5 -# TODO - delete the job from spool # Submit the job and ensure the RC is 0 JOBID="$(zowe jobs submit ds "$JCL" --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string)" CMDRC=$? @@ -16,12 +15,13 @@ then echo "Submit returned a non-zero return code" 1>&2 exit $CMDRC fi -echo $JOBID + +# Echo the JOBID for retrieval in tests +echo "Submitted job ID: $JOBID" + # Loop until the status is output STATUS="" -while [ "$STATUS" != "OUTPUT" ]; do - - # get the status +while [ "$STATUS" != "OUTPUT" ]; do STATUS="$(zowe zos-jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string)" RC=$? if [ $RC -gt 0 ] @@ -30,7 +30,7 @@ while [ "$STATUS" != "OUTPUT" ]; do echo "The submit data set command returned a non-zero return code: $RC" 1>&2 exit $RC fi -done +done zowe zos-jobs list spool-files-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false -exit $? +exit $? \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.jobs.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.jobs.system.test.ts index 54327bf0da..82c6430d08 100644 --- a/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.jobs.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.jobs.system.test.ts @@ -9,8 +9,9 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Session } from "@zowe/imperative"; @@ -55,24 +56,42 @@ describe("zos-jobs list jobs command", () => { describe("positive tests", () => { - it("should be able to submit two jobs and then find both in the output", - () => { - const response = runCliScript(scriptDir + "/submit_and_list_jobs.sh", TEST_ENVIRONMENT, - [TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("found"); - }); + it("should be able to submit two jobs and then find both in the output", () => { + const response = runCliScript(scriptDir + "/submit_and_list_jobs.sh", TEST_ENVIRONMENT, + [TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member]); - it("should be able to submit one job and then not see the job if we list jobs for a different user", - () => { - // note: this test could fail if your user Id starts with "FAKE" - const response = runCliScript(scriptDir + "/submit_and_list_jobs_no_match.sh", TEST_ENVIRONMENT, - [TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("test passed"); - }); + // Regex to extract both JOBIDs + const jobidRegex = /(?:First|Second) job ID (JOB\d+) found/g; + + // Extract all matching job IDs + const jobIds = [...response.stdout.toString().matchAll(jobidRegex)].map(match => match[1]); + + // Ensure both job IDs were captured correctly + expect(jobIds.length).toBe(2); + TEST_ENVIRONMENT.resources.jobs.push(...jobIds); + + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("found"); + }); + + it("should be able to submit one job and then not see the job if we list jobs for a different user", () => { + // note: this test could fail if your user Id starts with "FAKE" + const response = runCliScript(scriptDir + "/submit_and_list_jobs_no_match.sh", TEST_ENVIRONMENT, + [TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member]); + + // Regex to extract the JOBID + const jobidRegex = /Submitted job: (JOB\d+)/; + const match = response.stdout.toString().match(jobidRegex); + const jobId = match ? match[1] : null; + + expect(jobId).not.toBeNull(); + TEST_ENVIRONMENT.resources.jobs.push(jobId); + + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("test passed"); + }); describe("without profiles", () => { @@ -91,7 +110,7 @@ describe("zos-jobs list jobs command", () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); - it("should be able to submit two jobs and then find both in the output", async () => { + it("should be able to submit two jobs and then find both in the output", () => { const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; // if API Mediation layer is being used (basePath has a value) then @@ -109,6 +128,17 @@ describe("zos-jobs list jobs command", () => { SYSTEM_PROPS.zosmf.user, SYSTEM_PROPS.zosmf.password, ]); + + // Regex to extract both JOBIDs + const jobidRegex = /(?:First|Second) job ID (JOB\d+) found/g; + + // Extract all matching job IDs + const jobIds = [...response.stdout.toString().matchAll(jobidRegex)].map(match => match[1]); + + // Ensure both job IDs were captured correctly + expect(jobIds.length).toBe(2); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(...jobIds); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("found"); diff --git a/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.spool-files-by-jobid.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.spool-files-by-jobid.system.test.ts index b90a2aeb63..9d160aa2bd 100644 --- a/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.spool-files-by-jobid.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/list/cli.zos-jobs.list.spool-files-by-jobid.system.test.ts @@ -9,14 +9,15 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import * as fs from "fs"; import { Session, TextUtils } from "@zowe/imperative"; import { IJob, SubmitJobs } from "@zowe/zos-jobs-for-zowe-sdk"; -import { TEST_RESOURCES_DIR } from "../../../../../../packages/zosjobs/__tests__/__src__/ZosJobsTestConstants"; +import * as fs from "fs"; import { join } from "path"; +import { TEST_RESOURCES_DIR } from "@zowe/zos-jobs-for-zowe-sdk/__tests__/__src__/ZosJobsTestConstants"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; @@ -31,7 +32,6 @@ const LONG_TIMEOUT = 100000; const trimMessage = (message: string) => { // don't use more than one space or tab when checking error details - // this allows us to expect things like "reason: 6" regardless of how prettyjson aligns the text return message.replace(/( {2,})|\t/g, " "); }; @@ -88,10 +88,16 @@ describe("zos-jobs list spool-files-by-jobid command", () => { expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); - // TODO: Hopefully these DDs are deterministic on all of our test systems. - // TODO: Once available, we can submit from a local file via command - // TODO: with certain DDs (wanted this test to be entirely script driven - // TODO: to capture a "real world" scenario) + // Extract the JOBID using regex + const jobidRegex = /Submitted job ID: (JOB\d+)/; + const match = response.stdout.toString().match(jobidRegex); + const jobId = match ? match[1] : null; + + // Ensure the JOBID was captured correctly + expect(jobId).not.toBeNull(); + TEST_ENVIRONMENT.resources.jobs.push(jobId); + + // Validate DDs and output expect(response.stdout.toString()).toContain("JESMSGLG"); expect(response.stdout.toString()).toContain("JESJCL"); expect(response.stdout.toString()).toContain("JESYSMSG"); @@ -105,6 +111,7 @@ describe("zos-jobs list spool-files-by-jobid command", () => { // Submit the job const job: IJob = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + TEST_ENVIRONMENT.resources.jobs.push(job); // View the DDs const response = runCliScript(__dirname + "/__scripts__/spool-files-by-jobid/list_dds.sh", @@ -136,7 +143,7 @@ describe("zos-jobs list spool-files-by-jobid command", () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); - it("should display the ddnames for a job", async () => { + it("should display the ddnames for a job", () => { const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; // if API Mediation layer is being used (basePath has a value) then @@ -156,6 +163,17 @@ describe("zos-jobs list spool-files-by-jobid command", () => { ]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); + + // Extract the JOBID using regex + const jobidRegex = /Submitted job ID: (JOB\d+)/; + const match = response.stdout.toString().match(jobidRegex); + const jobId = match ? match[1] : null; + + // Ensure the JOBID was captured correctly + expect(jobId).not.toBeNull(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobId); + + // Validate DDs and output expect(response.stdout.toString()).toContain("JESMSGLG"); expect(response.stdout.toString()).toContain("JESJCL"); expect(response.stdout.toString()).toContain("JESYSMSG"); diff --git a/packages/cli/__tests__/zosjobs/__system__/modify/cli.zos-jobs.modify.job.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/modify/cli.zos-jobs.modify.job.system.test.ts index 6905d5fd60..62262941d4 100644 --- a/packages/cli/__tests__/zosjobs/__system__/modify/cli.zos-jobs.modify.job.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/modify/cli.zos-jobs.modify.job.system.test.ts @@ -9,8 +9,9 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; let TEST_ENVIRONMENT: ITestEnvironment; diff --git a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_no_job_submit.sh b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/missing_search_string.sh old mode 100644 new mode 100755 similarity index 59% rename from packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_no_job_submit.sh rename to packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/missing_search_string.sh index ccd3f9f253..60d1fa596f --- a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_no_job_submit.sh +++ b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/missing_search_string.sh @@ -1,11 +1,8 @@ #!/bin/bash -zowe jobs search job "$1" $2 +zowe jobs search job "$1" RC=$? -if [ $RC -gt 0 ] -then - echo $STATUS 1>&2 +if [ $RC -gt 0 ]; then echo "The search spool job command returned a non-zero rc: $RC" 1>&2 exit $RC fi - diff --git a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_regex.sh b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_regex.sh new file mode 100755 index 0000000000..f945ab2063 --- /dev/null +++ b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_regex.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +zowe jobs search job "$1" --search-regex "$2" ${@:3} +RC=$? +if [ $RC -gt 0 ]; then + echo "The search spool job command returned a non-zero rc: $RC" 1>&2 + exit $RC +fi diff --git a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_string.sh b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_string.sh new file mode 100755 index 0000000000..da2bdb98c4 --- /dev/null +++ b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_job_string.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +zowe jobs search job "$1" --search-string "$2" ${@:3} +RC=$? +if [ $RC -gt 0 ]; then + echo "The search spool job command returned a non-zero rc: $RC" 1>&2 + exit $RC +fi diff --git a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_string_spool_content.sh b/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_string_spool_content.sh deleted file mode 100644 index 4ee6abe2a9..0000000000 --- a/packages/cli/__tests__/zosjobs/__system__/search/__scripts__/job/search_string_spool_content.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# TODO - delete the job from spool -# Submit the job and ensure the RC is 0 -JOBID="$(zowe jobs submit ds "$1" --wfo true --rff jobid --rft string)" -CMDRC=$? -if [ $CMDRC -gt 0 ] -then - echo $JOBID 1>&2 - echo "Submit returned a non-zero return code" 1>&2 - exit $CMDRC -fi - -zowe jobs search job "$2" --search-string "$3" -RC=$? -if [ $RC -gt 0 ] -then - echo $STATUS 1>&2 - echo "The search spool job command returned a non-zero rc: $RC" 1>&2 - exit $RC -fi - diff --git a/packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.test.ts b/packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.system.test.ts similarity index 66% rename from packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.test.ts rename to packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.system.test.ts index 75e39a2d73..afbc82be18 100644 --- a/packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/search/cli.zos-jobs.search.job.system.test.ts @@ -9,23 +9,23 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Session } from "@zowe/imperative"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { SubmitJobs } from "@zowe/zos-jobs-for-zowe-sdk"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; -let IEFBR14_JOB: string; let REAL_SESSION: Session; -let ACCOUNT: string; let JOB_NAME: string; -let NON_HELD_JOBCLASS: string; -let SEARCH_STRING: string; -let REGEX_STRING: string; -let BAD_SEARCH_STRING: string; +const SEARCH_STRING = "PGM=IEFBR14"; +const REGEX_STRING = "IEFBR14|RC=0000"; +const BAD_SEARCH_STRING = "bluhbluh"; describe("zos-jobs search job command", () => { + // Create the unique test environment beforeAll(async () => { TEST_ENVIRONMENT = await TestEnvironment.setUp({ @@ -33,18 +33,12 @@ describe("zos-jobs search job command", () => { tempProfileTypes: ["zosmf"] }); - IEFBR14_JOB = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member; - const defaultSystem = TEST_ENVIRONMENT.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); + const iefbr14Job = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member; - ACCOUNT = defaultSystem.tso.account; - const JOB_LENGTH = 6; - JOB_NAME = REAL_SESSION.ISession.user.substring(0, JOB_LENGTH).toUpperCase() + "SF"; - NON_HELD_JOBCLASS = TEST_ENVIRONMENT.systemTestProperties.zosjobs.jobclass; - SEARCH_STRING = "PGM=IEFBR14"; - REGEX_STRING = "IEFBR14|RC=0000"; - BAD_SEARCH_STRING = "bluhbluh"; - + const job = await SubmitJobs.submitJob(REAL_SESSION, iefbr14Job); + JOB_NAME = job.jobname; + TEST_ENVIRONMENT.resources.jobs.push(job); }); afterAll(async () => { @@ -53,17 +47,16 @@ describe("zos-jobs search job command", () => { describe("Successful response", () => { it("should be able to search for a string in every spool file for a job", () => { - const response = runCliScript(__dirname + "/__scripts__/job/search_string_spool_content.sh", - TEST_ENVIRONMENT, [IEFBR14_JOB, JOB_NAME, SEARCH_STRING]); + const response = runCliScript(__dirname + "/__scripts__/job/search_job_string.sh", + TEST_ENVIRONMENT, [JOB_NAME, SEARCH_STRING]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(SEARCH_STRING); }); it("should be able to search for a regex in every spool file for a job", () => { - const argString = "--search-regex \"" + REGEX_STRING + "\""; - const response = runCliScript(__dirname + "/__scripts__/job/search_no_job_submit.sh", - TEST_ENVIRONMENT, [JOB_NAME, argString]); + const response = runCliScript(__dirname + "/__scripts__/job/search_job_regex.sh", + TEST_ENVIRONMENT, [JOB_NAME, REGEX_STRING]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("IEFBR14"); @@ -71,9 +64,8 @@ describe("zos-jobs search job command", () => { }); it("should limit the search when the --search-limit and --file-limit options are specified", () => { - const argString = "--search-string \"" + SEARCH_STRING + "\" --search-limit 5 --file-limit 3"; - const response = runCliScript(__dirname + "/__scripts__/job/search_no_job_submit.sh", - TEST_ENVIRONMENT, [JOB_NAME, argString]); + const response = runCliScript(__dirname + "/__scripts__/job/search_job_string.sh", + TEST_ENVIRONMENT, [JOB_NAME, SEARCH_STRING, "--search-limit", "5", "--file-limit", "3"]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain(SEARCH_STRING); @@ -82,25 +74,23 @@ describe("zos-jobs search job command", () => { describe("error handling", () => { it("should return a status code of 1 if the string is not found", () => { - const argString = "--search-string \"" + BAD_SEARCH_STRING + "\""; - const response = runCliScript(__dirname + "/__scripts__/job/search_no_job_submit.sh", - TEST_ENVIRONMENT, [JOB_NAME, argString]); + const response = runCliScript(__dirname + "/__scripts__/job/search_job_string.sh", + TEST_ENVIRONMENT, [JOB_NAME, BAD_SEARCH_STRING]); expect(response.stderr.toString()).toContain("The search spool job command returned a non-zero rc: 1"); expect(response.status).toBe(1); expect(response.stdout.toString()).toBe(""); }); it("should fail if no parameters are passed", () => { - const response = runCliScript(__dirname + "/__scripts__/job/search_no_job_submit.sh", - TEST_ENVIRONMENT, [JOB_NAME, ""]); + const response = runCliScript(__dirname + "/__scripts__/job/missing_search_string.sh", + TEST_ENVIRONMENT, [JOB_NAME]); expect(response.stderr.toString()).toContain("You must specify either the `--search-string` or `--search-regex` option"); expect(response.status).toBe(1); }); it("should fail if --search-string and --search-regex parameters are passed", () => { - const argString = "--search-regex \"" + REGEX_STRING +"\" --search-string \"" + SEARCH_STRING + "\""; - const response = runCliScript(__dirname + "/__scripts__/job/search_no_job_submit.sh", - TEST_ENVIRONMENT, [JOB_NAME, argString]); + const response = runCliScript(__dirname + "/__scripts__/job/search_job_string.sh", + TEST_ENVIRONMENT, [JOB_NAME, SEARCH_STRING, "--search-regex", REGEX_STRING]); expect(response.stderr.toString()).toContain("You must specify either the `--search-string` or `--search-regex` option"); expect(response.status).toBe(1); }); diff --git a/packages/cli/__tests__/zosjobs/__system__/submit/data-set/cli.zos-jobs.submit.data-set.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/submit/data-set/cli.zos-jobs.submit.data-set.system.test.ts index 6449eb7b64..43ddb3599a 100644 --- a/packages/cli/__tests__/zosjobs/__system__/submit/data-set/cli.zos-jobs.submit.data-set.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/submit/data-set/cli.zos-jobs.submit.data-set.system.test.ts @@ -9,21 +9,25 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { List } from "../../../../../../zosfiles/src/methods/list"; +import { List } from "@zowe/zos-files-for-zowe-sdk"; import { Session } from "@zowe/imperative"; +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; process.env.FORCE_COLOR = "0"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; +let REAL_SESSION: Session; +let JOB_NAME: string; +const jobNameRegex = /jobname: (\w+)/; let account: string; let jclMember: string; let psJclDataSet: string; -let REAL_SESSION: Session; describe("zos-jobs submit data-set command", () => { // Create the unique test environment beforeAll(async () => { @@ -31,7 +35,6 @@ describe("zos-jobs submit data-set command", () => { testName: "zos_jobs_submit_command", tempProfileTypes: ["zosmf"] }); - REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); account = TEST_ENVIRONMENT.systemTestProperties.tso.account; jclMember = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member; @@ -39,13 +42,21 @@ describe("zos-jobs submit data-set command", () => { }); afterAll(async () => { + // Retrieve jobs by prefix + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs = jobs; + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); - describe("Live system tests", () => { it("should submit a job in an existing valid data set from a PDS member", async () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_data_set.sh", TEST_ENVIRONMENT, [jclMember]); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); diff --git a/packages/cli/__tests__/zosjobs/__system__/submit/local-file/cli.zos-jobs.submit.local-file.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/submit/local-file/cli.zos-jobs.submit.local-file.system.test.ts index 8458d2fe76..886c953762 100644 --- a/packages/cli/__tests__/zosjobs/__system__/submit/local-file/cli.zos-jobs.submit.local-file.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/submit/local-file/cli.zos-jobs.submit.local-file.system.test.ts @@ -9,12 +9,13 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { IO, Session } from "@zowe/imperative"; -import { Get } from "../../../../../../zosfiles/src/methods/get"; - +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; +import { Get } from "@zowe/zos-files-for-zowe-sdk"; process.env.FORCE_COLOR = "0"; @@ -24,6 +25,9 @@ let REAL_SESSION: Session; let systemProps: ITestPropertiesSchema; let account: string; let jcl: string; +let JOB_NAME: string; +const jobNameRegex = /jobname: (\w+)/; + describe("zos-jobs submit local-file command", () => { // Create the unique test environment beforeAll(async () => { @@ -36,52 +40,68 @@ describe("zos-jobs submit local-file command", () => { REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); account = systemProps.tso.account; - const maxJobNamePrefixLength = 5; + // JCL to submit jcl = (await Get.dataSet(REAL_SESSION, systemProps.zosjobs.iefbr14Member)).toString(); - // Create an local file with JCL to submit + // Create a local file with JCL to submit const bufferJCL: Buffer = Buffer.from(jcl); IO.createFileSync(__dirname + "/testFileOfLocalJCL.txt"); IO.writeFile(__dirname + "/testFileOfLocalJCL.txt", bufferJCL); + + // Add the local file to resources for cleanup + TEST_ENVIRONMENT.resources.localFiles.push(__dirname + "/testFileOfLocalJCL.txt"); }); afterAll(async () => { + // Cleanup jobs before the environment is torn down + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); - IO.deleteFile(__dirname + "/testFileOfLocalJCL.txt"); }); describe("Live system tests", () => { - it("should submit a job in an existing valid local file", async () => { + it("should submit a job in an existing valid local file", () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_local_file.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt"]); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; }); - it("should submit a job in an existing valid local file with explicit RECFM, LRECL, and encoding", async () => { + it("should submit a job in an existing valid local file with explicit RECFM, LRECL, and encoding", () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_local_file.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt", "--job-encoding IBM-037 --job-record-format F --job-record-length 80"]); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); }); - it("should submit a job in an existing valid local file with 'view-all-spool-content' option", async () => { + it("should submit a job in an existing valid local file with 'view-all-spool-content' option", () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_local_file_vasc.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt", "--vasc"]); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("Spool file"); expect(response.stdout.toString()).toContain("JES2"); }); - it("should submit a job and wait for it to reach output status", async () => { + it("should submit a job and wait for it to reach output status", () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_local_file_wait.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt"]); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); @@ -89,19 +109,19 @@ describe("zos-jobs submit local-file command", () => { expect(response.stdout.toString()).toContain("CC 0000"); expect(response.stdout.toString()).not.toContain("null"); // retcode should not be null }); - it("should submit a job in an existing valid local file with 'directory' option", async () => { + + it("should submit a job in an existing valid local file with 'directory' option", () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_local_file_with_directory.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt", "--directory", "./"]); + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); expect(response.stdout.toString()).toContain("Successfully downloaded output to ./"); - expect(new RegExp("JOB\\d{5}", "g").test(response.stdout.toString())).toBe(true); }); describe("without profiles", () => { - // Create a separate test environment for no profiles let TEST_ENVIRONMENT_NO_PROF: ITestEnvironment; let DEFAULT_SYSTEM_PROPS: ITestPropertiesSchema; @@ -118,7 +138,7 @@ describe("zos-jobs submit local-file command", () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); - it("should submit a job in an existing valid local file", async () => { + it("should submit a job in an existing valid local file", () => { const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; // if API Mediation layer is being used (basePath has a value) then @@ -140,8 +160,11 @@ describe("zos-jobs submit local-file command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; }); }); }); - }); diff --git a/packages/cli/__tests__/zosjobs/__system__/submit/stdin/cli.zos-jobs.submit.stdin.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/submit/stdin/cli.zos-jobs.submit.stdin.system.test.ts index c697e8fcc5..a130780f0e 100644 --- a/packages/cli/__tests__/zosjobs/__system__/submit/stdin/cli.zos-jobs.submit.stdin.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/submit/stdin/cli.zos-jobs.submit.stdin.system.test.ts @@ -9,12 +9,13 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { IO, Session } from "@zowe/imperative"; -import { Get } from "../../../../../../zosfiles/src/methods/get"; - +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; +import { Get } from "@zowe/zos-files-for-zowe-sdk"; process.env.FORCE_COLOR = "0"; @@ -24,6 +25,9 @@ let REAL_SESSION: Session; let systemProps: ITestPropertiesSchema; let account: string; let jcl: string; +let JOB_NAME: string; +const jobNameRegex = /jobname: (\w+)/; + describe("zos-jobs submit stdin command", () => { beforeAll(async () => { TEST_ENVIRONMENT = await TestEnvironment.setUp({ @@ -35,19 +39,27 @@ describe("zos-jobs submit stdin command", () => { REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); account = systemProps.tso.account; - const maxJobNamePrefixLength = 5; + // JCL to submit jcl = (await Get.dataSet(REAL_SESSION, systemProps.zosjobs.iefbr14Member)).toString(); - // Create an local file with JCL to submit + // Create a local file with JCL to submit const bufferJCL: Buffer = Buffer.from(jcl); IO.createFileSync(__dirname + "/testFileOfLocalJCL.txt"); IO.writeFile(__dirname + "/testFileOfLocalJCL.txt", bufferJCL); + + // Add the local file to resources for cleanup + TEST_ENVIRONMENT.resources.localFiles.push(__dirname + "/testFileOfLocalJCL.txt"); }); afterAll(async () => { + // Cleanup jobs before the environment is torn down + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); - IO.deleteFile(__dirname + "/testFileOfLocalJCL.txt"); }); describe("Live system tests", () => { @@ -58,6 +70,10 @@ describe("zos-jobs submit stdin command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; }); it("should submit a job using JCL on stdin with explicit LRECL, RECFM, and encoding", async () => { @@ -77,6 +93,7 @@ describe("zos-jobs submit stdin command", () => { expect(response.stdout.toString()).toContain("Spool file"); expect(response.stdout.toString()).toContain("JES2"); }); + it("should submit a job and wait for it to reach output status", async () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_stdin_wait.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt"]); @@ -87,6 +104,7 @@ describe("zos-jobs submit stdin command", () => { expect(response.stdout.toString()).toContain("CC 0000"); expect(response.stdout.toString()).not.toContain("null"); // retcode should not be null }); + it("should submit a job using JCL on stdin with 'directory' option", async () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_stdin_with_directory.sh", TEST_ENVIRONMENT, [__dirname + "/testFileOfLocalJCL.txt", "--directory", "./"]); @@ -95,11 +113,9 @@ describe("zos-jobs submit stdin command", () => { expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); expect(response.stdout.toString()).toContain("Successfully downloaded output to ./"); - expect(new RegExp("JOB\\d{5}", "g").test(response.stdout.toString())).toBe(true); }); describe("without profiles", () => { - // Create a separate test environment for no profiles let TEST_ENVIRONMENT_NO_PROF: ITestEnvironment; let DEFAULT_SYSTEM_PROPS: ITestPropertiesSchema; @@ -138,6 +154,10 @@ describe("zos-jobs submit stdin command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); expect(response.stdout.toString()).toContain("jobid"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; }); }); }); diff --git a/packages/cli/__tests__/zosjobs/__system__/submit/uss-file/cli.zos-jobs.submit.uss-file.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/submit/uss-file/cli.zos-jobs.submit.uss-file.system.test.ts index c527d941c0..0a7cb895f7 100644 --- a/packages/cli/__tests__/zosjobs/__system__/submit/uss-file/cli.zos-jobs.submit.uss-file.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/submit/uss-file/cli.zos-jobs.submit.uss-file.system.test.ts @@ -9,20 +9,25 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Session } from "@zowe/imperative"; +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; process.env.FORCE_COLOR = "0"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; +let REAL_SESSION: Session; +let JOB_NAME: string; +const jobNameRegex = /jobname: (\w+)/; let account: string; let jclMember: string; let ussFile: string; -let REAL_SESSION: Session; + describe("zos-jobs submit uss-file command", () => { // Create the unique test environment beforeAll(async () => { @@ -30,13 +35,18 @@ describe("zos-jobs submit uss-file command", () => { testName: "zos_jobs_submit_command", tempProfileTypes: ["zosmf"] }); - REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); account = TEST_ENVIRONMENT.systemTestProperties.tso.account; ussFile = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14USSFile; }); afterAll(async () => { + // Retrieve jobs by prefix and clean them up + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs = jobs; + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); @@ -44,6 +54,11 @@ describe("zos-jobs submit uss-file command", () => { it("should submit a job in an existing valid uss file", async () => { const response = runCliScript(__dirname + "/__scripts__/submit_valid_uss_file.sh", TEST_ENVIRONMENT, [ussFile]); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); @@ -137,6 +152,11 @@ describe("zos-jobs submit uss-file command", () => { SYSTEM_PROPS.zosmf.user, SYSTEM_PROPS.zosmf.password, ]); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[1] : null; + expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("jobname"); diff --git a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.all-spool-content.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.all-spool-content.system.test.ts index ebd08c8d5d..b815ad48ec 100644 --- a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.all-spool-content.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.all-spool-content.system.test.ts @@ -9,10 +9,12 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Session } from "@zowe/imperative"; +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; @@ -22,6 +24,9 @@ let ACCOUNT: string; let JOB_NAME: string; let NON_HELD_JOBCLASS: string; +// Regex to match any job name that starts with "IEFBR14" +const jobNameRegex = /IEFBR14\w*/; + describe("zos-jobs view all-spool-content command", () => { // Create the unique test environment beforeAll(async () => { @@ -41,6 +46,12 @@ describe("zos-jobs view all-spool-content command", () => { }); afterAll(async () => { + // Cleanup jobs before the environment is torn down + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); @@ -53,6 +64,10 @@ describe("zos-jobs view all-spool-content command", () => { expect(response.stdout.toString()).not.toContain("!!!SPOOL FILE"); expect(response.stdout.toString()).toContain("Spool file: JESMSGLG"); expect(response.stdout.toString()).toContain("PGM=IEFBR14"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); describe("without profiles", () => { @@ -70,6 +85,12 @@ describe("zos-jobs view all-spool-content command", () => { }); afterAll(async () => { + // Cleanup jobs before the environment is torn down + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); @@ -96,6 +117,10 @@ describe("zos-jobs view all-spool-content command", () => { expect(response.stdout.toString()).not.toContain("!!!SPOOL FILE"); expect(response.stdout.toString()).toContain("Spool file: JESMSGLG"); expect(response.stdout.toString()).toContain("PGM=IEFBR14"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); }); }); @@ -110,4 +135,4 @@ describe("zos-jobs view all-spool-content command", () => { expect(response.stderr.toString()).toContain("Zero jobs were returned"); }); }); -}); +}); \ No newline at end of file diff --git a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.job-status-by-jobid.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.job-status-by-jobid.system.test.ts index 4c614e5f83..084f08432f 100644 --- a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.job-status-by-jobid.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.job-status-by-jobid.system.test.ts @@ -9,19 +9,26 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "@zowe/cli-test-utils"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { ICommandResponse } from "@zowe/imperative"; +import { ICommandResponse, Session } from "@zowe/imperative"; +import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; +let REAL_SESSION: Session; // Pulled from test properties file let account: string; let systemProps: ITestPropertiesSchema; let jclMember: string; let psJclDataSet: string; +let JOB_NAME: string; + +// Regex to match any job name that starts with "IEFBR14" +const jobNameRegex = /IEFBR14\w*/; describe("zos-jobs view job-status-by-jobid command", () => { // Create the unique test environment @@ -33,12 +40,18 @@ describe("zos-jobs view job-status-by-jobid command", () => { systemProps = TEST_ENVIRONMENT.systemTestProperties; + REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); account = systemProps.tso.account; jclMember = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14Member; psJclDataSet = TEST_ENVIRONMENT.systemTestProperties.zosjobs.iefbr14PSDataSet; }); afterAll(async () => { + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); @@ -52,6 +65,10 @@ describe("zos-jobs view job-status-by-jobid command", () => { expect(response.stdout.toString()).toContain("jobid:"); expect(response.stdout.toString()).toContain("status:"); expect(response.stdout.toString()).toContain("retcode:"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); it("should be able to submit the job then view the job and the details should match", () => { @@ -69,7 +86,7 @@ describe("zos-jobs view job-status-by-jobid command", () => { "/__scripts__/job-status-by-jobid/view_rfj.sh", TEST_ENVIRONMENT, [submitJson.data.jobid]); expect(response.stderr.toString()).toBe(""); expect(response.status).toBe(0); - const viewJson: ICommandResponse = JSON.parse(response.stdout.toString()); + const viewJson: ICommandResponse = JSON.parse(viewResponse.stdout.toString()); expect(viewJson.success).toBe(true); expect(viewJson.data.jobid).toBe(submitJson.data.jobid); expect(viewJson.data.jobname).toBe(submitJson.data.jobname); @@ -93,11 +110,16 @@ describe("zos-jobs view job-status-by-jobid command", () => { TEST_ENVIRONMENT_NO_PROF = await TestEnvironment.setUp({ testName: "zos_jobs_view_job_status_by_jobid_command_without_profiles" }); - + REAL_SESSION = TestEnvironment.createZosmfSession(TEST_ENVIRONMENT); DEFAULT_SYSTEM_PROPS = TEST_ENVIRONMENT_NO_PROF.systemTestProperties; }); afterAll(async () => { + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); @@ -125,6 +147,10 @@ describe("zos-jobs view job-status-by-jobid command", () => { expect(response.stdout.toString()).toContain("jobid:"); expect(response.stdout.toString()).toContain("status:"); expect(response.stdout.toString()).toContain("retcode:"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); }); }); diff --git a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.spool-file-by-id.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.spool-file-by-id.system.test.ts index b50c4bec4b..f160bcf731 100644 --- a/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.spool-file-by-id.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/view/cli.zos-jobs.view.spool-file-by-id.system.test.ts @@ -9,23 +9,27 @@ * */ -import { ITestEnvironment, runCliScript } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Session, TextUtils } from "@zowe/imperative"; import * as fs from "fs"; -import { IJob, SubmitJobs } from "@zowe/zos-jobs-for-zowe-sdk"; +import { IJob, SubmitJobs, GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import { TEST_RESOURCES_DIR } from "../../../../../../packages/zosjobs/__tests__/__src__/ZosJobsTestConstants"; import { join } from "path"; +import { runCliScript } from "@zowe/cli-test-utils"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; -let IEFBR14_JOB: string; let REAL_SESSION: Session; +let IEFBR14_JOB: string; let ACCOUNT: string; let JOB_NAME: string; let NON_HELD_JOBCLASS: string; +// Regex to match any job name that starts with "IEFBR14" +const jobNameRegex = /IEFBR14\w*/; + describe("zos-jobs view spool-file-by-id command", () => { // Create the unique test environment beforeAll(async () => { @@ -45,6 +49,11 @@ describe("zos-jobs view spool-file-by-id command", () => { }); afterAll(async () => { + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); @@ -56,13 +65,17 @@ describe("zos-jobs view spool-file-by-id command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("!!!SPOOL FILE"); expect(response.stdout.toString()).toContain("PGM=IEFBR14"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); it("should be able to view the contents of the requested DD", async () => { // Construct the JCL const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/multiple_procs.jcl")).toString(); const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: JOB_NAME, ACCOUNT, JOBCLASS: NON_HELD_JOBCLASS}); + { JOBNAME: JOB_NAME, ACCOUNT, JOBCLASS: NON_HELD_JOBCLASS }); // Submit the job const job: IJob = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); @@ -92,6 +105,11 @@ describe("zos-jobs view spool-file-by-id command", () => { }); afterAll(async () => { + if (JOB_NAME) { + const jobs = await GetJobs.getJobsByPrefix(REAL_SESSION, JOB_NAME); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(...jobs); + } + await TestEnvironment.cleanUp(TEST_ENVIRONMENT_NO_PROF); }); @@ -117,6 +135,10 @@ describe("zos-jobs view spool-file-by-id command", () => { expect(response.status).toBe(0); expect(response.stdout.toString()).toContain("!!!SPOOL FILE"); expect(response.stdout.toString()).toContain("PGM=IEFBR14"); + + // Set jobname for cleanup of all jobs + const match = response.stdout.toString().match(jobNameRegex); + JOB_NAME = match ? match[0] : null; }); }); }); diff --git a/packages/cli/__tests__/zostso/__system__/issue/__scripts__/as/change_proc.sh b/packages/cli/__tests__/zostso/__system__/issue/__scripts__/as/change_proc.sh index 45fe3a1a85..792814e2fc 100755 --- a/packages/cli/__tests__/zostso/__system__/issue/__scripts__/as/change_proc.sh +++ b/packages/cli/__tests__/zostso/__system__/issue/__scripts__/as/change_proc.sh @@ -2,4 +2,4 @@ set -e zowe config set profiles.changed_proc_tso.properties.account $1 --gc zowe config set profiles.changed_proc_tso.properties.logonProcedure $2 --gc -zowe tso issue cmd "status" --tso-p "changed_proc_tso" +zowe tso issue cmd "status" --tso-p "changed_proc_tso" --ssm false diff --git a/packages/cli/__tests__/zosuss/__system__/issue/cli.issue.ssh.system.test.ts b/packages/cli/__tests__/zosuss/__system__/issue/cli.issue.ssh.system.test.ts index fce953a4e2..b74ab3e7a5 100644 --- a/packages/cli/__tests__/zosuss/__system__/issue/cli.issue.ssh.system.test.ts +++ b/packages/cli/__tests__/zosuss/__system__/issue/cli.issue.ssh.system.test.ts @@ -9,14 +9,13 @@ * */ -import { Imperative, Session } from "@zowe/imperative"; +import { Session } from "@zowe/imperative"; import * as path from "path"; -import { ITestEnvironment, runCliScript, TempTestProfiles } from "@zowe/cli-test-utils"; +import { runCliScript, TempTestProfiles } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Shell } from "@zowe/zos-uss-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; // Test environment will be populated in the "beforeAll" @@ -65,31 +64,31 @@ describe("zowe uss issue ssh without running bash scripts", () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); - it("should return operating system name", async () => { + it("should return operating system name", () => { const commandName = "uname"; // Imperative.console.info("Return OS command:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); checkResponse(response, 0); expect(response.stdout.toString()).toMatch("OS/390"); }); - it("should resolve --cwd option", async () => { + it("should resolve --cwd option", () => { const commandName = "pwd"; const cwd = `${defaultSystem.unix.testdir}`; // Imperative.console.info("Resolve --cwd Command:" + commandName +"--cwd /" +cwd); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_with_cwd.sh", TEST_ENVIRONMENT, [commandName, "/" + cwd]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_with_cwd.sh", TEST_ENVIRONMENT, [commandName, "/" + cwd]); checkResponse(response, 0); // match only "/"+cwd with no following alpha-numeric character e.g. "/cwd " expect(response.stdout.toString()).toMatch(new RegExp(cwd.substring(1) + "\\s")); }); - it("should get directory invalid --cwd option", async () => { + it("should get directory invalid --cwd option", () => { const commandName = "pwd"; const cwd = "/invaliddir"; // Imperative.console.info("Invalid directory Command:" + commandName +"--cwd /" +cwd); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_with_cwd.sh", TEST_ENVIRONMENT, [commandName, "/" + cwd]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_with_cwd.sh", TEST_ENVIRONMENT, [commandName, "/" + cwd]); checkResponse(response, 1); expect(response.stdout.toString()).toContain("EDC5129I No such file or directory"); @@ -111,7 +110,7 @@ describe("Use a test directory to do stuff in that creates files", () => { // create a directory that the random dir will be created in const commandName = `mkdir ${directory}/usstest && cd ${directory}/usstest && pwd`; // Imperative.console.info("Make test directory cmd:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); checkResponse(response, 0); expect(response.stdout.toString()).toContain(directory.substring(1) + "usstest"); }); @@ -120,21 +119,20 @@ describe("Use a test directory to do stuff in that creates files", () => { const directory = `${defaultSystem.unix.testdir}/`; const commandName = "rm -rf " + directory + "usstest"; // Imperative.console.info("Remove test directory cmd:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); // Imperative.console.info("Remove Response:" + response.stdout.toString()); await TestEnvironment.cleanUp(TEST_ENVIRONMENT); }); // eslint-disable-next-line jest/expect-expect - it("should write a long directory", async () => { + it("should write a long directory", () => { const j = 200; const randomDir = generateRandomString(j); const directory = `${defaultSystem.unix.testdir}/`; - const testdir = directory + "test/"; - const commandName = "mkdir -p " + testdir + "usstest/" + randomDir + "; ls " + testdir + "usstest/" + randomDir; + const commandName = "mkdir -p " + directory + "usstest/" + randomDir + "; ls " + directory + "usstest/" + randomDir; // Imperative.console.info("Long Dir Command:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); checkResponse(response, 0); }); }); @@ -164,6 +162,7 @@ describe("zowe uss issue ssh running bash scripts", () => { // Imperative.console.info("Response:" + response.stdout.toString()); expect(response.stdout.toString()).toContain("USS file uploaded successfully"); // Imperative.console.info("Uploaded :" + localFileName + "to" + ussname); + TEST_ENVIRONMENT.resources.files.push(ussname); ussname = `${defaultSystem.unix.testdir}/killItself.sh`; // Imperative.console.info("Using ussfile:" + ussname); @@ -172,42 +171,18 @@ describe("zowe uss issue ssh running bash scripts", () => { // Imperative.console.info("Response:" + response.stdout.toString()); expect(response.stdout.toString()).toContain("USS file uploaded successfully"); // Imperative.console.info("Uploaded :" + localFileName + "to" + ussname); - - + TEST_ENVIRONMENT.resources.files.push(ussname); }); afterAll(async () => { await TestEnvironment.cleanUp(TEST_ENVIRONMENT); - let response: any; - // delete uploaded test bash scripts - ussname = `${defaultSystem.unix.testdir}/exit64.sh`; - const exit64: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, exit64); - // Imperative.console.info("Deleted :" + ussname); - } catch (err) { - Imperative.console.error(err); - } - - ussname = `${defaultSystem.unix.testdir}/killItself.sh`; - const killItself: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, killItself); - // Imperative.console.info("Deleted :" + ussname); - } catch (err) { - Imperative.console.error(err); - } - - }); - it("script issues exit64", async () => { + it("script issues exit64", () => { const directory = `${defaultSystem.unix.testdir}`; const commandName = "cd " + directory + " && chmod 777 exit64.sh && exit64.sh"; // Imperative.console.info("Exit command:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); const SIX_FOUR= 64; checkResponse(response, SIX_FOUR); @@ -215,11 +190,11 @@ describe("zowe uss issue ssh running bash scripts", () => { expect(response.stdout.toString()).not.toContain("It should not echo this"); }); - it("script kills itself", async () => { + it("script kills itself", () => { const directory = `${defaultSystem.unix.testdir}`; const commandName = " cd " + directory + " && chmod 777 killItself.sh && killItself.sh"; // Imperative.console.info("Script for kill command:" + commandName); - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [commandName]); const ONE_FOUR_THREE = 143; checkResponse(response, ONE_FOUR_THREE); @@ -255,7 +230,7 @@ describe("zowe uss issue ssh passwords and passkeys", () => { { host, port, user, password }); // now check the command can run const command = "uname"; - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [command, "--ssh-p", onlyPassword]); checkResponse(response, 0); expect(response.stdout.toString()).toMatch("OS/390"); @@ -268,7 +243,7 @@ describe("zowe uss issue ssh passwords and passkeys", () => { { host, port, user, password, privateKey: bogusPrivateKey, keyPassphrase }); // now check the command can run const command = "uname"; - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [command, "--ssh-p", invalidPrivateKey]); expect(response.stderr.toString()).toMatch("no such file or directory, open 'bogusKey'"); }); @@ -280,7 +255,7 @@ describe("zowe uss issue ssh passwords and passkeys", () => { { host, port, user, password }); const command = "echo test"; - const response = await runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, + const response = runCliScript(__dirname + "/__scripts__/issue_ssh_no_cwd.sh", TEST_ENVIRONMENT, [command, "--ssh-p", invalidCreds]); expect(response.stderr.toString()).toMatch("All configured authentication methods failed"); }); diff --git a/packages/workflows/__tests__/__system__/Archive.system.test.ts b/packages/workflows/__tests__/__system__/Archive.system.test.ts index f930010fce..80624f0a68 100644 --- a/packages/workflows/__tests__/__system__/Archive.system.test.ts +++ b/packages/workflows/__tests__/__system__/Archive.system.test.ts @@ -13,12 +13,12 @@ import { Session, Imperative } from "@zowe/imperative"; import { IArchivedWorkflow } from "../../src/doc/IArchivedWorkflow"; import { ArchiveWorkflow } from "../../src"; import { WorkflowConstants } from "../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { CreateWorkflow } from "../../src/Create"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; let session: Session; let testEnvironment: ITestEnvironment; @@ -53,6 +53,7 @@ describe("Archive workflow unit tests - successful scenarios", () => { beforeAll(async () => { await setup(); await Upload.fileToUssFile(session, localWorkflowPath, remoteWorkflowPath, { binary: true}); + testEnvironment.resources.files.push(remoteWorkflowPath); }); beforeEach(async () => { const systemName = testEnvironment.systemTestProperties.workflows.system; @@ -164,6 +165,7 @@ describe("Errors caused by the user interaction", () => { beforeAll(async () => { await setup(); await Upload.fileToUssFile(session, localWorkflowPath, remoteWorkflowPath, { binary: true }); + testEnvironment.resources.files.push(remoteWorkflowPath); }); it("404 Not Found", async () => { try { diff --git a/packages/workflows/__tests__/__system__/Cancel.system.test.ts b/packages/workflows/__tests__/__system__/Cancel.system.test.ts index 678e72b757..b953ee956f 100644 --- a/packages/workflows/__tests__/__system__/Cancel.system.test.ts +++ b/packages/workflows/__tests__/__system__/Cancel.system.test.ts @@ -11,14 +11,14 @@ import { CancelWorkflow, CreateWorkflow, DeleteWorkflow } from "../../src"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../__tests__/__src__/TestUtils"; import { noWorkflowKey, WrongWorkflowKey } from "../../src/WorkflowConstants"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -70,19 +70,7 @@ describe("Cancel workflow", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // Deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/workflows/__tests__/__system__/api/ArchivedDelete.system.test.ts b/packages/workflows/__tests__/__system__/api/ArchivedDelete.system.test.ts index 53dc8ea5ad..6382dd6b60 100644 --- a/packages/workflows/__tests__/__system__/api/ArchivedDelete.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/ArchivedDelete.system.test.ts @@ -9,16 +9,16 @@ * */ -import { ZosFilesConstants, Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; import { noWorkflowKey } from "../../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ArchivedDeleteWorkflow, ArchiveWorkflow, CreateWorkflow } from "../../../src"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; @@ -64,19 +64,7 @@ describe("Delete archived workflow", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // Deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/workflows/__tests__/__system__/api/Create.system.test.ts b/packages/workflows/__tests__/__system__/api/Create.system.test.ts index 69e3d3c143..d7fe57a983 100644 --- a/packages/workflows/__tests__/__system__/api/Create.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/Create.system.test.ts @@ -11,7 +11,6 @@ import { CreateWorkflow, DeleteWorkflow } from "../../../src"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ICreatedWorkflow } from "../../../src/doc/ICreatedWorkflow"; @@ -25,8 +24,9 @@ import { wrongOwner } from "../../../src/WorkflowConstants"; import { ICreatedWorkflowLocal } from "../../../src/doc/ICreatedWorkflowLocal"; -import { Upload, ZosFilesConstants, Delete } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload, Delete } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -74,25 +74,7 @@ describe("Create workflow", () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); await Upload.fileToUssFile(REAL_SESSION, vars, inputFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } - try { - const inputEndpoint = endpoint + inputFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, inputEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile, inputFile); }); afterEach(async () => { // deleting workflow diff --git a/packages/workflows/__tests__/__system__/api/Definition.system.test.ts b/packages/workflows/__tests__/__system__/api/Definition.system.test.ts index a1a0da3afe..b7996de06b 100644 --- a/packages/workflows/__tests__/__system__/api/Definition.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/Definition.system.test.ts @@ -12,14 +12,14 @@ import { DefinitionWorkflow } from "../../../src"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; import { noWorkflowDefinitionFile } from "../../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; import { IWorkflowDefinition } from "../../../src/doc/IWorkflowDefinition"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -64,19 +64,7 @@ describe("Properties workflow", () => { describe("Success Scenarios", () => { beforeAll(async () => { await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); it("Successful call without optional parameters returns definition response", async () => { let error; @@ -191,22 +179,6 @@ describe("Properties workflow", () => { }); }); describe("Fail scenarios", () => { - beforeAll(async () => { - await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } - }); it("Throws an error with undefined session.", async () => { let error: ImperativeError; let response: any; diff --git a/packages/workflows/__tests__/__system__/api/Delete.system.test.ts b/packages/workflows/__tests__/__system__/api/Delete.system.test.ts index 3fd4549ff9..18439d8a3d 100644 --- a/packages/workflows/__tests__/__system__/api/Delete.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/Delete.system.test.ts @@ -12,13 +12,13 @@ import { CreateWorkflow, DeleteWorkflow } from "../../../src"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; import { noWorkflowKey } from "../../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -63,19 +63,7 @@ describe("Delete workflow", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/workflows/__tests__/__system__/api/ListArchivedWorkflows.system.test.ts b/packages/workflows/__tests__/__system__/api/ListArchivedWorkflows.system.test.ts index 41fcc0396b..77f0a9a03e 100644 --- a/packages/workflows/__tests__/__system__/api/ListArchivedWorkflows.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/ListArchivedWorkflows.system.test.ts @@ -14,14 +14,14 @@ import { ArchivedDeleteWorkflow } from "../../../src/ArchivedDelete"; import { ListArchivedWorkflows } from "../../../src/ListArchivedWorkflows"; import { ArchiveWorkflow } from "../../../src/ArchiveWorkflow"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ICreatedWorkflow } from "../../../src/doc/ICreatedWorkflow"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; @@ -73,19 +73,7 @@ describe("List archived workflows", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // Deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/workflows/__tests__/__system__/api/ListWorkflows.system.test.ts b/packages/workflows/__tests__/__system__/api/ListWorkflows.system.test.ts index 0ba83c8b51..62895f83ff 100644 --- a/packages/workflows/__tests__/__system__/api/ListWorkflows.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/ListWorkflows.system.test.ts @@ -11,7 +11,6 @@ import { CreateWorkflow, DeleteWorkflow, ListWorkflows } from "../../../src"; import { Imperative, ImperativeError, Session } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ICreatedWorkflow } from "../../../src/doc/ICreatedWorkflow"; @@ -19,8 +18,9 @@ import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; import { wrongString } from "../../../src/WorkflowConstants"; import { IWorkflowsInfo } from "../../../src/doc/IWorkflowsInfo"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -71,19 +71,7 @@ describe("List workflows", () => { beforeAll(async () => { // Upload files only for successful scenarios await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // Deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); diff --git a/packages/workflows/__tests__/__system__/api/Properties.system.test.ts b/packages/workflows/__tests__/__system__/api/Properties.system.test.ts index 3f6269d9ab..efd524e7f3 100644 --- a/packages/workflows/__tests__/__system__/api/Properties.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/Properties.system.test.ts @@ -11,15 +11,15 @@ import { Imperative, ImperativeError, Session } from "@zowe/imperative"; import { noWorkflowKey } from "../../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { CreateWorkflow, DeleteWorkflow, PropertiesWorkflow } from "../../../src"; import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; import { IWorkflowInfo } from "../../../src/doc/IWorkflowInfo"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -65,19 +65,7 @@ describe("Properties workflow", () => { describe("Success Scenarios", () => { beforeAll(async () => { await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); @@ -198,30 +186,6 @@ describe("Properties workflow", () => { }); }); describe("Fail scenarios", () => { - beforeAll(async () => { - await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } - }); - beforeEach(async () => { - const response = await CreateWorkflow.createWorkflow(REAL_SESSION, wfName, definitionFile, system, owner); - wfKey = response.workflowKey; - }); - afterEach(async () => { - // deleting workflow - await DeleteWorkflow.deleteWorkflow(REAL_SESSION, wfKey); - }); it("Throws an error with undefined session.", async () => { let error: ImperativeError; let response: any; diff --git a/packages/workflows/__tests__/__system__/api/Start.system.test.ts b/packages/workflows/__tests__/__system__/api/Start.system.test.ts index 623f78b4fe..fcf6e478fe 100644 --- a/packages/workflows/__tests__/__system__/api/Start.system.test.ts +++ b/packages/workflows/__tests__/__system__/api/Start.system.test.ts @@ -11,7 +11,6 @@ import { Imperative, ImperativeError, Session } from "@zowe/imperative"; import { noWorkflowKey, WorkflowConstants } from "../../../src/WorkflowConstants"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { CreateWorkflow, DeleteWorkflow, PropertiesWorkflow, StartWorkflow } from "../../../src"; @@ -19,8 +18,9 @@ import { inspect } from "util"; import { getUniqueDatasetName } from "../../../../../__tests__/__src__/TestUtils"; import { IWorkflowInfo } from "../../../src/doc/IWorkflowInfo"; import { IStepInfo } from "../../../src/doc/IStepInfo"; -import { Upload, ZosFilesConstants } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosmfRestClient, nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { nozOSMFVersion, noSession } from "@zowe/core-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -64,28 +64,8 @@ describe("Start workflow", () => { describe("Success Scenarios", () => { beforeAll(async () => { // Upload files only for successful scenarios - let error; - let response; - try { - response = await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); - Imperative.console.info("Response: " + inspect(response)); - } catch (err) { - error = err; - Imperative.console.info("Error upload: " + inspect(error)); - } - }); - afterAll(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES; - // deleting uploaded workflow file - try { - const wfEndpoint = endpoint + definitionFile; - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, wfEndpoint); - } catch (err) { - error = err; - } + await Upload.fileToUssFile(REAL_SESSION, workflow, definitionFile, { binary: true }); + testEnvironment.resources.files.push(definitionFile); }); beforeEach(async () => { let error; diff --git a/packages/zosfiles/__tests__/__system__/methods/copy/Copy.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/copy/Copy.system.test.ts index 540acc395c..312fd5dd0b 100644 --- a/packages/zosfiles/__tests__/__system__/methods/copy/Copy.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/copy/Copy.system.test.ts @@ -13,11 +13,11 @@ import { Create, Upload, Delete, CreateDataSetTypeEnum, Copy, ZosFilesMessages, ICrossLparCopyDatasetOptions, IGetOptions, IZosFilesResponse } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { join } from "path"; import { readFileSync } from "fs"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let REAL_TARGET_SESSION: Session; diff --git a/packages/zosfiles/__tests__/__system__/methods/create/Create.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/create/Create.system.test.ts index 105fe7be10..0f55e52cb0 100644 --- a/packages/zosfiles/__tests__/__system__/methods/create/Create.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/create/Create.system.test.ts @@ -12,13 +12,13 @@ import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; import { Create, CreateDataSetTypeEnum, ICreateDataSetOptions, ICreateVsamOptions } from "../../../../src/methods/create"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Delete } from "../../../../src/methods/delete"; import { ZosFilesMessages } from "../../../../src"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { ICreateZfsOptions } from "../../../../src/methods/create/doc/ICreateZfsOptions"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteDataset.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteDataset.system.test.ts index e0a6c1c6bb..e2ff4859fa 100644 --- a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteDataset.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteDataset.system.test.ts @@ -12,9 +12,9 @@ import { Create, CreateDataSetTypeEnum, Delete, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts index 264d6c7f9e..3c005f6d66 100644 --- a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteUSSFile.system.test.ts @@ -12,15 +12,14 @@ import { Create, Delete, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; let defaultSystem: ITestPropertiesSchema; let ussname: string; -let filename: string; describe("Delete a USS File", () => { @@ -31,7 +30,7 @@ describe("Delete a USS File", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - ussname = `${defaultSystem.zosmf.user.trim()}`; + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFileSingle`.replace(/\./g, ""); }); afterAll(async () => { @@ -41,10 +40,8 @@ describe("Delete a USS File", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - let response; - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFileSingle`.replace(/\./g, ""); try { - response = await Create.uss(REAL_SESSION, filename, "file"); + await Create.uss(REAL_SESSION, ussname, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -56,7 +53,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -74,7 +71,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, undefined, {responseTimeout: 5}); + response = await Delete.ussFile(REAL_SESSION, ussname, undefined, {responseTimeout: 5}); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -92,7 +89,7 @@ describe("Delete a USS File", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, "//"+filename); + response = await Delete.ussFile(REAL_SESSION, "//"+ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -153,7 +150,7 @@ describe("Delete a USS File - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - ussname = `${defaultSystem.zosmf.user.trim() + ".Enco#ed"}`; + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFileSingle`.replace(/\./g, ""); }); afterAll(async () => { @@ -163,9 +160,8 @@ describe("Delete a USS File - encoded", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFileSingle`.replace(/\./g, ""); try { - await Create.uss(REAL_SESSION, filename, "file"); + await Create.uss(REAL_SESSION, ussname, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -177,7 +173,7 @@ describe("Delete a USS File - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -195,7 +191,7 @@ describe("Delete a USS File - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, "//"+filename); + response = await Delete.ussFile(REAL_SESSION, "//"+ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -219,7 +215,7 @@ describe("Delete USS Directory", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFolderDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFolderDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -229,9 +225,8 @@ describe("Delete USS Directory", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -243,7 +238,7 @@ describe("Delete USS Directory", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -258,21 +253,6 @@ describe("Delete USS Directory", () => { }); describe("Failure scenarios", () => { - beforeAll(async () => { - let error; - let response; - // ussname = ussname.replace(/\./g, ""); - filename = `${defaultSystem.unix.testdir}/${ussname}`; - try { - response = await Create.uss(REAL_SESSION, filename, "directory"); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - afterAll(async () => { - await TestEnvironment.cleanUp(testEnvironment); - }); it("should display proper error message when called with invalid directory name", async () => { let error; let response; @@ -318,7 +298,7 @@ describe("Delete USS Directory - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.Enco#ed.aTestUssFolderDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFolderDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -328,9 +308,8 @@ describe("Delete USS Directory - encoded", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -342,7 +321,7 @@ describe("Delete USS Directory - encoded", () => { let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -366,7 +345,7 @@ describe("Delete USS Directory with children", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.aTestUssFileDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.aTestUssFileDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -376,15 +355,14 @@ describe("Delete USS Directory with children", () => { describe("Success scenarios", () => { beforeEach(async () => { let error; - let response; try { - response = await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - response = await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -395,7 +373,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, true); + response = await Delete.ussFile(REAL_SESSION, ussname, true); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -412,13 +390,13 @@ describe("Delete USS Directory with children", () => { beforeEach(async () => { let error; try { - await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -437,7 +415,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename); + response = await Delete.ussFile(REAL_SESSION, ussname); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -452,7 +430,7 @@ describe("Delete USS Directory with children", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, false); + response = await Delete.ussFile(REAL_SESSION, ussname, false); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; @@ -474,7 +452,7 @@ describe("Delete USS Directory with children - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - filename = `${defaultSystem.unix.testdir}/${ussname}.Enco#ed.aTestUssFileDelete`.replace(/\./g, ""); + ussname = `${defaultSystem.unix.testdir}/${defaultSystem.zosmf.user.trim()}.Enco#ed.aTestUssFileDelete`.replace(/\./g, ""); }); afterAll(async () => { @@ -485,13 +463,13 @@ describe("Delete USS Directory with children - encoded", () => { beforeEach(async () => { let error; try { - await Create.uss(REAL_SESSION, filename, "directory"); + await Create.uss(REAL_SESSION, ussname, "directory"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } try { - await Create.uss(REAL_SESSION, `${filename}/aChild.txt`, "file"); + await Create.uss(REAL_SESSION, `${ussname}/aChild.txt`, "file"); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -502,7 +480,7 @@ describe("Delete USS Directory with children - encoded", () => { let error; let response; try { - response = await Delete.ussFile(REAL_SESSION, filename, true); + response = await Delete.ussFile(REAL_SESSION, ussname, true); Imperative.console.info("Response: " + inspect(response)); } catch (err) { error = err; diff --git a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteZfs.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteZfs.system.test.ts index 983827a193..ebb5f50ce7 100644 --- a/packages/zosfiles/__tests__/__system__/methods/delete/DeleteZfs.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/delete/DeleteZfs.system.test.ts @@ -12,11 +12,11 @@ import { Create, Delete, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { ICreateZfsOptions } from "../../../../src/methods/create/doc/ICreateZfsOptions"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/download/Download.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/download/Download.system.test.ts index 2009a9b432..ecddd8231e 100644 --- a/packages/zosfiles/__tests__/__system__/methods/download/Download.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/download/Download.system.test.ts @@ -19,7 +19,6 @@ import { IZosFilesResponse, Tag, Utilities, - ZosFilesConstants, ZosFilesMessages, ICreateZfsOptions, IMountFsOptions, @@ -29,11 +28,10 @@ import { } from "../../../../src"; import { Imperative, IO, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName, stripNewLines, delay } from "../../../../../../__tests__/__src__/TestUtils"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { deleteFiles, getUniqueDatasetName, stripNewLines, wait } from "../../../../../../__tests__/__src__/TestUtils"; import * as fs from "fs"; import { posix } from "path"; import { Shell } from "@zowe/zos-uss-for-zowe-sdk"; @@ -53,7 +51,7 @@ let ussDirname: string; let localDirname: string; let file: string; -describe("Download Data Set", () => { +describe.each([false, true])("Download Data Set - Encoded: %s", (encoded: boolean) => { beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ @@ -63,13 +61,19 @@ describe("Download Data Set", () => { REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.DOWNLOAD`); + dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.DOWNLOAD`, encoded); Imperative.console.info("Using dsname:" + dsname); // using unique DS function to generate unique USS file name - ussname = `${defaultSystem.unix.testdir}/${dsname}`; - ussDirname = `${defaultSystem.unix.testdir}/zos_file_download`; - localDirname = `${testEnvironment.workingDir}/ussDir`; + if (encoded) { + ussname = `${defaultSystem.unix.testdir}/ENCO#ED${dsname}`; + ussDirname = `${defaultSystem.unix.testdir}/ENCO#EDzos_file_download`; + localDirname = `${testEnvironment.workingDir}/ENCO#EDussDir`; + } else { + ussname = `${defaultSystem.unix.testdir}/${dsname}`; + ussDirname = `${defaultSystem.unix.testdir}/zos_file_download`; + localDirname = `${testEnvironment.workingDir}/ussDir`; + } }); afterAll(async () => { @@ -86,7 +90,7 @@ describe("Download Data Set", () => { try { response = await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -98,7 +102,7 @@ describe("Download Data Set", () => { try { response = await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -118,7 +122,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); try { response = await Download.dataSet(REAL_SESSION, dsname); @@ -147,7 +151,7 @@ describe("Download Data Set", () => { let response: IZosFilesResponse; await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); try { response = await Download.dataSet(REAL_SESSION, dsname, {responseTimeout: 5}); @@ -177,7 +181,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); try { response = await Download.dataSet(REAL_SESSION, dsname, { preserveOriginalLetterCase: true }); @@ -266,7 +270,7 @@ describe("Download Data Set", () => { let response: IZosFilesResponse; await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { returnEtag: true @@ -306,7 +310,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); try { response = await Download.dataSet(REAL_SESSION, dsname, options); @@ -337,7 +341,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); + await wait(delayTime); try { response = await Download.dataSet(REAL_SESSION, dsname, { stream: responseStream }); @@ -366,7 +370,7 @@ describe("Download Data Set", () => { try { response = await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -378,7 +382,7 @@ describe("Download Data Set", () => { try { response = await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -394,7 +398,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); try { response = await Download.allMembers(REAL_SESSION, dsname); @@ -424,7 +428,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); try { response = await Download.allMembers(REAL_SESSION, dsname, {responseTimeout: 5}); @@ -454,7 +458,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); try { response = await Download.allMembers(REAL_SESSION, dsname, { preserveOriginalLetterCase: true }); @@ -491,7 +495,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { binary: true @@ -521,7 +525,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { record: true @@ -551,7 +555,7 @@ describe("Download Data Set", () => { // upload data to the newly created data set await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { extension: "dat" @@ -584,7 +588,7 @@ describe("Download Data Set", () => { try { response = await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -596,7 +600,7 @@ describe("Download Data Set", () => { try { response = await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -766,7 +770,7 @@ describe("Download Data Set", () => { try { response = await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -778,7 +782,7 @@ describe("Download Data Set", () => { try { response = await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(delayTime); } catch (err) { error = err; } @@ -1003,14 +1007,7 @@ describe("Download Data Set", () => { describe("Download USS File", () => { afterAll(async () => { // Delete created uss file - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - await delay(delayTime); - } catch (err) { - Imperative.console.error(err); - } + await deleteFiles(REAL_SESSION, ussname); // Delete created local file IO.deleteFile(`./${posix.basename(ussname)}`); @@ -1022,7 +1019,7 @@ describe("Download Data Set", () => { let response: IZosFilesResponse; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname); @@ -1043,7 +1040,7 @@ describe("Download Data Set", () => { let response: IZosFilesResponse; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, {responseTimeout: 5}); @@ -1064,7 +1061,7 @@ describe("Download Data Set", () => { let response: IZosFilesResponse; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { returnEtag: true @@ -1096,7 +1093,7 @@ describe("Download Data Set", () => { const data = Buffer.from(buffer); await Upload.bufferToUssFile(REAL_SESSION, ussname, data); - await delay(delayTime); + await wait(delayTime); const options: IDownloadOptions = { returnEtag: true @@ -1122,7 +1119,7 @@ describe("Download Data Set", () => { }; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData), { binary: true }); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, options); @@ -1145,7 +1142,7 @@ describe("Download Data Set", () => { await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData), { binary: true }); await Utilities.chtag(REAL_SESSION, ussname, Tag.TEXT, "ISO8859-1"); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, options); @@ -1169,7 +1166,7 @@ describe("Download Data Set", () => { const data: string = "Hello, world¤"; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); await Utilities.chtag(REAL_SESSION, ussname, Tag.TEXT, "IBM-1147"); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, options); @@ -1193,7 +1190,7 @@ describe("Download Data Set", () => { const options: IDownloadOptions = {file: `test1.txt`}; await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, options); @@ -1217,7 +1214,7 @@ describe("Download Data Set", () => { const responseStream = new PassThrough(); await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); + await wait(delayTime); try { response = await Download.ussFile(REAL_SESSION, ussname, { stream: responseStream }); @@ -1360,7 +1357,7 @@ describe("Download Data Set", () => { } // Create and mount file system - zfsName = getUniqueDatasetName(defaultSystem.zosmf.user); + zfsName = getUniqueDatasetName(defaultSystem.zosmf.user, encoded); await Create.zfs(REAL_SESSION, zfsName, createZfsOptions); await Mount.fs(REAL_SESSION, zfsName, mountFolder, mountZfsOptions); @@ -1513,514 +1510,3 @@ describe("Download Data Set", () => { }); }); }); - -describe("Download Data Set - encoded", () => { - - beforeAll(async () => { - testEnvironment = await TestEnvironment.setUp({ - testName: "zos_file_download" - }); - defaultSystem = testEnvironment.systemTestProperties; - - REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - - dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.DOWNLOAD`, true); - Imperative.console.info("Using dsname:" + dsname); - - // using unique DS function to generate unique USS file name - ussname = `${defaultSystem.unix.testdir}/ENCO#ED${dsname}`; - ussDirname = `${defaultSystem.unix.testdir}/ENCO#EDzos_file_download`; - localDirname = `${testEnvironment.workingDir}/ENCO#EDussDir`; - }); - - afterAll(async () => { - await TestEnvironment.cleanUp(testEnvironment); - }); - - describe("Success Scenarios", () => { - - describe("Physical sequential data set", () => { - beforeEach(async () => { - let error; - try { - await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - - afterEach(async () => { - let error; - try { - await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - - // delete the top-level folder and the folders and file below - // variable 'file' should be set in the test - const folders = file.split("/"); - rimraf(folders[0]); - rimraf(file); - }); - - it("should download a data set", async () => { - let error; - let response: IZosFilesResponse; - - // upload data to the newly created data set - await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - await delay(delayTime); - - try { - response = await Download.dataSet(REAL_SESSION, dsname); - Imperative.console.info("Response: " + inspect(response)); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - expect(response.success).toBeTruthy(); - expect(response.commandResponse).toContain( - ZosFilesMessages.datasetDownloadedSuccessfully.message.substring(0, "Data set downloaded successfully".length + 1)); - - // convert the data set name to use as a path/file - const regex = /\./gi; - file = dsname.replace(regex, "/") + ".txt"; - file = file.toLowerCase(); - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`${file}`).toString()); - expect(fileContents).toEqual(testData); - }); - }); - - describe("Partitioned data set - all members", () => { - beforeEach(async () => { - let error; - try { - await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - - afterEach(async () => { - let error; - try { - await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - - // delete the top-level folder and the folders and file below - const folders = file.split("/"); - rimraf(folders[0]); - }); - - it("should download a data set member", async () => { - let error; - let response: IZosFilesResponse; - - // upload data to the newly created data set - await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - await delay(delayTime); - - try { - response = await Download.allMembers(REAL_SESSION, dsname); - Imperative.console.info("Response: " + inspect(response)); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - expect(response.success).toBeTruthy(); - expect(response.commandResponse).toContain( - ZosFilesMessages.datasetDownloadedSuccessfully.message.substring(0, "Data set downloaded successfully".length + 1)); - - // convert the data set name to use as a path/file - const regex = /\./gi; - file = dsname.replace(regex, "/"); - file = file.toLowerCase(); - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`${file}/member.txt`).toString()); - expect(fileContents).toEqual(testData); - }); - - }); - - describe("Data sets matching - all data sets - PO", () => { - - beforeEach(async () => { - let error; - try { - await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - - afterEach(async () => { - let error; - - try { - await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - - // delete the top-level folder and the folders and file below - try { - const folders = file.split("/"); - rimraf(folders[0]); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - - it("should download a data set", async () => { - let error; - let response: IZosFilesResponse; - - // upload data to the newly created data set - await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname + "(member)"); - - try { - response = await Download.allDataSets(REAL_SESSION, [{ dsname, dsorg: "PO", vol: "*" }]); - Imperative.console.info("Response: " + inspect(response)); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - expect(response.success).toBeTruthy(); - expect(response.commandResponse).toContain("1 data set(s) downloaded successfully"); - - // convert the data set name to use as a path/file - const regex = /\./gi; - file = dsname.toLowerCase().replace(regex, "/"); - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`${file}/member.txt`).toString()); - expect(fileContents).toEqual(testData); - }); - - }); - - describe("Data sets matching - all data sets - PS", () => { - - beforeEach(async () => { - let error; - try { - await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - }); - - afterEach(async () => { - let error; - try { - await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); - } catch (err) { - // Do nothing, sometimes the files are not created. - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - - // delete the top-level folder and the folders and file below - const folders = file.split("/"); - rimraf(folders[0]); - rimraf(file); - }); - - it("should download a data set", async () => { - let error; - let response: IZosFilesResponse; - - // upload data to the newly created data set - await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testData), dsname); - - try { - response = await Download.allDataSets(REAL_SESSION, [{ dsname, dsorg: "PS", vol: "*" }]); - Imperative.console.info("Response: " + inspect(response)); - } catch (err) { - error = err; - Imperative.console.info("Error: " + inspect(error)); - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - expect(response.success).toBeTruthy(); - expect(response.commandResponse).toContain("1 data set(s) downloaded successfully"); - - file = dsname.toLowerCase() + ".txt"; - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`${file}`).toString()); - expect(fileContents).toEqual(testData); - }); - - }); - }); - - describe("Download USS File", () => { - afterAll(async () => { - // Delete created uss file - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - await delay(delayTime); - } catch (err) { - Imperative.console.error(err); - } - - // Delete created local file - IO.deleteFile(`./${posix.basename(ussname)}`); - }); - - describe("Successful scenarios", () => { - it("should download uss file without any options", async () => { - let error; - let response: IZosFilesResponse; - - await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); - - try { - response = await Download.ussFile(REAL_SESSION, ussname); - } catch (err) { - error = err; - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`./${posix.basename(ussname)}`).toString()); - expect(fileContents).toEqual(testData); - - }); - - it("should download uss file content to local file", async () => { - - let error; - let response: IZosFilesResponse; - - const options: IDownloadOptions = {file: `test1.txt`}; - - await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(testData)); - await delay(delayTime); - - try { - response = await Download.ussFile(REAL_SESSION, ussname, options); - } catch (err) { - error = err; - } - expect(error).toBeFalsy(); - expect(response).toBeTruthy(); - - // Compare the downloaded contents to those uploaded - const fileContents = stripNewLines(fs.readFileSync(`test1.txt`).toString()); - expect(fileContents).toEqual(testData); - - // Delete created local file - IO.deleteFile("test1.txt"); - }); - - }); - - }); - - describe("Download USS Directory", () => { - describe("Success Scenarios", () => { - const testFileContents = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - const anotherTestFileContents = testFileContents.toLowerCase(); - const binaryFileContents = String.fromCharCode(...Array(256).keys()); - const createZfsOptions: ICreateZfsOptions = { - perms: 755, - cylsPri: 10, - cylsSec: 2, - timeout: 20 - }; - const mountZfsOptions: IMountFsOptions = { - "fs-type": "ZFS", - mode: "rdwr" - }; - let zfsName: string; - - const expectDownloaded = (dirname: string, options: IUSSListOptions = {}) => { - expect(fs.existsSync(`${dirname}/emptyFolder`)).toBe(true); - expect(fs.readdirSync(`${dirname}/emptyFolder`).length).toBe(0); - expect(fs.existsSync(`${dirname}/parentFolder`)).toBe(true); - expect(fs.readFileSync(`${dirname}/testFile.txt`, "utf-8")).toBe(testFileContents); - - // Test depth option - const depth = options.depth || 0; - expect(fs.existsSync(`${dirname}/parentFolder/childFolder`)).toBe(depth !== 1); - if (depth !== 1) { - expect(fs.readFileSync(`${dirname}/parentFolder/childFolder/anotherTestFile.txt`, "utf-8")).toBe(anotherTestFileContents); - } - - // Test filesys option - const filesys = options.filesys || false; - expect(fs.existsSync(`${dirname}/mountFolder`)).toBe(filesys); - if (filesys) { - expect(fs.readFileSync(`${dirname}/mountFolder/binaryFile.bin`, "utf-8")).toBe(binaryFileContents); - } - - // Test symlinks option - const symlinks = options.symlinks || false; - expect(fs.existsSync(`${dirname}/testFile.lnk`)).toBe(!symlinks); - if (!symlinks) { - expect(fs.readFileSync(`${dirname}/testFile.lnk`, "utf-8")).toBe(testFileContents); - } - }; - - beforeAll(async () => { - const emptyFolder = posix.join(ussDirname, "emptyFolder"); - const parentFolder = posix.join(ussDirname, "parentFolder"); - const childFolder = posix.join(parentFolder, "childFolder"); - const testFile = posix.join(ussDirname, "testFile.txt"); - const anotherTestFile = posix.join(childFolder, "anotherTestFile.txt"); - const mountFolder = posix.join(ussDirname, "mountFolder"); - const binaryFile = posix.join(mountFolder, "binaryFile.bin"); - const testSymlink = posix.join(ussDirname, "testFile.lnk"); - - // Create directories - for (const directory of [ussDirname, emptyFolder, parentFolder, childFolder, mountFolder]) { - await Create.uss(REAL_SESSION, directory, "directory"); - } - - // Create and mount file system - zfsName = getUniqueDatasetName(defaultSystem.zosmf.user, true); - await Create.zfs(REAL_SESSION, zfsName, createZfsOptions); - await Mount.fs(REAL_SESSION, zfsName, mountFolder, mountZfsOptions); - - // Upload files - await Upload.bufferToUssFile(REAL_SESSION, testFile, Buffer.from(testFileContents)); - await Upload.bufferToUssFile(REAL_SESSION, anotherTestFile, Buffer.from(anotherTestFileContents)); - await Upload.bufferToUssFile(REAL_SESSION, binaryFile, Buffer.from(binaryFileContents), { binary: true }); - await Utilities.chtag(REAL_SESSION, binaryFile, Tag.BINARY); - - // Create symlink - const SSH_SESSION: any = TestEnvironment.createSshSession(testEnvironment); - await Shell.executeSshCwd(SSH_SESSION, `ln -s ${posix.basename(testFile)} ${posix.basename(testSymlink)}`, ussDirname, jest.fn()); - }); - - afterEach(() => { - IO.deleteDirTree(localDirname); - }); - - afterAll(async () => { - // Unmount and delete file system - await Unmount.fs(REAL_SESSION, zfsName); - await Delete.zfs(REAL_SESSION, zfsName); - - // Delete directory recursively - const SSH_SESSION: any = TestEnvironment.createSshSession(testEnvironment); - await Shell.executeSshCwd(SSH_SESSION, `rm testFile.lnk`, ussDirname, jest.fn()); - await Delete.ussFile(REAL_SESSION, ussDirname, true); - }); - - it("should download directory recursively", async () => { - let caughtError; - try { - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname }); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expectDownloaded(localDirname); - }); - - it("should download directory with depth of 1", async () => { - const listOptions: IUSSListOptions = { depth: 1 }; - let caughtError; - try { - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname }, listOptions); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expectDownloaded(localDirname, listOptions); - }); - - it("should download directory including all filesystems", async () => { - const listOptions: IUSSListOptions = { filesys: true }; - let caughtError; - try { - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname }, listOptions); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expectDownloaded(localDirname, listOptions); - }); - - it("should download directory excluding symlinks", async () => { - const listOptions: IUSSListOptions = { symlinks: true }; - let caughtError; - try { - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname }, listOptions); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expectDownloaded(localDirname, listOptions); - }); - - it("should not download files that already exist", async () => { - let caughtError; - const testFile = posix.join(localDirname, "testFile.txt"); - try { - fs.mkdirSync(localDirname); - fs.writeFileSync(testFile, "test"); - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname }); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expect(fs.readFileSync(testFile).toString()).toEqual("test"); - }); - - it("should download files that already exist when overwrite is true", async () => { - let caughtError; - const testFile = posix.join(localDirname, "testFile.txt"); - try { - fs.mkdirSync(localDirname); - fs.writeFileSync(testFile, "test"); - await Download.ussDir(REAL_SESSION, ussDirname, { directory: localDirname, overwrite: true }); - } catch (error) { - caughtError = error; - } - expect(caughtError).toBeUndefined(); - expect(fs.readFileSync(testFile).toString()).toEqual(testFileContents); - }); - }); - - }); -}); \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/methods/get/Get.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/get/Get.system.test.ts index 5fff2be222..7de7bf0d49 100644 --- a/packages/zosfiles/__tests__/__system__/methods/get/Get.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/get/Get.system.test.ts @@ -9,13 +9,12 @@ * */ -import { Create, CreateDataSetTypeEnum, Delete, Get, IGetOptions, List, ZosFilesConstants } from "../../../../src"; +import { Create, CreateDataSetTypeEnum, Delete, Get, IGetOptions, List, Upload } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getRandomBytes, getUniqueDatasetName, stripNewLines } from "../../../../../../__tests__/__src__/TestUtils"; -import { ZosmfRestClient, ZosmfHeaders } from "@zowe/core-for-zowe-sdk"; +import { deleteFiles, getRandomBytes, getUniqueDatasetName, stripNewLines } from "../../../../../../__tests__/__src__/TestUtils"; import { IZosmfListResponse } from "../../../../src/methods/list/doc/IZosmfListResponse"; let REAL_SESSION: Session; @@ -33,7 +32,6 @@ describe("Get", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.VIEW`); Imperative.console.info("Using dsname:" + dsname); @@ -78,8 +76,7 @@ describe("Get", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + dsname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname); try { response = await Get.dataSet(REAL_SESSION, dsname); @@ -96,8 +93,7 @@ describe("Get", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + dsname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname); try { response = await Get.dataSet(REAL_SESSION, dsname, {responseTimeout: 5}); @@ -116,8 +112,7 @@ describe("Get", () => { const options: IGetOptions = {}; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + dsname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname); const listOfDataSets = await List.dataSet(REAL_SESSION, dsname, {attributes: true}); listOfDataSets.apiResponse.items.forEach((dataSetObj: IZosmfListResponse) => { options.volume = dataSetObj.vol; @@ -143,8 +138,7 @@ describe("Get", () => { const randomByteLength = 60; const data: Buffer = await getRandomBytes(randomByteLength); - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + dsname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [ZosmfHeaders.X_IBM_BINARY], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname, { binary: true }); try { response = await Get.dataSet(REAL_SESSION, dsname, options); @@ -165,8 +159,7 @@ describe("Get", () => { }; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + dsname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname); try { response = await Get.dataSet(REAL_SESSION, dsname, options); @@ -184,30 +177,8 @@ describe("Get", () => { }); }); describe("USS File", () => { - beforeEach(async () => { - let response; - let error; - const data = "{\"type\":\"file\",\"mode\":\"RWXRW-RW-\"}"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.postExpectString(REAL_SESSION, endpoint, [], data); - } catch (err) { - error = err; - } - }); - afterEach(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, ussname); }); it("should get uss file content", async () => { @@ -215,8 +186,7 @@ describe("Get", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); try { response = await Get.USSFile(REAL_SESSION, ussname); @@ -238,8 +208,7 @@ describe("Get", () => { const randomByteLength = 60; const data: Buffer = await getRandomBytes(randomByteLength); - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [ZosmfHeaders.X_IBM_BINARY], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data), { binary: true }); try { response = await Get.USSFile(REAL_SESSION, ussname, options); @@ -256,8 +225,7 @@ describe("Get", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\nabcdefghijklmnopqrstuvwxyz\nabcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); try { response = await Get.USSFile(REAL_SESSION, ussname, {range: "0,1"}); @@ -343,8 +311,8 @@ describe("Get", () => { const record = true; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - const rc = await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); + testEnvironment.resources.files.push(ussname); try { response = await Get.USSFile(REAL_SESSION, ussname, {record}); @@ -369,7 +337,6 @@ describe("Get - encoded", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.VIEW`, true); Imperative.console.info("Using dsname:" + dsname); @@ -408,8 +375,7 @@ describe("Get - encoded", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_DS_FILES + "/" + encodeURIComponent(dsname); - await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(data), dsname); try { response = await Get.dataSet(REAL_SESSION, dsname); @@ -423,25 +389,8 @@ describe("Get - encoded", () => { }); describe("USS File", () => { - beforeEach(async () => { - const data = "{\"type\":\"file\",\"mode\":\"RWXRW-RW-\"}"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - - try { - await ZosmfRestClient.postExpectString(REAL_SESSION, endpoint, [], data); - } catch (err) { - // Do nothing - } - }); - afterEach(async () => { - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - } catch (err) { - // Do nothing - } + await deleteFiles(REAL_SESSION, ussname); }); it("should get uss file content", async () => { @@ -449,8 +398,7 @@ describe("Get - encoded", () => { let response: Buffer; const data: string = "abcdefghijklmnopqrstuvwxyz\n"; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - await ZosmfRestClient.putExpectString(REAL_SESSION, endpoint, [], data); + await Upload.bufferToUssFile(REAL_SESSION, ussname, Buffer.from(data)); try { response = await Get.USSFile(REAL_SESSION, ussname); diff --git a/packages/zosfiles/__tests__/__system__/methods/hDelete/HDelete.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/hDelete/HDelete.system.test.ts index 4e1596f66a..0dde3c7be4 100644 --- a/packages/zosfiles/__tests__/__system__/methods/hDelete/HDelete.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/hDelete/HDelete.system.test.ts @@ -12,9 +12,9 @@ import { Create, Delete, CreateDataSetTypeEnum, HDelete, HMigrate, IDeleteOptions, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/hMigrate/HMigrate.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/hMigrate/HMigrate.system.test.ts index 208dbd40e6..090e259e98 100644 --- a/packages/zosfiles/__tests__/__system__/methods/hMigrate/HMigrate.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/hMigrate/HMigrate.system.test.ts @@ -12,9 +12,9 @@ import { Create, Delete, CreateDataSetTypeEnum, HMigrate, IListOptions, IMigrateOptions, List, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/hRecall/HRecall.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/hRecall/HRecall.system.test.ts index 8e76a56ae3..61d4c127e1 100644 --- a/packages/zosfiles/__tests__/__system__/methods/hRecall/HRecall.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/hRecall/HRecall.system.test.ts @@ -12,9 +12,9 @@ import { Create, Delete, CreateDataSetTypeEnum, HMigrate, HRecall, IListOptions, IRecallOptions, List, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts index 273503352a..a1daccc33d 100644 --- a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts @@ -13,7 +13,7 @@ import * as fs from "fs"; import { Imperative, Session, TextUtils } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ZosFilesMessages } from "../../../../src/constants/ZosFiles.messages"; @@ -36,7 +36,6 @@ describe("Invoke AMS", () => { systemProps = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${systemProps.zosmf.user}.ZOSFILE.VSAM`); volume = systemProps.datasets.vol.toUpperCase(); }); @@ -49,8 +48,12 @@ describe("Invoke AMS", () => { // replace DSN with unique data set name const AMSStatement = fs.readFileSync(templateFile).toString(); const updatedStatement = TextUtils.renderWithMustache(AMSStatement, {DSN: dsname, VOL: volume}); - fs.writeFileSync(templateFile + ".temp", updatedStatement); - return templateFile + ".temp"; + const filename = templateFile + ".temp"; + fs.writeFileSync(filename, updatedStatement); + if (!testEnvironment.resources.localFiles.includes(filename)) { + testEnvironment.resources.localFiles.push(filename); + } + return filename; } it("should create and delete a VSAM data set from command statement in files", async () => { @@ -75,9 +78,6 @@ describe("Invoke AMS", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate(__dirname + "/DeleteVSAM.ams"); @@ -95,9 +95,6 @@ describe("Invoke AMS", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); it("should create and delete a VSAM data set from command statement in files with response timeout", async () => { @@ -122,9 +119,6 @@ describe("Invoke AMS", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate(__dirname + "/DeleteVSAM.ams"); @@ -142,9 +136,6 @@ describe("Invoke AMS", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); it("should create and delete a VSAM data set from command statements", async () => { @@ -214,7 +205,6 @@ describe("Invoke AMS - encoded", () => { systemProps = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${systemProps.zosmf.user}.ZOSFILE.ENCO#ED.VSAM`); volume = systemProps.datasets.vol.toUpperCase(); }); @@ -253,9 +243,6 @@ describe("Invoke AMS - encoded", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate(__dirname + "/DeleteVSAM.ams"); @@ -273,9 +260,6 @@ describe("Invoke AMS - encoded", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); it("should create and delete a VSAM data set from command statement in files with response timeout", async () => { @@ -300,9 +284,6 @@ describe("Invoke AMS - encoded", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - // Delete the temp file - fs.unlinkSync(controlStatementFile); - // create a temporary file from the template file that has the proper high level qualifier to delete the VSAM file controlStatementFile = createTestAMSStatementFileFromTemplate(__dirname + "/DeleteVSAM.ams"); @@ -320,9 +301,6 @@ describe("Invoke AMS - encoded", () => { expect(response.success).toBe(true); expect(response.commandResponse).toContain(ZosFilesMessages.amsCommandExecutedSuccessfully.message); - - // Delete the temp file - fs.unlinkSync(controlStatementFile); }); it("should create and delete a VSAM data set from command statements", async () => { diff --git a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts index c359540c15..4e3981e4ae 100644 --- a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts @@ -12,10 +12,10 @@ import { Create, CreateDataSetTypeEnum, Delete, IListOptions, IZosFilesResponse, List, Upload, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { format, inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName, delay } from "../../../../../../__tests__/__src__/TestUtils"; +import { getUniqueDatasetName, wait, waitTime } from "../../../../../../__tests__/__src__/TestUtils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -23,7 +23,6 @@ let defaultSystem: ITestPropertiesSchema; let dsname: string; let path: string; let filename: string; -const delayTime = 2000; describe("List command group", () => { @@ -34,8 +33,7 @@ describe("List command group", () => { defaultSystem = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - - dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.LIST`); + dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.LIST`, false, 1); Imperative.console.info("Using dsname:" + dsname); const user = `${defaultSystem.zosmf.user.trim()}`.replace(/\./g, ""); @@ -54,14 +52,14 @@ describe("List command group", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testString), `${dsname}(${testString})`); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should list all members of a data set", async () => { @@ -132,7 +130,7 @@ describe("List command group", () => { try { await Delete.dataSet(REAL_SESSION, `${dsname}(${testString})`); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds response = await List.allMembers(REAL_SESSION, dsname); } catch (err) { error = err; @@ -182,12 +180,12 @@ describe("List command group", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should list a data set", async () => { @@ -299,9 +297,9 @@ describe("List command group", () => { let response; try { response = await Create.uss(REAL_SESSION, path, "directory"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds response = await Create.uss(REAL_SESSION, `${path}/${filename}`, "file"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); @@ -594,17 +592,17 @@ describe("List command group", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname + ".LIKE", { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Delete.dataSet(REAL_SESSION, dsname + ".LIKE"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should find data sets that match a pattern", async () => { @@ -655,8 +653,8 @@ describe("List command group", () => { caughtError = error; } - expect(response).toBeDefined(); expect(caughtError).not.toBeDefined(); + expect(response).toBeDefined(); expect(response.commandResponse).toContain("There are no data sets that match"); }); }); @@ -670,8 +668,8 @@ describe("List command group - encoded", () => { testName: "zos_file_list" }); defaultSystem = testEnvironment.systemTestProperties; - REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); + REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.LIST`, true); Imperative.console.info("Using dsname:" + dsname); @@ -691,14 +689,14 @@ describe("List command group - encoded", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Upload.bufferToDataSet(REAL_SESSION, Buffer.from(testString), `${dsname}(${testString})`); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should list all members of a data set", async () => { @@ -750,12 +748,12 @@ describe("List command group - encoded", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should list a data set", async () => { @@ -833,9 +831,9 @@ describe("List command group - encoded", () => { beforeAll(async () => { try { await Create.uss(REAL_SESSION, path, "directory"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Create.uss(REAL_SESSION, `${path}/${filename}`, "file"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds } catch (err) { Imperative.console.info("Error: " + inspect(err)); } @@ -931,17 +929,17 @@ describe("List command group - encoded", () => { beforeEach(async () => { await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname, { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_SEQUENTIAL, dsname + ".LIKE", { volser: defaultSystem.datasets.vol }); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); afterEach(async () => { await Delete.dataSet(REAL_SESSION, dsname); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds await Delete.dataSet(REAL_SESSION, dsname + ".LIKE"); - await delay(delayTime); + await wait(waitTime); //wait 2 seconds }); it("should find data sets that match a pattern", async () => { @@ -992,8 +990,8 @@ describe("List command group - encoded", () => { caughtError = error; } - expect(response).toBeDefined(); expect(caughtError).not.toBeDefined(); + expect(response).toBeDefined(); expect(response.commandResponse).toContain("There are no data sets that match"); }); }); diff --git a/packages/zosfiles/__tests__/__system__/methods/mount/Mount.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/mount/Mount.system.test.ts index a60253f675..3e695baaec 100644 --- a/packages/zosfiles/__tests__/__system__/methods/mount/Mount.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/mount/Mount.system.test.ts @@ -14,7 +14,6 @@ import { inspect } from "util"; import { Create } from "../../../../src/methods/create"; import { Mount, IMountFsOptions } from "../../../../src/methods/mount"; import { Unmount } from "../../../../src/methods/unmount"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Delete } from "../../../../src/methods/delete"; @@ -22,6 +21,7 @@ import { List, ZosFilesMessages } from "../../../../src"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { ICreateZfsOptions } from "../../../../src/methods/create/doc/ICreateZfsOptions"; import { SshSession, Shell } from "@zowe/zos-uss-for-zowe-sdk"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/rename/Rename.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/rename/Rename.system.test.ts index 3bdf6fcea7..7b45beb974 100644 --- a/packages/zosfiles/__tests__/__system__/methods/rename/Rename.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/rename/Rename.system.test.ts @@ -12,10 +12,10 @@ import { Create, CreateDataSetTypeEnum, Delete, List, Rename, Upload, ZosFilesMessages } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { join } from "path"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts index 34ba130ba8..db839abc14 100644 --- a/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts @@ -10,11 +10,11 @@ */ import { Session } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { getUniqueDatasetName } from "../../../../../../__tests__/__src__/TestUtils"; import { Create, Upload, Delete, Search, CreateDataSetTypeEnum, ISearchOptions, IZosFilesResponse } from "../../../../src"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index 48d6d257a7..e0797df365 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -10,22 +10,20 @@ */ import { Create, CreateDataSetTypeEnum, Delete, IUploadOptions, IZosFilesResponse, - Upload, ZosFilesMessages, Download, Get, ZosFilesConstants, IUploadMap, Utilities } from "../../../../src"; + Upload, ZosFilesMessages, Download, Get, IUploadMap, Utilities } from "../../../../src"; import { Imperative, Session } from "@zowe/imperative"; import { inspect } from "util"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { getUniqueDatasetName, stripNewLines, delay } from "../../../../../../__tests__/__src__/TestUtils"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { deleteFiles, getUniqueDatasetName, stripNewLines, wait, waitTime } from "../../../../../../__tests__/__src__/TestUtils"; import * as fs from "fs"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; let defaultSystem: ITestPropertiesSchema; let dsname: string; let ussname: string; -const delayTime = 2000; const inputfile = __dirname + "/testfiles/upload.txt"; const testdata = "abcdefghijklmnopqrstuvwxyz"; const uploadOptions: IUploadOptions = {} as any; @@ -730,16 +728,7 @@ describe("Upload USS file", () => { }); afterEach(async () => { - let error; - let response; - - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - - try { - response = await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, ussname); }); it("should upload a USS file", async () => { @@ -890,13 +879,7 @@ describe("Upload USS file - encoded", () => { }); afterEach(async () => { - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint); - } catch (err) { - // Do nothing - } + await deleteFiles(REAL_SESSION, ussname); }); it("should upload a USS file", async () => { @@ -943,6 +926,7 @@ describe("Upload a local directory to USS directory", () => { describe("Success scenarios", () => { const localDir = `${__dirname}/testfiles`; const localDirWithSpaces = `${__dirname}/testfiles/space dir`; + let tempUssname: string; beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ testName: "zos_file_upload_dir_to_uss" @@ -958,26 +942,15 @@ describe("Upload a local directory to USS directory", () => { }); afterAll(async () => { - let error; await TestEnvironment.cleanUp(testEnvironment); - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, - ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname + " space dir"), - [{"X-IBM-Option": "recursive"}]); - } catch (err) { - error = err; - } + }); + + beforeEach(() => { + tempUssname = null; }); afterEach(async () => { - let error; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint, [{"X-IBM-Option": "recursive"}]); - await delay(delayTime); - } catch (err) { - error = err; - } + await deleteFiles(REAL_SESSION, tempUssname ?? ussname); }); it("should upload local directory to USS", async () => { @@ -986,7 +959,7 @@ describe("Upload a local directory to USS directory", () => { let isDirectoryExist: boolean; try { uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDir, ussname); - await delay(delayTime); + await wait(waitTime); Imperative.console.info(`THIS IS USS ${ussname}/testfiles`); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, ussname); } catch (err) { @@ -1003,13 +976,12 @@ describe("Upload a local directory to USS directory", () => { it("should upload local directory (with space in name) to USS", async () => { let error; - let tempUssname; let uploadResponse: IZosFilesResponse; let isDirectoryExist: boolean; try { tempUssname = ussname + " space dir"; uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDirWithSpaces, tempUssname); - await delay(delayTime); + await wait(waitTime); Imperative.console.info(`THIS IS USS ${tempUssname}`); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, tempUssname); } catch (err) { @@ -1030,7 +1002,7 @@ describe("Upload a local directory to USS directory", () => { let isDirectoryExist: any; try { uploadResponse = await Upload.dirToUSSDirRecursive(REAL_SESSION, localDir, ussname, {binary: false}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, `${ussname}/longline`); } catch (err) { error = err; @@ -1051,7 +1023,7 @@ describe("Upload a local directory to USS directory", () => { let getResponse; try { uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDir, ussname, {binary: true}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, ussname); getResponse = await Get.USSFile(REAL_SESSION, `${ussname}/file1.txt`, {binary: true}); } catch (err) { @@ -1076,7 +1048,7 @@ describe("Upload a local directory to USS directory", () => { let longResponse: string = ""; try { uploadResponse = await Upload.dirToUSSDirRecursive(REAL_SESSION, localDir, ussname, {binary: true}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, ussname); getResponse = await Get.USSFile(REAL_SESSION, `${ussname}/longline/longline.txt`, {binary: true}); for (let i = 0; i < magicNum; i++) { @@ -1107,7 +1079,7 @@ describe("Upload a local directory to USS directory", () => { const fileMap: IUploadMap = {binary: true, fileNames: ["file3.txt", "longline.txt"]}; try { uploadResponse = await Upload.dirToUSSDirRecursive(REAL_SESSION, localDir, ussname, {binary: false, filesMap: fileMap}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, `${ussname}/longline`); // file3.txt should be binary as it is mentioned in filesMap getResponseFile3 = await Get.USSFile(REAL_SESSION, `${ussname}/file3.txt`, {binary: true}); @@ -1145,7 +1117,7 @@ describe("Upload a local directory to USS directory", () => { const filesMap: IUploadMap = {binary: false, fileNames: ["file3.txt", "longline.txt"]}; try { uploadResponse = await Upload.dirToUSSDirRecursive(REAL_SESSION, localDir, ussname, {binary: true, filesMap}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, `${ussname}/longline`); // file3.txt should be ASCII as it is mentioned in filesMap getResponseFile3 = await Get.USSFile(REAL_SESSION, `${ussname}/file3.txt`, {binary: false}); @@ -1182,17 +1154,11 @@ describe("Upload a local directory to USS directory", () => { REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); Imperative.console.info("Using ussfile:" + ussname); + testEnvironment.resources.files.push(ussname); }); afterAll(async () => { await TestEnvironment.cleanUp(testEnvironment); - let error; - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + ussname; - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint, [{"X-IBM-Option": "recursive"}]); - } catch (err) { - error = err; - } }); it("should throw an error if local directory is null", async () => { @@ -1307,6 +1273,7 @@ describe("Upload a local directory to USS directory - encoded", () => { describe("Success scenarios", () => { const localDir = `${__dirname}/testfiles`; const localDirWithSpaces = `${__dirname}/testfiles/space dir`; + let tempUssname: string; beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ testName: "zos_file_upload_dir_to_uss" @@ -1321,25 +1288,16 @@ describe("Upload a local directory to USS directory - encoded", () => { Imperative.console.info("Using ussfile:" + ussname); }); + beforeEach(() => { + tempUssname = null; + }); + afterAll(async () => { await TestEnvironment.cleanUp(testEnvironment); - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, - ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname + " space dir"), - [{"X-IBM-Option": "recursive"}]); - } catch (err) { - // Do nothing - } }); afterEach(async () => { - const endpoint: string = ZosFilesConstants.RESOURCE + ZosFilesConstants.RES_USS_FILES + encodeURIComponent(ussname); - try { - await ZosmfRestClient.deleteExpectString(REAL_SESSION, endpoint, [{"X-IBM-Option": "recursive"}]); - await delay(delayTime); - } catch (err) { - // Do nothing - } + await deleteFiles(REAL_SESSION, tempUssname ?? ussname); }); it("should upload local directory to USS", async () => { @@ -1348,7 +1306,7 @@ describe("Upload a local directory to USS directory - encoded", () => { let isDirectoryExist: boolean; try { uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDir, ussname); - await delay(delayTime); + await wait(waitTime); Imperative.console.info(`THIS IS USS ${ussname}/testfiles`); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, ussname); } catch (err) { @@ -1365,13 +1323,12 @@ describe("Upload a local directory to USS directory - encoded", () => { it("should upload local directory (with space in name) to USS", async () => { let error; - let tempUssname; let uploadResponse: IZosFilesResponse; let isDirectoryExist: boolean; try { tempUssname = ussname + " space dir"; uploadResponse = await Upload.dirToUSSDir(REAL_SESSION, localDirWithSpaces, tempUssname); - await delay(delayTime); + await wait(waitTime); Imperative.console.info(`THIS IS USS ${tempUssname}`); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, tempUssname); } catch (err) { @@ -1392,7 +1349,7 @@ describe("Upload a local directory to USS directory - encoded", () => { let isDirectoryExist: any; try { uploadResponse = await Upload.dirToUSSDirRecursive(REAL_SESSION, localDir, ussname, {binary: false}); - await delay(delayTime); + await wait(waitTime); isDirectoryExist = await Upload.isDirectoryExist(REAL_SESSION, `${ussname}/longline`); } catch (err) { error = err; @@ -1407,4 +1364,4 @@ describe("Upload a local directory to USS directory - encoded", () => { }); }); -}); \ No newline at end of file +}); diff --git a/packages/zosfiles/__tests__/__system__/methods/utilities/Utilities.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/utilities/Utilities.system.test.ts index d3a6bb3263..7473650100 100644 --- a/packages/zosfiles/__tests__/__system__/methods/utilities/Utilities.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/utilities/Utilities.system.test.ts @@ -10,36 +10,37 @@ */ import { posix } from "path"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { AbstractSession, Imperative, IO } from "@zowe/imperative"; -import { Utilities, Tag, Upload, Create, Download, Delete } from "../../../../src"; +import { Utilities, Tag, Upload, Create, Download } from "../../../../src"; import { getUniqueDatasetName, getTag } from "../../../../../../__tests__/__src__/TestUtils"; let REAL_SESSION: AbstractSession; let testEnvironment: ITestEnvironment; describe("USS Utilities", () => { - const localfile = __dirname + "/__data__/tagfile.txt"; let ussname: string; + beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ tempProfileTypes: ["zosmf"], testName: "zos_files_utilities" }); + REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); + const defaultSystem = testEnvironment.systemTestProperties; let dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILE.UPLOAD`); dsname = dsname.replace(/\./g, ""); ussname = `${defaultSystem.unix.testdir}/${dsname}`; Imperative.console.info("Using ussDir:" + ussname); - REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - + testEnvironment.resources.files.push(ussname); }); + afterAll(async () => { - await Delete.ussFile(REAL_SESSION, ussname); await TestEnvironment.cleanUp(testEnvironment); }); @@ -93,6 +94,7 @@ describe("USS Utilities", () => { // Delete created local file IO.deleteFile(posix.basename(newName)); + testEnvironment.resources.files.push(newName); }); it("should rename USS file - encoded", async () => { @@ -115,6 +117,7 @@ describe("USS Utilities", () => { // Delete created local file IO.deleteFile(posix.basename(newName)); + testEnvironment.resources.files.push(newName); }); describe("applyTaggedEncoding", () => { diff --git a/packages/zosfiles/__tests__/__unit__/methods/search/Search.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/search/Search.unit.test.ts index 79f86328e8..de4bb9f4db 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/search/Search.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/search/Search.unit.test.ts @@ -1508,4 +1508,4 @@ describe("Search", () => { expect(response).toEqual({responses: [], failures: []}); }); }); -}); +}); \ No newline at end of file diff --git a/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts index 06822f259d..5ce5b20883 100644 --- a/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts @@ -11,10 +11,10 @@ import { ImperativeError, Session, RestClientError } from "@zowe/imperative"; import { CancelJobs, SubmitJobs, IJob } from "../../src"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { JobTestsUtils } from "./JobTestsUtils"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { JobTestsUtils } from "./JobTestsUtils"; let REAL_SESSION: Session; let sleepJCL: string; @@ -35,16 +35,20 @@ describe("CancelJobs System tests", () => { const ACCOUNT = systemProps.tso.account; const maxStepNum = 6; // Use lots of steps to make the job stay in INPUT status longer - sleepJCL = JobTestsUtils.getSleepJCL(REAL_SESSION.ISession.user, ACCOUNT, systemProps.zosjobs.jobclass, maxStepNum); }); + afterAll(async () => { + await TestEnvironment.cleanUp(testEnvironment); + }); + describe("Positive tests", () => { it("should be able to cancel a job using cancelJob (modify version 1)", async () => { const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); expect(job.retcode).toBeNull(); // job is not complete, no CC const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid, "1.0"); expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJob (modify version 2)", async () => { @@ -53,6 +57,7 @@ describe("CancelJobs System tests", () => { const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid, "2.0"); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJob (modify version default)", async () => { @@ -61,6 +66,7 @@ describe("CancelJobs System tests", () => { const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version 1)", async () => { @@ -68,6 +74,7 @@ describe("CancelJobs System tests", () => { expect(job.retcode).toBeNull(); // job is not complete, no CC const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job, "1.0"); expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version 2)", async () => { @@ -76,6 +83,7 @@ describe("CancelJobs System tests", () => { const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job, "2.0"); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version default)", async () => { @@ -84,6 +92,7 @@ describe("CancelJobs System tests", () => { const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 1)", async () => { @@ -91,6 +100,7 @@ describe("CancelJobs System tests", () => { expect(job.retcode).toBeNull(); // job is not complete, no CC const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "1.0"}); expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous)", async () => { @@ -99,6 +109,7 @@ describe("CancelJobs System tests", () => { const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "2.0"}); expect(response).toBeDefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version default)", async () => { @@ -106,6 +117,7 @@ describe("CancelJobs System tests", () => { expect(job.retcode).toBeNull(); // job is not complete, no CC const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous) and return an error feedback object", async () => { @@ -115,6 +127,7 @@ describe("CancelJobs System tests", () => { expect(response?.status).toEqual("0"); response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "2.0"}); expect(response?.status).toEqual("156"); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); }); @@ -184,10 +197,13 @@ describe("CancelJobs System tests - encoded", () => { const ACCOUNT = systemProps.tso.account; const maxStepNum = 6; // Use lots of steps to make the job stay in INPUT status longer - sleepJCL = JobTestsUtils.getSleepJCL(REAL_SESSION.ISession.user, ACCOUNT, systemProps.zosjobs.jobclass, maxStepNum, true); }); + afterAll(async () => { + await TestEnvironment.cleanUp(testEnvironment); + }); + describe("Positive tests", () => { it("should be able to cancel a job using cancelJob (modify version default)", async () => { const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); @@ -195,6 +211,7 @@ describe("CancelJobs System tests - encoded", () => { const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version default)", async () => { @@ -203,6 +220,7 @@ describe("CancelJobs System tests - encoded", () => { const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); expect(response).not.toBeUndefined(); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version default)", async () => { @@ -210,6 +228,7 @@ describe("CancelJobs System tests - encoded", () => { expect(job.retcode).toBeNull(); // job is not complete, no CC const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous) and return an error feedback object", async () => { @@ -219,6 +238,7 @@ describe("CancelJobs System tests - encoded", () => { expect(response?.status).toEqual("0"); response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "2.0"}); expect(response?.status).toEqual("156"); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); }); }); diff --git a/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts index a12dc6957c..d0f96bf6bf 100644 --- a/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts @@ -12,11 +12,11 @@ import { ImperativeError, Session } from "@zowe/imperative"; import { DeleteJobs, IJobFeedback, SubmitJobs } from "../../src"; import { IJob } from "../../src/doc/response/IJob"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Get } from "@zowe/zos-files-for-zowe-sdk"; import { JobTestsUtils } from "./JobTestsUtils"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; let REAL_SESSION: Session; let iefbr14JCL: string; diff --git a/packages/zosjobs/__tests__/__system__/DownloadJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/DownloadJobs.system.test.ts index ce1e1bedaa..ba34e0f1ed 100644 --- a/packages/zosjobs/__tests__/__system__/DownloadJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/DownloadJobs.system.test.ts @@ -9,9 +9,9 @@ * */ -import { DeleteJobs, DownloadJobs, GetJobs, IJobFile, SubmitJobs } from "../../src"; +import { DownloadJobs, GetJobs, IJobFile, SubmitJobs } from "../../src"; import { ImperativeError, IO, Session, TextUtils } from "@zowe/imperative"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { Get } from "@zowe/zos-files-for-zowe-sdk"; @@ -44,6 +44,7 @@ describe("Download Jobs - System tests", () => { testEnvironment = await TestEnvironment.setUp({ testName: "zos_download_jobs" }); + outputDirectory = testEnvironment.workingDir + "/output"; defaultSystem = testEnvironment.systemTestProperties; @@ -56,6 +57,7 @@ describe("Download Jobs - System tests", () => { const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, { jcl: iefbr14JCL }); + testEnvironment.resources.jobs.push(job); jobid = job.jobid; jobname = job.jobname; jobFiles = await GetJobs.getSpoolFiles(REAL_SESSION, jobname, jobid); @@ -78,7 +80,7 @@ describe("Download Jobs - System tests", () => { }); afterAll(async () => { - await DeleteJobs.deleteJob(REAL_SESSION, jobname, jobid); + await TestEnvironment.cleanUp(testEnvironment); }); describe("Special Positive tests", () => { @@ -91,6 +93,7 @@ describe("Download Jobs - System tests", () => { const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, { jcl: iefbr14JCLAltered }); + testEnvironment.resources.jobs.push(job); alteredjobid = job.jobid; alteredjobname = job.jobname; alteredjobFiles = await GetJobs.getSpoolFiles(REAL_SESSION, alteredjobname, alteredjobid); @@ -259,6 +262,8 @@ describe("Download Jobs - System tests", () => { const job: IJob = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + testEnvironment.resources.jobs.push(job); + await MonitorJobs.waitForJobOutputStatus(REAL_SESSION, job); await DownloadJobs.downloadAllSpoolContentCommon(REAL_SESSION, { @@ -364,6 +369,7 @@ describe("Download Jobs - System tests - Encoded", () => { const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, { jcl: iefbr14JCL }); + testEnvironment.resources.jobs.push(job); jobid = job.jobid; jobname = job.jobname; jobFiles = await GetJobs.getSpoolFiles(REAL_SESSION, jobname, jobid); @@ -385,7 +391,7 @@ describe("Download Jobs - System tests - Encoded", () => { }); afterAll(async () => { - await DeleteJobs.deleteJob(REAL_SESSION, jobname, jobid); + await TestEnvironment.cleanUp(testEnvironment); }); describe("Positive tests", () => { @@ -498,6 +504,7 @@ describe("Download Jobs - System tests - Encoded", () => { {JOBNAME: DOWNLOAD_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); const job: IJob = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + testEnvironment.resources.jobs.push(job); await MonitorJobs.waitForJobOutputStatus(REAL_SESSION, job); diff --git a/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts index 5a65c75ec6..5ca70448c9 100644 --- a/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/GetJobs.system.test.ts @@ -15,9 +15,10 @@ import { DeleteJobs, GetJobs, IJob, JOB_STATUS_ORDER, SubmitJobs } from "../../s import * as fs from "fs"; import { TEST_RESOURCES_DIR } from "../__src__/ZosJobsTestConstants"; import { join } from "path"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; +import { wait } from "../../../../__tests__/__src__/TestUtils"; /**********************************************************************************/ let ACCOUNT: string; @@ -43,15 +44,6 @@ const trimMessage = (message: string) => { // this allows us to expect things like "reason: 6" regardless of how prettyjson aligns the text return message.replace(/( {2,})|\t/g, " "); }; -const waitThreeSeconds = () => { - return new Promise((resolveWaitTime) => { - const threeSeconds = 3000; - setTimeout(() => { - resolveWaitTime(); - }, threeSeconds); - } - ); -}; let defaultSystem: ITestPropertiesSchema; let testEnvironment: ITestEnvironment; @@ -160,7 +152,7 @@ describe("Get Jobs - System Tests", () => { } // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Obtain all jobs for the user const allJobs: IJob[] = await GetJobs.getJobs(REAL_SESSION); @@ -197,7 +189,7 @@ describe("Get Jobs - System Tests", () => { // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Search all jobs returned for each of the submitted jobs const foundJob = await GetJobs.getJob(REAL_SESSION, job.jobid); @@ -225,7 +217,7 @@ describe("Get Jobs - System Tests", () => { // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Search all jobs returned for each of the submitted jobs const foundJobs = await GetJobs.getJobsCommon(REAL_SESSION, {jobid: job.jobid}); @@ -296,7 +288,7 @@ describe("Get Jobs - System Tests", () => { // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Obtain the three jobs submitted const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, MONITOR_JOB_NAME + "*"); @@ -354,7 +346,7 @@ describe("Get Jobs - System Tests", () => { // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Obtain the three jobs submitted const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, TEST_JOB_NAME + "*"); @@ -440,7 +432,7 @@ describe("Get Jobs - System Tests", () => { // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); // Obtain all jobs for ***REMOVED*** const allJobs: IJob[] = await GetJobs.getJobsByOwner(REAL_SESSION, REAL_SESSION.ISession.user); expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); @@ -459,614 +451,716 @@ describe("Get Jobs - System Tests", () => { }, LONG_TIMEOUT); }); }); -}); - -/**********************************************/ -// API methods "getStatus..." system tests -describe("Get Status APIs", () => { /**********************************************/ - // API methods "getStatus" system tests - describe("get status API", () => { - describe("invalid request error handling", () => { - it("should detect and surface an error for an invalid user", - async () => { + // API methods "getStatus..." system tests + describe("Get Status APIs", () => { + + /**********************************************/ + // API methods "getStatus" system tests + describe("get status API", () => { + describe("invalid request error handling", () => { + it("should detect and surface an error for an invalid user", + async () => { + let err; + try { + await GetJobs.getStatus(INVALID_SESSION, "FAKE", "FAKE"); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + expect(err.message).toContain("status 401"); // unauthorized - bad credentials + } + ); + + it("should detect and surface an error for an invalid jobname", async () => { let err; try { - await GetJobs.getStatus(INVALID_SESSION, "FAKE", "FAKE"); + await GetJobs.getStatus(REAL_SESSION, "))))))))", "JOB123"); } catch (e) { err = e; } expect(err).toBeDefined(); expect(err instanceof ImperativeError).toBe(true); - expect(err.message).toContain("status 401"); // unauthorized - bad credentials - } - ); - - it("should detect and surface an error for an invalid jobname", async () => { - let err; - try { - await GetJobs.getStatus(REAL_SESSION, "))))))))", "JOB123"); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); - }); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }); - it("should detect and surface an error for an invalid jobid", async () => { - let err; - try { - await GetJobs.getStatus(REAL_SESSION, "***REMOVED***1", "))))))))))"); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); + it("should detect and surface an error for an invalid jobid", async () => { + let err; + try { + await GetJobs.getStatus(REAL_SESSION, "***REMOVED***1", "))))))))))"); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }); }); - }); - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - }); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect the jobname to match - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); + // Expect the jobname to match + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); - }); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); - }, LONG_TIMEOUT); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); + }); }); - }); - /**********************************************/ - // API methods "getStatusCommon" system tests - describe("get status common API", () => { - describe("invalid request error handling", () => { - it("should detect and surface an error for an invalid user", async () => { - let err; - try { - await GetJobs.getStatusCommon(INVALID_SESSION, {jobname: "FAKE", jobid: "FAKE"}); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - expect(err.message).toContain("status 401"); // unauthorized - bad credentials - }); + /**********************************************/ + // API methods "getStatusCommon" system tests + describe("get status common API", () => { + describe("invalid request error handling", () => { + it("should detect and surface an error for an invalid user", async () => { + let err; + try { + await GetJobs.getStatusCommon(INVALID_SESSION, {jobname: "FAKE", jobid: "FAKE"}); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + expect(err.message).toContain("status 401"); // unauthorized - bad credentials + }); - it("should detect and surface an error for an invalid jobname", async () => { - let err; - try { - await GetJobs.getStatusCommon(REAL_SESSION, {jobname: "))))))))", jobid: "JOB123"}); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); - expect(trimmedErrorMessage).toContain("JOB123"); - }); + it("should detect and surface an error for an invalid jobname", async () => { + let err; + try { + await GetJobs.getStatusCommon(REAL_SESSION, {jobname: "))))))))", jobid: "JOB123"}); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + expect(trimmedErrorMessage).toContain("JOB123"); + }); - it("should detect and surface an error for an invalid jobid", async () => { - let err; - try { - await GetJobs.getStatusCommon(REAL_SESSION, {jobname: "***REMOVED***1", jobid: "))))))))))"}); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); + it("should detect and surface an error for an invalid jobid", async () => { + let err; + try { + await GetJobs.getStatusCommon(REAL_SESSION, {jobname: "***REMOVED***1", jobid: "))))))))))"}); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }); }); - }); - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - }); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is input - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); + // Expect that the status is input + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); - }); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); - }, LONG_TIMEOUT); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); + }); }); - }); - /**********************************************/ - // API methods "getStatusForJob" system tests - describe("get status for job API", () => { - describe("invalid request error handling", () => { - it("should detect and surface an error for an invalid user", async () => { - let err; - try { - const job: any = {jobname: "FAKE", jobid: "fake"}; - await GetJobs.getStatusForJob(INVALID_SESSION, job); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - expect(trimmedErrorMessage).toContain("status 401"); - }); + /**********************************************/ + // API methods "getStatusForJob" system tests + describe("get status for job API", () => { + describe("invalid request error handling", () => { + it("should detect and surface an error for an invalid user", async () => { + let err; + try { + const job: any = {jobname: "FAKE", jobid: "fake"}; + await GetJobs.getStatusForJob(INVALID_SESSION, job); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + expect(trimmedErrorMessage).toContain("status 401"); + }); - it("should be able to get a job that was submitted and get proper error when the job is deleted", async () => { - const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); - const jobStatus = await GetJobs.getStatusForJob(REAL_SESSION, job); + it("should be able to get a job that was submitted and get proper error when the job is deleted", async () => { + const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); + const jobStatus = await GetJobs.getStatusForJob(REAL_SESSION, job); - await DeleteJobs.deleteJobForJob(REAL_SESSION, job); - await waitThreeSeconds(); // make sure jobs is deleted - let error; - try { - await GetJobs.getStatusForJob(REAL_SESSION, job); - } catch (thrownError) { - error = thrownError; - } - expect(error).toBeDefined(); - expect(JSON.parse(error.causeErrors).rc).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).reason).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).category).toMatchSnapshot(); - }, LONG_TIMEOUT); + await DeleteJobs.deleteJobForJob(REAL_SESSION, job); + await wait(3000); // make sure jobs is deleted + let error; + try { + await GetJobs.getStatusForJob(REAL_SESSION, job); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(JSON.parse(error.causeErrors).rc).toEqual(4); + expect(JSON.parse(error.causeErrors).reason).toEqual(10); + expect(JSON.parse(error.causeErrors).category).toEqual(6); + }, LONG_TIMEOUT); - it("should detect and surface an error for an invalid jobname", async () => { - let err; - try { - await GetJobs.getStatusForJob(REAL_SESSION, {jobname: "))))))))", jobid: "JOB123"} as any); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); - }); + it("should detect and surface an error for an invalid jobname", async () => { + let err; + try { + await GetJobs.getStatusForJob(REAL_SESSION, {jobname: "))))))))", jobid: "JOB123"} as any); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }); - it("should detect and surface an error for an invalid jobid", async () => { - let err; - try { - await GetJobs.getStatusForJob(REAL_SESSION, {jobname: "***REMOVED***1", jobid: "))))))))))"} as any); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err instanceof ImperativeError).toBe(true); - const trimmedErrorMessage = trimMessage(err.message); - const jsonCauseErrors = JSON.parse(err.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(7); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); + it("should detect and surface an error for an invalid jobid", async () => { + let err; + try { + await GetJobs.getStatusForJob(REAL_SESSION, {jobname: "***REMOVED***1", jobid: "))))))))))"} as any); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err instanceof ImperativeError).toBe(true); + const trimmedErrorMessage = trimMessage(err.message); + const jsonCauseErrors = JSON.parse(err.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(7); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }); }); - }); - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - }); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is input - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); + // Expect that the status is input + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); - }); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); - }, LONG_TIMEOUT); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); + }); }); }); -}); -/**********************************************/ -// API methods "getSpool..." system tests -describe("Get spool APIs", () => { - describe("invalid request error handling", () => { - it("should detect and surface an error for getting spool content that doesnt exist", async () => { - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - await DeleteJobs.deleteJobForJob(REAL_SESSION, job); - await waitThreeSeconds(); - let error; - try { - const content = await GetJobs.getSpoolContent(REAL_SESSION, files[0]); - } catch (thrownError) { - error = thrownError; - } - expect(error).toBeDefined(); - expect(JSON.parse(error.causeErrors).rc).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).reason).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).category).toMatchSnapshot(); - const trimmedErrorMessage = trimMessage(error.message); - const jsonCauseErrors = JSON.parse(error.causeErrors); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(10); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); - }, LONG_TIMEOUT); - }); + /**********************************************/ + // API methods "getSpool..." system tests + describe("Get spool APIs", () => { + describe("invalid request error handling", () => { + it("should detect and surface an error for getting spool content that doesnt exist", async () => { + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + await DeleteJobs.deleteJobForJob(REAL_SESSION, job); + await wait(3000); + let error; + try { + const content = await GetJobs.getSpoolContent(REAL_SESSION, files[0]); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(JSON.parse(error.causeErrors).rc).toEqual(4); + expect(JSON.parse(error.causeErrors).reason).toEqual(10); + expect(JSON.parse(error.causeErrors).category).toEqual(6); + const trimmedErrorMessage = trimMessage(error.message); + const jsonCauseErrors = JSON.parse(error.causeErrors); + expect(jsonCauseErrors.category).toEqual(6); + expect(jsonCauseErrors.reason).toEqual(10); + expect(jsonCauseErrors.rc).toEqual(4); + expect(trimmedErrorMessage).toContain("status 400"); + }, LONG_TIMEOUT); + }); - describe("list spool files/dds", () => { - it("should be able to get all spool files in a job", async () => { - const NUM_OF_SPOOL_FILES = 3; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - files.forEach((file) => { - expect(file.jobname).toEqual(job.jobname); // verify jobname is in each jobfile + describe("list spool files/dds", () => { + it("should be able to get all spool files in a job", async () => { + const NUM_OF_SPOOL_FILES = 3; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + files.forEach((file) => { + expect(file.jobname).toEqual(job.jobname); // verify jobname is in each jobfile + }); + await DeleteJobs.deleteJobForJob(REAL_SESSION, job); }); - await DeleteJobs.deleteJobForJob(REAL_SESSION, job); }); - }); - describe("download spool files", () => { - it("Should get spool content from a job", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - let found = false; - - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file); - expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - found = true; + describe("download spool files", () => { + it("Should get spool content from a job", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + let found = false; + + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file); + expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + found = true; + } } - } - expect(found).toBe(true); - }, LONG_TIMEOUT); - - it("Should get spool content from a job with encoding", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY¬¬"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - let found = false; - - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file, "IBM-037"); - expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - expect(dataContent).toContain("PUTTYPUTTYPUTTY"); - expect(dataContent).not.toContain("¬¬"); - expect(dataContent).toContain("^^"); - found = true; + expect(found).toBe(true); + }, LONG_TIMEOUT); + + it("Should get spool content from a job with encoding", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY¬¬"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + let found = false; + + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file, "IBM-037"); + expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + expect(dataContent).toContain("PUTTYPUTTYPUTTY"); + expect(dataContent).not.toContain("¬¬"); + expect(dataContent).toContain("^^"); + found = true; + } } - } - expect(found).toBe(true); - }, LONG_TIMEOUT); - - it("Should get spool content for a single job", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id); - expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - break; + expect(found).toBe(true); + }, LONG_TIMEOUT); + + it("Should get spool content for a single job", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id); + expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + break; + } } - } - }, LONG_TIMEOUT); - - it("Should get spool content for a single job with encoding", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY¬¬"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id, "IBM-037"); - expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - expect(content).toContain("PUTTYPUTTYPUTTY"); - expect(content).not.toContain("¬¬"); - expect(content).toContain("^^"); - break; + }, LONG_TIMEOUT); + + it("Should get spool content for a single job with encoding", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY¬¬"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id, "IBM-037"); + expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + expect(content).toContain("PUTTYPUTTYPUTTY"); + expect(content).not.toContain("¬¬"); + expect(content).toContain("^^"); + break; + } } - } - }, LONG_TIMEOUT); + }, LONG_TIMEOUT); + }); }); -}); -/**********************************************/ -// API methods "getJcl..." system tests -describe("Get JCL APIs", () => { - describe("invalid request error handling", () => { - it("should detect and surface an error for getting JCL that doesnt exist", async () => { - const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); - await DeleteJobs.deleteJobForJob(REAL_SESSION, job); - await waitThreeSeconds(); - let error; - try { - await GetJobs.getJclForJob(REAL_SESSION, job); - } catch (thrownError) { - error = thrownError; - } - expect(error).toBeDefined(); - expect(JSON.parse(error.causeErrors).rc).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).reason).toMatchSnapshot(); - expect(JSON.parse(error.causeErrors).category).toMatchSnapshot(); - const trimmedErrorMessage = trimMessage(error.message); - expect(trimmedErrorMessage).toContain("status 400"); - expect(trimmedErrorMessage).toContain(job.jobid); + /**********************************************/ + // API methods "getJcl..." system tests + describe("Get JCL APIs", () => { + describe("invalid request error handling", () => { + it("should detect and surface an error for getting JCL that doesnt exist", async () => { + const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); + await DeleteJobs.deleteJobForJob(REAL_SESSION, job); + await wait(3000); + let error; + try { + await GetJobs.getJclForJob(REAL_SESSION, job); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(JSON.parse(error.causeErrors).rc).toEqual(4); + expect(JSON.parse(error.causeErrors).reason).toEqual(10); + expect(JSON.parse(error.causeErrors).category).toEqual(6); + const trimmedErrorMessage = trimMessage(error.message); + expect(trimmedErrorMessage).toContain("status 400"); + expect(trimmedErrorMessage).toContain(job.jobid); + }); }); - }); - describe("download JCL", () => { - it("should be able to get jcl from a job that was submitted", async () => { - const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); - const jcl = await GetJobs.getJclForJob(REAL_SESSION, job); - expect(jcl).toContain("EXEC PGM=IEFBR14"); - expect(jcl).toContain("JOB"); + describe("download JCL", () => { + it("should be able to get jcl from a job that was submitted", async () => { + const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); + const jcl = await GetJobs.getJclForJob(REAL_SESSION, job); + expect(jcl).toContain("EXEC PGM=IEFBR14"); + expect(jcl).toContain("JOB"); + }); }); }); -}); -describe("Get Jobs - System Tests - Encoded", () => { + describe("Get Jobs - System Tests - Encoded", () => { - beforeAll(async () => { - testEnvironment = await TestEnvironment.setUp({ - testName: "zos_get_jobs_encoded" - }); - defaultSystem = testEnvironment.systemTestProperties; + beforeAll(async () => { + testEnvironment = await TestEnvironment.setUp({ + testName: "zos_get_jobs_encoded" + }); + defaultSystem = testEnvironment.systemTestProperties; - REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); + REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - INVALID_SESSION = new Session({ - user: "fakeuser", - password: "fake", - hostname: defaultSystem.zosmf.host, - port: defaultSystem.zosmf.port, - type: "basic", - rejectUnauthorized: false + INVALID_SESSION = new Session({ + user: "fakeuser", + password: "fake", + hostname: defaultSystem.zosmf.host, + port: defaultSystem.zosmf.port, + type: "basic", + rejectUnauthorized: false + }); + + ACCOUNT = defaultSystem.tso.account; + MONITOR_JOB_NAME = REAL_SESSION.ISession.user?.toUpperCase().substring(0, 5) + "#G"; + + JOBCLASS = testEnvironment.systemTestProperties.zosjobs.jobclass; + SYSAFF = testEnvironment.systemTestProperties.zosjobs.sysaff; + + // TODO: What string goes in the removed section? + JCL = + "//" + MONITOR_JOB_NAME + " JOB '" + ACCOUNT + "',CLASS=" + JOBCLASS + "\n" + + "//IEFBR14 EXEC PGM=IEFBR14"; // GetJobs }); - ACCOUNT = defaultSystem.tso.account; - MONITOR_JOB_NAME = REAL_SESSION.ISession.user?.toUpperCase().substring(0, 5) + "#G"; + // Cleanup before & after each test - this will ensure that hopefully no jobs are left outstanding (or are currently + // outstanding) when the tests run + beforeEach(async () => { + await cleanTestJobs(MONITOR_JOB_NAME); + await cleanTestJobs(TEST_JOB_NAME); + }); + afterEach(async () => { + await cleanTestJobs(MONITOR_JOB_NAME); + await cleanTestJobs(TEST_JOB_NAME); + }); - JOBCLASS = testEnvironment.systemTestProperties.zosjobs.jobclass; - SYSAFF = testEnvironment.systemTestProperties.zosjobs.sysaff; + /**********************************************/ + // API methods "getJobs..." system tests + describe("Get Jobs APIs", () => { + + /**********************************************/ + // API methods "getJobs" system tests + describe("get jobs API", () => { + describe("list jobs", () => { + it("should return all jobs for the user in the session", async () => { + // Read the JCL template file + const NUM_JOBS = 3; + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + + // Submit a few jobs to list + const jobs: IJob[] = []; + for (let x = 0; x < NUM_JOBS; x++) { + + // Render the job with increasing job name + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + expect(job.status).toEqual("OUTPUT"); + expect(job.retcode).toEqual("CC 0000"); + jobs.push(job); + } + // TODO: this is a workaround for an issue where listing jobs immediately after they are completed + // results in the jobs being omitted from the results + await wait(3000); + + // Obtain all jobs for the user + const allJobs: IJob[] = await GetJobs.getJobs(REAL_SESSION); + expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); + + // Search all jobs returned for each of the submitted jobs + jobs.forEach((submittedJob) => { + let found = false; + for (const returnedJob of allJobs) { + if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { + found = true; + break; + } + } + expect(found).toBe(true); + }); + }, LONG_TIMEOUT); - // TODO: What string goes in the removed section? - JCL = - "//" + MONITOR_JOB_NAME + " JOB '" + ACCOUNT + "',CLASS=" + JOBCLASS + "\n" + - "//IEFBR14 EXEC PGM=IEFBR14"; // GetJobs - }); + it("should be able to get a single job by job ID", async () => { + // Read the JCL template file + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - // Cleanup before & after each test - this will ensure that hopefully no jobs are left outstanding (or are currently - // outstanding) when the tests run - beforeEach(async () => { - await cleanTestJobs(MONITOR_JOB_NAME); - await cleanTestJobs(TEST_JOB_NAME); - }); - afterEach(async () => { - await cleanTestJobs(MONITOR_JOB_NAME); - await cleanTestJobs(TEST_JOB_NAME); - }); + // submit a job that we can list + // Render the job with increasing job name + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME + "S", ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - /**********************************************/ - // API methods "getJobs..." system tests - describe("Get Jobs APIs", () => { + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + expect(job.status).toEqual("OUTPUT"); + expect(job.retcode).toEqual("CC 0000"); + + + // TODO: this is a workaround for an issue where listing jobs immediately after they are completed + // results in the jobs being omitted from the results + await wait(3000); + + // Search all jobs returned for each of the submitted jobs + const foundJob = await GetJobs.getJob(REAL_SESSION, job.jobid); + expect(foundJob).toBeDefined(); + expect(foundJob.jobid).toEqual(job.jobid); + expect(foundJob.jobname).toEqual(job.jobname); + }, LONG_TIMEOUT); + }); + + it("should be able to get a single job by job ID with jobid parm on the getJobs API", async () => { + // Read the JCL template file + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + + // submit a job that we can list + // Render the job with increasing job name + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME + "S", ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + expect(job.status).toEqual("OUTPUT"); + expect(job.retcode).toEqual("CC 0000"); + + + // TODO: this is a workaround for an issue where listing jobs immediately after they are completed + // results in the jobs being omitted from the results + await wait(3000); + + // Search all jobs returned for each of the submitted jobs + const foundJobs = await GetJobs.getJobsCommon(REAL_SESSION, {jobid: job.jobid}); + expect(foundJobs).toBeDefined(); + expect(foundJobs.length).toEqual(1); + expect(foundJobs[0].jobid).toEqual(job.jobid); + expect(foundJobs[0].jobname).toEqual(job.jobname); + }, LONG_TIMEOUT); + }); + }); /**********************************************/ - // API methods "getJobs" system tests - describe("get jobs API", () => { + // API methods "getJobsByPrefix" system tests + describe("get jobs by prefix API", () => { describe("list jobs", () => { - it("should return all jobs for the user in the session", async () => { + it("should return all jobs for the prefix of the user id and the owner is the session user id", async () => { // Read the JCL template file const NUM_JOBS = 3; const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); @@ -1086,12 +1180,13 @@ describe("Get Jobs - System Tests - Encoded", () => { expect(job.retcode).toEqual("CC 0000"); jobs.push(job); } + // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); - // Obtain all jobs for the user - const allJobs: IJob[] = await GetJobs.getJobs(REAL_SESSION); + // Obtain the three jobs submitted + const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, MONITOR_JOB_NAME + "*"); expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); // Search all jobs returned for each of the submitted jobs @@ -1107,510 +1202,407 @@ describe("Get Jobs - System Tests - Encoded", () => { }); }, LONG_TIMEOUT); - it("should be able to get a single job by job ID", async () => { + it("should throw an error if we specify a job ID that doesn't exist", async () => { + let err: ImperativeError; + try { + await GetJobs.getJob(REAL_SESSION, "J999999"); + } catch (e) { + err = e; + } + expect(err).toBeDefined(); + expect(err.causeErrors).toContain("Zero jobs"); + }); + + it("should return no jobs for a prefix that doesn't match anything", async () => { + const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, "FAKENE"); + expect(allJobs.length).toBe(0); + }); + + it("should return all jobs for the non user id prefix specified and the owner is the session user id", async () => { // Read the JCL template file + const NUM_JOBS = 3; const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - // submit a job that we can list - // Render the job with increasing job name - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME + "S", ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + // Submit a few jobs to list + const jobs: IJob[] = []; + for (let x = 0; x < NUM_JOBS; x++) { - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - expect(job.status).toEqual("OUTPUT"); - expect(job.retcode).toEqual("CC 0000"); + // Render the job with increasing job name + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: TEST_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + expect(job.status).toEqual("OUTPUT"); + expect(job.retcode).toEqual("CC 0000"); + jobs.push(job); + } // TODO: this is a workaround for an issue where listing jobs immediately after they are completed // results in the jobs being omitted from the results - await waitThreeSeconds(); + await wait(3000); + + // Obtain the three jobs submitted + const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, TEST_JOB_NAME + "*"); + expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); // Search all jobs returned for each of the submitted jobs - const foundJob = await GetJobs.getJob(REAL_SESSION, job.jobid); - expect(foundJob).toBeDefined(); - expect(foundJob.jobid).toEqual(job.jobid); - expect(foundJob.jobname).toEqual(job.jobname); + jobs.forEach((submittedJob) => { + let found = false; + for (const returnedJob of allJobs) { + if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { + found = true; + break; + } + } + expect(found).toBe(true); + }); }, LONG_TIMEOUT); }); + }); - it("should be able to get a single job by job ID with jobid parm on the getJobs API", async () => { - // Read the JCL template file - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + /**********************************************/ + // API methods "getJobsByPrefix" system tests + describe("get jobs by owner API", () => { + describe("list jobs", () => { + it("should return no jobs for a nonexistent owner", async () => { + // Obtain the three jobs submitted + const allJobs: IJob[] = await GetJobs.getJobsByOwner(REAL_SESSION, "FAKENE"); + expect(allJobs.length).toBe(0); + }); - // submit a job that we can list - // Render the job with increasing job name - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME + "S", ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should return all jobs for the user (of the session) when specified as the owner", async () => { + // Read the JCL template file + const NUM_JOBS = 3; + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - expect(job.status).toEqual("OUTPUT"); - expect(job.retcode).toEqual("CC 0000"); + // Submit a few jobs to list + const jobs: IJob[] = []; + for (let x = 0; x < NUM_JOBS; x++) { + // Render the job with increasing job name + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // TODO: this is a workaround for an issue where listing jobs immediately after they are completed - // results in the jobs being omitted from the results - await waitThreeSeconds(); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + expect(job.status).toEqual("OUTPUT"); + expect(job.retcode).toEqual("CC 0000"); + jobs.push(job); + } - // Search all jobs returned for each of the submitted jobs - const foundJobs = await GetJobs.getJobsCommon(REAL_SESSION, {jobid: job.jobid}); - expect(foundJobs).toBeDefined(); - expect(foundJobs.length).toEqual(1); - expect(foundJobs[0].jobid).toEqual(job.jobid); - expect(foundJobs[0].jobname).toEqual(job.jobname); - }, LONG_TIMEOUT); + // TODO: this is a workaround for an issue where listing jobs immediately after they are completed + // results in the jobs being omitted from the results + await wait(3000); + // Obtain all jobs for ***REMOVED*** + const allJobs: IJob[] = await GetJobs.getJobsByOwner(REAL_SESSION, REAL_SESSION.ISession.user); + expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); + + // Search all jobs returned for each of the submitted jobs + jobs.forEach((submittedJob) => { + let found = false; + for (const returnedJob of allJobs) { + if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { + found = true; + break; + } + } + expect(found).toBe(true); + }); + }, LONG_TIMEOUT); + }); }); }); - /**********************************************/ - // API methods "getJobsByPrefix" system tests - describe("get jobs by prefix API", () => { - describe("list jobs", () => { - it("should return all jobs for the prefix of the user id and the owner is the session user id", async () => { - // Read the JCL template file - const NUM_JOBS = 3; - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - - // Submit a few jobs to list - const jobs: IJob[] = []; - for (let x = 0; x < NUM_JOBS; x++) { + describe("Get Status APIs - Encoded", () => { + /**********************************************/ + // API methods "getStatus" system tests + describe("get status API", () => { + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); const jobRender = iefbr14JclTemplate; const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - expect(job.status).toEqual("OUTPUT"); - expect(job.retcode).toEqual("CC 0000"); - jobs.push(job); - } + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // TODO: this is a workaround for an issue where listing jobs immediately after they are completed - // results in the jobs being omitted from the results - await waitThreeSeconds(); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Obtain the three jobs submitted - const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, MONITOR_JOB_NAME + "*"); - expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Search all jobs returned for each of the submitted jobs - jobs.forEach((submittedJob) => { - let found = false; - for (const returnedJob of allJobs) { - if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { - found = true; - break; - } - } - expect(found).toBe(true); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); }); - }, LONG_TIMEOUT); - - it("should throw an error if we specify a job ID that doesn't exist", async () => { - let err: ImperativeError; - try { - await GetJobs.getJob(REAL_SESSION, "J999999"); - } catch (e) { - err = e; - } - expect(err).toBeDefined(); - expect(err.causeErrors).toContain("Zero jobs"); - }); - - it("should return no jobs for a prefix that doesn't match anything", async () => { - const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, "FAKENE"); - expect(allJobs.length).toBe(0); - }); - - it("should return all jobs for the non user id prefix specified and the owner is the session user id", async () => { - // Read the JCL template file - const NUM_JOBS = 3; - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - - // Submit a few jobs to list - const jobs: IJob[] = []; - for (let x = 0; x < NUM_JOBS; x++) { + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); const jobRender = iefbr14JclTemplate; const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: TEST_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - expect(job.status).toEqual("OUTPUT"); - expect(job.retcode).toEqual("CC 0000"); - jobs.push(job); - } + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // TODO: this is a workaround for an issue where listing jobs immediately after they are completed - // results in the jobs being omitted from the results - await waitThreeSeconds(); + // Expect the jobname to match + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Obtain the three jobs submitted - const allJobs: IJob[] = await GetJobs.getJobsByPrefix(REAL_SESSION, TEST_JOB_NAME + "*"); - expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Search all jobs returned for each of the submitted jobs - jobs.forEach((submittedJob) => { - let found = false; - for (const returnedJob of allJobs) { - if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { - found = true; - break; - } - } - expect(found).toBe(true); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); }); - }, LONG_TIMEOUT); - }); - }); - - /**********************************************/ - // API methods "getJobsByPrefix" system tests - describe("get jobs by owner API", () => { - describe("list jobs", () => { - it("should return no jobs for a nonexistent owner", async () => { - // Obtain the three jobs submitted - const allJobs: IJob[] = await GetJobs.getJobsByOwner(REAL_SESSION, "FAKENE"); - expect(allJobs.length).toBe(0); - }); - - it("should return all jobs for the user (of the session) when specified as the owner", async () => { - // Read the JCL template file - const NUM_JOBS = 3; - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - - // Submit a few jobs to list - const jobs: IJob[] = []; - for (let x = 0; x < NUM_JOBS; x++) { + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); const jobRender = iefbr14JclTemplate; const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME + x.toString(), ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); // Submit the job const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - expect(job.status).toEqual("OUTPUT"); - expect(job.retcode).toEqual("CC 0000"); - jobs.push(job); - } - - // TODO: this is a workaround for an issue where listing jobs immediately after they are completed - // results in the jobs being omitted from the results - await waitThreeSeconds(); - // Obtain all jobs for ***REMOVED*** - const allJobs: IJob[] = await GetJobs.getJobsByOwner(REAL_SESSION, REAL_SESSION.ISession.user); - expect(allJobs.length).toBeGreaterThanOrEqual(NUM_JOBS); - - // Search all jobs returned for each of the submitted jobs - jobs.forEach((submittedJob) => { - let found = false; - for (const returnedJob of allJobs) { - if (returnedJob.jobname === submittedJob.jobname && returnedJob.jobid === submittedJob.jobid) { - found = true; - break; - } - } - expect(found).toBe(true); - }); - }, LONG_TIMEOUT); - }); - }); -}); - -describe("Get Status APIs - Encoded", () => { - - /**********************************************/ - // API methods "getStatus" system tests - describe("get status API", () => { - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); }); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); + /**********************************************/ + // API methods "getStatusCommon" system tests + describe("get status common API", () => { + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect the jobname to match - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); - }); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); + // Expect that the status is input + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatus(REAL_SESSION, job.jobname, job.jobid); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); - }, LONG_TIMEOUT); - }); - }); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); + }); - /**********************************************/ - // API methods "getStatusCommon" system tests - describe("get status common API", () => { - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); }); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); + /**********************************************/ + // API methods "getStatusForJob" system tests + describe("get status for job API", () => { + describe("obtain job status", () => { + it("should be able to get the status of a recently submitted job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is input - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); + // Expect that the status is one of the three possible + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); - }); + // Expect that the status is one of the three possible + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted job on INPUT queue", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); + // Expect that the status is input + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.INPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); - }, LONG_TIMEOUT); - }); - }); + // Expect that the status is input + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.INPUT); + }); - /**********************************************/ - // API methods "getStatusForJob" system tests - describe("get status for job API", () => { - describe("obtain job status", () => { - it("should be able to get the status of a recently submitted job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); + it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { + // Render the job with increasing job name + const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); + const jobRender = iefbr14JclTemplate; + const renderedJcl = TextUtils.renderWithMustache(jobRender, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); + // Submit the job + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - // Expect that the status is one of the three possible - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(job.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(job.jobname).toBe(MONITOR_JOB_NAME); + expect(job.status).toBe(JOB_STATUS.OUTPUT); - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); + // Get the status of the job submitted + const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - // Expect that the status is one of the three possible - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(JOB_STATUS_ORDER.indexOf(status.status as JOB_STATUS)).toBeGreaterThanOrEqual(0); + // Expect that the status is output + expect(status.jobname).toBe(MONITOR_JOB_NAME); + expect(status.status).toBe(JOB_STATUS.OUTPUT); + }, LONG_TIMEOUT); }); + }); + }); - it("should be able to get the status of a recently submitted job on INPUT queue", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: ",TYPRUN=HOLD", SYSAFF}); - - // Submit the job - const job = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - - // Expect that the status is input - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.INPUT); - - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - - // Expect that the status is input - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.INPUT); + describe("Get spool APIs - encoded", () => { + describe("list spool files/dds", () => { + it("should be able to get all spool files in a job", async () => { + const NUM_OF_SPOOL_FILES = 3; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + files.forEach((file) => { + expect(file.jobname).toEqual(job.jobname); // verify jobname is in each jobfile + }); + await DeleteJobs.deleteJobForJob(REAL_SESSION, job); }); + }); - it("should be able to get the status of a recently submitted and completed (OUTPUT) job", async () => { - // Render the job with increasing job name - const iefbr14JclTemplate = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const jobRender = iefbr14JclTemplate; - const renderedJcl = TextUtils.renderWithMustache(jobRender, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // Submit the job + describe("download spool files", () => { + it("Should get spool content from a job", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + let found = false; + + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file); + expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + found = true; + } + } + expect(found).toBe(true); + }, LONG_TIMEOUT); - // Expect that the status is output - expect(job.jobname).toBe(MONITOR_JOB_NAME); - expect(job.status).toBe(JOB_STATUS.OUTPUT); - - // Get the status of the job submitted - const status = await GetJobs.getStatusForJob(REAL_SESSION, job); - - // Expect that the status is output - expect(status.jobname).toBe(MONITOR_JOB_NAME); - expect(status.status).toBe(JOB_STATUS.OUTPUT); + it("Should get spool content for a single job", async () => { + const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); + const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; + const renderedJcl = TextUtils.renderWithMustache(idcams, + {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); + const NUM_OF_SPOOL_FILES = 4; + const DD_WITH_CONTENT = "SYSTSPRT"; + const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); + const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); + expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs + for (const file of files) { + if (file.ddname === DD_WITH_CONTENT) { + const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id); + expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); + break; + } + } }, LONG_TIMEOUT); }); }); -}); -describe("Get spool APIs - encoded", () => { - describe("list spool files/dds", () => { - it("should be able to get all spool files in a job", async () => { - const NUM_OF_SPOOL_FILES = 3; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, JCL); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - files.forEach((file) => { - expect(file.jobname).toEqual(job.jobname); // verify jobname is in each jobfile + /**********************************************/ + // API methods "getJcl..." system tests + describe("Get JCL APIs - encoded", () => { + describe("download JCL", () => { + it("should be able to get jcl from a job that was submitted", async () => { + const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); + const jcl = await GetJobs.getJclForJob(REAL_SESSION, job); + expect(jcl).toContain("EXEC PGM=IEFBR14"); + expect(jcl).toContain("JOB"); }); - await DeleteJobs.deleteJobForJob(REAL_SESSION, job); }); }); - - describe("download spool files", () => { - it("Should get spool content from a job", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - let found = false; - - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const dataContent = await GetJobs.getSpoolContent(REAL_SESSION, file); - expect(dataContent).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - found = true; - } - } - expect(found).toBe(true); - }, LONG_TIMEOUT); - - it("Should get spool content for a single job", async () => { - const idcams = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_content.jcl")).toString(); - const DATA_TO_CHECK = "PUTTYPUTTYPUTTYPUTTY"; - const renderedJcl = TextUtils.renderWithMustache(idcams, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF, CONTENT: DATA_TO_CHECK}); - const NUM_OF_SPOOL_FILES = 4; - const DD_WITH_CONTENT = "SYSTSPRT"; - const job = await SubmitJobs.submitJclNotify(REAL_SESSION, renderedJcl); - const files = await GetJobs.getSpoolFilesForJob(REAL_SESSION, job); - expect(files.length).toBe(NUM_OF_SPOOL_FILES); // verify expected number of DDs - for (const file of files) { - if (file.ddname === DD_WITH_CONTENT) { - const content = await GetJobs.getSpoolContentById(REAL_SESSION, job.jobname, job.jobid, file.id); - expect(content).toContain("NUMBER OF RECORDS PROCESSED WAS 3"); - break; - } - } - }, LONG_TIMEOUT); - }); }); - -/**********************************************/ -// API methods "getJcl..." system tests -describe("Get JCL APIs - encoded", () => { - describe("download JCL", () => { - it("should be able to get jcl from a job that was submitted", async () => { - const job = await SubmitJobs.submitJcl(REAL_SESSION, JCL); - const jcl = await GetJobs.getJclForJob(REAL_SESSION, job); - expect(jcl).toContain("EXEC PGM=IEFBR14"); - expect(jcl).toContain("JOB"); - }); - }); -}); \ No newline at end of file diff --git a/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts index f2bb072a1a..2ccc7fff18 100644 --- a/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts @@ -10,8 +10,8 @@ */ import { ImperativeError, Session } from "@zowe/imperative"; -import { IJob, SubmitJobs, ModifyJobs, CancelJobs } from "../../src"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { IJob, SubmitJobs, ModifyJobs } from "../../src"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { JobTestsUtils } from "./JobTestsUtils"; @@ -40,10 +40,10 @@ describe("Modify Jobs - System Tests", () => { iefbr14Job = await SubmitJobs.submitJob(REAL_SESSION, testEnvironment.systemTestProperties.zosjobs.iefbr14Member ); + testEnvironment.resources.jobs.push(iefbr14Job); }); afterAll(async () => { - await CancelJobs.cancelJob(REAL_SESSION, iefbr14Job.jobname, iefbr14Job.jobid); await TestEnvironment.cleanUp(testEnvironment); }); @@ -80,7 +80,6 @@ describe("Modify Jobs - System Tests", () => { }); describe("Negative tests", () => { - it("should surface an error from z/OSMF when calling an unknown jobid", async () => { let err: any; try { @@ -108,15 +107,16 @@ describe("Modify Jobs - System Tests - Encoded", () => { systemProps = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); account = systemProps.tso.account; - jobclass = testEnvironment.systemTestProperties.zosjobs.jobclass; - modifiedJobClass = testEnvironment.systemTestProperties.zosjobs.modifiedJobclass; + jobclass = systemProps.zosjobs.jobclass; + modifiedJobClass = systemProps.zosjobs.modifiedJobclass; + const maxStepNum = 6; const sleepJCL = JobTestsUtils.getSleepJCL(REAL_SESSION.ISession.user, account, systemProps.zosjobs.jobclass, maxStepNum, true); sleepJCLJob = await SubmitJobs.submitJcl(REAL_SESSION, sleepJCL); + testEnvironment.resources.jobs.push(sleepJCLJob); }); afterAll(async () => { - await CancelJobs.cancelJob(REAL_SESSION, iefbr14Job.jobname, iefbr14Job.jobid); await TestEnvironment.cleanUp(testEnvironment); }); diff --git a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts index 427fa943f4..5ba150128f 100644 --- a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts @@ -15,9 +15,9 @@ import { ImperativeError, Session, TextUtils } from "@zowe/imperative"; import * as fs from "fs"; import { join } from "path"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; // long running test timeout const LONG_TIMEOUT = 100000; @@ -66,7 +66,7 @@ const trimMessage = (message: string) => { return message.replace(/( {2,})|\t/g, " "); }; -describe("System Tests - Monitor Jobs", () => { +describe.each([false, true])("System Tests - Monitor Jobs - Encoded: %s", (encoded: boolean) => { beforeAll(async () => { testEnvironment = await TestEnvironment.setUp({ @@ -77,8 +77,13 @@ describe("System Tests - Monitor Jobs", () => { REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); ACCOUNT = defaultSystem.tso.account; - const JOB_LENGTH = 6; - MONITOR_JOB_NAME = REAL_SESSION.ISession.user.substring(0, JOB_LENGTH).toUpperCase() + "MJ"; + if (encoded) { + const JOB_LENGTH = 5; + MONITOR_JOB_NAME = REAL_SESSION.ISession.user.substring(0, JOB_LENGTH).toUpperCase() + "#MJ"; + } else { + const JOB_LENGTH = 6; + MONITOR_JOB_NAME = REAL_SESSION.ISession.user.substring(0, JOB_LENGTH).toUpperCase() + "MJ"; + } JOBCLASS = testEnvironment.systemTestProperties.zosjobs.jobclass; SYSAFF = testEnvironment.systemTestProperties.zosjobs.sysaff; @@ -680,500 +685,3 @@ describe("System Tests - Monitor Jobs", () => { }); }); }); - -describe("System Tests - Monitor Jobs - Encoded", () => { - - beforeAll(async () => { - testEnvironment = await TestEnvironment.setUp({ - testName: "zos_monitor_jobs_encoded" - }); - defaultSystem = testEnvironment.systemTestProperties; - - REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - - ACCOUNT = defaultSystem.tso.account; - const JOB_LENGTH = 5; - MONITOR_JOB_NAME = REAL_SESSION.ISession.user?.substring(0, JOB_LENGTH).toUpperCase() + "#MJ"; - - JOBCLASS = testEnvironment.systemTestProperties.zosjobs.jobclass; - SYSAFF = testEnvironment.systemTestProperties.zosjobs.sysaff; - }); - - // Cleanup before & after each test - this will ensure that hopefully no jobs are left outstanding (or are currently - // outstanding) when the tests run - beforeEach(async () => { - GetJobs.getStatusCommon = ORIG_JOBS_STATUS; - await cleanTestJobs(); - }); - afterEach(async () => { - GetJobs.getStatusCommon = ORIG_JOBS_STATUS; - await cleanTestJobs(); - }); - - /**********************************************/ - // API method "waitForOutputStatus" system tests - describe("api method wait for output status", () => { - // Single polling situation - the majority are tested via the common method (which this method invokes) - describe("polling/transitions", () => { - // eslint-disable-next-line jest/no-done-callback - it("should detect when a job transitions from INPUT to OUTPUT", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_delay.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: TYPE_RUN_HOLD, SYSAFF}); - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // Initial status should be input because of HELD jobclass - expect(jobInfo.status).toBe("INPUT"); - - // start checking the job status - let doneCalled: boolean = false; - MonitorJobs.waitForOutputStatus(REAL_SESSION, jobInfo.jobname, jobInfo.jobid).then((status) => { - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("OUTPUT"); - done(); - }).catch((error) => { - if (!doneCalled) { - doneCalled = true; - done(`wait for status error: ${error.message}`); - } - }); - - // Change the jobclass after a period of time - setTimeout(() => { - new ZosmfRestClient(REAL_SESSION).request({ - resource: `/zosmf/restjobs/jobs/${encodeURIComponent(jobInfo.jobname)}/${encodeURIComponent(jobInfo.jobid)}`, - request: "PUT", - reqHeaders: [{"Content-Type": "application/json"}], - writeData: { - request: "release", - version: "2.0" - } - }).then((response) => { - // Nothing to do here - }).catch((releaseErr) => { - if (!doneCalled) { - doneCalled = true; - done(`Release error: ${releaseErr.message}`); - } - }); - }, TIMEOUT_TEST_CHECK); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - }); - }); - - /**********************************************/ - // API method "waitForJobOutputStatus" system tests - describe("api method wait for job output status", () => { - // Single polling situation - the majority are tested via the common method (which this method invokes) - describe("polling/transitions", () => { - // eslint-disable-next-line jest/no-done-callback - it("should detect when the job submitted transitions from INPUT to OUTPUT", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_delay.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: TYPE_RUN_HOLD, SYSAFF}); - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // Initial status should be input because of HELD jobclass - expect(jobInfo.status).toBe("INPUT"); - - // start checking the job status - let doneCalled: boolean = false; - MonitorJobs.waitForJobOutputStatus(REAL_SESSION, jobInfo).then((status) => { - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("OUTPUT"); - done(); - }).catch((error) => { - if (!doneCalled) { - doneCalled = true; - done(`wait for status error: ${error.message}`); - } - }); - - // Release the job - setTimeout(() => { - new ZosmfRestClient(REAL_SESSION).request({ - resource: `/zosmf/restjobs/jobs/${encodeURIComponent(jobInfo.jobname)}/${encodeURIComponent(jobInfo.jobid)}`, - request: "PUT", - reqHeaders: [{"Content-Type": "application/json"}], - writeData: { - request: "release", - version: "2.0" - } - }).then((response) => { - // Nothing to do here - }).catch((releaseErr) => { - if (!doneCalled) { - doneCalled = true; - done(`Release error: ${releaseErr.message}`); - } - }); - }, TIMEOUT_TEST_CHECK); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - }); - }); - - /**********************************************/ - // API method "waitForStatusCommon" system tests - describe("api method wait for output status common", () => { - // Tests that do not initiate polling - should return immediately from a request - describe("initial status checks", () => { - it("should detect that a job is in INPUT status", async () => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: TYPE_RUN_HOLD, SYSAFF}); - - // submit the job - const jobInfo = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - expect(jobInfo.status).toBe("INPUT"); - - // "Mock" the function - which just invokes the actual function - const mockedGetJobs = jest.fn(async (session, parms) => { - return ORIG_JOBS_STATUS(session, parms); - }); - GetJobs.getStatusCommon = mockedGetJobs; - - // check that the status is input - const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, - { - jobname: jobInfo.jobname, - jobid: jobInfo.jobid, - status: "INPUT" - }); - - // verify that the status and info is correct - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("INPUT"); - expect(mockedGetJobs).toHaveBeenCalledTimes(1); - }); - - it("should detect that a job is in ACTIVE status", async () => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_forever_loop.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // submit the job - const jobInfo = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - - // Wait for the job to become active indefinitely - jest timeout will occur eventually - let jobCheck: IJob; - do { - jobCheck = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: jobInfo.jobname, jobid: jobInfo.jobid}); - } while (jobCheck.status !== "ACTIVE"); - - // "Mock" the function - which just invokes the actual function - const mockedGetJobs = jest.fn(async (session, parms) => { - return ORIG_JOBS_STATUS(session, parms); - }); - GetJobs.getStatusCommon = mockedGetJobs; - - // check that the status is active - const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, - { - jobname: jobInfo.jobname, - jobid: jobInfo.jobid, - status: "ACTIVE" - }); - - // verify that the status and info is correct - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("ACTIVE"); - expect(mockedGetJobs).toHaveBeenCalledTimes(1); - }, LONG_TIMEOUT); - - it("should detect that a job is in OUTPUT status", async () => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/iefbr14.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // submit the job - const jobInfo = await SubmitJobs.submitJcl(REAL_SESSION, renderedJcl); - - // Wait for the job to become active indefinitely - jest timeout will occur eventually - let jobCheck: IJob; - do { - jobCheck = await GetJobs.getStatusCommon(REAL_SESSION, {jobname: jobInfo.jobname, jobid: jobInfo.jobid}); - } while (jobCheck.status !== "OUTPUT"); - - // "Mock" the function - which just invokes the actual function - const mockedGetJobs = jest.fn(async (session, parms) => { - return ORIG_JOBS_STATUS(session, parms); - }); - GetJobs.getStatusCommon = mockedGetJobs; - - // check that the status is output - const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, - { - jobname: jobInfo.jobname, - jobid: jobInfo.jobid, - status: "OUTPUT" - }); - - // verify that the status and info is correct - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("OUTPUT"); - expect(mockedGetJobs).toHaveBeenCalledTimes(1); - }, LONG_TIMEOUT); - }); - - // All tests that perform polling, etc to eventually obtain the status - describe("polling/transitions", () => { - /* eslint-disable jest/no-done-callback */ - it("should detect and surface an error if the job is purged/deleted while waiting for status", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_forever_loop.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // "Mock" the function - which just invokes the actual function - const mockedGetJobs = jest.fn(async (session, parms) => { - return ORIG_JOBS_STATUS(session, parms); - }); - GetJobs.getStatusCommon = mockedGetJobs; - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // start checking the job status - let doneCalled: boolean = false; - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "OUTPUT" - }).then((status) => { - if (!doneCalled) { - doneCalled = true; - done(`Error - we should not have received a status of OUTPUT`); - } - }).catch((error) => { - // const regex: RegExp = new RegExp(fs.readFileSync(TEST_REGEX_DIR + "/polling_job_deleted.regex").toString(), "g"); - // expect(regex.test(error.message)).toBe(true); - const trimmedErrorMessage = trimMessage(error.message); - const jsonCauseErrors = JSON.parse(error.causeErrors); - expect(trimmedErrorMessage).toContain("Error obtaining status for jobname"); - expect(jsonCauseErrors.category).toEqual(6); - expect(jsonCauseErrors.reason).toEqual(10); - expect(jsonCauseErrors.rc).toEqual(4); - expect(trimmedErrorMessage).toContain("status 400"); - expect(trimmedErrorMessage).toContain("No job found for reference"); - if (!doneCalled) { - doneCalled = true; - done(); - } - }); - - // Cancel and purge the job after a period of time - setTimeout(() => { - DeleteJobs.deleteJob(REAL_SESSION, jobInfo.jobname, jobInfo.jobid).catch((error) => { - if (!doneCalled) { - doneCalled = true; - done(`Error deleting the job: ${error.message}`); - } - }); - }, TIMEOUT_TEST_CHECK); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - - it("should detect and surface an error if the max poll attempts are exceeded", (done) => { - // Attempts - const ATTEMPTS = 3; - - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_forever_loop.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // "Mock" the function - which just invokes the actual function - const mockedGetJobs = jest.fn(async (session, parms) => { - return ORIG_JOBS_STATUS(session, parms); - }); - GetJobs.getStatusCommon = mockedGetJobs; - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // start checking the job status - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "OUTPUT", attempts: ATTEMPTS - }).then((status) => { - done(`Error - we should not have received a status of OUTPUT`); - }).catch((error) => { - expect(error instanceof ImperativeError).toBe(true); - expect(error.message).toContain("Error obtaining status for jobname"); - expect(error.message).toContain("Error Details: Reached max poll attempts of \"3\""); - expect(mockedGetJobs).toHaveBeenCalledTimes(ATTEMPTS); - done(); - }); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - - it("should detect when a job transitions from INPUT to ACTIVE", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_forever_loop.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: TYPE_RUN_HOLD, SYSAFF}); - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // Initial status should be input because of HELD jobclass - expect(jobInfo.status).toBe("INPUT"); - - // start checking the job status - let doneCalled: boolean = false; - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "ACTIVE" - }).then((status) => { - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("ACTIVE"); - done(); - }).catch((error) => { - if (!doneCalled) { - doneCalled = true; - done(`wait for status error: ${error.message}`); - } - }); - - // Change the jobclass after a period of time - setTimeout(() => { - new ZosmfRestClient(REAL_SESSION).request({ - resource: `/zosmf/restjobs/jobs/${encodeURIComponent(jobInfo.jobname)}/${encodeURIComponent(jobInfo.jobid)}`, - request: "PUT", - reqHeaders: [{"Content-Type": "application/json"}], - writeData: { - request: "release", - version: "2.0" - } - }).then((response) => { - // Nothing to do here - }).catch((releaseErr) => { - if (!doneCalled) { - doneCalled = true; - done(`Release error: ${releaseErr.message}`); - } - }); - }, TIMEOUT_TEST_CHECK); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - - it("should detect when a job transitions from INPUT to OUTPUT", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_delay.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: TYPE_RUN_HOLD, SYSAFF}); - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // Initial status should be input because of HELD jobclass - expect(jobInfo.status).toBe("INPUT"); - - // start checking the job status - let doneCalled: boolean = false; - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "OUTPUT" - }).then((status) => { - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("OUTPUT"); - done(); - }).catch((error) => { - if (!doneCalled) { - doneCalled = true; - done(`wait for status error: ${error.message}`); - } - }); - - // Change the jobclass after a period of time - setTimeout(() => { - new ZosmfRestClient(REAL_SESSION).request({ - resource: `/zosmf/restjobs/jobs/${encodeURIComponent(jobInfo.jobname)}/${encodeURIComponent(jobInfo.jobid)}`, - request: "PUT", - reqHeaders: [{"Content-Type": "application/json"}], - writeData: { - request: "release", - version: "2.0" - } - }).then((response) => { - // Nothing to do here - }).catch((releaseErr) => { - if (!doneCalled) { - doneCalled = true; - done(`Release error: ${releaseErr.message}`); - } - }); - }, TIMEOUT_TEST_CHECK); - - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - - it("should detect when a job transitions from INPUT to ACTIVE to OUTPUT", (done) => { - // Construct the JCL - const iefbr14Jcl = fs.readFileSync(join(TEST_RESOURCES_DIR, "jcl/instream_rexx_delay.jcl")).toString(); - const renderedJcl = TextUtils.renderWithMustache(iefbr14Jcl, - {JOBNAME: MONITOR_JOB_NAME, ACCOUNT, JOBCLASS, TYPERUNPARM: "", SYSAFF}); - - // submit the job - SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { - - // Wait for the status to be active - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "ACTIVE" - }).then((status) => { - expect(status.jobid).toEqual(jobInfo.jobid); - expect(status.jobname).toEqual(jobInfo.jobname); - expect(status.status).toBe("ACTIVE"); - - // Wait for the status to be output - MonitorJobs.waitForStatusCommon(REAL_SESSION, { - jobname: jobInfo.jobname, jobid: jobInfo.jobid, status: "OUTPUT" - }).then((nextStatus) => { - expect(nextStatus.jobid).toEqual(jobInfo.jobid); - expect(nextStatus.jobname).toEqual(jobInfo.jobname); - expect(nextStatus.status).toBe("OUTPUT"); - done(); - }).catch((error) => { - done(`wait for status error: ${error.message}`); - }); - }).catch((error) => { - done(`wait for status error: ${error.message}`); - }); - }).catch((submitErr) => { - done(`Job submission error: ${submitErr.message}`); - }); - }, LONG_TIMEOUT); - /* eslint-enable jest/no-done-callback */ - }); - }); -}); \ No newline at end of file diff --git a/packages/zosjobs/__tests__/__system__/SearchJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/SearchJobs.system.test.ts index 5d9c45e593..baf25132ae 100644 --- a/packages/zosjobs/__tests__/__system__/SearchJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/SearchJobs.system.test.ts @@ -11,7 +11,7 @@ import { ImperativeError, Session } from "@zowe/imperative"; import { DeleteJobs, GetJobs, IJob, SearchJobs } from "../../src"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; @@ -84,6 +84,10 @@ describe("Search Jobs - System Tests", () => { "//IEFBR14 EXEC PGM=IEFBR14"; // GetJobs }); + afterAll(async () => { + await TestEnvironment.cleanUp(testEnvironment); + }); + // Cleanup before & after each test - this will ensure that hopefully no jobs are left outstanding (or are currently // outstanding) when the tests run beforeEach(async () => { @@ -106,7 +110,7 @@ describe("Search Jobs - System Tests", () => { it("should detect and surface an error for an invalid user", async () => { let err; try { - await SearchJobs.searchJobs(INVALID_SESSION,{jobName: "IBMUSER"}); + await SearchJobs.searchJobs(INVALID_SESSION,{jobName: "IBMUSER", searchString: "dummy"}); } catch (e) { err = e; } diff --git a/packages/zosjobs/__tests__/__system__/SubmitJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/SubmitJobs.system.test.ts index a97bfd2b68..9f24590386 100644 --- a/packages/zosjobs/__tests__/__system__/SubmitJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/SubmitJobs.system.test.ts @@ -10,14 +10,13 @@ */ import { ImperativeError, Session } from "@zowe/imperative"; -import { DeleteJobs, IJob, SubmitJobs } from "../../src"; -import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { GetJobs, IJob, ISpoolFile, SubmitJobs } from "../../src"; +import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { wait } from "../../../../__tests__/__src__/TestUtils"; import { existsSync } from "fs"; import { ZosJobsMessages } from "../../src/JobsMessages"; -const rimraf = require("rimraf").sync; - let testEnvironment: ITestEnvironment; let systemProps: ITestPropertiesSchema; @@ -29,19 +28,8 @@ let iefbr14JCL: string; const badJCL = "thIsIs BaDJCL!"; const badDataSet = "DOES.NOT.EXIST(FAKE)"; const badUSSFile = "/tmp/does/not/exist/fake.txt"; - const LONG_TIMEOUT = 100000; // 100 second timeout - jobs could take a while to complete due to system load -const waitThreeSeconds = () => { - return new Promise((resolveWaitTime) => { - const threeSeconds = 3000; - setTimeout(() => { - resolveWaitTime(); - }, threeSeconds); - } - ); -}; - describe("Submit Jobs - System Tests", () => { beforeAll(async () => { @@ -64,10 +52,6 @@ describe("Submit Jobs - System Tests", () => { await TestEnvironment.cleanUp(testEnvironment); }); - // helper to delete a job - const deleteJob = async (job: IJob) => { - await DeleteJobs.deleteJob(REAL_SESSION, job.jobname, job.jobid); - }; describe("Positive tests", () => { it("should allow users to call submitJCLCommon with correct parameters", async () => { const job = await SubmitJobs.submitJclCommon(REAL_SESSION, { @@ -75,7 +59,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); it("should allow users to call submitJCLCommon with correct extended parameters", async () => { @@ -87,7 +71,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); @@ -98,7 +82,7 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); @@ -115,8 +99,8 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await waitThreeSeconds(); - await deleteJob(job); + await wait(3000); // Waits for 3 seconds + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); @@ -136,7 +120,7 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitJobCommon with correct parameters (with data set)", async () => { @@ -145,7 +129,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); it("should allow users to call submitJobCommon with correct parameters (with uss file)", async () => { @@ -154,7 +138,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); it("should allow users to call submitJobNotifyCommon with correct parameters (using a data set)", async () => { @@ -163,7 +147,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitJobNotifyCommon with correct parameters (using a uss file)", async () => { @@ -172,7 +156,7 @@ describe("Submit Jobs - System Tests", () => { }); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitJCLNotify with correct parameters", async () => { @@ -185,7 +169,7 @@ describe("Submit Jobs - System Tests", () => { "IBM-037"); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitJobNotify with correct parameters", async () => { @@ -194,7 +178,7 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitUSSJobNotify with correct parameters", async () => { @@ -203,7 +187,7 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }, LONG_TIMEOUT); it("should allow users to call submitJob with correct parameters", async () => { @@ -212,7 +196,7 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); it("should allow users to call submitUSSJob with correct parameters", async () => { @@ -221,45 +205,75 @@ describe("Submit Jobs - System Tests", () => { ); expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); - await deleteJob(job); + testEnvironment.resources.jobs.push(job); }); - it("should return the job info of a submitted JCL string", async () => { - const job: any = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", {jclSource: "stdin"}); + const jobOrSpoolFiles = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", { jclSource: "stdin" }); + + // Now `jobOrSpoolFiles` is guaranteed to be of type `IJob` + const job: IJob = jobOrSpoolFiles as IJob; + + // Ensure jobid and jobname are defined before proceeding expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); + testEnvironment.resources.jobs.push(job); }); it("should return the job info of a submitted JCL string with extended options", async () => { - const job: any = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", { + const jobOrSpoolFiles = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", { jclSource: "stdin", internalReaderFileEncoding: "IBM-037", internalReaderLrecl: "80", internalReaderRecfm: "F" }); + + // Now `jobOrSpoolFiles` is guaranteed to be of type `IJob` + const job: IJob = jobOrSpoolFiles as IJob; + expect(job.jobid).toBeDefined(); expect(job.jobname).toBeDefined(); + testEnvironment.resources.jobs.push(job); }); it("should return an array of spool content", async () => { - const job: any = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", {jclSource: "stdin", viewAllSpoolContent: true}); - expect(job.constructor === Array).toBe(true); - expect(job[0].data.toString()).toContain("J E S 2 J O B L O G"); + // Submit the JCL and request spool content to be returned + const jobOrSpoolFiles = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", { + jclSource: "stdin", + viewAllSpoolContent: true + }); + + // Now `jobOrSpoolFiles` is guaranteed to be of type `ISpoolFile[]` + const spoolFiles: ISpoolFile[] = jobOrSpoolFiles as ISpoolFile[]; + + expect(spoolFiles.constructor === Array).toBe(true); + expect(spoolFiles[0].data.toString()).toContain("J E S 2 J O B L O G"); + + // Extract job ID from the spool file content + const jobLogContent = spoolFiles[0].data.toString(); + const jobIdMatch = jobLogContent.match(/JOB\d{5}/).toString(); + const job = await GetJobs.getJob(REAL_SESSION, jobIdMatch); + testEnvironment.resources.jobs.push(job); }); it("should download spool content to a local directory", async () => { - const job: any = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", - { - jclSource: "stdin", - viewAllSpoolContent: false, - directory: "./" - }); - // check if the file was created + const jobOrSpoolFiles = await SubmitJobs.submitJclString(REAL_SESSION, "//JOBNAME1 JOB", { + jclSource: "stdin", + viewAllSpoolContent: false, + directory: "./" + }); + + // Now `jobOrSpoolFiles` is guaranteed to be of type `IJob` + const job: IJob = jobOrSpoolFiles as IJob; + + // Ensure jobid and jobname and file are defined before proceeding + expect(job.jobid).toBeDefined(); + expect(job.jobname).toBeDefined(); expect(existsSync(`${job.jobid}/JES2`)).toBeTruthy(); - // delete locally created directory - require("rimraf").sync(job.jobid, {maxBusyTries: 10}); + testEnvironment.resources.jobs.push(job); + // Delete the locally created directory + require("rimraf").sync(job.jobid, { maxBusyTries: 10 }); }); }); diff --git a/packages/zosjobs/__tests__/__system__/__snapshots__/GetJobs.system.test.ts.snap b/packages/zosjobs/__tests__/__system__/__snapshots__/GetJobs.system.test.ts.snap deleted file mode 100644 index 26d7179d5a..0000000000 --- a/packages/zosjobs/__tests__/__system__/__snapshots__/GetJobs.system.test.ts.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Get JCL APIs invalid request error handling should detect and surface an error for getting JCL that doesnt exist 1`] = `4`; - -exports[`Get JCL APIs invalid request error handling should detect and surface an error for getting JCL that doesnt exist 2`] = `10`; - -exports[`Get JCL APIs invalid request error handling should detect and surface an error for getting JCL that doesnt exist 3`] = `6`; - -exports[`Get Status APIs get status for job API invalid request error handling should be able to get a job that was submitted and get proper error when the job is deleted 1`] = `4`; - -exports[`Get Status APIs get status for job API invalid request error handling should be able to get a job that was submitted and get proper error when the job is deleted 2`] = `10`; - -exports[`Get Status APIs get status for job API invalid request error handling should be able to get a job that was submitted and get proper error when the job is deleted 3`] = `6`; - -exports[`Get spool APIs invalid request error handling should detect and surface an error for getting spool content that doesnt exist 1`] = `4`; - -exports[`Get spool APIs invalid request error handling should detect and surface an error for getting spool content that doesnt exist 2`] = `10`; - -exports[`Get spool APIs invalid request error handling should detect and surface an error for getting spool content that doesnt exist 3`] = `6`; diff --git a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts index 22bf915403..d7697c68dd 100644 --- a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts @@ -16,7 +16,6 @@ import * as fs from "fs"; import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; -import { IIssueTsoCmdParms } from "../../src"; import { IIssueTsoCmdOpts } from "../../src/doc/input/IIssueTsoCmdOpts"; let testEnvironment: ITestEnvironment; let systemProperties: ITestPropertiesSchema; @@ -25,7 +24,6 @@ let ACCOUNT_NUMBER: string; let START_PARAMS: IStartTsoParms; let ISSUE_PARAMS: IIssueTsoParms; -let COMMAND_PARAMS: IIssueTsoCmdParms; let AS_OPTIONS: IIssueTsoCmdOpts; describe("IssueTso.issueTsoCommand", () => { @@ -52,9 +50,6 @@ describe("IssueTso.issueTsoCommand", () => { accountNumber: ACCOUNT_NUMBER, startParams: START_PARAMS }; - COMMAND_PARAMS = { - command: "TIME" - }; AS_OPTIONS = { addressSpaceOptions: START_PARAMS };