Skip to content

Commit

Permalink
better way to log task progress together with their associated job
Browse files Browse the repository at this point in the history
  • Loading branch information
rlindner81 committed Apr 24, 2024
1 parent 18bbc03 commit 59749a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
15 changes: 11 additions & 4 deletions src/submodules/capMultitenancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,17 @@ const _cdsUpgradeMtxs = async (

const { status, tasks } = pollJobResponseData || {};
assert(status, "no status retrieved for jobId %s", jobId);
console.log("polled status %s for jobId %s", status, jobId);
const taskSummary = _getTaskSummary(tasks ?? []);
const [queued, running, failed, finished] = taskSummary.map((count) => String(count).padStart(countLength, "0"));
console.log("task progress is queued/running: %s/%s | failed/finished: %s/%s", queued, running, failed, finished);
const [queued, running, failed, finished] = taskSummary.map((count) => String(count).padStart(countLength));
console.log(
"job %s is %s with tasks queued/running: %s/%s | failed/finished: %s/%s",
jobId,
status,
queued,
running,
failed,
finished
);
if (!lastTaskSummary || lastTaskSummary.some((index, value) => taskSummary[index] !== value)) {
const currentTime = Date.now();
if (currentTime - (lastTimeOfChange ?? currentTime) >= CDS_CHANGE_TIMEOUT) {
Expand Down Expand Up @@ -283,7 +290,7 @@ const _cdsUpgradeMtx = async (

const { status } = pollJobResponseData || {};
assert(status, "no status retrieved for jobId %s", jobId);
console.log("polled status %s for jobId %s", status, jobId);
console.log("job %s is %s", jobId, status);

if (status !== "RUNNING") {
break;
Expand Down
25 changes: 10 additions & 15 deletions test/capMultitenancy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,9 @@ describe("cds tests", () => {
expect(outputFromLoggerPartitionFetch(loggerSpy.info.mock.calls)).toMatchInlineSnapshot(`
"targeting cf api https://api.cf.sap.hana.ondemand.com / org "skyfin" / space "dev"
started upgrade on server with jobId e85db10b-c269-4897-bd78-dde0d36f72cc polling interval 15sec
polled status RUNNING for jobId e85db10b-c269-4897-bd78-dde0d36f72cc
task progress is queued/running: 0/1 | failed/finished: 0/0
polled status RUNNING for jobId e85db10b-c269-4897-bd78-dde0d36f72cc
task progress is queued/running: 0/1 | failed/finished: 0/0
polled status FINISHED for jobId e85db10b-c269-4897-bd78-dde0d36f72cc
task progress is queued/running: 0/0 | failed/finished: 0/1
job e85db10b-c269-4897-bd78-dde0d36f72cc is RUNNING with tasks queued/running: 0/1 | failed/finished: 0/0
job e85db10b-c269-4897-bd78-dde0d36f72cc is RUNNING with tasks queued/running: 0/1 | failed/finished: 0/0
job e85db10b-c269-4897-bd78-dde0d36f72cc is FINISHED with tasks queued/running: 0/0 | failed/finished: 0/1
# tenantId status message
1 5ecc7413-2b7e-414a-9496-ad4a61f6cccf FINISHED
Expand All @@ -185,10 +182,8 @@ describe("cds tests", () => {
expect(outputFromLoggerPartitionFetch(loggerSpy.info.mock.calls)).toMatchInlineSnapshot(`
"targeting cf api https://api.cf.sap.hana.ondemand.com / org "skyfin" / space "dev"
started upgrade on server with jobId 00e7cfd9-b5aa-4485-b6c7-ab79b8f08e0c polling interval 15sec
polled status RUNNING for jobId 00e7cfd9-b5aa-4485-b6c7-ab79b8f08e0c
task progress is queued/running: 0/1 | failed/finished: 0/0
polled status FINISHED for jobId 00e7cfd9-b5aa-4485-b6c7-ab79b8f08e0c
task progress is queued/running: 0/0 | failed/finished: 0/1
job 00e7cfd9-b5aa-4485-b6c7-ab79b8f08e0c is RUNNING with tasks queued/running: 0/1 | failed/finished: 0/0
job 00e7cfd9-b5aa-4485-b6c7-ab79b8f08e0c is FINISHED with tasks queued/running: 0/0 | failed/finished: 0/1
# tenantId status message
1 5ecc7413-2b7e-414a-9496-ad4a61f6cccf FINISHED
Expand All @@ -214,11 +209,11 @@ describe("cds tests", () => {
expect(outputFromLoggerPartitionFetch(infoCallsFiltered)).toMatchInlineSnapshot(`
"targeting cf api https://api.cf.sap.hana.ondemand.com / org "skyfin" / space "dev"
started upgrade on server with jobId 83499cfe-548a-4245-9eae-f25aa06d879c polling interval 15sec
task progress is queued/running: 1/5 | failed/finished: 0/0
task progress is queued/running: 1/4 | failed/finished: 0/1
task progress is queued/running: 0/1 | failed/finished: 0/5
task progress is queued/running: 0/1 | failed/finished: 0/5
task progress is queued/running: 0/0 | failed/finished: 0/6
job 83499cfe-548a-4245-9eae-f25aa06d879c is RUNNING with tasks queued/running: 1/5 | failed/finished: 0/0
job 83499cfe-548a-4245-9eae-f25aa06d879c is RUNNING with tasks queued/running: 1/4 | failed/finished: 0/1
job 83499cfe-548a-4245-9eae-f25aa06d879c is RUNNING with tasks queued/running: 0/1 | failed/finished: 0/5
job 83499cfe-548a-4245-9eae-f25aa06d879c is RUNNING with tasks queued/running: 0/1 | failed/finished: 0/5
job 83499cfe-548a-4245-9eae-f25aa06d879c is FINISHED with tasks queued/running: 0/0 | failed/finished: 0/6
# tenantId status message
1 4c0909b1-a84e-4763-a26e-532fdb9e40fa FINISHED
2 5ecc7413-2b7e-414a-9496-ad4a61f6cccf FINISHED
Expand Down

0 comments on commit 59749a9

Please sign in to comment.