Skip to content

Commit

Permalink
adjust retry interval
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzevzl committed Sep 6, 2022
1 parent 9f2e1e5 commit 078f2ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type ApiEventSelectResult = {

type FeatureIdByIntegerId = Record<number, string>;

export const retriesIntervalForSpecificationStatusInSeconds = 30;

@Injectable()
@LegacyProjectImportPieceProcessorProvider()
export class FeaturesSpecificationLegacyProjectPieceImporter
Expand Down Expand Up @@ -250,7 +252,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter
): Promise<Either<string, true>> {
const timeout = left('specification timeout');
const failure = left('specification failed');
const intervalSeconds = 30;
const intervalSeconds = retriesIntervalForSpecificationStatusInSeconds;
let triesLeft = retries;

return new Promise<Either<string, true>>((resolve) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { Either, isLeft, left, right } from 'fp-ts/lib/Either';
import { Readable } from 'stream';
import { EntityManager, In, Repository } from 'typeorm';
import { v4 } from 'uuid';
import { FeaturesSpecificationLegacyProjectPieceImporter } from '../../../src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer';
import { FeaturesSpecificationLegacyProjectPieceImporter, retriesIntervalForSpecificationStatusInSeconds } from '../../../src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer';
import {
specDatFeatureIdPropertyKey,
specDatPuidPropertyKey,
Expand Down Expand Up @@ -224,7 +224,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessFails()
.ThenASpecificationDidntFinishErrorShouldBeThrown();
});
}, fixtures.timeoutForTestsThatNeedToCheckSpecificationJobStatus);

it(`fails when specification async job timeouts`, async () => {
const specDatFileType = LegacyProjectImportFileType.SpecDat;
Expand All @@ -248,7 +248,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessTimeouts()
.ThenASpecificationDidntFinishErrorShouldBeThrown();
}, 70_000);
}, fixtures.timeoutForTestsThatNeedToCheckSpecificationJobStatus * 2);

it(`fails if features data records does not contain required properties`, async () => {
const specDatFileType = LegacyProjectImportFileType.SpecDat;
Expand All @@ -275,7 +275,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessSucceeds()
.ThenAMissingRequiredPropertiesErrorShouldBeThrown();
});
}, fixtures.timeoutForTestsThatNeedToCheckSpecificationJobStatus);

it('fails if puvspr.dat contains features not present in spec.dat', async () => {
const specDatFileType = LegacyProjectImportFileType.SpecDat;
Expand Down Expand Up @@ -329,7 +329,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessSucceeds()
.ThenScenarioFeaturesDataShouldBeImported();
});
}, fixtures.timeoutForTestsThatNeedToCheckSpecificationJobStatus);
});

const getFixtures = async () => {
Expand Down Expand Up @@ -479,6 +479,9 @@ const getFixtures = async () => {
};

return {
// needs to be comfortably > than the retries interval when polling for
// status
timeoutForTestsThatNeedToCheckSpecificationJobStatus: 2 * retriesIntervalForSpecificationStatusInSeconds * 1000,
cleanUp: async () => {
await DeleteProjectPus(geoEntityManager, projectId);

Expand Down

0 comments on commit 078f2ef

Please sign in to comment.