Search in sources :

Example 26 with SnapshotSummaryModel

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

the class DatasetIntegrationTest method testSoftDeleteNotInFullView.

@Test
public void testSoftDeleteNotInFullView() throws Exception {
    datasetId = ingestedDataset();
    // get row ids
    DatasetModel dataset = dataRepoFixtures.getDataset(steward(), datasetId);
    BigQuery bigQuery = BigQueryFixtures.getBigQuery(dataset.getDataProject(), stewardToken);
    List<String> participantRowIds = getRowIds(bigQuery, dataset, "participant", 3L);
    List<String> sampleRowIds = getRowIds(bigQuery, dataset, "sample", 2L);
    // swap in these row ids in the request
    SnapshotRequestModel requestModelAll = jsonLoader.loadObject("ingest-test-snapshot-fullviews.json", SnapshotRequestModel.class);
    requestModelAll.getContents().get(0).datasetName(dataset.getName());
    SnapshotSummaryModel snapshotSummaryAll = dataRepoFixtures.createSnapshotWithRequest(steward(), dataset.getName(), requestModelAll);
    snapshotIds.add(snapshotSummaryAll.getId());
    SnapshotModel snapshotAll = dataRepoFixtures.getSnapshot(steward(), snapshotSummaryAll.getId());
    // The steward is the custodian in this case, so is a reader in big query.
    BigQuery bigQueryAll = BigQueryFixtures.getBigQuery(snapshotAll.getDataProject(), stewardToken);
    assertSnapshotTableCount(bigQueryAll, snapshotAll, "participant", 5L);
    assertSnapshotTableCount(bigQueryAll, snapshotAll, "sample", 7L);
    // write them to GCS
    String participantPath = writeListToScratch("softDel", participantRowIds);
    String samplePath = writeListToScratch("softDel", sampleRowIds);
    // build the deletion request with pointers to the two files with row ids to soft delete
    List<DataDeletionTableModel> dataDeletionTableModels = Arrays.asList(deletionTableFile("participant", participantPath), deletionTableFile("sample", samplePath));
    DataDeletionRequest request = dataDeletionRequest().tables(dataDeletionTableModels);
    // send off the soft delete request
    dataRepoFixtures.deleteData(steward(), datasetId, request);
    // make sure the new counts make sense
    assertTableCount(bigQuery, dataset, "participant", 2L);
    assertTableCount(bigQuery, dataset, "sample", 5L);
    // make full views snapshot
    SnapshotRequestModel requestModelLess = jsonLoader.loadObject("ingest-test-snapshot-fullviews.json", SnapshotRequestModel.class);
    requestModelLess.getContents().get(0).datasetName(dataset.getName());
    SnapshotSummaryModel snapshotSummaryLess = dataRepoFixtures.createSnapshotWithRequest(steward(), dataset.getName(), requestModelLess);
    snapshotIds.add(snapshotSummaryLess.getId());
    SnapshotModel snapshotLess = dataRepoFixtures.getSnapshot(steward(), snapshotSummaryLess.getId());
    BigQuery bigQueryLess = BigQueryFixtures.getBigQuery(snapshotLess.getDataProject(), stewardToken);
    // make sure the old counts stayed the same
    assertSnapshotTableCount(bigQueryAll, snapshotAll, "participant", 5L);
    assertSnapshotTableCount(bigQueryAll, snapshotAll, "sample", 7L);
    // make sure the new counts make sense
    assertSnapshotTableCount(bigQueryLess, snapshotLess, "participant", 2L);
    assertSnapshotTableCount(bigQueryLess, snapshotLess, "sample", 5L);
}
Also used : BigQuery(com.google.cloud.bigquery.BigQuery) SnapshotSummaryModel(bio.terra.model.SnapshotSummaryModel) DataDeletionRequest(bio.terra.model.DataDeletionRequest) EnumerateDatasetModel(bio.terra.model.EnumerateDatasetModel) DatasetModel(bio.terra.model.DatasetModel) SnapshotRequestModel(bio.terra.model.SnapshotRequestModel) SnapshotModel(bio.terra.model.SnapshotModel) DataDeletionTableModel(bio.terra.model.DataDeletionTableModel) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 27 with SnapshotSummaryModel

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

the class ConnectedOperations method createSnapshot.

public SnapshotSummaryModel createSnapshot(DatasetSummaryModel datasetSummaryModel, String resourcePath, String infix) throws Exception {
    MockHttpServletResponse response = launchCreateSnapshot(datasetSummaryModel, resourcePath, infix);
    SnapshotSummaryModel snapshotSummary = handleCreateSnapshotSuccessCase(response);
    return snapshotSummary;
}
Also used : SnapshotSummaryModel(bio.terra.model.SnapshotSummaryModel) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 28 with SnapshotSummaryModel

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

the class SimpleScenarioFaultTests method simpleScenario.

private void simpleScenario() throws Exception {
    // TODO: Since dataset creation and add policy is sync, it doesn't survive the fault. So for now, turn it off
    // for those operations.
    dataRepoFixtures.setFault(steward(), "SAM_TIMEOUT_FAULT", false);
    DatasetSummaryModel datasetSummaryModel = dataRepoFixtures.createDataset(steward(), "ingest-test-dataset.json");
    datasetId = datasetSummaryModel.getId();
    dataRepoFixtures.addDatasetPolicyMember(steward(), datasetId, IamRole.CUSTODIAN, custodian().getEmail());
    dataRepoFixtures.setFault(steward(), "SAM_TIMEOUT_FAULT", true);
    IngestRequestModel ingestRequest = dataRepoFixtures.buildSimpleIngest("participant", "ingest-test/ingest-test-participant.json");
    IngestResponseModel ingestResponse = dataRepoFixtures.ingestJsonData(steward(), datasetId, ingestRequest);
    assertThat("correct participant row count", ingestResponse.getRowCount(), equalTo(5L));
    ingestRequest = dataRepoFixtures.buildSimpleIngest("sample", "ingest-test/ingest-test-sample.json");
    ingestResponse = dataRepoFixtures.ingestJsonData(steward(), datasetId, ingestRequest);
    assertThat("correct sample row count", ingestResponse.getRowCount(), equalTo(7L));
    ingestRequest = dataRepoFixtures.buildSimpleIngest("file", "ingest-test/ingest-test-file.json");
    ingestResponse = dataRepoFixtures.ingestJsonData(steward(), datasetId, ingestRequest);
    assertThat("correct file row count", ingestResponse.getRowCount(), equalTo(1L));
    SnapshotSummaryModel snapshotSummary = dataRepoFixtures.createSnapshot(custodian(), datasetSummaryModel, "ingest-test-snapshot.json");
    snapshotId = snapshotSummary.getId();
    // TODO: ditto from above
    dataRepoFixtures.setFault(steward(), "SAM_TIMEOUT_FAULT", false);
    if (snapshotId != null) {
        dataRepoFixtures.deleteSnapshot(custodian(), snapshotId);
        snapshotId = null;
    }
    if (datasetId != null) {
        dataRepoFixtures.deleteDataset(steward(), datasetId);
        datasetId = null;
    }
    dataRepoFixtures.setFault(steward(), "SAM_TIMEOUT_FAULT", true);
}
Also used : SnapshotSummaryModel(bio.terra.model.SnapshotSummaryModel) DatasetSummaryModel(bio.terra.model.DatasetSummaryModel) IngestRequestModel(bio.terra.model.IngestRequestModel) IngestResponseModel(bio.terra.model.IngestResponseModel)

Aggregations

SnapshotSummaryModel (bio.terra.model.SnapshotSummaryModel)28 Test (org.junit.Test)20 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)20 SnapshotModel (bio.terra.model.SnapshotModel)17 IngestRequestModel (bio.terra.model.IngestRequestModel)13 DatasetSummaryModel (bio.terra.model.DatasetSummaryModel)12 EnumerateSnapshotModel (bio.terra.model.EnumerateSnapshotModel)10 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)10 SnapshotRequestModel (bio.terra.model.SnapshotRequestModel)9 BigQuery (com.google.cloud.bigquery.BigQuery)7 BlobInfo (com.google.cloud.storage.BlobInfo)7 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 MvcResult (org.springframework.test.web.servlet.MvcResult)6 DRSObject (bio.terra.model.DRSObject)5 DatasetModel (bio.terra.model.DatasetModel)5 DeleteResponseModel (bio.terra.model.DeleteResponseModel)5 ErrorModel (bio.terra.model.ErrorModel)5 FileModel (bio.terra.model.FileModel)5 BillingProfileModel (bio.terra.model.BillingProfileModel)4 DrsId (bio.terra.service.filedata.DrsId)4