Skip to content

Commit

Permalink
allow to pass through retries param to tune awaiting for piece import…
Browse files Browse the repository at this point in the history
…er to finish
  • Loading branch information
hotzevzl committed Sep 13, 2022
1 parent 49b4825 commit 9850687
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter
specRows: PropSpecDatRow[],
projectId: string,
scenarioId: string,
retries?: number,
): Promise<void> {
const featureIdByIntegerId = await this.getFeatureIdByIntegerIdMap(
projectId,
Expand Down Expand Up @@ -330,6 +331,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter

const specificationResult = await this.waitUntilSpecificationEnds(
scenarioId,
retries
);
if (isLeft(specificationResult)) {
this.logAndThrow(
Expand Down Expand Up @@ -395,6 +397,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter

async run(
input: LegacyProjectImportJobInput,
retries?: number,
): Promise<LegacyProjectImportJobOutput> {
const { files, projectId, scenarioId } = input;

Expand All @@ -415,7 +418,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter
}

const specRows = this.getPropSpecRows(specRowsOrError, puvsprRowsOrError);
await this.runSpecification(specRows, projectId, scenarioId);
await this.runSpecification(specRows, projectId, scenarioId, retries);
await this.updateScenarioFeaturesData(specRows, scenarioId);

return input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.ThenASpecificationDidntFinishErrorShouldBeThrown();
}, timeoutForTestsThatNeedToCheckSpecificationJobStatus);

it(`fails when specification async job timeouts`, async () => {
it(`fails when specification async job times out`, async () => {
const specDatFileType = LegacyProjectImportFileType.SpecDat;
const puvsprDatFileType = LegacyProjectImportFileType.PuvsprDat;

Expand All @@ -249,7 +249,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {

await fixtures
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessTimeouts()
.AndSpecificationProcessTimesOut()
.ThenASpecificationDidntFinishErrorShouldBeThrown();
}, timeoutForTestsThatNeedToCheckSpecificationJobStatus * 2);

Expand Down Expand Up @@ -685,7 +685,7 @@ const getFixtures = async () => {
}),
);
},
WhenPieceImporterIsInvoked: (input: LegacyProjectImportJobInput) => {
WhenPieceImporterIsInvoked: (input: LegacyProjectImportJobInput, retries?: number) => {
return {
ThenADatFileNotFoundErrorShouldBeThrown: async (
file: LegacyProjectImportFileType,
Expand Down Expand Up @@ -732,10 +732,10 @@ const getFixtures = async () => {
},
};
},
AndSpecificationProcessTimeouts: () => {
AndSpecificationProcessTimesOut: () => {
return {
ThenASpecificationDidntFinishErrorShouldBeThrown: async () => {
await expect(sut.run(input)).rejects.toThrow(
await expect(sut.run(input, retries)).rejects.toThrow(
/specification didn't finish: specification timeout/gi,
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LegacyProjectImportPiece } from './domain/legacy-project-import-piece';

export abstract class LegacyProjectImportPieceProcessor<I, O> {
abstract run(input: I): Promise<O>;
abstract run(input: I, retries?: number): Promise<O>;

abstract isSupported(piece: LegacyProjectImportPiece): boolean;
}

0 comments on commit 9850687

Please sign in to comment.