Skip to content

Commit

Permalink
DOP-4177: Replacing job.useWithBenchmark with job.payload.isNextGen (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mayaraman19 authored Dec 18, 2023
1 parent c15b72c commit c190d8e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 28 deletions.
2 changes: 0 additions & 2 deletions src/entities/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export type EnhancedPayload = {

export type Job = {
_id: string;
useWithBenchmark?: boolean;
payload: Payload;
createdTime: Date;
endTime: Date | null | undefined;
Expand All @@ -114,7 +113,6 @@ export type Job = {

export type EnhancedJob = {
_id: string;
useWithBenchmark?: boolean;
payload: EnhancedPayload;
createdTime: Date;
endTime: Date | null | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 0 additions & 3 deletions src/job/jobManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`);
Expand Down
22 changes: 0 additions & 22 deletions tests/unit/job/productionJobHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ describe('ProductionJobHandler Tests', () => {
output: 'Great work',
error: null,
});
jobHandlerTestHelper.job.useWithBenchmark = true;
await jobHandlerTestHelper.jobHandler.execute();
jobHandlerTestHelper.verifyNextGenSuccess();
});
Expand Down Expand Up @@ -328,34 +327,13 @@ 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();
jobHandlerTestHelper.verifyNextGenSuccess();
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();
Expand Down

0 comments on commit c190d8e

Please sign in to comment.