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 12, 2022
1 parent 98b95d1 commit 49b4825
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 All @@ -54,6 +54,9 @@ import {
} from '../cloning/fixtures';

let fixtures: FixtureType<typeof getFixtures>;
// needs to be comfortably > than the retries interval when polling for
// status
const timeoutForTestsThatNeedToCheckSpecificationJobStatus = 2 * retriesIntervalForSpecificationStatusInSeconds * 1000;

describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
beforeEach(async () => {
Expand Down Expand Up @@ -224,7 +227,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => {
.WhenPieceImporterIsInvoked(job)
.AndSpecificationProcessFails()
.ThenASpecificationDidntFinishErrorShouldBeThrown();
});
}, timeoutForTestsThatNeedToCheckSpecificationJobStatus);

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

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

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

const getFixtures = async () => {
Expand Down

0 comments on commit 49b4825

Please sign in to comment.