Search in sources :

Example 1 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestBadPathTest.

@Test
public void ingestBadPathTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("file", "totally-legit-file.json");
    DataRepoResponse<JobModel> ingestJobResponse = dataRepoFixtures.ingestJsonDataLaunch(steward(), datasetId, request);
    DataRepoResponse<IngestResponseModel> ingestResponse = dataRepoClient.waitForResponse(steward(), ingestJobResponse, IngestResponseModel.class);
    assertThat("ingest failed", ingestResponse.getStatusCode(), equalTo(HttpStatus.NOT_FOUND));
    assertThat("failure is explained", ingestResponse.getErrorObject().orElseThrow(IllegalStateException::new).getMessage(), containsString("not found"));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestBadMultiWildcardTest.

@Test
public void ingestBadMultiWildcardTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("file", "ingest-prefix/*/ingest/suffix/*.json");
    DataRepoResponse<JobModel> ingestJobResponse = dataRepoFixtures.ingestJsonDataLaunch(steward(), datasetId, request);
    DataRepoResponse<IngestResponseModel> ingestResponse = dataRepoClient.waitForResponse(steward(), ingestJobResponse, IngestResponseModel.class);
    assertThat("ingest failed", ingestResponse.getStatusCode(), equalTo(HttpStatus.BAD_REQUEST));
    assertThat("failure is explained", ingestResponse.getErrorObject().orElseThrow(IllegalStateException::new).getMessage(), containsString("not supported"));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestUnauthorizedTest.

@Test
public void ingestUnauthorizedTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("participant", "ingest-test/ingest-test-participant.json");
    DataRepoResponse<JobModel> ingestCustResp = dataRepoFixtures.ingestJsonDataLaunch(custodian(), datasetId, request);
    assertThat("Custodian is not authorized to ingest data", ingestCustResp.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
    DataRepoResponse<JobModel> ingestReadResp = dataRepoFixtures.ingestJsonDataLaunch(reader(), datasetId, request);
    assertThat("Reader is not authorized to ingest data", ingestReadResp.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class IngestTest method ingestSingleFileMalformedTest.

@Test
public void ingestSingleFileMalformedTest() throws Exception {
    IngestRequestModel request = dataRepoFixtures.buildSimpleIngest("file", "ingest-test/ingest-test-prtcpnt-malformed.json");
    DataRepoResponse<JobModel> ingestJobResponse = dataRepoFixtures.ingestJsonDataLaunch(steward(), datasetId, request);
    DataRepoResponse<IngestResponseModel> ingestResponse = dataRepoClient.waitForResponse(steward(), ingestJobResponse, IngestResponseModel.class);
    assertThat("ingest failed", ingestResponse.getStatusCode(), equalTo(HttpStatus.BAD_REQUEST));
    assertThat("failure is explained", ingestResponse.getErrorObject().orElseThrow(IllegalStateException::new).getErrorDetail(), hasItem(containsString("too many errors")));
}
Also used : JobModel(bio.terra.model.JobModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with JobModel

use of bio.terra.model.JobModel in project jade-data-repo by DataBiosphere.

the class FileTest method fileParallelFailedLoadTest.

// DR-612 filesystem corruption test; use a non-existent file to make sure everything errors
// Do file ingests in parallel using a filename that will cause failure
@Test
public void fileParallelFailedLoadTest() throws Exception {
    List<DataRepoResponse<JobModel>> responseList = new ArrayList<>();
    String gsPath = "gs://" + testConfiguration.getIngestbucket() + "/nonexistentfile";
    String filePath = "/foo" + UUID.randomUUID().toString() + "/bar";
    for (int i = 0; i < 20; i++) {
        DataRepoResponse<JobModel> launchResp = dataRepoFixtures.ingestFileLaunch(steward(), datasetId, profileId, gsPath, filePath + i);
        responseList.add(launchResp);
    }
    int failureCount = 0;
    for (DataRepoResponse<JobModel> resp : responseList) {
        DataRepoResponse<FileModel> response = dataRepoClient.waitForResponse(steward(), resp, FileModel.class);
        if (response.getStatusCode() == HttpStatus.NOT_FOUND) {
            System.out.println("Got expected not found");
        } else {
            System.out.println("Unexpected: " + response.getStatusCode().toString());
            if (response.getErrorObject().isPresent()) {
                ErrorModel errorModel = response.getErrorObject().get();
                System.out.println("Error: " + errorModel.getMessage());
            }
            failureCount++;
        }
    }
    assertThat("No unexpected failures", failureCount, equalTo(0));
}
Also used : BulkLoadFileModel(bio.terra.model.BulkLoadFileModel) FileModel(bio.terra.model.FileModel) ArrayList(java.util.ArrayList) ErrorModel(bio.terra.model.ErrorModel) JobModel(bio.terra.model.JobModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

JobModel (bio.terra.model.JobModel)18 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 IngestRequestModel (bio.terra.model.IngestRequestModel)8 IngestResponseModel (bio.terra.model.IngestResponseModel)8 BulkLoadFileModel (bio.terra.model.BulkLoadFileModel)2 ErrorModel (bio.terra.model.ErrorModel)2 FileModel (bio.terra.model.FileModel)2 ArrayList (java.util.ArrayList)2 HttpStatus (org.springframework.http.HttpStatus)2 BulkLoadArrayResultModel (bio.terra.model.BulkLoadArrayResultModel)1 DatasetModel (bio.terra.model.DatasetModel)1 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)1 EnumerateDatasetModel (bio.terra.model.EnumerateDatasetModel)1 EnumerateSnapshotModel (bio.terra.model.EnumerateSnapshotModel)1 SnapshotModel (bio.terra.model.SnapshotModel)1 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)1 InternalStairwayException (bio.terra.service.job.exception.InternalStairwayException)1 JobServiceShutdownException (bio.terra.service.job.exception.JobServiceShutdownException)1 FlightFilter (bio.terra.stairway.FlightFilter)1