Skip to content

Commit

Permalink
Adding integration test for dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Sophie Guo committed Oct 16, 2024
1 parent e59013c commit 4aa8735
Show file tree
Hide file tree
Showing 3 changed files with 473 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.github.ambry.account.Dataset;


import static com.github.ambry.utils.TestUtils.*;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -258,6 +260,44 @@ public void postGetHeadUpdateDeleteUndeleteTest() throws Exception {
}
}

@Test
public void datasetTest() throws Exception {
Account refAccount = ACCOUNT_SERVICE.createAndAddRandomAccount();
Container namedBlobOptionalContainer =
new ContainerBuilder((short) 11, "optional", Container.ContainerStatus.ACTIVE, "",
refAccount.getId()).setNamedBlobMode(Container.NamedBlobMode.OPTIONAL).build();
ACCOUNT_SERVICE.updateContainers(refAccount.getName(), Arrays.asList(namedBlobOptionalContainer));
String contentType = "application/octet-stream";
String ownerId = "datasetTest";
List<Dataset> datasetList = doDatasetPutUpdateGetTest(refAccount, namedBlobOptionalContainer);
List<Pair<String, String>> allDatasetVersions = new ArrayList<>();
Pair<List<String>, byte[]> idsAndContent =
uploadDataChunksAndVerify(refAccount, namedBlobOptionalContainer, null, 50, 50, 50, 50, 17);
//Test put and get
List<Pair<String, String>> datasetVersionsFromPut =
doDatasetVersionPutGetTest(refAccount, namedBlobOptionalContainer, datasetList, contentType, ownerId);
//Test Stitch and Get
ownerId = "stitchedUploadTest";
List<Pair<String, String>> datasetVersionsFromStitch =
doStitchDatasetVersionGetTest(refAccount, namedBlobOptionalContainer, datasetList, contentType, ownerId,
idsAndContent.getFirst(), idsAndContent.getSecond(), 217);
allDatasetVersions.addAll(datasetVersionsFromPut);
allDatasetVersions.addAll(datasetVersionsFromStitch);
InMemAccountService.PAGE_SIZE = -1;
//Test List dataset
doListDatasetAndVerify(refAccount.getName(), namedBlobOptionalContainer.getName(), datasetList);
//Test List dataset version
List<Pair<String, String>> allDatasetVersionPairs = doListDatasetVersionAndVerify(datasetList, allDatasetVersions);
//Test delete
doDeleteDatasetVersionAndVerify(refAccount.getName(), namedBlobOptionalContainer.getName(), allDatasetVersionPairs);
//After delete, it should have an empty list.
doListDatasetVersionAndVerify(datasetList, new ArrayList<>());
//Test delete dataset
doDeleteDatasetAndVerify(refAccount.getName(), namedBlobOptionalContainer.getName(), datasetList);
doListDatasetAndVerify(refAccount.getName(), namedBlobOptionalContainer.getName(), new ArrayList<>());
}


/**
* Tests multipart POST and verifies it via GET operations.
* @throws Exception
Expand Down
Loading

0 comments on commit 4aa8735

Please sign in to comment.