Skip to content

Commit 72a836a

Browse files
committed
region summary and review comments
1 parent d3d3b1b commit 72a836a

File tree

3 files changed

+232
-48
lines changed

3 files changed

+232
-48
lines changed

__tests__/api/BundlePush/BundlePusher.test.ts

Lines changed: 175 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ describe("BundlePusher01", () => {
11001100
expect(uploadSpy).toHaveBeenCalledTimes(1);
11011101
expect(cmciSpy).toHaveBeenCalledTimes(1);
11021102
});
1103-
it("should tolerate a Node.js diagnostics generation failure", async () => {
1103+
it("should tolerate a Node.js diagnostics generation failure - region", async () => {
11041104
zosmfProfile = { host: "wibble", user: "user" };
11051105
sshProfile = { host: "wibble", user: "user" };
11061106
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
@@ -1123,26 +1123,124 @@ describe("BundlePusher01", () => {
11231123
expect(uploadSpy).toHaveBeenCalledTimes(1);
11241124
expect(cmciSpy).toHaveBeenCalledTimes(1);
11251125
});
1126+
it("should tolerate a Node.js diagnostics generation failure - nodejsapp", async () => {
1127+
zosmfProfile = { host: "wibble", user: "user" };
1128+
sshProfile = { host: "wibble", user: "user" };
1129+
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
1130+
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
1131+
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1132+
cmciSpy.mockImplementation((cicsSession: any, nodejsData: cmci.IResourceParms) => {
1133+
if (nodejsData.name === "CICSNodejsapp") {
1134+
throw new Error("Injected CMCI GET error");
1135+
}
1136+
else if (nodejsData.name === "CICSRegion") {
1137+
return { response: {
1138+
records: {
1139+
cicsregion: {
1140+
applid: "ABCDEFG", jobid: "JOB12345", jobname: "MYCICS"
1141+
}
1142+
}
1143+
}
1144+
};
1145+
}
1146+
else {
1147+
return {};
1148+
}
1149+
});
1150+
1151+
await runPushTest("__tests__/__resources__/ExampleBundle01", false, "PUSH operation completed.");
1152+
1153+
expect(consoleText).toContain("zowe cics get resource CICSNodejsapp --region-name 12345678 --criteria \"BUNDLE=12345678\" --cics-plex 12345678");
1154+
expect(zosMFSpy).toHaveBeenCalledTimes(1);
1155+
expect(sshSpy).toHaveBeenCalledTimes(1);
1156+
expect(listSpy).toHaveBeenCalledTimes(1);
1157+
expect(createSpy).toHaveBeenCalledTimes(1);
1158+
expect(shellSpy).toHaveBeenCalledTimes(0);
1159+
expect(membersSpy).toHaveBeenCalledTimes(2);
1160+
expect(submitSpy).toHaveBeenCalledTimes(1);
1161+
expect(existsSpy).toHaveBeenCalledTimes(1);
1162+
expect(readSpy).toHaveBeenCalledTimes(1);
1163+
expect(uploadSpy).toHaveBeenCalledTimes(1);
1164+
expect(cmciSpy).toHaveBeenCalledTimes(2);
1165+
});
1166+
it("should tolerate a Node.js diagnostics generation failure - nodejsapp empty", async () => {
1167+
zosmfProfile = { host: "wibble", user: "user" };
1168+
sshProfile = { host: "wibble", user: "user" };
1169+
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
1170+
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
1171+
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1172+
cmciSpy.mockImplementation((cicsSession: any, nodejsData: cmci.IResourceParms) => {
1173+
if (nodejsData.name === "CICSNodejsapp") {
1174+
return {};
1175+
}
1176+
else if (nodejsData.name === "CICSRegion") {
1177+
return { response: {
1178+
records: {
1179+
cicsregion: {
1180+
applid: "ABCDEFG", jobid: "JOB12345", jobname: "MYCICS"
1181+
}
1182+
}
1183+
}
1184+
};
1185+
}
1186+
else {
1187+
return {};
1188+
}
1189+
});
1190+
1191+
await runPushTest("__tests__/__resources__/ExampleBundle01", false, "PUSH operation completed.");
1192+
1193+
expect(consoleText).toContain("zowe cics get resource CICSNodejsapp --region-name 12345678 --criteria \"BUNDLE=12345678\" --cics-plex 12345678");
1194+
expect(zosMFSpy).toHaveBeenCalledTimes(1);
1195+
expect(sshSpy).toHaveBeenCalledTimes(1);
1196+
expect(listSpy).toHaveBeenCalledTimes(1);
1197+
expect(createSpy).toHaveBeenCalledTimes(1);
1198+
expect(shellSpy).toHaveBeenCalledTimes(0);
1199+
expect(membersSpy).toHaveBeenCalledTimes(2);
1200+
expect(submitSpy).toHaveBeenCalledTimes(1);
1201+
expect(existsSpy).toHaveBeenCalledTimes(1);
1202+
expect(readSpy).toHaveBeenCalledTimes(1);
1203+
expect(uploadSpy).toHaveBeenCalledTimes(1);
1204+
expect(cmciSpy).toHaveBeenCalledTimes(2);
1205+
});
11261206
it("should generate Node.js diagnostics for 1 enabled NODEJSAPP", async () => {
11271207
zosmfProfile = { host: "wibble", user: "user" };
11281208
sshProfile = { host: "wibble", user: "user" };
11291209
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
11301210
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
11311211
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1132-
cmciSpy.mockImplementationOnce(() => (
1133-
{ response: {
1134-
records: {
1135-
cicsnodejsapp: {
1136-
name: "name", pid: "22", enablestatus: "ENABLED", stderr: "/tmp/stderr", stdout: "/tmp/stdout", eyu_cicsname: "1"
1212+
cmciSpy.mockImplementation((cicsSession: any, nodejsData: cmci.IResourceParms) => {
1213+
if (nodejsData.name === "CICSNodejsapp") {
1214+
return { response: {
1215+
records: {
1216+
cicsnodejsapp: {
1217+
name: "name", pid: "22", enablestatus: "ENABLED", stderr: "/tmp/stderr", stdout: "/tmp/stdout", eyu_cicsname: "1"
1218+
}
11371219
}
11381220
}
1139-
}
1140-
})
1141-
);
1221+
};
1222+
}
1223+
else if (nodejsData.name === "CICSRegion") {
1224+
return { response: {
1225+
records: {
1226+
cicsregion: {
1227+
applid: "ABCDEFG", jobid: "JOB12345", jobname: "MYCICS"
1228+
}
1229+
}
1230+
}
1231+
};
1232+
}
1233+
else {
1234+
return {};
1235+
}
1236+
});
11421237

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

1145-
expect(consoleText).toContain("CICS NODEJSAPP resource 'name' is in 'ENABLED' state in region '1' with process id '22'.");
1240+
expect(consoleText).toContain("CICS Regions in Scope '12345678' of CICSplex '12345678':");
1241+
expect(consoleText).toContain("Applid: ABCDEFG jobname: MYCICS jobid: JOB12345");
1242+
expect(consoleText).toContain("NODEJSAPP resources for Bundle '12345678' in Scope '12345678':");
1243+
expect(consoleText).toContain("CICS NODEJSAPP resource 'name' is in 'ENABLED' state in region '1' with process id '22'");
11461244
expect(consoleText).toContain("stdout: /tmp/stdout");
11471245
expect(consoleText).toContain("stderr: /tmp/stderr");
11481246
expect(zosMFSpy).toHaveBeenCalledTimes(1);
@@ -1155,27 +1253,45 @@ describe("BundlePusher01", () => {
11551253
expect(existsSpy).toHaveBeenCalledTimes(1);
11561254
expect(readSpy).toHaveBeenCalledTimes(1);
11571255
expect(uploadSpy).toHaveBeenCalledTimes(1);
1158-
expect(cmciSpy).toHaveBeenCalledTimes(1);
1256+
expect(cmciSpy).toHaveBeenCalledTimes(2);
11591257
});
11601258
it("should generate Node.js diagnostics for 1 disabled NODEJSAPP", async () => {
11611259
zosmfProfile = { host: "wibble", user: "user" };
11621260
sshProfile = { host: "wibble", user: "user" };
11631261
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
11641262
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
11651263
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1166-
cmciSpy.mockImplementationOnce(() => (
1167-
{ response: {
1168-
records: {
1169-
cicsnodejsapp: {
1170-
name: "name", pid: "0", enablestatus: "DISABLED", stderr: "", stdout: "", eyu_cicsname: "1"
1264+
cmciSpy.mockImplementation((cicsSession: any, nodejsData: cmci.IResourceParms) => {
1265+
if (nodejsData.name === "CICSNodejsapp") {
1266+
return { response: {
1267+
records: {
1268+
cicsnodejsapp: {
1269+
name: "name", pid: "0", enablestatus: "DISABLED", stderr: "", stdout: "", eyu_cicsname: "1"
1270+
}
11711271
}
11721272
}
1173-
}
1174-
})
1175-
);
1273+
};
1274+
}
1275+
else if (nodejsData.name === "CICSRegion") {
1276+
return { response: {
1277+
records: {
1278+
cicsregion: {
1279+
applid: "ABCD", jobid: "JOB12345", jobname: "MYCICS"
1280+
}
1281+
}
1282+
}
1283+
};
1284+
}
1285+
else {
1286+
return {};
1287+
}
1288+
});
11761289

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

1292+
expect(consoleText).toContain("CICS Regions in Scope '12345678' of CICSplex '12345678':");
1293+
expect(consoleText).toContain("Applid: ABCD jobname: MYCICS jobid: JOB12345");
1294+
expect(consoleText).toContain("NODEJSAPP resources for Bundle '12345678' in Scope '12345678':");
11791295
expect(consoleText).toContain("CICS NODEJSAPP resource 'name' is in 'DISABLED' state in region '1' with process id '0'.");
11801296
expect(consoleText).toContain("stdout: <not available>");
11811297
expect(consoleText).toContain("stderr: <not available>");
@@ -1189,32 +1305,56 @@ describe("BundlePusher01", () => {
11891305
expect(existsSpy).toHaveBeenCalledTimes(1);
11901306
expect(readSpy).toHaveBeenCalledTimes(1);
11911307
expect(uploadSpy).toHaveBeenCalledTimes(1);
1192-
expect(cmciSpy).toHaveBeenCalledTimes(1);
1308+
expect(cmciSpy).toHaveBeenCalledTimes(2);
11931309
});
11941310
it("should generate Node.js diagnostics for 2 NODEJSAPPs", async () => {
11951311
zosmfProfile = { host: "wibble", user: "user" };
11961312
sshProfile = { host: "wibble", user: "user" };
11971313
cicsProfile = { host: "wibble", user: "user", password: "thisIsntReal", cicsPlex: "12345678", regionName: "12345678" };
11981314
submitSpy = jest.spyOn(SubmitJobs, "submitJclString").mockImplementation(() =>
11991315
[{ddName: "SYSTSPRT", stepName: "DFHDPLOY", data: "DFHRL2012I http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP"}] );
1200-
cmciSpy.mockImplementationOnce(() => (
1201-
{ response: {
1202-
records: {
1203-
cicsnodejsapp: [
1204-
{
1205-
name: "name", pid: "22", enablestatus: "ENABLED", stderr: "/tmp/stderr", stdout: "/tmp/stdout", eyu_cicsname: "1"
1206-
},
1207-
{
1208-
name: "name2", pid: "33", enablestatus: "ENABLED", stderr: "/tmp/name2err", stdout: "/tmp/name2out", eyu_cicsname: "1"
1209-
}
1210-
]
1316+
cmciSpy.mockImplementation((cicsSession: any, nodejsData: cmci.IResourceParms) => {
1317+
if (nodejsData.name === "CICSNodejsapp") {
1318+
return { response: {
1319+
records: {
1320+
cicsnodejsapp: [
1321+
{
1322+
name: "name", pid: "22", enablestatus: "ENABLED", stderr: "/tmp/stderr", stdout: "/tmp/stdout", eyu_cicsname: "1"
1323+
},
1324+
{
1325+
name: "name2", pid: "33", enablestatus: "ENABLED", stderr: "/tmp/name2err", stdout: "/tmp/name2out", eyu_cicsname: "1"
1326+
}
1327+
]
1328+
}
12111329
}
1212-
}
1213-
})
1214-
);
1330+
};
1331+
}
1332+
else if (nodejsData.name === "CICSRegion") {
1333+
return { response: {
1334+
records: {
1335+
cicsregion: [
1336+
{
1337+
applid: "ABCD", jobid: "JOB12345", jobname: "MYCICS"
1338+
},
1339+
{
1340+
applid: "EFGHIHJK", jobid: "JOB54321", jobname: "MYCICS2"
1341+
},
1342+
]
1343+
}
1344+
}
1345+
};
1346+
}
1347+
else {
1348+
return {};
1349+
}
1350+
});
12151351

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

1354+
expect(consoleText).toContain("CICS Regions in Scope '12345678' of CICSplex '12345678':");
1355+
expect(consoleText).toContain("Applid: ABCD jobname: MYCICS jobid: JOB12345");
1356+
expect(consoleText).toContain("Applid: EFGHIHJK jobname: MYCICS2 jobid: JOB54321");
1357+
expect(consoleText).toContain("NODEJSAPP resources for Bundle '12345678' in Scope '12345678':");
12181358
expect(consoleText).toContain("CICS NODEJSAPP resource 'name' is in 'ENABLED' state in region '1' with process id '22'.");
12191359
expect(consoleText).toContain("stdout: /tmp/stdout");
12201360
expect(consoleText).toContain("stderr: /tmp/stderr");
@@ -1231,7 +1371,7 @@ describe("BundlePusher01", () => {
12311371
expect(existsSpy).toHaveBeenCalledTimes(1);
12321372
expect(readSpy).toHaveBeenCalledTimes(1);
12331373
expect(uploadSpy).toHaveBeenCalledTimes(1);
1234-
expect(cmciSpy).toHaveBeenCalledTimes(1);
1374+
expect(cmciSpy).toHaveBeenCalledTimes(2);
12351375
});
12361376
});
12371377

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"configurationModule": "lib/imperative.js"
3232
},
3333
"dependencies": {
34-
"xml2json": "^0.11.2"
34+
"xml2json": "^0.11.2",
35+
"@zowe/cics": "^2.0.1"
3536
},
3637
"devDependencies": {
3738
"@zowe/cli": "^5.5.0",
@@ -68,7 +69,6 @@
6869
},
6970
"peerDependencies": {
7071
"@zowe/cli": "^5.5.0",
71-
"@zowe/cics": "^2.0.1",
7272
"@zowe/imperative": "^4.1.2"
7373
},
7474
"jest": {

src/api/BundlePush/BundlePusher.ts

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -644,24 +644,58 @@ export class BundlePusher {
644644
private async gatherNodejsDiagnosticsFromCics(cicsSession: AbstractSession): Promise<boolean> {
645645
// Issue a CMCI get to the target CICSplex
646646
try {
647-
const data: IResourceParms = { name: "CICSNodejsapp",
648-
criteria: "BUNDLE=" + this.params.arguments.name,
649-
regionName: this.params.arguments.scope,
650-
cicsPlex: this.params.arguments.cicsplex };
651-
const cmciResponse = await getResource(cicsSession, data);
652-
const outputRecord = cmciResponse.response.records.cicsnodejsapp;
653-
if (outputRecord === undefined) {
654-
throw new Error("CICSNodejsapp output record not found.");
647+
// First process each Region in the Scope
648+
this.updateStatus("Querying Regions in Scope over CMCI");
649+
const regionData: IResourceParms = { name: "CICSRegion",
650+
regionName: this.params.arguments.scope,
651+
cicsPlex: this.params.arguments.cicsplex };
652+
const cmciRegionResponse = await getResource(cicsSession, regionData);
653+
if (cmciRegionResponse === undefined ||
654+
cmciRegionResponse.response === undefined ||
655+
cmciRegionResponse.response.records === undefined ||
656+
cmciRegionResponse.response.records.cicsregion === undefined) {
657+
throw new Error("CICSRegion CMCI output record not found.");
655658
}
659+
const outputRegionRecords = cmciRegionResponse.response.records.cicsregion;
660+
let msg = "CICS Regions in Scope '" + this.params.arguments.scope + "' of CICSplex '" + this.params.arguments.cicsplex + "':\n";
661+
this.issueMessage(msg);
656662

657663
// We may have an array of records if there was more than one NODEJSAPP in the bundle
658-
if (Array.isArray(outputRecord)) {
659-
for (const record of outputRecord) {
664+
if (Array.isArray(outputRegionRecords)) {
665+
for (const record of outputRegionRecords) {
666+
this.reportRegionData(record);
667+
}
668+
}
669+
else {
670+
this.reportRegionData(outputRegionRecords);
671+
}
672+
673+
// Next process each NODEJSAPP in the Scope
674+
this.updateStatus("Querying NODEJSAPP resources over CMCI");
675+
const nodejsData: IResourceParms = { name: "CICSNodejsapp",
676+
criteria: "BUNDLE=" + this.params.arguments.name,
677+
regionName: this.params.arguments.scope,
678+
cicsPlex: this.params.arguments.cicsplex };
679+
const cmciNodejsResponse = await getResource(cicsSession, nodejsData);
680+
if (cmciNodejsResponse === undefined ||
681+
cmciNodejsResponse.response === undefined ||
682+
cmciNodejsResponse.response.records === undefined ||
683+
cmciNodejsResponse.response.records.cicsnodejsapp === undefined) {
684+
throw new Error("CICSNodejsapp CMCI output record not found.");
685+
}
686+
const outputNodejsRecords = cmciNodejsResponse.response.records.cicsnodejsapp;
687+
688+
msg = "\nNODEJSAPP resources for Bundle '" + this.params.arguments.name + "' in Scope '" + this.params.arguments.scope + "':\n";
689+
this.issueMessage(msg);
690+
691+
// We may have an array of records if there was more than one NODEJSAPP in the bundle
692+
if (Array.isArray(outputNodejsRecords)) {
693+
for (const record of outputNodejsRecords) {
660694
this.reportNODEJSAPPData(record);
661695
}
662696
}
663697
else {
664-
this.reportNODEJSAPPData(outputRecord);
698+
this.reportNODEJSAPPData(outputNodejsRecords);
665699
}
666700
}
667701
catch (error) {
@@ -671,6 +705,16 @@ export class BundlePusher {
671705
return true;
672706
}
673707

708+
private reportRegionData(outputRecord: any) {
709+
const MAX_LENGTH = 8;
710+
const applid = outputRecord.applid.padEnd(MAX_LENGTH, " ");
711+
const jobid = outputRecord.jobid.padEnd(MAX_LENGTH, " ");
712+
const jobname = outputRecord.jobname.padEnd(MAX_LENGTH, " ");
713+
714+
const msg = " Applid: " + applid + " jobname: " + jobname + " jobid: " + jobid + "\n";
715+
this.issueMessage(msg);
716+
}
717+
674718
private reportNODEJSAPPData(outputRecord: any) {
675719
const name = outputRecord.name;
676720
const enablestatus = outputRecord.enablestatus;

0 commit comments

Comments
 (0)