Skip to content

Commit 6280225

Browse files
committed
switch create to zosmf
1 parent c216764 commit 6280225

File tree

9 files changed

+91
-48
lines changed

9 files changed

+91
-48
lines changed

__tests__/api/BundleContent/BundleSimple.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as fs from "fs";
1414

1515
describe("Bundle01", () => {
1616
afterEach(() => {
17-
jest.resetAllMocks();
17+
jest.restoreAllMocks();
1818
});
1919
it("should read an existing bundle", () => {
2020

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
5757
describe("BundleDeployer01", () => {
5858

5959
afterEach(() => {
60-
jest.resetAllMocks();
60+
jest.restoreAllMocks();
6161
});
6262
it("should complain with missing zOSMF profile for deploy", async () => {
6363
const createSpy = jest.spyOn(ZosmfSession, "createBasicZosmfSession").mockImplementationOnce(() => { throw new Error( "Injected Create error" ); });

__tests__/api/BundleDeploy/__snapshots__/BundleDeployer.test.ts.snap

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 1`] = `"DFHDPLOY stopped processing due to an error."`;
3+
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 1`] = `"DFHRL2055I"`;
4+
5+
exports[`BundleDeployer01 should complain if DFHDPLOY ends with an error 2`] = `"DFHDPLOY stopped processing due to an error."`;
46

57
exports[`BundleDeployer01 should complain if SYSTSPRT not found 1`] = `"SYSTSPRT output from DFHDPLOY not found. Most recent status update: 'Submitting DFHDPLOY JCL for the DEPLOY action'."`;
68

@@ -12,13 +14,17 @@ exports[`BundleDeployer01 should complain if cpsmhlq not found 1`] = `"Validatio
1214

1315
exports[`BundleDeployer01 should complain if cpsmhlq not found2 1`] = `"EYU9ABSI not found in SEYUAUTH within the --cpsmhlq dataset: abcde12345abcde12345abcde12345abcde.SEYUAUTH"`;
1416

15-
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `"DFHDPLOY command completed, but status cannot be determined."`;
17+
exports[`BundleDeployer01 should complain if status can't be determined 1`] = `" "`;
18+
19+
exports[`BundleDeployer01 should complain if status can't be determined 2`] = `"DFHDPLOY command completed, but status cannot be determined."`;
1620

1721
exports[`BundleDeployer01 should complain with missing zOSMF profile for deploy 1`] = `"Injected Create error"`;
1822

1923
exports[`BundleDeployer01 should complain with missing zOSMF profile for undeploy 1`] = `"Injected Create error"`;
2024

21-
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHDPLOY completed with warnings."`;
25+
exports[`BundleDeployer01 should complete with warnings 1`] = `"DFHRL2043I"`;
26+
27+
exports[`BundleDeployer01 should complete with warnings 2`] = `"DFHDPLOY completed with warnings."`;
2228

2329
exports[`BundleDeployer01 should deploy successfully 1`] = `"Bundle deployment successful."`;
2430

@@ -503,7 +509,9 @@ UNDEPLOY BUNDLE(12345678)
503509
"
504510
`;
505511

506-
exports[`BundleDeployer01 should support verbose=true output for deploy 1`] = `
512+
exports[`BundleDeployer01 should support verbose=true output for deploy 1`] = `"DFHRL2012I"`;
513+
514+
exports[`BundleDeployer01 should support verbose=true output for deploy 2`] = `
507515
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
508516
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
509517
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD
@@ -522,7 +530,9 @@ DEPLOY BUNDLE(12345678)
522530
"
523531
`;
524532

525-
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `
533+
exports[`BundleDeployer01 should support verbose=true output for undeploy 1`] = `"DFHRL2037I"`;
534+
535+
exports[`BundleDeployer01 should support verbose=true output for undeploy 2`] = `
526536
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT
527537
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
528538
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 44 additions & 33 deletions
Large diffs are not rendered by default.

__tests__/cli/deploy/bundle/DeployBundle.handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = {
6262

6363
describe("bundle Handler", () => {
6464
afterEach(() => {
65-
jest.resetAllMocks();
65+
jest.restoreAllMocks();
6666
});
6767
it("should complain with no name parameter", async () => {
6868
await testNameError(undefined, "--name parameter is not set");

__tests__/cli/generate/bundle/GenerateBundle.handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const DEFAULT_PARAMTERS: IHandlerParameters = {
5959

6060
describe("bundle Handler", () => {
6161
afterEach(() => {
62-
jest.resetAllMocks();
62+
jest.restoreAllMocks();
6363
});
6464
it("should process the current directory", async () => {
6565
DEFAULT_PARAMTERS.arguments.nosave = "true";

__tests__/cli/push/bundle/PushBundle.handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = {
6262

6363
describe("bundle Handler", () => {
6464
afterEach(() => {
65-
jest.resetAllMocks();
65+
jest.restoreAllMocks();
6666
});
6767
it("should complain with missing parameters", async () => {
6868
const params = getCommonParms();

__tests__/cli/undeploy/bundle/UndeployBundle.handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = {
5858

5959
describe("bundle Handler", () => {
6060
afterEach(() => {
61-
jest.resetAllMocks();
61+
jest.restoreAllMocks();
6262
});
6363
it("should complain with no parameters", async () => {
6464

src/api/BundlePush/BundlePusher.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"use strict";
1313

1414
import { IHandlerParameters, AbstractSession, ITaskWithStatus, TaskStage } from "@zowe/imperative";
15-
import { List, ZosmfSession, SshSession, Shell, Upload, IUploadOptions, ZosFilesAttributes } from "@zowe/cli";
15+
import { List, ZosmfSession, SshSession, Shell, Upload, IUploadOptions, ZosFilesAttributes, Create } from "@zowe/cli";
1616
import { BundleDeployer } from "../BundleDeploy/BundleDeployer";
1717
import { Bundle } from "../BundleContent/Bundle";
1818

@@ -71,7 +71,7 @@ export class BundlePusher {
7171
this.params.response.progress.startBar({task: this.progressBar});
7272

7373
// Attempt to make the target bundledir
74-
await this.makeBundleDir(sshSession);
74+
await this.makeBundleDir(zosMFSession);
7575

7676
// Check that the remote bundledir is suitable.
7777
await this.validateBundleDirExistsAndIsEmpty(zosMFSession);
@@ -246,9 +246,31 @@ export class BundlePusher {
246246
this.sshOutputText += data;
247247
}
248248

249-
private async makeBundleDir(sshSession: SshSession) {
249+
private async makeBundleDir(zosMFSession: AbstractSession) {
250250
this.updateStatus("Making remote bundle directory");
251-
await this.runSshCommandInRemoteDirectory(sshSession, this.params.arguments.targetdir, "mkdir " + this.params.arguments.name);
251+
252+
const WARNING = 4;
253+
const ALREADY_EXISTS = 19;
254+
try {
255+
await Create.uss(zosMFSession, this.params.arguments.bundledir, "directory");
256+
}
257+
catch (error) {
258+
try {
259+
const json = JSON.parse(error.causeErrors);
260+
if (json.category === 1 &&
261+
json.rc === WARNING &&
262+
json.reason === ALREADY_EXISTS) {
263+
// if it already exists, no worries
264+
return;
265+
}
266+
}
267+
catch (innerError) {
268+
// If this occurs we probably didn't receive an ImperativeError
269+
}
270+
271+
throw new Error("A problem occurred attempting to create directory '" + this.params.arguments.bundledir + "'. " +
272+
"Problem is: " + error.message);
273+
}
252274
}
253275

254276
private async deleteBundleDirContents(sshSession: SshSession) {

0 commit comments

Comments
 (0)