Skip to content

Commit 50bc4a1

Browse files
authored
Merge branch 'master' into fix/jenkins
2 parents 2eea523 + 65837e6 commit 50bc4a1

File tree

2 files changed

+108
-19
lines changed

2 files changed

+108
-19
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,43 @@ describe("BundlePusher01", () => {
10391039
expect(uploadSpy).toHaveBeenCalledTimes(1);
10401040
expect(cmciSpy).toHaveBeenCalledTimes(1);
10411041
});
1042+
it("should query scope even with no NODEJSAPPs", async () => {
1043+
zosmfProfile = { host: "wibble", user: "user" };
1044+
sshProfile = { host: "wibble", user: "user" };
1045+
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678" };
1046+
cmciSpy.mockImplementation((cicsSession: any, regionData: cmci.IResourceParms) => {
1047+
if (regionData.name === "CICSRegion") {
1048+
return { response: {
1049+
records: {
1050+
cicsregion: {
1051+
applid: "ABCDEFG", jobid: "JOB12345", jobname: "MYCICS"
1052+
}
1053+
}
1054+
}
1055+
};
1056+
}
1057+
else {
1058+
return {};
1059+
}
1060+
});
1061+
1062+
await runPushTest("__tests__/__resources__/ExampleBundle01", false, "PUSH operation completed.");
1063+
1064+
expect(consoleText).toContain("CICS Regions in Scope '12345678' of CICSplex '12345678':");
1065+
expect(consoleText).toContain("Applid: ABCDEFG jobname: MYCICS jobid: JOB12345");
1066+
expect(consoleText).not.toContain("NODEJSAPP");
1067+
expect(zosMFSpy).toHaveBeenCalledTimes(1);
1068+
expect(sshSpy).toHaveBeenCalledTimes(1);
1069+
expect(listSpy).toHaveBeenCalledTimes(1);
1070+
expect(createSpy).toHaveBeenCalledTimes(1);
1071+
expect(shellSpy).toHaveBeenCalledTimes(0);
1072+
expect(membersSpy).toHaveBeenCalledTimes(2);
1073+
expect(submitSpy).toHaveBeenCalledTimes(1);
1074+
expect(existsSpy).toHaveBeenCalledTimes(1);
1075+
expect(readSpy).toHaveBeenCalledTimes(1);
1076+
expect(uploadSpy).toHaveBeenCalledTimes(1);
1077+
expect(cmciSpy).toHaveBeenCalledTimes(1);
1078+
});
10421079
it("should cope with a NODEJSAPP in the bundle with a CICS profile specified and --verbose", async () => {
10431080
zosmfProfile = { host: "wibble", user: "user" };
10441081
sshProfile = { host: "wibble", user: "user" };
@@ -1056,7 +1093,8 @@ describe("BundlePusher01", () => {
10561093
expect(consoleText).toContain("WARNING: No .zosAttributes file found in the bundle directory, default values will be applied");
10571094
expect(consoleText).toContain("Deploying bundle '12345678' to CICS");
10581095
expect(consoleText).toContain("Deploy complete");
1059-
expect(consoleText).toContain("Gathering Node.js diagnostics");
1096+
expect(consoleText).toContain("Gathering Scope information");
1097+
expect(consoleText).toContain("Querying Regions in Scope over CMCI");
10601098
expect(zosMFSpy).toHaveBeenCalledTimes(1);
10611099
expect(sshSpy).toHaveBeenCalledTimes(1);
10621100
expect(listSpy).toHaveBeenCalledTimes(1);
@@ -1075,6 +1113,22 @@ describe("BundlePusher01", () => {
10751113
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal" };
10761114
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
10771115
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2055I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1116+
cmciSpy.mockImplementation((cicsSession: any, regionData: cmci.IResourceParms) => {
1117+
if (regionData.name === "CICSRegion") {
1118+
return { response: {
1119+
records: {
1120+
cicsregion: {
1121+
applid: "ABCDEFG", jobid: "JOB12345", jobname: "MYCICS"
1122+
}
1123+
}
1124+
}
1125+
};
1126+
}
1127+
else {
1128+
return {};
1129+
}
1130+
});
1131+
10781132
const parms = getCommonParmsForPushTests();
10791133
parms.arguments.verbose = true;
10801134

@@ -1087,7 +1141,12 @@ describe("BundlePusher01", () => {
10871141
expect(consoleText).toContain("WARNING: No .zosAttributes file found in the bundle directory, default values will be applied");
10881142
expect(consoleText).toContain("Deploying bundle '12345678' to CICS");
10891143
expect(consoleText).toContain("Deploy ended with errors");
1090-
expect(consoleText).toContain("Gathering Node.js diagnostics");
1144+
expect(consoleText).toContain("Gathering Scope information");
1145+
expect(consoleText).toContain("Querying Regions in Scope over CMCI");
1146+
expect(consoleText).toContain("CICS Regions in Scope '12345678' of CICSplex '12345678':");
1147+
expect(consoleText).toContain("Applid: ABCDEFG jobname: MYCICS jobid: JOB12345");
1148+
expect(consoleText).toContain("Querying NODEJSAPP resources over CMCI");
1149+
expect(consoleText).toContain("zowe cics get resource CICSNodejsapp --region-name 12345678 --criteria \"BUNDLE=12345678\" --cics-plex 12345678");
10911150
expect(zosMFSpy).toHaveBeenCalledTimes(1);
10921151
expect(sshSpy).toHaveBeenCalledTimes(1);
10931152
expect(listSpy).toHaveBeenCalledTimes(1);
@@ -1098,7 +1157,7 @@ describe("BundlePusher01", () => {
10981157
expect(existsSpy).toHaveBeenCalledTimes(1);
10991158
expect(readSpy).toHaveBeenCalledTimes(1);
11001159
expect(uploadSpy).toHaveBeenCalledTimes(1);
1101-
expect(cmciSpy).toHaveBeenCalledTimes(1);
1160+
expect(cmciSpy).toHaveBeenCalledTimes(2);
11021161
});
11031162
it("should tolerate a Node.js diagnostics generation failure - region", async () => {
11041163
zosmfProfile = { host: "wibble", user: "user" };
@@ -1110,7 +1169,6 @@ describe("BundlePusher01", () => {
11101169

11111170
await runPushTest("__tests__/__resources__/ExampleBundle01", false, "PUSH operation completed.");
11121171

1113-
expect(consoleText).toContain("zowe cics get resource CICSNodejsapp --region-name 12345678 --criteria \"BUNDLE=12345678\" --cics-plex 12345678");
11141172
expect(zosMFSpy).toHaveBeenCalledTimes(1);
11151173
expect(sshSpy).toHaveBeenCalledTimes(1);
11161174
expect(listSpy).toHaveBeenCalledTimes(1);

src/api/BundlePush/BundlePusher.ts

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,12 @@ export class BundlePusher {
367367
}
368368
this.startProgressBar();
369369

370-
// Generate additional output for Node.js
371-
await this.outputNodejsDiagnostics(cicsSession, dfhdployOutput);
370+
// Collect general information about the regions in the CICSplex scope
371+
const diagnosticsWorking = await this.outputGeneralDiagnostics(cicsSession);
372+
if (diagnosticsWorking) {
373+
// Generate additional diagnostic output for Node.js
374+
await this.outputNodejsSpecificDiagnostics(cicsSession, dfhdployOutput);
375+
}
372376

373377
// Now rethrow the original error, if there was one.
374378
if (deployError !== undefined) {
@@ -610,16 +614,35 @@ export class BundlePusher {
610614
}
611615
}
612616

613-
private async outputNodejsDiagnostics(cicsSession: AbstractSession, dfhdployOutput: string) {
617+
private async outputGeneralDiagnostics(cicsSession: AbstractSession): Promise<boolean> {
618+
let scopeFound = false;
619+
try {
620+
if (cicsSession !== undefined) {
621+
// Attempt to gather additional Node.js specific information from CICS
622+
this.updateStatus("Gathering Scope information");
623+
scopeFound = await this.gatherGeneralDiagnosticsFromCics(cicsSession);
624+
}
625+
}
626+
catch (diagnosticsError) {
627+
// Something went wrong generating scope info. Don't trouble the user
628+
// with what might be an exotic error message (e.g. hex dump of an entire HTML page),
629+
// just log the failure.
630+
if (this.params.arguments.silent === undefined) {
631+
const logger = Logger.getAppLogger();
632+
logger.debug(diagnosticsError.message);
633+
}
634+
}
635+
return scopeFound;
636+
}
637+
638+
private async outputNodejsSpecificDiagnostics(cicsSession: AbstractSession, dfhdployOutput: string) {
614639
// Did the Bundle contents include a NODEJSAPP?
615640
if (dfhdployOutput.indexOf("http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP") > -1) {
616641
let diagnosticsIssued = false;
617642
try {
618-
if (cicsSession !== undefined) {
619-
// Attempt to gather additional Node.js specific information from CICS
620-
this.updateStatus("Gathering Node.js diagnostics");
621-
diagnosticsIssued = await this.gatherNodejsDiagnosticsFromCics(cicsSession);
622-
}
643+
// Attempt to gather additional Node.js specific information from CICS
644+
this.updateStatus("Gathering Node.js diagnostics");
645+
diagnosticsIssued = await this.gatherNodejsDiagnosticsFromCics(cicsSession);
623646
}
624647
catch (diagnosticsError) {
625648
// Something went wrong generating diagnostic info. Don't trouble the user
@@ -631,7 +654,7 @@ export class BundlePusher {
631654
}
632655
}
633656

634-
// If we don't have a cics profile or if we do but the diagnostics collection failed, issue a message.
657+
// We must have a cics profile in order to have got this far, so suggest a command that can be run to figure out more.
635658
if (diagnosticsIssued === false) {
636659
const msg = "For further information on the state of your NODEJSAPP resources, consider running the following command:\n\n" +
637660
"zowe cics get resource CICSNodejsapp --region-name " + this.params.arguments.scope +
@@ -641,10 +664,9 @@ export class BundlePusher {
641664
}
642665
}
643666

644-
private async gatherNodejsDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
667+
private async gatherGeneralDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
645668
// Issue a CMCI get to the target CICSplex
646669
try {
647-
// First process each Region in the Scope
648670
this.updateStatus("Querying Regions in Scope over CMCI");
649671
const regionData: IResourceParms = { name: "CICSRegion",
650672
regionName: this.params.arguments.scope,
@@ -657,10 +679,10 @@ export class BundlePusher {
657679
throw new Error("CICSRegion CMCI output record not found.");
658680
}
659681
const outputRegionRecords = cmciRegionResponse.response.records.cicsregion;
660-
let msg = "CICS Regions in Scope '" + this.params.arguments.scope + "' of CICSplex '" + this.params.arguments.cicsplex + "':\n";
682+
const msg = "CICS Regions in Scope '" + this.params.arguments.scope + "' of CICSplex '" + this.params.arguments.cicsplex + "':\n";
661683
this.issueMessage(msg);
662684

663-
// We may have an array of records if there was more than one NODEJSAPP in the bundle
685+
// We may have an array of records if there was more than one Region in the scope
664686
if (Array.isArray(outputRegionRecords)) {
665687
for (const record of outputRegionRecords) {
666688
this.reportRegionData(record);
@@ -669,8 +691,17 @@ export class BundlePusher {
669691
else {
670692
this.reportRegionData(outputRegionRecords);
671693
}
694+
}
695+
catch (error) {
696+
throw new Error("Failure collecting diagnostics for Bundle " + this.params.arguments.name + ": " + error.message);
697+
}
672698

673-
// Next process each NODEJSAPP in the Scope
699+
return true;
700+
}
701+
702+
private async gatherNodejsDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
703+
try {
704+
// Process each NODEJSAPP in the Scope
674705
this.updateStatus("Querying NODEJSAPP resources over CMCI");
675706
const nodejsData: IResourceParms = { name: "CICSNodejsapp",
676707
criteria: "BUNDLE=" + this.params.arguments.name,
@@ -685,7 +716,7 @@ export class BundlePusher {
685716
}
686717
const outputNodejsRecords = cmciNodejsResponse.response.records.cicsnodejsapp;
687718

688-
msg = "\nNODEJSAPP resources for Bundle '" + this.params.arguments.name + "' in Scope '" + this.params.arguments.scope + "':\n";
719+
const msg = "\nNODEJSAPP resources for Bundle '" + this.params.arguments.name + "' in Scope '" + this.params.arguments.scope + "':\n";
689720
this.issueMessage(msg);
690721

691722
// We may have an array of records if there was more than one NODEJSAPP in the bundle

0 commit comments

Comments
 (0)