use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testOverlappingDeletes.
@Test
public void testOverlappingDeletes() throws Exception {
// create a snapshot
SnapshotSummaryModel summaryModel = connectedOperations.createSnapshot(datasetSummary, "snapshot-test-snapshot.json", "_d2_");
// NO ASSERTS inside the block below where hang is enabled to reduce chance of failing before disabling the hang
// ====================================================
// enable hang in DeleteSnapshotPrimaryDataStep
configService.setFault(ConfigEnum.SNAPSHOT_DELETE_LOCK_CONFLICT_STOP_FAULT.name(), true);
// try to delete the snapshot
MvcResult result1 = mvc.perform(delete("/api/repository/v1/snapshots/" + summaryModel.getId())).andReturn();
// try to delete the snapshot again, this should fail with a lock exception
// note: asserts are below outside the hang block
MvcResult result2 = mvc.perform(delete("/api/repository/v1/snapshots/" + summaryModel.getId())).andReturn();
// disable hang in DeleteSnapshotPrimaryDataStep
configService.setFault(ConfigEnum.SNAPSHOT_DELETE_LOCK_CONFLICT_CONTINUE_FAULT.name(), true);
// ====================================================
// check the response from the first delete request
MockHttpServletResponse response1 = connectedOperations.validateJobModelAndWait(result1);
DeleteResponseModel deleteResponseModel = connectedOperations.handleSuccessCase(response1, DeleteResponseModel.class);
assertEquals("First delete returned successfully", DeleteResponseModel.ObjectStateEnum.DELETED, deleteResponseModel.getObjectState());
// check the response from the second delete request
MockHttpServletResponse response2 = connectedOperations.validateJobModelAndWait(result2);
ErrorModel errorModel2 = connectedOperations.handleFailureCase(response2, HttpStatus.INTERNAL_SERVER_ERROR);
assertThat("delete failed on lock exception", errorModel2.getMessage(), startsWith("Failed to lock the snapshot"));
// confirm deleted
connectedOperations.getSnapshotExpectError(summaryModel.getId(), HttpStatus.NOT_FOUND);
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testBadData.
@Test
public void testBadData() throws Exception {
SnapshotRequestModel badDataRequest = makeSnapshotTestRequest(datasetSummary, "snapshot-test-snapshot-baddata.json");
MockHttpServletResponse response = performCreateSnapshot(badDataRequest, "_baddata_");
ErrorModel errorModel = handleCreateSnapshotFailureCase(response);
assertThat(errorModel.getMessage(), containsString("Fred"));
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method testDuplicateName.
@Test
public void testDuplicateName() throws Exception {
// create a snapshot
SnapshotRequestModel snapshotRequest = makeSnapshotTestRequest(datasetSummary, "snapshot-test-snapshot.json");
MockHttpServletResponse response = performCreateSnapshot(snapshotRequest, "_dup_");
SnapshotSummaryModel summaryModel = validateSnapshotCreated(snapshotRequest, response);
// fetch the snapshot and confirm the metadata matches the request
SnapshotModel snapshotModel = getTestSnapshot(summaryModel.getId(), snapshotRequest, datasetSummary);
assertNotNull("fetched snapshot successfully after creation", snapshotModel);
// check that the snapshot metadata row is unlocked
String exclusiveLock = snapshotDao.getExclusiveLockState(UUID.fromString(snapshotModel.getId()));
assertNull("snapshot row is unlocked", exclusiveLock);
// try to create the same snapshot again and check that it fails
snapshotRequest.setName(snapshotModel.getName());
response = performCreateSnapshot(snapshotRequest, null);
ErrorModel errorModel = handleCreateSnapshotFailureCase(response);
assertThat(response.getStatus(), equalTo(HttpStatus.BAD_REQUEST.value()));
assertThat("error message includes name conflict", errorModel.getMessage(), containsString("Snapshot name already exists"));
// delete and confirm deleted
connectedOperations.deleteTestSnapshot(snapshotModel.getId());
connectedOperations.getSnapshotExpectError(snapshotModel.getId(), HttpStatus.NOT_FOUND);
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class FileOperationTest method multiFileLoadBadLineTest.
@Test
public void multiFileLoadBadLineTest() throws Exception {
// part 1: test that we exit with the bad line error when we have fewer than the max
BulkLoadRequestModel loadRequest = makeBulkFileLoad("multiFileLoadBadLineSuccess", 0, 3, false, new boolean[] { true, false, true, false });
loadRequest.maxFailedFileLoads(4);
ErrorModel errorModel = connectedOperations.ingestBulkFileFailure(datasetSummary.getId(), loadRequest);
assertThat("Expected error", errorModel.getMessage(), containsString("bad lines in the control file"));
assertThat("Expected error", errorModel.getMessage(), containsString("There were"));
assertThat("Expected number of error details", errorModel.getErrorDetail().size(), equalTo(3));
// part 2: test that we exit with bad line error when we have more than the max
loadRequest = makeBulkFileLoad("multiFileLoadBadLineSuccess", 0, 6, false, new boolean[] { true, true, true, true });
loadRequest.maxFailedFileLoads(4);
errorModel = connectedOperations.ingestBulkFileFailure(datasetSummary.getId(), loadRequest);
assertThat("Expected error", errorModel.getMessage(), containsString("bad lines in the control file"));
assertThat("Expected error", errorModel.getMessage(), containsString("More than"));
assertThat("Expected number of error details", errorModel.getErrorDetail().size(), greaterThan(5));
}
use of bio.terra.model.ErrorModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testInvalidRelationshipTermTableColumn.
@Test
public void testInvalidRelationshipTermTableColumn() throws Exception {
// participant_id is part of the sample table, not participant
RelationshipTermModel mismatchedTerm = new RelationshipTermModel().table("participant").column("participant_id");
RelationshipModel mismatchedRelationship = new RelationshipModel().name("participant_sample").from(mismatchedTerm).to(buildSampleTerm());
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().relationships(Collections.singletonList(mismatchedRelationship));
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "InvalidRelationshipTermTableColumn" });
}
Aggregations