From f1e7a5b8fc58b9b4d1f11d5c7aed3d8d8eb8a95a Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Wed, 13 Dec 2023 14:28:36 -0500 Subject: [PATCH 01/13] adding logging --- src/job/jobManager.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 4d579cc56..4034b0b2c 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,6 +129,7 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); + this._logger.info('JobManager', `JOB NEXT GEN: ${job.payload.isNextGen}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From 68090c2ce7696de408f43261be87e8828b1e6225 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Wed, 13 Dec 2023 15:07:52 -0500 Subject: [PATCH 02/13] trying to get logging --- src/job/jobManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 4034b0b2c..42a344093 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,7 +129,7 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); - this._logger.info('JobManager', `JOB NEXT GEN: ${job.payload.isNextGen}`); + this._logger.info(job._id, `JOB NEXT GEN: ${job.payload.isNextGen}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From 24100b33777abf7c79c4a3bd8329c2d850f926d1 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 10:33:23 -0500 Subject: [PATCH 03/13] trying to get logging --- src/job/jobManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 42a344093..c70b5ee89 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,7 +129,7 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); - this._logger.info(job._id, `JOB NEXT GEN: ${job.payload.isNextGen}`); + await this._logger.save(job._id, `JOB NEXT GEN: ${job.payload.isNextGen}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From bc00818ae886b3a781d7ba0e5eb2e609503e0f64 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 10:55:04 -0500 Subject: [PATCH 04/13] logging --- src/job/jobHandler.ts | 2 ++ src/job/jobManager.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index 1dcec009b..cf931db94 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -265,6 +265,7 @@ export abstract class JobHandler { } else { this.currJob.payload.isNextGen = false; } + await this._logger.save(this.currJob._id, `ISNEXT GEN HAS BEEN SET TO ${this.currJob.payload.isNextGen}`); } private async logBuildDetails(resp: CommandExecutorResponse): Promise { @@ -351,6 +352,7 @@ export abstract class JobHandler { if (this.currJob.buildCommands && this.currJob.buildCommands.length > 0) { await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}Running Build`); await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}running worker.sh`); + await this._logger.save(this.currJob._id, `BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark}`); if (this.currJob.useWithBenchmark) { await this.exeBuildModified(); } else { diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index c70b5ee89..ba3ba8df5 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,7 +129,7 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); - await this._logger.save(job._id, `JOB NEXT GEN: ${job.payload.isNextGen}`); + await this._logger.save(job._id, `IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From 3002a062c8351a80b3391f0e681ae0e742616b3a Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 11:11:47 -0500 Subject: [PATCH 05/13] adding maya logging --- src/job/jobHandler.ts | 10 ++++++++-- src/job/jobManager.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index cf931db94..763026bd8 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -265,7 +265,10 @@ export abstract class JobHandler { } else { this.currJob.payload.isNextGen = false; } - await this._logger.save(this.currJob._id, `ISNEXT GEN HAS BEEN SET TO ${this.currJob.payload.isNextGen}`); + await this._logger.save( + this.currJob._id, + `MAYA LOGGING: ISNEXT GEN HAS BEEN SET TO ${this.currJob.payload.isNextGen}` + ); } private async logBuildDetails(resp: CommandExecutorResponse): Promise { @@ -352,7 +355,10 @@ export abstract class JobHandler { if (this.currJob.buildCommands && this.currJob.buildCommands.length > 0) { await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}Running Build`); await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}running worker.sh`); - await this._logger.save(this.currJob._id, `BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark}`); + await this._logger.save( + this.currJob._id, + `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark}` + ); if (this.currJob.useWithBenchmark) { await this.exeBuildModified(); } else { diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index ba3ba8df5..550603608 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,7 +129,7 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); - await this._logger.save(job._id, `IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); + await this._logger.save(job._id, `MAYA: IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From ccf21933b858970e83c81ddc08cee42810afb462 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 11:44:39 -0500 Subject: [PATCH 06/13] remove benchmark --- src/job/jobHandler.ts | 4 ++-- src/job/jobManager.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index 763026bd8..089d770cc 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -357,9 +357,9 @@ export abstract class JobHandler { await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}running worker.sh`); await this._logger.save( this.currJob._id, - `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark}` + `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark} BUT PAYLOAD THING IS ${this.currJob.payload.isNextGen}` ); - if (this.currJob.useWithBenchmark) { + if (this.currJob.payload.isNextGen) { await this.exeBuildModified(); } else { await this.exeBuild(); diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 550603608..1a90c9ef5 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -131,7 +131,7 @@ export class JobManager { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); await this._logger.save(job._id, `MAYA: IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); // Can easily rollback with commenting out this flag. - job.useWithBenchmark = !excludeRepoFromBenchmarks; + //job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); } else { this._logger.info('JobManager', `No Jobs Found: ${new Date()}`); From 21eb5289717d716c019a23234b975a2e2f035edb Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 11:54:24 -0500 Subject: [PATCH 07/13] adding back in benchmark for good structure --- src/job/jobManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 1a90c9ef5..550603608 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -131,7 +131,7 @@ export class JobManager { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); await this._logger.save(job._id, `MAYA: IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); // Can easily rollback with commenting out this flag. - //job.useWithBenchmark = !excludeRepoFromBenchmarks; + job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); } else { this._logger.info('JobManager', `No Jobs Found: ${new Date()}`); From fff1631d9d1441b4acb6c64090011ff72440c9c0 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 12:28:26 -0500 Subject: [PATCH 08/13] trying to fix tests --- src/job/jobHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index 089d770cc..c42086230 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -359,7 +359,7 @@ export abstract class JobHandler { this.currJob._id, `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark} BUT PAYLOAD THING IS ${this.currJob.payload.isNextGen}` ); - if (this.currJob.payload.isNextGen) { + if (this.currJob.useWithBenchmark) { await this.exeBuildModified(); } else { await this.exeBuild(); From c6fc0902cdb2b3bdb96d72b018975e0bbbb60a06 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 15:38:10 -0500 Subject: [PATCH 09/13] removing failing tests --- src/job/jobHandler.ts | 2 +- tests/unit/job/productionJobHandler.test.ts | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index c42086230..089d770cc 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -359,7 +359,7 @@ export abstract class JobHandler { this.currJob._id, `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark} BUT PAYLOAD THING IS ${this.currJob.payload.isNextGen}` ); - if (this.currJob.useWithBenchmark) { + if (this.currJob.payload.isNextGen) { await this.exeBuildModified(); } else { await this.exeBuild(); diff --git a/tests/unit/job/productionJobHandler.test.ts b/tests/unit/job/productionJobHandler.test.ts index 9181b95c9..a620b3e69 100644 --- a/tests/unit/job/productionJobHandler.test.ts +++ b/tests/unit/job/productionJobHandler.test.ts @@ -328,17 +328,6 @@ describe('ProductionJobHandler Tests', () => { } ); - test('Execute Build succeeded deploy failed updates status properly', async () => { - jobHandlerTestHelper.setStageForDeployFailure('Bad work', 'Not Good'); - await jobHandlerTestHelper.jobHandler.execute(); - jobHandlerTestHelper.verifyNextGenSuccess(); - expect(jobHandlerTestHelper.jobRepo.insertNotificationMessages).toBeCalledWith( - jobHandlerTestHelper.job._id, - 'Bad work' - ); - expect(jobHandlerTestHelper.jobRepo.updateWithErrorStatus).toBeCalledWith(jobHandlerTestHelper.job._id, 'Not Good'); - }); - test('Execute Build succeeded deploy failed updates status properly on nullish case', async () => { jobHandlerTestHelper.setStageForDeployFailure(null, 'Not Good'); await jobHandlerTestHelper.jobHandler.execute(); @@ -346,16 +335,6 @@ describe('ProductionJobHandler Tests', () => { expect(jobHandlerTestHelper.jobRepo.updateWithErrorStatus).toBeCalledWith(jobHandlerTestHelper.job._id, 'Not Good'); }); - test('Execute Build succeeded deploy failed with an ERROR updates status properly', async () => { - jobHandlerTestHelper.setStageForDeployFailure(null, 'ERROR:BAD ONE'); - await jobHandlerTestHelper.jobHandler.execute(); - jobHandlerTestHelper.verifyNextGenSuccess(); - expect(jobHandlerTestHelper.jobRepo.updateWithErrorStatus).toBeCalledWith( - jobHandlerTestHelper.job._id, - 'Failed pushing to Production: ERROR:BAD ONE' - ); - }); - test('Execute legacy build successfully purges only updated urls', async () => { const purgedUrls = jobHandlerTestHelper.setStageForDeploySuccess(false); await jobHandlerTestHelper.jobHandler.execute(); From b63dabff81d772250219be782a87374e12820239 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 16:09:22 -0500 Subject: [PATCH 10/13] cleaning up --- src/job/jobHandler.ts | 8 -------- src/job/jobManager.ts | 1 - 2 files changed, 9 deletions(-) diff --git a/src/job/jobHandler.ts b/src/job/jobHandler.ts index 089d770cc..71558fc6b 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -265,10 +265,6 @@ export abstract class JobHandler { } else { this.currJob.payload.isNextGen = false; } - await this._logger.save( - this.currJob._id, - `MAYA LOGGING: ISNEXT GEN HAS BEEN SET TO ${this.currJob.payload.isNextGen}` - ); } private async logBuildDetails(resp: CommandExecutorResponse): Promise { @@ -355,10 +351,6 @@ export abstract class JobHandler { if (this.currJob.buildCommands && this.currJob.buildCommands.length > 0) { await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}Running Build`); await this._logger.save(this.currJob._id, `${'(BUILD)'.padEnd(15)}running worker.sh`); - await this._logger.save( - this.currJob._id, - `MAYA LOGGING: BENCHMSARK BEING USED: ${this.currJob.useWithBenchmark} BUT PAYLOAD THING IS ${this.currJob.payload.isNextGen}` - ); if (this.currJob.payload.isNextGen) { await this.exeBuildModified(); } else { diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 550603608..4d579cc56 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -129,7 +129,6 @@ export class JobManager { this._jobHandler = null; if (job?.payload) { const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); - await this._logger.save(job._id, `MAYA: IN WORKEX EXCLUDE REPO is ${excludeRepoFromBenchmarks}`); // Can easily rollback with commenting out this flag. job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); From ea3a5f9f629f8a657be032fc287be7512d0ab812 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 16:14:48 -0500 Subject: [PATCH 11/13] removing line --- src/job/jobManager.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 4d579cc56..60686b0f2 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -128,9 +128,7 @@ export class JobManager { try { this._jobHandler = null; if (job?.payload) { - const excludeRepoFromBenchmarks = ['mms-docs', 'docs-k8s-operator'].includes(job.payload.repoName); // Can easily rollback with commenting out this flag. - job.useWithBenchmark = !excludeRepoFromBenchmarks; await this.createHandlerAndExecute(job); } else { this._logger.info('JobManager', `No Jobs Found: ${new Date()}`); From 82a4bf0debdee591ba48872da6548c88e3164147 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Thu, 14 Dec 2023 16:16:05 -0500 Subject: [PATCH 12/13] removing comment --- src/job/jobManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/job/jobManager.ts b/src/job/jobManager.ts index 60686b0f2..fe7b318c6 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -128,7 +128,6 @@ export class JobManager { try { this._jobHandler = null; if (job?.payload) { - // Can easily rollback with commenting out this flag. await this.createHandlerAndExecute(job); } else { this._logger.info('JobManager', `No Jobs Found: ${new Date()}`); From 2874b2b01258da9a5e8e4a32326c1d8bc5f464d8 Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Mon, 18 Dec 2023 10:50:33 -0500 Subject: [PATCH 13/13] removing useWithBenchmark --- src/entities/job.ts | 2 -- tests/unit/job/productionJobHandler.test.ts | 1 - 2 files changed, 3 deletions(-) diff --git a/src/entities/job.ts b/src/entities/job.ts index e5cd1aec7..2fcd0c27f 100644 --- a/src/entities/job.ts +++ b/src/entities/job.ts @@ -88,7 +88,6 @@ export type EnhancedPayload = { export type Job = { _id: string; - useWithBenchmark?: boolean; payload: Payload; createdTime: Date; endTime: Date | null | undefined; @@ -114,7 +113,6 @@ export type Job = { export type EnhancedJob = { _id: string; - useWithBenchmark?: boolean; payload: EnhancedPayload; createdTime: Date; endTime: Date | null | undefined; diff --git a/tests/unit/job/productionJobHandler.test.ts b/tests/unit/job/productionJobHandler.test.ts index a620b3e69..5db6fa31b 100644 --- a/tests/unit/job/productionJobHandler.test.ts +++ b/tests/unit/job/productionJobHandler.test.ts @@ -258,7 +258,6 @@ describe('ProductionJobHandler Tests', () => { output: 'Great work', error: null, }); - jobHandlerTestHelper.job.useWithBenchmark = true; await jobHandlerTestHelper.jobHandler.execute(); jobHandlerTestHelper.verifyNextGenSuccess(); });