From c190d8ef1ef130f40ffcf23548343d8c6e0d7d1a Mon Sep 17 00:00:00 2001 From: Maya Raman Date: Mon, 18 Dec 2023 12:33:08 -0500 Subject: [PATCH] DOP-4177: Replacing job.useWithBenchmark with job.payload.isNextGen (#953) * adding logging * trying to get logging * trying to get logging * logging * adding maya logging * remove benchmark * adding back in benchmark for good structure * trying to fix tests * removing failing tests * cleaning up * removing line * removing comment * removing useWithBenchmark --- src/entities/job.ts | 2 -- src/job/jobHandler.ts | 2 +- src/job/jobManager.ts | 3 --- tests/unit/job/productionJobHandler.test.ts | 22 --------------------- 4 files changed, 1 insertion(+), 28 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/src/job/jobHandler.ts b/src/job/jobHandler.ts index 1dcec009b..71558fc6b 100644 --- a/src/job/jobHandler.ts +++ b/src/job/jobHandler.ts @@ -351,7 +351,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`); - 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 4d579cc56..fe7b318c6 100644 --- a/src/job/jobManager.ts +++ b/src/job/jobManager.ts @@ -128,9 +128,6 @@ 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()}`); diff --git a/tests/unit/job/productionJobHandler.test.ts b/tests/unit/job/productionJobHandler.test.ts index 9181b95c9..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(); }); @@ -328,17 +327,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 +334,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();