Search in sources :

Example 1 with IngestResponseModel

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

the class IngestInsertIntoDatasetTableStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException {
    Dataset dataset = IngestUtils.getDataset(context, datasetService);
    DatasetTable targetTable = IngestUtils.getDatasetTable(context, dataset);
    String stagingTableName = IngestUtils.getStagingTableName(context);
    IngestRequestModel ingestRequest = IngestUtils.getIngestRequestModel(context);
    PdaoLoadStatistics loadStatistics = IngestUtils.getIngestStatistics(context);
    IngestResponseModel ingestResponse = new IngestResponseModel().dataset(dataset.getName()).datasetId(dataset.getId().toString()).table(ingestRequest.getTable()).path(ingestRequest.getPath()).loadTag(ingestRequest.getLoadTag()).badRowCount(loadStatistics.getBadRecords()).rowCount(loadStatistics.getRowCount());
    context.getWorkingMap().put(JobMapKeys.RESPONSE.getKeyName(), ingestResponse);
    bigQueryPdao.insertIntoDatasetTable(dataset, targetTable, stagingTableName);
    return StepResult.getStepResultSuccess();
}
Also used : Dataset(bio.terra.service.dataset.Dataset) IngestRequestModel(bio.terra.model.IngestRequestModel) DatasetTable(bio.terra.service.dataset.DatasetTable) PdaoLoadStatistics(bio.terra.common.PdaoLoadStatistics) IngestResponseModel(bio.terra.model.IngestResponseModel)

Example 2 with IngestResponseModel

use of bio.terra.model.IngestResponseModel 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 3 with IngestResponseModel

use of bio.terra.model.IngestResponseModel 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 4 with IngestResponseModel

use of bio.terra.model.IngestResponseModel 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 IngestResponseModel

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

the class IngestTest method ingestBadBucketPatternTest.

@Test
public void ingestBadBucketPatternTest() throws Exception {
    IngestRequestModel request = new IngestRequestModel().table("file").format(IngestRequestModel.FormatEnum.JSON).path("gs://bucket*pattern/some-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.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)

Aggregations

IngestResponseModel (bio.terra.model.IngestResponseModel)19 IngestRequestModel (bio.terra.model.IngestRequestModel)16 Test (org.junit.Test)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 JobModel (bio.terra.model.JobModel)8 SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)3 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)2 FileModel (bio.terra.model.FileModel)2 WriteChannel (com.google.cloud.WriteChannel)2 BlobInfo (com.google.cloud.storage.BlobInfo)2 Storage (com.google.cloud.storage.Storage)2 PdaoLoadStatistics (bio.terra.common.PdaoLoadStatistics)1 BulkLoadFileModel (bio.terra.model.BulkLoadFileModel)1 DRSObject (bio.terra.model.DRSObject)1 SnapshotModel (bio.terra.model.SnapshotModel)1 Dataset (bio.terra.service.dataset.Dataset)1 DatasetTable (bio.terra.service.dataset.DatasetTable)1 BigQuery (com.google.cloud.bigquery.BigQuery)1 BlobId (com.google.cloud.storage.BlobId)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1