diff --git a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer.ts b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer.ts index fc1fc6c718..3ad767f728 100644 --- a/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer.ts +++ b/api/apps/geoprocessing/src/legacy-project-import/legacy-piece-importers/features-specification.legacy-piece-importer.ts @@ -47,6 +47,8 @@ type ApiEventSelectResult = { type FeatureIdByIntegerId = Record; +export const retriesIntervalForSpecificationStatusInSeconds = 30; + @Injectable() @LegacyProjectImportPieceProcessorProvider() export class FeaturesSpecificationLegacyProjectPieceImporter @@ -250,7 +252,7 @@ export class FeaturesSpecificationLegacyProjectPieceImporter ): Promise> { const timeout = left('specification timeout'); const failure = left('specification failed'); - const intervalSeconds = 30; + const intervalSeconds = retriesIntervalForSpecificationStatusInSeconds; let triesLeft = retries; return new Promise>((resolve) => { diff --git a/api/apps/geoprocessing/test/integration/legacy-project-import/features-specification.legacy-piece-importer.e2e-spec.ts b/api/apps/geoprocessing/test/integration/legacy-project-import/features-specification.legacy-piece-importer.e2e-spec.ts index d7e0fb2a11..7a2b534d5f 100644 --- a/api/apps/geoprocessing/test/integration/legacy-project-import/features-specification.legacy-piece-importer.e2e-spec.ts +++ b/api/apps/geoprocessing/test/integration/legacy-project-import/features-specification.legacy-piece-importer.e2e-spec.ts @@ -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, @@ -54,6 +54,9 @@ import { } from '../cloning/fixtures'; let fixtures: FixtureType; +// needs to be comfortably > than the retries interval when polling for +// status +const timeoutForTestsThatNeedToCheckSpecificationJobStatus = 2 * retriesIntervalForSpecificationStatusInSeconds * 1000; describe(FeaturesSpecificationLegacyProjectPieceImporter, () => { beforeEach(async () => { @@ -224,7 +227,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => { .WhenPieceImporterIsInvoked(job) .AndSpecificationProcessFails() .ThenASpecificationDidntFinishErrorShouldBeThrown(); - }); + }, timeoutForTestsThatNeedToCheckSpecificationJobStatus); it(`fails when specification async job timeouts`, async () => { const specDatFileType = LegacyProjectImportFileType.SpecDat; @@ -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; @@ -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; @@ -329,7 +332,7 @@ describe(FeaturesSpecificationLegacyProjectPieceImporter, () => { .WhenPieceImporterIsInvoked(job) .AndSpecificationProcessSucceeds() .ThenScenarioFeaturesDataShouldBeImported(); - }); + }, timeoutForTestsThatNeedToCheckSpecificationJobStatus); }); const getFixtures = async () => {