From 832c540036eacd2106268f0eccf879fdfdf4a8ff Mon Sep 17 00:00:00 2001 From: "nathaniel.doef" Date: Thu, 2 Feb 2023 16:32:43 -0500 Subject: [PATCH] failing test --- .../uhn/fhir/jpa/bulk/BulkDataExportTest.java | 31 +++++++++++++++++++ .../ca/uhn/fhir/jpa/api/config/DaoConfig.java | 4 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java index edc5aea249e..f7490517585 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/bulk/BulkDataExportTest.java @@ -5,8 +5,11 @@ import ca.uhn.fhir.jpa.api.model.BulkExportJobResults; import ca.uhn.fhir.jpa.api.svc.IBatch2JobRunner; import ca.uhn.fhir.jpa.batch.models.Batch2JobStartResponse; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; +import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.util.BulkExportUtils; import ca.uhn.fhir.rest.api.Constants; +import ca.uhn.fhir.rest.api.server.RequestDetails; +import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; import ca.uhn.fhir.util.JsonUtil; import com.google.common.collect.Sets; @@ -72,6 +75,7 @@ public class BulkDataExportTest extends BaseResourceProviderR4Test { @AfterEach void afterEach() { myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.DISABLED); + myDaoConfig.setBulkExportFileMaximumCapacity(DaoConfig.DEFAULT_BULK_EXPORT_FILE_MAXIMUM_CAPACITY); } @Test @@ -618,6 +622,33 @@ public class BulkDataExportTest extends BaseResourceProviderR4Test { verifyBulkExportResults(options, List.of("Patient/P1", deviceId), Collections.emptyList()); } + @Test + public void testConsecutiveExportsWithLowMaxFileCapacity() { + final int numPatients = 1000; + myDaoConfig.setBulkExportFileMaximumCapacity(1); + myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); + + RequestDetails details = new SystemRequestDetails(); + for(int i = 0; i < numPatients; i++){ + Patient patient = new Patient(); + patient.getNameFirstRep().addGiven("Patient-"+i); + myPatientDao.create(patient, details); + } + + int patientsCreated = myPatientDao.search(SearchParameterMap.newSynchronous(), details).size(); + assertEquals(numPatients, patientsCreated); + + BulkDataExportOptions options = new BulkDataExportOptions(); + options.setResourceTypes(Sets.newHashSet("Patient")); + options.setExportStyle(BulkDataExportOptions.ExportStyle.PATIENT); + options.setOutputFormat(Constants.CT_FHIR_NDJSON); + + Batch2JobStartResponse job1 = myJobRunner.startNewJob(BulkExportUtils.createBulkExportJobParametersFromExportOptions(options)); + Batch2JobStartResponse job2 = myJobRunner.startNewJob(BulkExportUtils.createBulkExportJobParametersFromExportOptions(options)); + myBatch2JobHelper.awaitJobCompletion(job1.getJobId()); + myBatch2JobHelper.awaitJobCompletion(job2.getJobId()); + } + @ParameterizedTest @MethodSource("bulkExportOptionsResourceTypes") public void testDeviceBulkExportWithPatientPartOfGroup(Set resourceTypesForExport) { diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java index 3dacf4d2d19..7c9ef175b12 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java @@ -97,6 +97,8 @@ public class DaoConfig { public static final int DEFAULT_BUNDLE_BATCH_POOL_SIZE = 20; // 1 for single thread public static final int DEFAULT_BUNDLE_BATCH_MAX_POOL_SIZE = 100; // 1 for single thread public static final int DEFAULT_BUNDLE_BATCH_QUEUE_CAPACITY = 200; + + public static final int DEFAULT_BULK_EXPORT_FILE_MAXIMUM_CAPACITY = 1_000; /** * Default value for {@link #setMaximumSearchResultCountInTransaction(Integer)} * @@ -332,7 +334,7 @@ public class DaoConfig { /** * Since 6.2.0 */ - private int myBulkExportFileMaximumCapacity = 1_000; + private int myBulkExportFileMaximumCapacity = DEFAULT_BULK_EXPORT_FILE_MAXIMUM_CAPACITY; /** * Since 6.4.0 */