From 59749a9e6da7760f4461b2dac86e1a8a829b65b8 Mon Sep 17 00:00:00 2001 From: Richard Lindner Date: Wed, 24 Apr 2024 18:23:02 +0200 Subject: [PATCH] better way to log task progress together with their associated job --- src/submodules/capMultitenancy.js | 15 +++++++++++---- test/capMultitenancy.test.js | 25 ++++++++++--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/submodules/capMultitenancy.js b/src/submodules/capMultitenancy.js index 0813f46..a9661cf 100644 --- a/src/submodules/capMultitenancy.js +++ b/src/submodules/capMultitenancy.js @@ -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) { @@ -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; diff --git a/test/capMultitenancy.test.js b/test/capMultitenancy.test.js index 06be1b7..1044f59 100644 --- a/test/capMultitenancy.test.js +++ b/test/capMultitenancy.test.js @@ -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 @@ -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 @@ -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